Retry loading more posts.

This commit is contained in:
Docile-Alligator 2022-11-06 17:22:15 +11:00
parent ff10eb5f92
commit 93e98b4cb5
4 changed files with 21 additions and 4 deletions

View File

@ -294,6 +294,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
searchTextInputEditText.setImeOptions(searchTextInputEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); searchTextInputEditText.setImeOptions(searchTextInputEditText.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING);
} }
if (loadingMorePostsStatus == LoadingMorePostsStatus.LOADING) {
loadingMorePostsStatus = LoadingMorePostsStatus.NOT_LOADING;
fetchMorePosts();
}
checkNewAccountAndBindView(savedInstanceState); checkNewAccountAndBindView(savedInstanceState);
} }
@ -515,6 +520,11 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
loadingMorePostsStatus = LoadingMorePostsStatus.LOADING; loadingMorePostsStatus = LoadingMorePostsStatus.LOADING;
MorePostsInfoFragment morePostsFragment = sectionsPagerAdapter.getMorePostsInfoFragment();
if (morePostsFragment != null) {
morePostsFragment.setStatus(LoadingMorePostsStatus.LOADING);
}
Handler handler = new Handler(Looper.getMainLooper()); Handler handler = new Handler(Looper.getMainLooper());
if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) { if (postType != HistoryPostPagingSource.TYPE_READ_POSTS) {

View File

@ -14,7 +14,7 @@ import javax.inject.Inject;
import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.Infinity;
import ml.docilealligator.infinityforreddit.LoadingMorePostsStatus; import ml.docilealligator.infinityforreddit.LoadingMorePostsStatus;
import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.R;
import ml.docilealligator.infinityforreddit.activities.BaseActivity; import ml.docilealligator.infinityforreddit.activities.ViewPostDetailActivity;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
import ml.docilealligator.infinityforreddit.databinding.FragmentMorePostsInfoBinding; import ml.docilealligator.infinityforreddit.databinding.FragmentMorePostsInfoBinding;
@ -25,7 +25,7 @@ public class MorePostsInfoFragment extends Fragment {
@Inject @Inject
CustomThemeWrapper mCustomThemeWrapper; CustomThemeWrapper mCustomThemeWrapper;
private FragmentMorePostsInfoBinding binding; private FragmentMorePostsInfoBinding binding;
private BaseActivity mActivity; private ViewPostDetailActivity mActivity;
@LoadingMorePostsStatus @LoadingMorePostsStatus
int status; int status;
@ -44,6 +44,12 @@ public class MorePostsInfoFragment extends Fragment {
setStatus(getArguments().getInt(EXTRA_STATUS, LoadingMorePostsStatus.LOADING)); setStatus(getArguments().getInt(EXTRA_STATUS, LoadingMorePostsStatus.LOADING));
binding.getRoot().setOnClickListener(view -> {
if (status == LoadingMorePostsStatus.FAILED) {
mActivity.fetchMorePosts();
}
});
return binding.getRoot(); return binding.getRoot();
} }
@ -74,6 +80,6 @@ public class MorePostsInfoFragment extends Fragment {
@Override @Override
public void onAttach(@NonNull Context context) { public void onAttach(@NonNull Context context) {
super.onAttach(context); super.onAttach(context);
mActivity = (BaseActivity) context; mActivity = (ViewPostDetailActivity) context;
} }
} }

View File

@ -22,6 +22,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="16dp" android:layout_margin="16dp"
android:gravity="center"
android:fontFamily="?attr/font_family" android:fontFamily="?attr/font_family"
android:textSize="?attr/font_18" android:textSize="?attr/font_18"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@ -1312,7 +1312,7 @@
<string name="invalid_regex">Invalid regex pattern</string> <string name="invalid_regex">Invalid regex pattern</string>
<string name="load_more_posts_failed">Failed to load more posts</string> <string name="load_more_posts_failed">Failed to load more posts.\nTap to retry.</string>
<string name="no_more_posts">No more posts</string> <string name="no_more_posts">No more posts</string>
</resources> </resources>