mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-26 02:48:23 +01:00
parent
e9ecae117d
commit
dd3b72bc1f
@ -869,7 +869,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
if (postListPosition == position && post != null) {
|
if (postListPosition == position && post != null) {
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||||
} else {
|
} else {
|
||||||
@ -885,12 +885,12 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (post == null) {
|
if (post == null) {
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getStringExtra(EXTRA_POST_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_ID, getIntent().getIntExtra(EXTRA_POST_ID, 0));
|
||||||
} else {
|
} else {
|
||||||
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
|
||||||
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
|
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
|
||||||
}
|
}
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
|
bundle.putInt(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getIntExtra(EXTRA_SINGLE_COMMENT_ID, 0));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
|
||||||
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
|
||||||
}
|
}
|
||||||
|
@ -437,6 +437,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewSubredditDetailActivity.class);
|
||||||
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getCommunityName());
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_SUBREDDIT_NAME_KEY, comment.getCommunityName());
|
||||||
|
intent.putExtra(ViewSubredditDetailActivity.EXTRA_COMMUNITY_FULL_NAME_KEY, comment.getCommunityQualifiedName());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -469,7 +470,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
Comment comment = getItem(getBindingAdapterPosition());
|
Comment comment = getItem(getBindingAdapterPosition());
|
||||||
if (comment != null) {
|
if (comment != null) {
|
||||||
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getPostId());
|
||||||
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getId());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,6 @@ public class ParseComment {
|
|||||||
|
|
||||||
ArrayList<Comment> expandedNewComments = new ArrayList<>();
|
ArrayList<Comment> expandedNewComments = new ArrayList<>();
|
||||||
ArrayList<Integer> moreChildrenIds = new ArrayList<>();
|
ArrayList<Integer> moreChildrenIds = new ArrayList<>();
|
||||||
ArrayList<Comment> newComments = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
Map<Integer, Comment> parsedComments = new HashMap<>();
|
Map<Integer, Comment> parsedComments = new HashMap<>();
|
||||||
@ -51,8 +50,13 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Comment parentComment = (commentId != null) ? parsedComments.get(commentId) : null;
|
Comment parentComment = (commentId != null) ? parsedComments.get(commentId) : null;
|
||||||
if (parentComment != null && parentComment.getDepth() == 0)
|
if (parentComment != null) {
|
||||||
parentComment = null;
|
if (parentComment.getDepth() == 0) {
|
||||||
|
parentComment = null;
|
||||||
|
} else {
|
||||||
|
expandedNewComments.add(parentComment);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = orderedComments.size() - 1; i >= 0; i--) {
|
for (int i = orderedComments.size() - 1; i >= 0; i--) {
|
||||||
Comment c = orderedComments.get(i);
|
Comment c = orderedComments.get(i);
|
||||||
@ -66,9 +70,7 @@ public class ParseComment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Add all comments to newComments
|
//Add all comments to newComments
|
||||||
for (int i = 0; i < topLevelComments.size(); i++) {
|
ArrayList<Comment> newComments = new ArrayList<>(topLevelComments);
|
||||||
newComments.add(topLevelComments.get(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
expandChildren(newComments, expandedNewComments, expandChildren);
|
expandChildren(newComments, expandedNewComments, expandChildren);
|
||||||
|
|
||||||
|
@ -85,7 +85,6 @@ import eu.toldi.infinityforlemmy.activities.SubmitCrosspostActivity;
|
|||||||
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
import eu.toldi.infinityforlemmy.activities.ViewPostDetailActivity;
|
||||||
import eu.toldi.infinityforlemmy.adapters.CommentsRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.CommentsRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.adapters.PostDetailRecyclerViewAdapter;
|
import eu.toldi.infinityforlemmy.adapters.PostDetailRecyclerViewAdapter;
|
||||||
import eu.toldi.infinityforlemmy.apis.LemmyAPI;
|
|
||||||
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
import eu.toldi.infinityforlemmy.apis.RedditAPI;
|
||||||
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
import eu.toldi.infinityforlemmy.apis.StreamableAPI;
|
||||||
import eu.toldi.infinityforlemmy.asynctasks.LoadUserData;
|
import eu.toldi.infinityforlemmy.asynctasks.LoadUserData;
|
||||||
@ -95,7 +94,6 @@ import eu.toldi.infinityforlemmy.comment.Comment;
|
|||||||
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
import eu.toldi.infinityforlemmy.comment.FetchComment;
|
||||||
import eu.toldi.infinityforlemmy.comment.FetchRemovedComment;
|
import eu.toldi.infinityforlemmy.comment.FetchRemovedComment;
|
||||||
import eu.toldi.infinityforlemmy.comment.FetchRemovedCommentReveddit;
|
import eu.toldi.infinityforlemmy.comment.FetchRemovedCommentReveddit;
|
||||||
import eu.toldi.infinityforlemmy.comment.ParseComment;
|
|
||||||
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
import eu.toldi.infinityforlemmy.customtheme.CustomThemeWrapper;
|
||||||
import eu.toldi.infinityforlemmy.customviews.CustomToroContainer;
|
import eu.toldi.infinityforlemmy.customviews.CustomToroContainer;
|
||||||
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
import eu.toldi.infinityforlemmy.customviews.LinearLayoutManagerBugFixed;
|
||||||
@ -109,7 +107,6 @@ import eu.toldi.infinityforlemmy.message.ReadMessage;
|
|||||||
import eu.toldi.infinityforlemmy.post.FetchPost;
|
import eu.toldi.infinityforlemmy.post.FetchPost;
|
||||||
import eu.toldi.infinityforlemmy.post.FetchRemovedPost;
|
import eu.toldi.infinityforlemmy.post.FetchRemovedPost;
|
||||||
import eu.toldi.infinityforlemmy.post.HidePost;
|
import eu.toldi.infinityforlemmy.post.HidePost;
|
||||||
import eu.toldi.infinityforlemmy.post.ParsePost;
|
|
||||||
import eu.toldi.infinityforlemmy.post.Post;
|
import eu.toldi.infinityforlemmy.post.Post;
|
||||||
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
import eu.toldi.infinityforlemmy.readpost.InsertReadPost;
|
||||||
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
import eu.toldi.infinityforlemmy.subreddit.FetchSubredditData;
|
||||||
@ -546,11 +543,11 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mSingleCommentId = (getArguments().getString(EXTRA_SINGLE_COMMENT_ID) == null) ? null : Integer.valueOf(getArguments().getString(EXTRA_SINGLE_COMMENT_ID));
|
mSingleCommentId = getArguments().getInt(EXTRA_SINGLE_COMMENT_ID, 0);
|
||||||
mContextNumber = getArguments().getString(EXTRA_CONTEXT_NUMBER, "8");
|
mContextNumber = getArguments().getString(EXTRA_CONTEXT_NUMBER, "8");
|
||||||
|
|
||||||
if (savedInstanceState == null) {
|
if (savedInstanceState == null) {
|
||||||
if (mSingleCommentId != null) {
|
if (mSingleCommentId != 0) {
|
||||||
isSingleCommentThreadMode = true;
|
isSingleCommentThreadMode = true;
|
||||||
}
|
}
|
||||||
mMessageFullname = getArguments().getString(EXTRA_MESSAGE_FULLNAME);
|
mMessageFullname = getArguments().getString(EXTRA_MESSAGE_FULLNAME);
|
||||||
@ -594,7 +591,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mPost == null) {
|
if (mPost == null) {
|
||||||
fetchPostAndCommentsById(getArguments().getString(EXTRA_POST_ID));
|
fetchPostAndCommentsById(getArguments().getInt(EXTRA_POST_ID));
|
||||||
} else {
|
} else {
|
||||||
setupMenu();
|
setupMenu();
|
||||||
|
|
||||||
@ -1240,153 +1237,91 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchPostAndCommentsById(String subredditId) {
|
private void fetchPostAndCommentsById(int subredditId) {
|
||||||
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
mFetchPostInfoLinearLayout.setVisibility(View.GONE);
|
||||||
mSwipeRefreshLayout.setRefreshing(true);
|
mSwipeRefreshLayout.setRefreshing(true);
|
||||||
mGlide.clear(mFetchPostInfoImageView);
|
mGlide.clear(mFetchPostInfoImageView);
|
||||||
|
FetchPost.fetchPost(mExecutor, new Handler(), mRetrofit.getRetrofit(), String.valueOf(subredditId), mAccessToken,
|
||||||
Call<String> postAndComments = mRetrofit.getRetrofit().create(LemmyAPI.class).getComments("All", sortType.value, 5, 1, 25, null, null, Integer.valueOf(subredditId), mSingleCommentId, false, mAccessToken);
|
new FetchPost.FetchPostListener() {
|
||||||
postAndComments.enqueue(new Callback<>() {
|
@Override
|
||||||
@Override
|
public void fetchPostSuccess(Post post) {
|
||||||
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
|
if (!isAdded()) {
|
||||||
if (!isAdded()) {
|
return;
|
||||||
return;
|
}
|
||||||
}
|
mPost = post;
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
||||||
|
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
||||||
if (response.isSuccessful()) {
|
mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
||||||
ParsePost.parsePost(mExecutor, new Handler(), response.body(), new ParsePost.ParsePostListener() {
|
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
||||||
@Override
|
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
||||||
public void onParsePostSuccess(Post post) {
|
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
||||||
mPost = post;
|
mPostDetailsSharedPreferences, mExoCreator,
|
||||||
tryMarkingPostAsRead();
|
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
||||||
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
setupMenu();
|
FetchComment.fetchComments(mExecutor, new Handler(), mRetrofit.getRetrofit(), mAccessToken, subredditId, mSingleCommentId, sortType, mExpandChildren, 1, new FetchComment.FetchCommentListener() {
|
||||||
|
@Override
|
||||||
mPostAdapter = new PostDetailRecyclerViewAdapter(activity,
|
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> children) {
|
||||||
ViewPostDetailFragment.this, mExecutor, mCustomThemeWrapper,
|
pages_loaded++;
|
||||||
mRetrofit.getRetrofit(), mOauthRetrofit, mGfycatRetrofit, mRedgifsRetrofit,
|
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
||||||
mStreamableApiProvider, mRedditDataRoomDatabase, mGlide, mSeparatePostAndComments,
|
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
|
||||||
mAccessToken, mAccountName, mPost, mLocale, mSharedPreferences,
|
mRetrofit.getRetrofit(), mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
|
||||||
mCurrentAccountSharedPreferences, mNsfwAndSpoilerSharedPreferences,
|
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
|
||||||
mPostDetailsSharedPreferences, mExoCreator,
|
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
||||||
post1 -> EventBus.getDefault().post(new PostUpdateEventToPostList(mPost, postListPosition)));
|
|
||||||
|
|
||||||
mCommentsAdapter = new CommentsRecyclerViewAdapter(activity,
|
|
||||||
ViewPostDetailFragment.this, mCustomThemeWrapper, mExecutor,
|
|
||||||
mRetrofit.getRetrofit(), mOauthRetrofit, mAccessToken, mAccountName, mPost, mLocale,
|
|
||||||
mSingleCommentId, isSingleCommentThreadMode, mSharedPreferences,
|
|
||||||
new CommentsRecyclerViewAdapter.CommentRecyclerViewAdapterCallback() {
|
|
||||||
@Override
|
|
||||||
public void retryFetchingComments() {
|
|
||||||
fetchCommentsRespectRecommendedSort(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void retryFetchingMoreComments() {
|
|
||||||
isLoadingMoreChildren = false;
|
|
||||||
loadMoreChildrenSuccess = true;
|
|
||||||
|
|
||||||
fetchMoreComments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SortType.Type getSortType() {
|
|
||||||
return sortType;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (mCommentsRecyclerView != null) {
|
|
||||||
mRecyclerView.setAdapter(mPostAdapter);
|
|
||||||
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
|
|
||||||
} else {
|
|
||||||
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
|
|
||||||
mRecyclerView.setAdapter(mConcatAdapter);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mRespectSubredditRecommendedSortType) {
|
|
||||||
fetchCommentsRespectRecommendedSort(false);
|
|
||||||
} else {
|
|
||||||
ParseComment.parseComments(mExecutor, new Handler(), response.body(), null,
|
|
||||||
mExpandChildren, new ParseComment.ParseCommentListener() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentSuccess(ArrayList<Comment> topLevelComments, ArrayList<Comment> expandedComments, Integer parentId, ArrayList<Integer> moreChildrenIds) {
|
public void retryFetchingComments() {
|
||||||
ViewPostDetailFragment.this.children = moreChildrenIds;
|
fetchCommentsRespectRecommendedSort(false);
|
||||||
|
|
||||||
hasMoreChildren = children.size() != 0;
|
|
||||||
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
|
|
||||||
|
|
||||||
if (children.size() > 0) {
|
|
||||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).clearOnScrollListeners();
|
|
||||||
(mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).addOnScrollListener(new RecyclerView.OnScrollListener() {
|
|
||||||
@Override
|
|
||||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
|
||||||
super.onScrolled(recyclerView, dx, dy);
|
|
||||||
if (!mIsSmoothScrolling && !mLockFab) {
|
|
||||||
if (!recyclerView.canScrollVertically(1)) {
|
|
||||||
activity.hideFab();
|
|
||||||
} else {
|
|
||||||
if (dy > 0) {
|
|
||||||
if (mSwipeUpToHideFab) {
|
|
||||||
activity.showFab();
|
|
||||||
} else {
|
|
||||||
activity.hideFab();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mSwipeUpToHideFab) {
|
|
||||||
activity.hideFab();
|
|
||||||
} else {
|
|
||||||
activity.showFab();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isLoadingMoreChildren && loadMoreChildrenSuccess) {
|
|
||||||
int visibleItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getChildCount();
|
|
||||||
int totalItemCount = (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager().getItemCount();
|
|
||||||
int firstVisibleItemPosition = ((LinearLayoutManagerBugFixed) (mCommentsRecyclerView == null ? mRecyclerView : mCommentsRecyclerView).getLayoutManager()).findFirstVisibleItemPosition();
|
|
||||||
|
|
||||||
if ((visibleItemCount + firstVisibleItemPosition >= totalItemCount) && firstVisibleItemPosition >= 0) {
|
|
||||||
fetchMoreComments();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
|
||||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
||||||
mIsSmoothScrolling = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParseCommentFailed() {
|
public void retryFetchingMoreComments() {
|
||||||
mCommentsAdapter.initiallyLoadCommentsFailed();
|
isLoadingMoreChildren = false;
|
||||||
|
loadMoreChildrenSuccess = true;
|
||||||
|
|
||||||
|
fetchMoreComments();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SortType.Type getSortType() {
|
||||||
|
return sortType;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (mCommentsRecyclerView != null) {
|
||||||
|
mRecyclerView.setAdapter(mPostAdapter);
|
||||||
|
mCommentsRecyclerView.setAdapter(mCommentsAdapter);
|
||||||
|
} else {
|
||||||
|
mConcatAdapter = new ConcatAdapter(mPostAdapter, mCommentsAdapter);
|
||||||
|
mRecyclerView.setAdapter(mConcatAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mRespectSubredditRecommendedSortType) {
|
||||||
|
fetchCommentsRespectRecommendedSort(false);
|
||||||
|
}
|
||||||
|
ViewPostDetailFragment.this.children = children;
|
||||||
|
|
||||||
|
hasMoreChildren = false;
|
||||||
|
mCommentsAdapter.addComments(expandedComments, hasMoreChildren);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onParsePostFail() {
|
public void onFetchCommentFailed() {
|
||||||
showErrorView(subredditId);
|
if (isAdded()) {
|
||||||
}
|
showErrorView(subredditId);
|
||||||
});
|
}
|
||||||
} else {
|
}
|
||||||
showErrorView(subredditId);
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void fetchPostFailed() {
|
||||||
|
if (isAdded()) {
|
||||||
|
showMessage(R.string.refresh_post_failed);
|
||||||
|
isRefreshing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
|
|
||||||
if (isAdded()) {
|
|
||||||
showErrorView(subredditId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState, SortType.Type sortType) {
|
private void fetchCommentsRespectRecommendedSort(boolean changeRefreshState, SortType.Type sortType) {
|
||||||
@ -1598,7 +1533,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorView(String subredditId) {
|
private void showErrorView(int subredditId) {
|
||||||
mSwipeRefreshLayout.setRefreshing(false);
|
mSwipeRefreshLayout.setRefreshing(false);
|
||||||
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
|
mFetchPostInfoLinearLayout.setVisibility(View.VISIBLE);
|
||||||
mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId));
|
mFetchPostInfoLinearLayout.setOnClickListener(view -> fetchPostAndCommentsById(subredditId));
|
||||||
|
Loading…
Reference in New Issue
Block a user