Minor bugs fixed.

This commit is contained in:
Alex Ning 2020-12-01 19:16:25 +08:00
parent a476d10151
commit ca010f1c01
3 changed files with 28 additions and 13 deletions

View File

@ -295,7 +295,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
startActivity(intent); startActivity(intent);
return true; return true;
case R.id.action_refresh_search_result_activity: case R.id.action_refresh_search_result_activity:
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.refresh(); sectionsPagerAdapter.refresh();
}
return true; return true;
case R.id.action_change_post_layout_search_result_activity: case R.id.action_change_post_layout_search_result_activity:
postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag()); postLayoutBottomSheetFragment.show(getSupportFragmentManager(), postLayoutBottomSheetFragment.getTag());
@ -321,9 +323,12 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Override @Override
public void sortTypeSelected(SortType sortType) { public void sortTypeSelected(SortType sortType) {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.changeSortType(sortType); sectionsPagerAdapter.changeSortType(sortType);
} }
}
@Override @Override
public void sortTypeSelected(String sortType) { public void sortTypeSelected(String sortType) {
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
@ -334,14 +339,20 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Override @Override
public void searchUserAndSubredditSortTypeSelected(SortType sortType, int fragmentPosition) { public void searchUserAndSubredditSortTypeSelected(SortType sortType, int fragmentPosition) {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.changeSortType(sortType, fragmentPosition); sectionsPagerAdapter.changeSortType(sortType, fragmentPosition);
} }
}
@Override @Override
public void postLayoutSelected(int postLayout) { public void postLayoutSelected(int postLayout) {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.changePostLayout(postLayout); sectionsPagerAdapter.changePostLayout(postLayout);
} }
}
@Subscribe @Subscribe
public void onAccountSwitchEvent(SwitchAccountEvent event) { public void onAccountSwitchEvent(SwitchAccountEvent event) {
finish(); finish();
@ -349,8 +360,10 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
@Subscribe @Subscribe
public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) { public void onChangeNSFWEvent(ChangeNSFWEvent changeNSFWEvent) {
if (sectionsPagerAdapter != null) {
sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw); sectionsPagerAdapter.changeNSFW(changeNSFWEvent.nsfw);
} }
}
@Override @Override
public void onLongPress() { public void onLongPress() {

View File

@ -62,11 +62,13 @@ public class ReportReasonRecyclerViewAdapter extends RecyclerView.Adapter<Recycl
} }
public ReportReason getSelectedReason() { public ReportReason getSelectedReason() {
if (rules != null) {
for (ReportReason reportReason : rules) { for (ReportReason reportReason : rules) {
if (reportReason.isSelected()) { if (reportReason.isSelected()) {
return reportReason; return reportReason;
} }
} }
}
for (ReportReason reportReason : generalReasons) { for (ReportReason reportReason : generalReasons) {
if (reportReason.isSelected()) { if (reportReason.isSelected()) {

View File

@ -323,7 +323,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
int currentPostsSize = postLinkedHashSet.size(); int currentPostsSize = postLinkedHashSet.size();
postLinkedHashSet.addAll(newPosts); postLinkedHashSet.addAll(newPosts);
if (currentPostsSize == postLinkedHashSet.size()) { if (currentPostsSize == postLinkedHashSet.size()) {
callback.onResult(new ArrayList<>(), lastItem); loadBestPostsAfter(params, callback, lastItem);
} else { } else {
List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
callback.onResult(newPostsList, lastItem); callback.onResult(newPostsList, lastItem);
@ -457,7 +457,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
int currentPostsSize = postLinkedHashSet.size(); int currentPostsSize = postLinkedHashSet.size();
postLinkedHashSet.addAll(newPosts); postLinkedHashSet.addAll(newPosts);
if (currentPostsSize == postLinkedHashSet.size()) { if (currentPostsSize == postLinkedHashSet.size()) {
callback.onResult(new ArrayList<>(), lastItem); loadSubredditPostsAfter(params, callback, lastItem);
} else { } else {
List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
callback.onResult(newPostsList, lastItem); callback.onResult(newPostsList, lastItem);
@ -589,7 +589,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
int currentPostsSize = postLinkedHashSet.size(); int currentPostsSize = postLinkedHashSet.size();
postLinkedHashSet.addAll(newPosts); postLinkedHashSet.addAll(newPosts);
if (currentPostsSize == postLinkedHashSet.size()) { if (currentPostsSize == postLinkedHashSet.size()) {
callback.onResult(new ArrayList<>(), lastItem); loadUserPostsAfter(params, callback, lastItem);
} else { } else {
List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
callback.onResult(newPostsList, lastItem); callback.onResult(newPostsList, lastItem);
@ -763,7 +763,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
int currentPostsSize = postLinkedHashSet.size(); int currentPostsSize = postLinkedHashSet.size();
postLinkedHashSet.addAll(newPosts); postLinkedHashSet.addAll(newPosts);
if (currentPostsSize == postLinkedHashSet.size()) { if (currentPostsSize == postLinkedHashSet.size()) {
callback.onResult(new ArrayList<>(), lastItem); loadSearchPostsAfter(params, callback, lastItem);
} else { } else {
List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
callback.onResult(newPostsList, lastItem); callback.onResult(newPostsList, lastItem);
@ -894,7 +894,7 @@ public class PostDataSource extends PageKeyedDataSource<String, Post> {
int currentPostsSize = postLinkedHashSet.size(); int currentPostsSize = postLinkedHashSet.size();
postLinkedHashSet.addAll(newPosts); postLinkedHashSet.addAll(newPosts);
if (currentPostsSize == postLinkedHashSet.size()) { if (currentPostsSize == postLinkedHashSet.size()) {
callback.onResult(new ArrayList<>(), lastItem); loadMultiRedditPostsAfter(params, callback, lastItem);
} else { } else {
List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size()); List<Post> newPostsList = new ArrayList<>(postLinkedHashSet).subList(currentPostsSize, postLinkedHashSet.size());
callback.onResult(newPostsList, lastItem); callback.onResult(newPostsList, lastItem);