mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-26 08:37:29 +00:00
instagram mess
This commit is contained in:
parent
12299a5d26
commit
cf97b29995
@ -171,6 +171,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
|||||||
|
|
||||||
final JSONObject pageInfo = parentComments.getJSONObject("page_info");
|
final JSONObject pageInfo = parentComments.getJSONObject("page_info");
|
||||||
final String foundEndCursor = pageInfo.optString("end_cursor");
|
final String foundEndCursor = pageInfo.optString("end_cursor");
|
||||||
|
final boolean hasNextPage = pageInfo.optBoolean("has_next_page", !TextUtils.isEmpty(foundEndCursor));
|
||||||
|
|
||||||
// final boolean containsToken = endCursor.contains("bifilter_token");
|
// final boolean containsToken = endCursor.contains("bifilter_token");
|
||||||
// if (!Utils.isEmpty(endCursor) && (containsToken || endCursor.contains("cached_comments_cursor"))) {
|
// if (!Utils.isEmpty(endCursor) && (containsToken || endCursor.contains("cached_comments_cursor"))) {
|
||||||
@ -219,7 +220,8 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
|||||||
likedBy != null ? likedBy.optLong("count", 0) : 0,
|
likedBy != null ? likedBy.optLong("count", 0) : 0,
|
||||||
comment.getBoolean("viewer_has_liked"),
|
comment.getBoolean("viewer_has_liked"),
|
||||||
profileModel);
|
profileModel);
|
||||||
commentModel.setPageCursor(!TextUtils.isEmpty(foundEndCursor), TextUtils.isEmpty(foundEndCursor) ? null : foundEndCursor);
|
if (i == 0 && !foundEndCursor.contains("tao_cursor"))
|
||||||
|
commentModel.setPageCursor(hasNextPage, TextUtils.isEmpty(foundEndCursor) ? null : foundEndCursor);
|
||||||
JSONObject tempJsonObject;
|
JSONObject tempJsonObject;
|
||||||
final JSONArray childCommentsArray;
|
final JSONArray childCommentsArray;
|
||||||
final int childCommentsLen;
|
final int childCommentsLen;
|
||||||
@ -228,13 +230,13 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
|||||||
&& (childCommentsLen = childCommentsArray.length()) > 0) {
|
&& (childCommentsLen = childCommentsArray.length()) > 0) {
|
||||||
|
|
||||||
final String childEndCursor;
|
final String childEndCursor;
|
||||||
final boolean hasNextPage;
|
final boolean childHasNextPage;
|
||||||
if ((tempJsonObject = tempJsonObject.optJSONObject("page_info")) != null) {
|
if ((tempJsonObject = tempJsonObject.optJSONObject("page_info")) != null) {
|
||||||
childEndCursor = tempJsonObject.optString("end_cursor");
|
childEndCursor = tempJsonObject.optString("end_cursor");
|
||||||
hasNextPage = tempJsonObject.optBoolean("has_next_page", !TextUtils.isEmpty(childEndCursor));
|
childHasNextPage = tempJsonObject.optBoolean("has_next_page", !TextUtils.isEmpty(childEndCursor));
|
||||||
} else {
|
} else {
|
||||||
childEndCursor = null;
|
childEndCursor = null;
|
||||||
hasNextPage = false;
|
childHasNextPage = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final List<CommentModel> childCommentModels = new ArrayList<>();
|
final List<CommentModel> childCommentModels = new ArrayList<>();
|
||||||
@ -269,7 +271,7 @@ public final class CommentsFetcher extends AsyncTask<Void, Void, List<CommentMod
|
|||||||
childComment.getBoolean("viewer_has_liked"),
|
childComment.getBoolean("viewer_has_liked"),
|
||||||
childProfileModel));
|
childProfileModel));
|
||||||
}
|
}
|
||||||
childCommentModels.get(childCommentsLen - 1).setPageCursor(hasNextPage, childEndCursor);
|
childCommentModels.get(childCommentsLen - 1).setPageCursor(childHasNextPage, childEndCursor);
|
||||||
commentModel.setChildCommentModels(childCommentModels);
|
commentModel.setChildCommentModels(childCommentModels);
|
||||||
}
|
}
|
||||||
commentModels.add(commentModel);
|
commentModels.add(commentModel);
|
||||||
|
@ -71,7 +71,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
private InputMethodManager imm;
|
private InputMethodManager imm;
|
||||||
private AppCompatActivity fragmentActivity;
|
private AppCompatActivity fragmentActivity;
|
||||||
private LinearLayoutCompat root;
|
private LinearLayoutCompat root;
|
||||||
private boolean shouldRefresh = true;
|
private boolean shouldRefresh = true, hasNextPage = false;
|
||||||
private MediaService mediaService;
|
private MediaService mediaService;
|
||||||
private String postId;
|
private String postId;
|
||||||
private AsyncTask<Void, Void, List<CommentModel>> currentlyRunning;
|
private AsyncTask<Void, Void, List<CommentModel>> currentlyRunning;
|
||||||
@ -87,6 +87,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
public void onResult(final List<CommentModel> commentModels) {
|
public void onResult(final List<CommentModel> commentModels) {
|
||||||
if (commentModels != null && commentModels.size() > 0) {
|
if (commentModels != null && commentModels.size() > 0) {
|
||||||
endCursor = commentModels.get(0).getEndCursor();
|
endCursor = commentModels.get(0).getEndCursor();
|
||||||
|
hasNextPage = commentModels.get(0).hasNextPage();
|
||||||
List<CommentModel> list = commentsViewModel.getList().getValue();
|
List<CommentModel> list = commentsViewModel.getList().getValue();
|
||||||
list = list != null ? new LinkedList<>(list) : new LinkedList<>();
|
list = list != null ? new LinkedList<>(list) : new LinkedList<>();
|
||||||
// final int oldSize = list != null ? list.size() : 0;
|
// final int oldSize = list != null ? list.size() : 0;
|
||||||
@ -259,7 +260,7 @@ public final class CommentsViewerFragment extends BottomSheetDialogFragment impl
|
|||||||
binding.commentField.setEndIconOnClickListener(newCommentListener);
|
binding.commentField.setEndIconOnClickListener(newCommentListener);
|
||||||
}
|
}
|
||||||
lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
|
||||||
if (!TextUtils.isEmpty(endCursor))
|
if (hasNextPage && !TextUtils.isEmpty(endCursor))
|
||||||
currentlyRunning = new CommentsFetcher(shortCode, endCursor, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
currentlyRunning = new CommentsFetcher(shortCode, endCursor, fetchListener).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
endCursor = null;
|
endCursor = null;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user