aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/Account
diff options
context:
space:
mode:
authorAlex Ning <chineseperson5@gmail.com>2019-08-19 09:57:04 +0000
committerAlex Ning <chineseperson5@gmail.com>2019-08-19 09:57:04 +0000
commit556047aa42b8fba25be56c38e5e919690444858b (patch)
tree0c2ee2a1ac74e1f2eafbcca7137cd562b90495c1 /app/src/main/java/Account
parent5bf002629d92610c152ee3ef9bd2ca7b71fd5cbc (diff)
downloadinfinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar.gz
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar.bz2
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar.lz
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar.xz
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.tar.zst
infinity-for-reddit-556047aa42b8fba25be56c38e5e919690444858b.zip
Finish MainActivity if clicking a notification for another user.
Diffstat (limited to 'app/src/main/java/Account')
-rw-r--r--app/src/main/java/Account/AccountDao.java3
-rw-r--r--app/src/main/java/Account/AccountRepository.java6
-rw-r--r--app/src/main/java/Account/AccountViewModel.java6
3 files changed, 3 insertions, 12 deletions
diff --git a/app/src/main/java/Account/AccountDao.java b/app/src/main/java/Account/AccountDao.java
index c05e5552..67caf71d 100644
--- a/app/src/main/java/Account/AccountDao.java
+++ b/app/src/main/java/Account/AccountDao.java
@@ -37,6 +37,9 @@ public interface AccountDao {
@Query("SELECT * FROM accounts WHERE is_current_user = 1 LIMIT 1")
Account getCurrentAccount();
+ @Query("SELECT * FROM accounts WHERE is_current_user = 1 LIMIT 1")
+ LiveData<Account> getCurrentAccountLiveData();
+
@Query("UPDATE accounts SET profile_image_url = :profileImageUrl, banner_image_url = :bannerImageUrl, " +
"karma = :karma WHERE username = :username")
void updateAccountInfo(String username, String profileImageUrl, String bannerImageUrl, int karma);
diff --git a/app/src/main/java/Account/AccountRepository.java b/app/src/main/java/Account/AccountRepository.java
index 7aa77b51..573f00f8 100644
--- a/app/src/main/java/Account/AccountRepository.java
+++ b/app/src/main/java/Account/AccountRepository.java
@@ -10,19 +10,13 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class AccountRepository {
private AccountDao mAccountDao;
- private LiveData<Account> mAccountLiveData;
private LiveData<List<Account>> mAccountsExceptCurrentAccountLiveData;
AccountRepository(RedditDataRoomDatabase redditDataRoomDatabase, String username) {
mAccountDao = redditDataRoomDatabase.accountDao();
- mAccountLiveData = mAccountDao.getAccountLiveData(username);
mAccountsExceptCurrentAccountLiveData = mAccountDao.getAccountsExceptCurrentAccountLiveData();
}
- LiveData<Account> getAccountLiveData() {
- return mAccountLiveData;
- }
-
public LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData() {
return mAccountsExceptCurrentAccountLiveData;
}
diff --git a/app/src/main/java/Account/AccountViewModel.java b/app/src/main/java/Account/AccountViewModel.java
index 15fe6143..53fb0013 100644
--- a/app/src/main/java/Account/AccountViewModel.java
+++ b/app/src/main/java/Account/AccountViewModel.java
@@ -14,20 +14,14 @@ import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
public class AccountViewModel extends AndroidViewModel {
private AccountRepository mAccountRepository;
- private LiveData<Account> mAccountLiveData;
private LiveData<List<Account>> mAccountsExceptCurrentAccountLiveData;
public AccountViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) {
super(application);
mAccountRepository = new AccountRepository(redditDataRoomDatabase, id);
- mAccountLiveData = mAccountRepository.getAccountLiveData();
mAccountsExceptCurrentAccountLiveData = mAccountRepository.getAccountsExceptCurrentAccountLiveData();
}
- public LiveData<Account> getAccountLiveData() {
- return mAccountLiveData;
- }
-
public LiveData<List<Account>> getAccountsExceptCurrentAccountLiveData() {
return mAccountsExceptCurrentAccountLiveData;
}