From e542ac51388b9293297bb74b851dcb5ded621a3e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 8 Aug 2019 20:05:45 +0800 Subject: Log in other reddit accounts are available. Add an account switcher in the navigation drawer in MainActivity. --- app/src/main/java/Account/AccountViewModel.java | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'app/src/main/java/Account/AccountViewModel.java') diff --git a/app/src/main/java/Account/AccountViewModel.java b/app/src/main/java/Account/AccountViewModel.java index ab6e9663..15fe6143 100644 --- a/app/src/main/java/Account/AccountViewModel.java +++ b/app/src/main/java/Account/AccountViewModel.java @@ -8,22 +8,30 @@ import androidx.lifecycle.LiveData; import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModelProvider; +import java.util.List; + import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; public class AccountViewModel extends AndroidViewModel { private AccountRepository mAccountRepository; private LiveData mAccountLiveData; + private LiveData> mAccountsExceptCurrentAccountLiveData; public AccountViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) { super(application); mAccountRepository = new AccountRepository(redditDataRoomDatabase, id); mAccountLiveData = mAccountRepository.getAccountLiveData(); + mAccountsExceptCurrentAccountLiveData = mAccountRepository.getAccountsExceptCurrentAccountLiveData(); } public LiveData getAccountLiveData() { return mAccountLiveData; } + public LiveData> getAccountsExceptCurrentAccountLiveData() { + return mAccountsExceptCurrentAccountLiveData; + } + public void insert(Account userData) { mAccountRepository.insert(userData); } -- cgit v1.2.3