Skip to content

Commit

Permalink
Merge pull request #20958 from wordpress-mobile/issue/19811-paging-un…
Browse files Browse the repository at this point in the history
…followed-tags-not-working

Remove maximum number of posts that can be loaded in ReaderPostAdapter
  • Loading branch information
nbradbury authored Aug 28, 2024
2 parents 7cc442c + cb7260b commit 481cff8
Showing 1 changed file with 1 addition and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public class ReaderPostAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
private final int mPhotonHeight;
private final int mAvatarSzSmall;

private boolean mCanRequestMorePosts;

@NonNull private final ReaderTypes.ReaderPostListType mPostListType;
@NonNull private String mSource;
private final ReaderPostList mPosts = new ReaderPostList();
Expand Down Expand Up @@ -677,8 +675,7 @@ private void renderPostNew(final int position, final ReaderPostNewViewHolder hol
* if we're nearing the end of the posts, fire request to load more
*/
private void checkLoadMore(int position) {
if (mCanRequestMorePosts
&& mDataRequestedListener != null
if (mDataRequestedListener != null
&& (position >= getItemCount() - 1)) {
mDataRequestedListener.onRequestData();
}
Expand Down Expand Up @@ -939,7 +936,6 @@ public void removeGapMarker() {
private class LoadPostsTask extends AsyncTask<Void, Void, Boolean> {
private ReaderPostList mAllPosts;

private boolean mCanRequestMorePostsTemp;
private int mGapMarkerPositionTemp;

@Override
Expand All @@ -954,21 +950,17 @@ protected void onCancelled() {

@Override
protected Boolean doInBackground(Void... params) {
int numExisting = 0;
switch (getPostListType()) {
case TAG_PREVIEW:
case TAG_FOLLOWED:
case SEARCH_RESULTS:
mAllPosts = ReaderPostTable.getPostsWithTag(mCurrentTag, MAX_ROWS, EXCLUDE_TEXT_COLUMN);
numExisting = ReaderPostTable.getNumPostsWithTag(mCurrentTag);
break;
case BLOG_PREVIEW:
if (mCurrentFeedId != 0) {
mAllPosts = ReaderPostTable.getPostsInFeed(mCurrentFeedId, MAX_ROWS, EXCLUDE_TEXT_COLUMN);
numExisting = ReaderPostTable.getNumPostsInFeed(mCurrentFeedId);
} else {
mAllPosts = ReaderPostTable.getPostsInBlog(mCurrentBlogId, MAX_ROWS, EXCLUDE_TEXT_COLUMN);
numExisting = ReaderPostTable.getNumPostsInBlog(mCurrentBlogId);
}
break;
case TAGS_FEED:
Expand All @@ -979,10 +971,6 @@ protected Boolean doInBackground(Void... params) {
return false;
}

// if we're not already displaying the max # posts, enable requesting more when
// the user scrolls to the end of the list
mCanRequestMorePostsTemp = (numExisting < ReaderConstants.READER_MAX_POSTS_TO_DISPLAY);

// determine whether a gap marker exists - only applies to tagged posts
mGapMarkerPositionTemp = getGapMarkerPosition();

Expand Down Expand Up @@ -1022,7 +1010,6 @@ private int getGapMarkerPosition() {
protected void onPostExecute(Boolean result) {
if (result) {
ReaderPostAdapter.this.mGapMarkerPosition = mGapMarkerPositionTemp;
ReaderPostAdapter.this.mCanRequestMorePosts = mCanRequestMorePostsTemp;
mPosts.clear();
mPosts.addAll(mAllPosts);
notifyDataSetChanged();
Expand Down

0 comments on commit 481cff8

Please sign in to comment.