aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-11-06 06:37:58 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2022-11-06 06:37:58 +0000
commitfd63dba91b29478009a289323a5d2c2f951dc308 (patch)
tree430d07d6e2ca6263f3db8d94474c6bacb2b0c2e1 /app
parent93e98b4cb57c2105880a2005c95ba37866fa1e1d (diff)
downloadinfinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar.gz
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar.bz2
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar.lz
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar.xz
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.tar.zst
infinity-for-reddit-fd63dba91b29478009a289323a5d2c2f951dc308.zip
Fix screen staying at MorePostsInfoFragment after retrying.
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MorePostsInfoFragment.java2
2 files changed, 10 insertions, 4 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
index 651dbfd1..b2aa20bb 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewPostDetailActivity.java
@@ -296,7 +296,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
if (loadingMorePostsStatus == LoadingMorePostsStatus.LOADING) {
loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
- fetchMorePosts();
+ fetchMorePosts(false);
}
checkNewAccountAndBindView(savedInstanceState);
@@ -379,7 +379,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
@Override
public void onPageSelected(int position) {
if (posts != null && position > posts.size() - 5) {
- fetchMorePosts();
+ fetchMorePosts(false);
}
}
});
@@ -513,7 +513,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
}
}
- public void fetchMorePosts() {
+ public void fetchMorePosts(boolean changePage) {
if (loadingMorePostsStatus == LoadingMorePostsStatus.LOADING || loadingMorePostsStatus == LoadingMorePostsStatus.NO_MORE_POSTS) {
return;
}
@@ -670,6 +670,9 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
} else {
posts = new ArrayList<>(postLinkedHashSet);
handler.post(() -> {
+ if (changePage) {
+ viewPager2.setCurrentItem(currentPostsSize - 1, false);
+ }
sectionsPagerAdapter.notifyItemRangeInserted(currentPostsSize, postLinkedHashSet.size() - currentPostsSize);
loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
MorePostsInfoFragment fragment = sectionsPagerAdapter.getMorePostsInfoFragment();
@@ -749,6 +752,9 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
} else {
posts = new ArrayList<>(postLinkedHashSet);
handler.post(() -> {
+ if (changePage) {
+ viewPager2.setCurrentItem(currentPostsSize - 1, false);
+ }
sectionsPagerAdapter.notifyItemRangeInserted(currentPostsSize, postLinkedHashSet.size() - currentPostsSize);
loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
MorePostsInfoFragment fragment = sectionsPagerAdapter.getMorePostsInfoFragment();
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MorePostsInfoFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MorePostsInfoFragment.java
index 151d5ec4..f38527dd 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MorePostsInfoFragment.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/MorePostsInfoFragment.java
@@ -46,7 +46,7 @@ public class MorePostsInfoFragment extends Fragment {
binding.getRoot().setOnClickListener(view -> {
if (status == LoadingMorePostsStatus.FAILED) {
- mActivity.fetchMorePosts();
+ mActivity.fetchMorePosts(true);
}
});