diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-07-02 13:50:59 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-07-02 13:50:59 +0000 |
commit | 4ee01960aeffa293f6361c91f63b3f08e1b79881 (patch) | |
tree | d8cf012b9eb51e51631cc4bab0ada4d3323b1307 /app/src/main/java/ml/docilealligator/infinityforreddit | |
parent | e4c11e8d61c45248f5e89b2000a16a8781daa9b2 (diff) | |
download | infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar.gz infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar.bz2 infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar.lz infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar.xz infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.tar.zst infinity-for-reddit-4ee01960aeffa293f6361c91f63b3f08e1b79881.zip |
Use ViewModel instead of AndroidViewModel. Update some dependencies.
Diffstat (limited to 'app/src/main/java/ml/docilealligator/infinityforreddit')
15 files changed, 34 insertions, 55 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java index a9790078..bac079a8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/EditProfileActivity.java @@ -101,7 +101,7 @@ public class EditProfileActivity extends BaseActivity { final RequestManager glide = Glide.with(this); final UserViewModel.Factory userViewModelFactory = - new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName); + new UserViewModel.Factory(mRedditDataRoomDatabase, accountName); final UserViewModel userViewModel = new ViewModelProvider(this, userViewModelFactory).get(UserViewModel.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java index e07e025c..07b66e49 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/FilteredPostsActivity.java @@ -273,7 +273,7 @@ public class FilteredPostsActivity extends BaseActivity implements SortTypeSelec getSupportActionBar().setTitle(subredditNamePrefixed); mSubredditViewModel = new ViewModelProvider(this, - new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, name)) + new SubredditViewModel.Factory(mRedditDataRoomDatabase, name)) .get(SubredditViewModel.class); mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> { if (subredditData != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 7a1bd74d..2665c6b7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -912,7 +912,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb loadSubscriptions(); - multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory(getApplication(), + multiRedditViewModel = new ViewModelProvider(this, new MultiRedditViewModel.Factory( mRedditDataRoomDatabase, accountName)) .get(MultiRedditViewModel.class); @@ -929,7 +929,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb }); subscribedSubredditViewModel = new ViewModelProvider(this, - new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName)) + new SubscribedSubredditViewModel.Factory(mRedditDataRoomDatabase, accountName)) .get(SubscribedSubredditViewModel.class); subscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java index 8b2d8227..d4421cf1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubredditMultiselectionActivity.java @@ -113,7 +113,7 @@ public class SubredditMultiselectionActivity extends BaseActivity implements Act binding.recyclerViewSubscribedSubscribedSubredditsMultiselectionActivity.setAdapter(mAdapter); mSubscribedSubredditViewModel = new ViewModelProvider(this, - new SubscribedSubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, accountName)) + new SubscribedSubredditViewModel.Factory(mRedditDataRoomDatabase, accountName)) .get(SubscribedSubredditViewModel.class); mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(this, subscribedSubredditData -> { binding.swipeRefreshLayoutSubscribedSubscribedSubredditsMultiselectionActivity.setRefreshing(false); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 48898f00..f466a036 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -363,7 +363,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp }); mSubredditViewModel = new ViewModelProvider(this, - new SubredditViewModel.Factory(getApplication(), mRedditDataRoomDatabase, subredditName)) + new SubredditViewModel.Factory(mRedditDataRoomDatabase, subredditName)) .get(SubredditViewModel.class); mSubredditViewModel.getSubredditLiveData().observe(this, subredditData -> { if (subredditData != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index e1876da3..3a90e082 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -357,7 +357,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele return false; }); - userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(getApplication(), mRedditDataRoomDatabase, username)) + userViewModel = new ViewModelProvider(this, new UserViewModel.Factory(mRedditDataRoomDatabase, username)) .get(UserViewModel.class); userViewModel.getUserLiveData().observe(this, userData -> { if (userData != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java index 1d66cbfb..c1486d2c 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/FollowedUsersListingFragment.java @@ -100,7 +100,7 @@ public class FollowedUsersListingFragment extends Fragment implements FragmentCo new FastScrollerBuilder(binding.recyclerViewFollowedUsersListingFragment).useMd2Style().build(); mSubscribedUserViewModel = new ViewModelProvider(this, - new SubscribedUserViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName)) + new SubscribedUserViewModel.Factory(mRedditDataRoomDatabase, mActivity.accountName)) .get(SubscribedUserViewModel.class); mSubscribedUserViewModel.getAllSubscribedUsers().observe(getViewLifecycleOwner(), subscribedUserData -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java index 4b35e7f6..2a0f1a16 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MultiRedditListingFragment.java @@ -138,7 +138,7 @@ public class MultiRedditListingFragment extends Fragment implements FragmentComm new FastScrollerBuilder(binding.recyclerViewMultiRedditListingFragment).useMd2Style().build(); mMultiRedditViewModel = new ViewModelProvider(this, - new MultiRedditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName)) + new MultiRedditViewModel.Factory(mRedditDataRoomDatabase, mActivity.accountName)) .get(MultiRedditViewModel.class); mMultiRedditViewModel.getAllMultiReddits().observe(getViewLifecycleOwner(), subscribedUserData -> { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java index e23c4610..b3f139b1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java @@ -204,7 +204,7 @@ public class SidebarFragment extends Fragment { }); mSubredditViewModel = new ViewModelProvider(activity, - new SubredditViewModel.Factory(activity.getApplication(), mRedditDataRoomDatabase, subredditName)) + new SubredditViewModel.Factory(mRedditDataRoomDatabase, subredditName)) .get(SubredditViewModel.class); mSubredditViewModel.getSubredditLiveData().observe(getViewLifecycleOwner(), subredditData -> { if (subredditData != null) { diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java index e59cb3d0..33f15adc 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SubscribedSubredditsListingFragment.java @@ -114,7 +114,7 @@ public class SubscribedSubredditsListingFragment extends Fragment implements Fra new FastScrollerBuilder(binding.recyclerViewSubscribedSubredditsListingFragment).useMd2Style().build(); mSubscribedSubredditViewModel = new ViewModelProvider(this, - new SubscribedSubredditViewModel.Factory(mActivity.getApplication(), mRedditDataRoomDatabase, mActivity.accountName)) + new SubscribedSubredditViewModel.Factory(mRedditDataRoomDatabase, mActivity.accountName)) .get(SubscribedSubredditViewModel.class); mSubscribedSubredditViewModel.getAllSubscribedSubreddits().observe(getViewLifecycleOwner(), subscribedSubredditData -> { binding.swipeRefreshLayoutSubscribedSubredditsListingFragment.setRefreshing(false); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java index c1bc193a..918f2d5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java @@ -3,25 +3,25 @@ package ml.docilealligator.infinityforreddit.multireddit; import android.app.Application; import androidx.annotation.NonNull; -import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Transformations; import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModelProvider; +import androidx.lifecycle.viewmodel.CreationExtras; import java.util.List; +import kotlin.reflect.KClass; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -public class MultiRedditViewModel extends AndroidViewModel { +public class MultiRedditViewModel extends ViewModel { private final MultiRedditRepository mMultiRedditRepository; private final LiveData<List<MultiReddit>> mAllMultiReddits; private final LiveData<List<MultiReddit>> mAllFavoriteMultiReddits; private final MutableLiveData<String> searchQueryLiveData; - public MultiRedditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - super(application); + public MultiRedditViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { mMultiRedditRepository = new MultiRedditRepository(redditDataRoomDatabase, accountName); searchQueryLiveData = new MutableLiveData<>(""); @@ -42,12 +42,10 @@ public class MultiRedditViewModel extends AndroidViewModel { } public static class Factory extends ViewModelProvider.NewInstanceFactory { - private final Application mApplication; private final RedditDataRoomDatabase mRedditDataRoomDatabase; private final String mAccountName; - public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - mApplication = application; + public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { mRedditDataRoomDatabase = redditDataRoomDatabase; mAccountName = accountName; } @@ -55,7 +53,7 @@ public class MultiRedditViewModel extends AndroidViewModel { @NonNull @Override public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { - return (T) new MultiRedditViewModel(mApplication, mRedditDataRoomDatabase, mAccountName); + return (T) new MultiRedditViewModel(mRedditDataRoomDatabase, mAccountName); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditViewModel.java index 56048138..c62886d7 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditViewModel.java @@ -1,21 +1,17 @@ package ml.docilealligator.infinityforreddit.subreddit; -import android.app.Application; - import androidx.annotation.NonNull; -import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.ViewModel; import androidx.lifecycle.ViewModelProvider; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -public class SubredditViewModel extends AndroidViewModel { +public class SubredditViewModel extends ViewModel { private final SubredditRepository mSubredditRepository; private final LiveData<SubredditData> mSubredditLiveData; - public SubredditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) { - super(application); + public SubredditViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String id) { mSubredditRepository = new SubredditRepository(redditDataRoomDatabase, id); mSubredditLiveData = mSubredditRepository.getSubredditLiveData(); } @@ -30,13 +26,10 @@ public class SubredditViewModel extends AndroidViewModel { public static class Factory extends ViewModelProvider.NewInstanceFactory { - @NonNull - private final Application mApplication; private final RedditDataRoomDatabase mRedditDataRoomDatabase; private final String mSubredditName; - public Factory(@NonNull Application application, RedditDataRoomDatabase redditDataRoomDatabase, String subredditname) { - mApplication = application; + public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String subredditname) { mRedditDataRoomDatabase = redditDataRoomDatabase; mSubredditName = subredditname; } @@ -44,8 +37,8 @@ public class SubredditViewModel extends AndroidViewModel { @NonNull @Override public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { - //noinspection unchecked - return (T) new SubredditViewModel(mApplication, mRedditDataRoomDatabase, mSubredditName); + //noinspection + return (T) new SubredditViewModel(mRedditDataRoomDatabase, mSubredditName); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java index 5e3416ff..478f6335 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java @@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.subscribedsubreddit; import android.app.Application; import androidx.annotation.NonNull; -import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Transformations; @@ -14,14 +13,13 @@ import java.util.List; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -public class SubscribedSubredditViewModel extends AndroidViewModel { +public class SubscribedSubredditViewModel extends ViewModel { private final SubscribedSubredditRepository mSubscribedSubredditRepository; private final LiveData<List<SubscribedSubredditData>> mAllSubscribedSubreddits; private final LiveData<List<SubscribedSubredditData>> mAllFavoriteSubscribedSubreddits; private final MutableLiveData<String> searchQueryLiveData; - public SubscribedSubredditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - super(application); + public SubscribedSubredditViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { mSubscribedSubredditRepository = new SubscribedSubredditRepository(redditDataRoomDatabase, accountName); searchQueryLiveData = new MutableLiveData<>(""); @@ -46,12 +44,10 @@ public class SubscribedSubredditViewModel extends AndroidViewModel { } public static class Factory extends ViewModelProvider.NewInstanceFactory { - private final Application mApplication; private final RedditDataRoomDatabase mRedditDataRoomDatabase; private final String mAccountName; - public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - this.mApplication = application; + public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { this.mRedditDataRoomDatabase = redditDataRoomDatabase; this.mAccountName = accountName; } @@ -59,7 +55,7 @@ public class SubscribedSubredditViewModel extends AndroidViewModel { @NonNull @Override public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { - return (T) new SubscribedSubredditViewModel(mApplication, mRedditDataRoomDatabase, mAccountName); + return (T) new SubscribedSubredditViewModel(mRedditDataRoomDatabase, mAccountName); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java index 09ff8752..4b84c506 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java @@ -3,7 +3,6 @@ package ml.docilealligator.infinityforreddit.subscribeduser; import android.app.Application; import androidx.annotation.NonNull; -import androidx.lifecycle.AndroidViewModel; import androidx.lifecycle.LiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Transformations; @@ -14,14 +13,13 @@ import java.util.List; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -public class SubscribedUserViewModel extends AndroidViewModel { +public class SubscribedUserViewModel extends ViewModel { private final SubscribedUserRepository mSubscribedUserRepository; private final LiveData<List<SubscribedUserData>> mAllSubscribedUsers; private final LiveData<List<SubscribedUserData>> mAllFavoriteSubscribedUsers; private final MutableLiveData<String> searchQueryLiveData; - public SubscribedUserViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - super(application); + public SubscribedUserViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { mSubscribedUserRepository = new SubscribedUserRepository(redditDataRoomDatabase, accountName); searchQueryLiveData = new MutableLiveData<>(""); @@ -46,12 +44,10 @@ public class SubscribedUserViewModel extends AndroidViewModel { } public static class Factory extends ViewModelProvider.NewInstanceFactory { - private final Application mApplication; private final RedditDataRoomDatabase mRedditDataRoomDatabase; private final String mAccountName; - public Factory(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { - mApplication = application; + public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { mRedditDataRoomDatabase = redditDataRoomDatabase; mAccountName = accountName; } @@ -59,7 +55,7 @@ public class SubscribedUserViewModel extends AndroidViewModel { @NonNull @Override public <T extends ViewModel> T create(@NonNull Class<T> modelClass) { - return (T) new SubscribedUserViewModel(mApplication, mRedditDataRoomDatabase, mAccountName); + return (T) new SubscribedUserViewModel(mRedditDataRoomDatabase, mAccountName); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserViewModel.java index 478542ea..637e813e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserViewModel.java @@ -10,12 +10,11 @@ import androidx.lifecycle.ViewModelProvider; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; -public class UserViewModel extends AndroidViewModel { +public class UserViewModel extends ViewModel { private final UserRepository mSubredditRepository; private final LiveData<UserData> mUserLiveData; - public UserViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String id) { - super(application); + public UserViewModel(RedditDataRoomDatabase redditDataRoomDatabase, String id) { mSubredditRepository = new UserRepository(redditDataRoomDatabase, id); mUserLiveData = mSubredditRepository.getUserLiveData(); } @@ -30,13 +29,10 @@ public class UserViewModel extends AndroidViewModel { public static class Factory extends ViewModelProvider.NewInstanceFactory { - @NonNull - private final Application mApplication; private final RedditDataRoomDatabase mRedditDataRoomDatabase; private final String mUsername; - public Factory(@NonNull Application application, RedditDataRoomDatabase redditDataRoomDatabase, String username) { - mApplication = application; + public Factory(RedditDataRoomDatabase redditDataRoomDatabase, String username) { mRedditDataRoomDatabase = redditDataRoomDatabase; mUsername = username; } @@ -44,7 +40,7 @@ public class UserViewModel extends AndroidViewModel { @Override public <T extends ViewModel> T create(Class<T> modelClass) { //noinspection unchecked - return (T) new UserViewModel(mApplication, mRedditDataRoomDatabase, mUsername); + return (T) new UserViewModel(mRedditDataRoomDatabase, mUsername); } } } |