Added simple handling for pagination in CommentListTask

This commit is contained in:
Clayton Hickey 2020-05-28 20:42:00 -04:00
parent e88706e500
commit 9e6acd9a0d
2 changed files with 9 additions and 5 deletions

View file

@ -17,12 +17,16 @@ import io.lbry.browser.utils.Helper;
import io.lbry.browser.utils.Lbry;
public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
private String claim;
private final int page;
private final int pageSize;
private final String claim;
private ProgressBar progressBar;
private CommentListHandler handler;
private Exception error;
public CommentListTask(String claim, ProgressBar progressBar, CommentListHandler handler) {
public CommentListTask(int page, int pageSize, String claim, ProgressBar progressBar, CommentListHandler handler) {
this.page = page;
this.pageSize = pageSize;
this.claim = claim;
this.progressBar = progressBar;
this.handler = handler;
@ -39,8 +43,8 @@ public class CommentListTask extends AsyncTask<Void, Void, List<Comment>> {
Map<String, Object> options = new HashMap<>();
options.put("claim_id", claim);
options.put("page", 1);
options.put("page_size", 999);
options.put("page", page);
options.put("page_size", pageSize);
options.put("include_replies", false);
options.put("is_channel_signature_valid", true);
options.put("visible", true);

View file

@ -1872,7 +1872,7 @@ public class FileViewFragment extends BaseFragment implements
View root = getView();
ProgressBar relatedLoading = root.findViewById(R.id.file_view_comments_progress);
if (claim != null && root != null) {
CommentListTask relatedTask = new CommentListTask(claim.getClaimId(), relatedLoading, new CommentListHandler() {
CommentListTask relatedTask = new CommentListTask(1, 999, claim.getClaimId(), relatedLoading, new CommentListHandler() {
@Override
public void onSuccess(List<Comment> comments) {
Context ctx = getContext();