diff options
author | Alex Ning <chineseperson5@gmail.com> | 2020-12-01 11:16:25 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2020-12-01 11:16:25 +0000 |
commit | ca010f1c01683f9b9c7102abf60fc11f628bd82c (patch) | |
tree | 23d8528b1a2250a0d439ba32a9f85685a5b545f0 /app | |
parent | a476d101510ae4be4d63689d332512e0613104c2 (diff) | |
download | infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar.gz infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar.bz2 infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar.lz infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar.xz infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.tar.zst infinity-for-reddit-ca010f1c01683f9b9c7102abf60fc11f628bd82c.zip |
Minor bugs fixed.
Diffstat (limited to 'app')
3 files changed, 28 insertions, 13 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index 249e6ed2..c3f8fad1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -295,7 +295,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect startActivity(intent); return true; case R.id.action_refresh_search_result_activity: - sectionsPagerAdapter.refresh(); + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.refresh(); + } return true; case R.id.action_change_post_layout_search_result_activity: postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); @@ -321,7 +323,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override public void sortTypeSelected(SortType sortType) { - sectionsPagerAdapter.changeSortType(sortType); + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.changeSortType(sortType); + } + } @Override @@ -334,12 +339,18 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Override public void searchUserAndSubredditSortTypeSelected(SortType sortType, int fragmentPosition) { - sectionsPagerAdapter.changeSortType(sortType, fragmentPosition); + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.changeSortType(sortType, fragmentPosition); + } + } @Override public void postLayoutSelected(int postLayout) { - sectionsPagerAdapter.changePostLayout(postLayout); + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.changePostLayout(postLayout); + } + } @Subscribe @@ -349,7 +360,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect @Subscribe public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) { - sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw); + if (sectionsPagerAdapter != null) { + sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw); + } } @Override diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java index 4bb9c255..5e5572ff 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/ReportReasonRecyclerViewAdapter.java @@ -62,9 +62,11 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<Recycl } public ReportReason getSelectedReason() { - for (ReportReason reportReason : rules) { - if (reportReason.isSelected()) { - return reportReason; + if (rules != null) { + for (ReportReason reportReason : rules) { + if (reportReason.isSelected()) { + return reportReason; + } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java index e1e50733..20e43fce 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/post/PostDataSource.java @@ -323,7 +323,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { int currentPostsSize = postLinkedHashSet.size(); postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { - callback.onResult(new ArrayList<>(), lastItem); + loadBestPostsAfter(params, callback, lastItem); } else { List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); callback.onResult(newPostsList, lastItem); @@ -457,7 +457,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { int currentPostsSize = postLinkedHashSet.size(); postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { - callback.onResult(new ArrayList<>(), lastItem); + loadSubredditPostsAfter(params, callback, lastItem); } else { List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); callback.onResult(newPostsList, lastItem); @@ -589,7 +589,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { int currentPostsSize = postLinkedHashSet.size(); postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { - callback.onResult(new ArrayList<>(), lastItem); + loadUserPostsAfter(params, callback, lastItem); } else { List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); callback.onResult(newPostsList, lastItem); @@ -763,7 +763,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { int currentPostsSize = postLinkedHashSet.size(); postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { - callback.onResult(new ArrayList<>(), lastItem); + loadSearchPostsAfter(params, callback, lastItem); } else { List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); callback.onResult(newPostsList, lastItem); @@ -894,7 +894,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> { int currentPostsSize = postLinkedHashSet.size(); postLinkedHashSet.addAll(newPosts); if (currentPostsSize == postLinkedHashSet.size()) { - callback.onResult(new ArrayList<>(), lastItem); + loadMultiRedditPostsAfter(params, callback, lastItem); } else { List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); callback.onResult(newPostsList, lastItem); |