aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Account
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-08 12:19:38 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-08 12:19:38 +0000
commit85597a82d065374955153c0481663fac2b0c3264 (patch)
tree34160d0db12a8b9ffdd532b2112c27b427683996 /app/src/main/java/Account
parente542ac51388b9293297bb74b851dcb5ded621a3e (diff)
downloadinfinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar.gz
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar.bz2
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar.lz
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar.xz
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.tar.zst
infinity-for-reddit-85597a82d065374955153c0481663fac2b0c3264.zip
Switch between all logged-in reddit accounts is available.
Diffstat (limited to 'app/src/main/java/Account')
-rw-r--r--app/src/main/java/Account/AccountDao.java7
-rw-r--r--app/src/main/java/Account/AccountRepository.java2
2 files changed, 6 insertions, 3 deletions
diff --git a/app/src/main/java/Account/AccountDao.java b/app/src/main/java/Account/AccountDao.java
index 22eae5d5..b3672bb5 100644
--- a/app/src/main/java/Account/AccountDao.java
+++ b/app/src/main/java/Account/AccountDao.java
@@ -35,6 +35,9 @@ public interface AccountDao {
"karma = :karma WHERE username = :username")
void updateAccountInfo(String username, String profileImageUrl, String bannerImageUrl, int karma);
- @Query("SELECT * FROM accounts WHERE username != :username")
- LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData(String username);
+ @Query("SELECT * FROM accounts WHERE is_current_user = 0 ORDER BY username COLLATE NOCASE ASC")
+ LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData();
+
+ @Query("UPDATE accounts SET is_current_user = 1 WHERE username = :username")
+ void markAccountCurrent(String username);
}
diff --git a/app/src/main/java/Account/AccountRepository.java b/app/src/main/java/Account/AccountRepository.java
index 33927077..7aa77b51 100644
--- a/app/src/main/java/Account/AccountRepository.java
+++ b/app/src/main/java/Account/AccountRepository.java
@@ -16,7 +16,7 @@ public class AccountRepository {
AccountRepository(RedditDataRoomDatabase redditDataRoomDatabase, String username) {
mAccountDao = redditDataRoomDatabase.accountDao();
mAccountLiveData = mAccountDao.getAccountLiveData(username);
- mAccountsExceptCurrentAccountLiveData = mAccountDao.getAccountsExceptCurrentAccountLiveData(username);
+ mAccountsExceptCurrentAccountLiveData = mAccountDao.getAccountsExceptCurrentAccountLiveData();
}
LiveData<Account> getAccountLiveData() {