mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2025-10-06 13:59:49 +02:00
Finish MainActivity if clicking a notification for another user.
This commit is contained in:
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user