diff options
16 files changed, 40 insertions, 61 deletions
diff --git a/app/build.gradle b/app/build.gradle index 522e5db3..fd6cc433 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -57,13 +57,13 @@ android { dependencies { /** AndroidX **/ - implementation 'androidx.appcompat:appcompat:1.7.0-beta01' + implementation 'androidx.appcompat:appcompat:1.7.0' implementation 'androidx.biometric:biometric:1.2.0-alpha05' implementation 'androidx.browser:browser:1.8.0' implementation 'androidx.cardview:cardview:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - implementation 'androidx.activity:activity:1.8.0' + implementation 'androidx.activity:activity:1.9.0' def lifecycleVersion = "2.7.0" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-livedata:$lifecycleVersion" @@ -71,7 +71,7 @@ dependencies { implementation "androidx.lifecycle:lifecycle-runtime:$lifecycleVersion" implementation "androidx.lifecycle:lifecycle-viewmodel:$lifecycleVersion" - def pagingVersion = '3.2.1' + def pagingVersion = '3.3.0' implementation "androidx.paging:paging-runtime:$pagingVersion" implementation "androidx.paging:paging-guava:$pagingVersion" implementation 'androidx.preference:preference:1.2.1' @@ -80,12 +80,12 @@ dependencies { implementation "androidx.room:room-runtime:$roomVersion" annotationProcessor "androidx.room:room-compiler:$roomVersion" implementation "androidx.room:room-guava:$roomVersion" - implementation 'androidx.viewpager2:viewpager2:1.1.0-rc01' + implementation 'androidx.viewpager2:viewpager2:1.1.0' implementation 'androidx.work:work-runtime:2.9.0' implementation 'com.google.android.material:material:1.12.0' /** ExoPlayer **/ - def media3_version = "1.4.0-alpha02" + def media3_version = "1.4.0-beta01" implementation "androidx.media3:media3-exoplayer:$media3_version" implementation "androidx.media3:media3-exoplayer-dash:$media3_version" implementation "androidx.media3:media3-exoplayer-hls:$media3_version" @@ -109,7 +109,7 @@ dependencies { annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion" // Binding - compileOnly 'com.android.databinding:viewbinding:8.4.0' + compileOnly 'com.android.databinding:viewbinding:8.5.0' // Events def eventbusVersion = "3.3.1" 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); } } } |