diff options
Diffstat (limited to 'app/src/main/java')
9 files changed, 21 insertions, 37 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/CommentViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/CommentViewModel.java index 9848d499..de9f246b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/comment/CommentViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/comment/CommentViewModel.java @@ -35,8 +35,7 @@ public class CommentViewModel extends ViewModel { hasCommentLiveData = Transformations.switchMap(commentDataSourceFactory.getCommentDataSourceLiveData(), CommentDataSource::hasPostLiveData); - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); + sortTypeLiveData = new MutableLiveData<>(sortType); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/message/MessageViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/message/MessageViewModel.java index 27833e82..dfcc91cd 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/message/MessageViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/message/MessageViewModel.java @@ -32,8 +32,7 @@ public class MessageViewModel extends ViewModel { hasMessageLiveData = Transformations.switchMap(messageDataSourceFactory.getMessageDataSourceLiveData(), MessageDataSource::hasPostLiveData); - whereLiveData = new MutableLiveData<>(); - whereLiveData.postValue(where); + whereLiveData = new MutableLiveData<>(where); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) 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 efb532de..2ba3ec44 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/multireddit/MultiRedditViewModel.java @@ -23,8 +23,7 @@ public class MultiRedditViewModel extends AndroidViewModel { public MultiRedditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { super(application); mMultiRedditRepository = new MultiRedditRepository(redditDataRoomDatabase, accountName); - searchQueryLiveData = new MutableLiveData<>(); - searchQueryLiveData.postValue(""); + searchQueryLiveData = new MutableLiveData<>(""); mAllMultiReddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mMultiRedditRepository.getAllMultiRedditsWithSearchQuery(searchQuery)); mAllFavoriteMultiReddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mMultiRedditRepository.getAllFavoriteMultiRedditsWithSearchQuery(searchQuery)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/HistoryPostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/HistoryPostViewModel.java index be68ce32..4629ab5a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/HistoryPostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/HistoryPostViewModel.java @@ -46,10 +46,9 @@ public class HistoryPostViewModel extends ViewModel { this.postType = postType; this.postFilter = postFilter; - postFilterLiveData = new MutableLiveData<>(); - postFilterLiveData.postValue(postFilter); + postFilterLiveData = new MutableLiveData<>(postFilter); - Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce); + Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 4, false, 10), this::returnPagingSoruce); posts = Transformations.switchMap(postFilterLiveData, postFilterValue -> PagingLiveData.cachedIn(PagingLiveData.getLiveData(pager), ViewModelKt.getViewModelScope(this))); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java index 66505924..b1d32cf6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostViewModel.java @@ -65,14 +65,12 @@ public class PostViewModel extends ViewModel { this.postFilter = postFilter; this.readPostList = readPostList; - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); - postFilterLiveData = new MutableLiveData<>(); - postFilterLiveData.postValue(postFilter); + sortTypeLiveData = new MutableLiveData<>(sortType); + postFilterLiveData = new MutableLiveData<>(postFilter); sortTypeAndPostFilterLiveData = new SortTypeAndPostFilterLiveData(sortTypeLiveData, postFilterLiveData); - Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce); + Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 4, false, 1), this::returnPagingSoruce); posts = Transformations.switchMap(sortTypeAndPostFilterLiveData, sortAndPostFilter -> { changeSortTypeAndPostFilter( @@ -107,14 +105,12 @@ public class PostViewModel extends ViewModel { this.readPostList = readPostList; this.name = subredditName; - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); - postFilterLiveData = new MutableLiveData<>(); - postFilterLiveData.postValue(postFilter); + sortTypeLiveData = new MutableLiveData<>(sortType); + postFilterLiveData = new MutableLiveData<>(postFilter); sortTypeAndPostFilterLiveData = new SortTypeAndPostFilterLiveData(sortTypeLiveData, postFilterLiveData); - Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce); + Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 4, false, 1), this::returnPagingSoruce); posts = Transformations.switchMap(sortTypeAndPostFilterLiveData, sortAndPostFilter -> { changeSortTypeAndPostFilter( @@ -152,14 +148,12 @@ public class PostViewModel extends ViewModel { this.name = username; this.userWhere = userWhere; - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); - postFilterLiveData = new MutableLiveData<>(); - postFilterLiveData.postValue(postFilter); + sortTypeLiveData = new MutableLiveData<>(sortType); + postFilterLiveData = new MutableLiveData<>(postFilter); sortTypeAndPostFilterLiveData = new SortTypeAndPostFilterLiveData(sortTypeLiveData, postFilterLiveData); - Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce); + Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 4, false, 1), this::returnPagingSoruce); posts = Transformations.switchMap(sortTypeAndPostFilterLiveData, sortAndPostFilter -> { changeSortTypeAndPostFilter( @@ -197,14 +191,12 @@ public class PostViewModel extends ViewModel { this.query = query; this.trendingSource = trendingSource; - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); - postFilterLiveData = new MutableLiveData<>(); - postFilterLiveData.postValue(postFilter); + sortTypeLiveData = new MutableLiveData<>(sortType); + postFilterLiveData = new MutableLiveData<>(postFilter); sortTypeAndPostFilterLiveData = new SortTypeAndPostFilterLiveData(sortTypeLiveData, postFilterLiveData); - Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 25, false), this::returnPagingSoruce); + Pager<String, Post> pager = new Pager<>(new PagingConfig(25, 4, false, 1), this::returnPagingSoruce); posts = Transformations.switchMap(sortTypeAndPostFilterLiveData, sortAndPostFilter -> { changeSortTypeAndPostFilter( diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingViewModel.java index a559aee2..2cf72a52 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subreddit/SubredditListingViewModel.java @@ -31,8 +31,7 @@ public class SubredditListingViewModel extends ViewModel { hasSubredditLiveData = Transformations.switchMap(subredditListingDataSourceFactory.getSubredditListingDataSourceMutableLiveData(), SubredditListingDataSource::hasSubredditLiveData); - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); + sortTypeLiveData = new MutableLiveData<>(sortType); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) 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 6191b680..a4d1f817 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribedsubreddit/SubscribedSubredditViewModel.java @@ -23,8 +23,7 @@ public class SubscribedSubredditViewModel extends AndroidViewModel { public SubscribedSubredditViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { super(application); mSubscribedSubredditRepository = new SubscribedSubredditRepository(redditDataRoomDatabase, accountName); - searchQueryLiveData = new MutableLiveData<>(); - searchQueryLiveData.postValue(""); + searchQueryLiveData = new MutableLiveData<>(""); mAllSubscribedSubreddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedSubredditRepository.getAllSubscribedSubredditsWithSearchQuery(searchQuery)); mAllFavoriteSubscribedSubreddits = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedSubredditRepository.getAllFavoriteSubscribedSubredditsWithSearchQuery(searchQuery)); 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 100703f8..332ccb11 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/subscribeduser/SubscribedUserViewModel.java @@ -23,8 +23,7 @@ public class SubscribedUserViewModel extends AndroidViewModel { public SubscribedUserViewModel(Application application, RedditDataRoomDatabase redditDataRoomDatabase, String accountName) { super(application); mSubscribedUserRepository = new SubscribedUserRepository(redditDataRoomDatabase, accountName); - searchQueryLiveData = new MutableLiveData<>(); - searchQueryLiveData.postValue(""); + searchQueryLiveData = new MutableLiveData<>(""); mAllSubscribedUsers = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedUserRepository.getAllSubscribedUsersWithSearchQuery(searchQuery)); mAllFavoriteSubscribedUsers = Transformations.switchMap(searchQueryLiveData, searchQuery -> mSubscribedUserRepository.getAllFavoriteSubscribedUsersWithSearchQuery(searchQuery)); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java index 054e3dfb..e1e2155b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/user/UserListingViewModel.java @@ -31,8 +31,7 @@ public class UserListingViewModel extends ViewModel { hasUserLiveData = Transformations.switchMap(userListingDataSourceFactory.getUserListingDataSourceMutableLiveData(), UserListingDataSource::hasUserLiveData); - sortTypeLiveData = new MutableLiveData<>(); - sortTypeLiveData.postValue(sortType); + sortTypeLiveData = new MutableLiveData<>(sortType); PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) |