Continuing comment thread is now available. It can now show all the comments with depth >= 10.

This commit is contained in:
Alex Ning 2021-04-27 15:16:44 +08:00
parent 03d5a02480
commit 8d4e2fb149
12 changed files with 373 additions and 339 deletions

View File

@ -70,6 +70,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
public static final String EXTRA_POST_ID = "EPI";
public static final String EXTRA_POST_LIST_POSITION = "EPLP";
public static final String EXTRA_SINGLE_COMMENT_ID = "ESCI";
public static final String EXTRA_CONTEXT_NUMBER = "ECN";
public static final String EXTRA_MESSAGE_FULLNAME = "ENI";
public static final String EXTRA_NEW_ACCOUNT_NAME = "ENAN";
public static final String EXTRA_POST_FRAGMENT_ID = "EPFI";
@ -510,6 +511,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, post);
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, position);
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
} else {
bundle.putParcelable(ViewPostDetailFragment.EXTRA_POST_DATA, posts.get(position));
@ -523,6 +525,7 @@ public class ViewPostDetailActivity extends BaseActivity implements SortTypeSele
bundle.putInt(ViewPostDetailFragment.EXTRA_POST_LIST_POSITION, postListPosition);
}
bundle.putString(ViewPostDetailFragment.EXTRA_SINGLE_COMMENT_ID, getIntent().getStringExtra(EXTRA_SINGLE_COMMENT_ID));
bundle.putString(ViewPostDetailFragment.EXTRA_CONTEXT_NUMBER, getIntent().getStringExtra(EXTRA_CONTEXT_NUMBER));
bundle.putString(ViewPostDetailFragment.EXTRA_MESSAGE_FULLNAME, getIntent().getStringExtra(EXTRA_MESSAGE_FULLNAME));
}
fragment.setArguments(bundle);

View File

@ -637,7 +637,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
Comment comment = mVisibleComments.get(position - 2);
if (!comment.isPlaceHolder()) {
if (comment.getPlaceholderType() == Comment.NOT_PLACEHOLDER) {
if (mFullyCollapseComment && !comment.isExpanded() && comment.hasExpandedBefore()) {
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
}
@ -655,7 +655,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
Comment comment = mVisibleComments.get(position - 1);
if (!comment.isPlaceHolder()) {
if (comment.getPlaceholderType() == Comment.NOT_PLACEHOLDER) {
if (mFullyCollapseComment && !comment.isExpanded() && comment.hasExpandedBefore()) {
return VIEW_TYPE_COMMENT_FULLY_COLLAPSED;
}
@ -1035,13 +1035,8 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
}
}
} else if (holder instanceof CommentViewHolder) {
Comment comment;
if (mIsSingleCommentThreadMode) {
comment = mVisibleComments.get(holder.getBindingAdapterPosition() - 2);
} else {
comment = mVisibleComments.get(holder.getBindingAdapterPosition() - 1);
}
Comment comment = getCurrentComment(position);
if (comment != null) {
if (mIsSingleCommentThreadMode && comment.getId().equals(mSingleCommentId)) {
((CommentViewHolder) holder).itemView.setBackgroundColor(mSingleCommentThreadBackgroundColor);
} else if (comment.getAwards() != null && !comment.getAwards().equals("")) {
@ -1159,14 +1154,10 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} else {
((CommentViewHolder) holder).saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
Comment comment;
if (mIsSingleCommentThreadMode) {
comment = mVisibleComments.get(holder.getBindingAdapterPosition() - 2);
} else {
comment = mVisibleComments.get(holder.getBindingAdapterPosition() - 1);
}
} else if (holder instanceof CommentFullyCollapsedViewHolder) {
Comment comment = getCurrentComment(position);
if (comment != null) {
String authorWithPrefix = "u/" + comment.getAuthor();
((CommentFullyCollapsedViewHolder) holder).usernameTextView.setText(authorWithPrefix);
if (mShowElapsedTime) {
@ -1177,6 +1168,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((CommentFullyCollapsedViewHolder) holder).scoreTextView.setText(mActivity.getString(R.string.top_score,
Utils.getNVotes(mShowAbsoluteNumberOfVotes, comment.getScore() + comment.getVoteType())));
((CommentFullyCollapsedViewHolder) holder).commentIndentationView.setLevelAndColors(comment.getDepth(), verticalBlockColors);
}
} else if (holder instanceof LoadMoreChildCommentsViewHolder) {
Comment placeholder;
placeholder = mIsSingleCommentThreadMode ? mVisibleComments.get(holder.getBindingAdapterPosition() - 2)
@ -1184,6 +1176,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
((LoadMoreChildCommentsViewHolder) holder).commentIndentationView.setLevelAndColors(placeholder.getDepth(), verticalBlockColors);
if (placeholder.getPlaceholderType() == Comment.PLACEHOLDER_LOAD_MORE_COMMENTS) {
if (placeholder.isLoadingMoreChildren()) {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.loading);
} else if (placeholder.isLoadMoreChildrenFailed()) {
@ -1191,7 +1184,11 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
} else {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_load_more_comments);
}
} else {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setText(R.string.comment_continue_thread);
}
if (placeholder.getPlaceholderType() == Comment.PLACEHOLDER_LOAD_MORE_COMMENTS) {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
int commentPosition = mIsSingleCommentThreadMode ? holder.getBindingAdapterPosition() - 2 : holder.getBindingAdapterPosition() - 1;
int parentPosition = getParentPosition(commentPosition);
@ -1372,6 +1369,18 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
});
}
});
} else {
((LoadMoreChildCommentsViewHolder) holder).placeholderTextView.setOnClickListener(view -> {
Comment comment = getCurrentComment(position);
if (comment != null) {
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_DATA, mPost);
intent.putExtra(ViewPostDetailActivity.EXTRA_SINGLE_COMMENT_ID, comment.getParentId());
intent.putExtra(ViewPostDetailActivity.EXTRA_CONTEXT_NUMBER, "0");
mActivity.startActivity(intent);
}
});
}
}
}

View File

@ -243,7 +243,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (holder instanceof CommentViewHolder) {
Comment comment = getItem(holder.getAdapterPosition());
Comment comment = getItem(holder.getBindingAdapterPosition());
if (comment != null) {
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
String name = "u/" + comment.getLinkAuthor();
@ -477,11 +477,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
commentDivider.setBackgroundColor(mDividerColor);
authorTextView.setOnClickListener(view -> {
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
Comment comment = getItem(getAdapterPosition());
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
if (comment.getSubredditName().substring(2).equals(comment.getLinkAuthor())) {
Intent intent = new Intent(mActivity, ViewUserDetailActivity.class);
@ -496,11 +496,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
});
moreButton.setOnClickListener(view -> {
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
Comment comment = getItem(getAdapterPosition());
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
Bundle bundle = new Bundle();
if (comment.getAuthor().equals(mAccountName)) {
@ -508,7 +508,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
}
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_ACCESS_TOKEN, mAccessToken);
bundle.putParcelable(CommentMoreBottomSheetFragment.EXTRA_COMMENT, comment);
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getAdapterPosition());
bundle.putInt(CommentMoreBottomSheetFragment.EXTRA_POSITION, getBindingAdapterPosition());
bundle.putString(CommentMoreBottomSheetFragment.EXTRA_COMMENT_MARKDOWN, comment.getCommentMarkdown());
CommentMoreBottomSheetFragment commentMoreBottomSheetFragment = new CommentMoreBottomSheetFragment();
commentMoreBottomSheetFragment.setArguments(bundle);
@ -517,11 +517,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
});
itemView.setOnClickListener(view -> {
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
Comment comment = getItem(getAdapterPosition());
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
Intent intent = new Intent(mActivity, ViewPostDetailActivity.class);
intent.putExtra(ViewPostDetailActivity.EXTRA_POST_ID, comment.getLinkId());
@ -542,11 +542,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
return;
}
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
Comment comment = getItem(getAdapterPosition());
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
int previousVoteType = comment.getVoteType();
String newVoteType;
@ -574,7 +574,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getAdapterPosition();
int currentPosition = getBindingAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_UPVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_UPVOTE);
if (currentPosition == position) {
@ -599,7 +599,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void onVoteThingFail(int position) {
}
}, comment.getFullName(), newVoteType, getAdapterPosition());
}, comment.getFullName(), newVoteType, getBindingAdapterPosition());
}
});
@ -609,11 +609,11 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
return;
}
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
Comment comment = getItem(getAdapterPosition());
Comment comment = getItem(getBindingAdapterPosition());
if (comment != null) {
int previousVoteType = comment.getVoteType();
String newVoteType;
@ -640,7 +640,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
VoteThing.voteThing(mActivity, mOauthRetrofit, mAccessToken, new VoteThing.VoteThingListener() {
@Override
public void onVoteThingSuccess(int position1) {
int currentPosition = getAdapterPosition();
int currentPosition = getBindingAdapterPosition();
if (newVoteType.equals(APIUtils.DIR_DOWNVOTE)) {
comment.setVoteType(Comment.VOTE_TYPE_DOWNVOTE);
if (currentPosition == position) {
@ -665,12 +665,12 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void onVoteThingFail(int position1) {
}
}, comment.getFullName(), newVoteType, getAdapterPosition());
}, comment.getFullName(), newVoteType, getBindingAdapterPosition());
}
});
saveButton.setOnClickListener(view -> {
int position = getAdapterPosition();
int position = getBindingAdapterPosition();
if (position < 0) {
return;
}
@ -682,7 +682,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void success() {
comment.setSaved(false);
if (getAdapterPosition() == position) {
if (getBindingAdapterPosition() == position) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
Toast.makeText(mActivity, R.string.comment_unsaved_success, Toast.LENGTH_SHORT).show();
@ -691,7 +691,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void failed() {
comment.setSaved(true);
if (getAdapterPosition() == position) {
if (getBindingAdapterPosition() == position) {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
}
Toast.makeText(mActivity, R.string.comment_unsaved_failed, Toast.LENGTH_SHORT).show();
@ -703,7 +703,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void success() {
comment.setSaved(true);
if (getAdapterPosition() == position) {
if (getBindingAdapterPosition() == position) {
saveButton.setImageResource(R.drawable.ic_bookmark_grey_24dp);
}
Toast.makeText(mActivity, R.string.comment_saved_success, Toast.LENGTH_SHORT).show();
@ -712,7 +712,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
@Override
public void failed() {
comment.setSaved(false);
if (getAdapterPosition() == position) {
if (getBindingAdapterPosition() == position) {
saveButton.setImageResource(R.drawable.ic_bookmark_border_grey_24dp);
}
Toast.makeText(mActivity, R.string.comment_saved_failed, Toast.LENGTH_SHORT).show();

View File

@ -197,18 +197,18 @@ public interface RedditAPI {
@GET("/r/{subredditName}/about/rules.json?raw_json=1")
Call<String> getRules(@Path("subredditName") String subredditName);
@GET("/comments/{id}/placeholder/{singleCommentId}.json?context=8&raw_json=1")
@GET("/comments/{id}/placeholder/{singleCommentId}.json?raw_json=1")
Call<String> getPostAndCommentsSingleThreadByIdOauth(@Path("id") String id, @Path("singleCommentId") String singleCommentId,
@Query("sort") String sortType,
@Query("sort") String sortType, @Query("context") String contextNumber,
@HeaderMap Map<String, String> headers);
@GET("/comments/{id}.json?raw_json=1")
Call<String> getPostAndCommentsByIdOauth(@Path("id") String id, @Query("sort") String sortType,
@HeaderMap Map<String, String> headers);
@GET("/comments/{id}/placeholder/{singleCommentId}.json?context=8&raw_json=1")
@GET("/comments/{id}/placeholder/{singleCommentId}.json?raw_json=1")
Call<String> getPostAndCommentsSingleThreadById(@Path("id") String id, @Path("singleCommentId") String singleCommentId,
@Query("sort") String sortType);
@Query("sort") String sortType, @Query("context") String contextNumber);
@GET("/comments/{id}.json?raw_json=1")
Call<String> getPostAndCommentsById(@Path("id") String id, @Query("sort") String sortType);

View File

@ -11,6 +11,9 @@ public class Comment implements Parcelable {
public static final int VOTE_TYPE_NO_VOTE = 0;
public static final int VOTE_TYPE_UPVOTE = 1;
public static final int VOTE_TYPE_DOWNVOTE = -1;
public static final int NOT_PLACEHOLDER = 0;
public static final int PLACEHOLDER_LOAD_MORE_COMMENTS = 1;
public static final int PLACEHOLDER_CONTINUE_THREAD = 2;
public static final Creator<Comment> CREATOR = new Creator<Comment>() {
@Override
public Comment createFromParcel(Parcel in) {
@ -50,7 +53,7 @@ public class Comment implements Parcelable {
private ArrayList<Comment> children;
private ArrayList<String> moreChildrenFullnames;
private int moreChildrenStartingIndex;
private boolean isPlaceHolder;
private int placeholderType;
private boolean isLoadingMoreChildren;
private boolean loadMoreChildrenFailed;
@ -87,17 +90,25 @@ public class Comment implements Parcelable {
this.isExpanded = false;
this.hasExpandedBefore = false;
moreChildrenStartingIndex = 0;
isPlaceHolder = false;
placeholderType = NOT_PLACEHOLDER;
}
public Comment(String parentFullName, int depth) {
public Comment(String parentFullName, int depth, int placeholderType) {
if (placeholderType == PLACEHOLDER_LOAD_MORE_COMMENTS) {
this.fullName = parentFullName;
} else {
this.parentId = parentFullName.substring(3);
}
this.depth = depth;
isPlaceHolder = true;
this.placeholderType = placeholderType;
isLoadingMoreChildren = false;
loadMoreChildrenFailed = false;
}
public Comment(String parentFullName) {
}
protected Comment(Parcel in) {
id = in.readString();
fullName = in.readString();
@ -126,7 +137,7 @@ public class Comment implements Parcelable {
children = in.readArrayList(Comment.class.getClassLoader());
moreChildrenFullnames = in.readArrayList(Comment.class.getClassLoader());
moreChildrenStartingIndex = in.readInt();
isPlaceHolder = in.readByte() != 0;
placeholderType = in.readInt();
isLoadingMoreChildren = in.readByte() != 0;
loadMoreChildrenFailed = in.readByte() != 0;
}
@ -286,7 +297,7 @@ public class Comment implements Parcelable {
if (children == null || children.size() == 0) {
setChildren(moreChildren);
} else {
if (children.size() > 1 && children.get(children.size() - 1).isPlaceHolder) {
if (children.size() > 1 && children.get(children.size() - 1).placeholderType == PLACEHOLDER_LOAD_MORE_COMMENTS) {
children.addAll(children.size() - 2, moreChildren);
} else {
children.addAll(moreChildren);
@ -329,8 +340,8 @@ public class Comment implements Parcelable {
this.moreChildrenStartingIndex = moreChildrenStartingIndex;
}
public boolean isPlaceHolder() {
return isPlaceHolder;
public int getPlaceholderType() {
return placeholderType;
}
public boolean isLoadingMoreChildren() {
@ -383,7 +394,7 @@ public class Comment implements Parcelable {
parcel.writeList(children);
parcel.writeList(moreChildrenFullnames);
parcel.writeInt(moreChildrenStartingIndex);
parcel.writeByte((byte) (isPlaceHolder ? 1 : 0));
parcel.writeInt(placeholderType);
parcel.writeByte((byte) (isLoadingMoreChildren ? 1 : 0));
parcel.writeByte((byte) (loadMoreChildrenFailed ? 1 : 0));
}

View File

@ -245,7 +245,7 @@ public class CommentDataSource extends PageKeyedDataSource<String, Comment> {
for (int i = 0; i < commentsJSONArray.length(); i++) {
try {
JSONObject commentJSON = commentsJSONArray.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
comments.add(ParseComment.parseSingleComment(commentJSON, 0, locale));
comments.add(ParseComment.parseSingleComment(commentJSON, 0));
} catch (JSONException ignored) {
}
}

View File

@ -15,7 +15,7 @@ import retrofit2.Retrofit;
public class FetchComment {
public static void fetchComments(Retrofit retrofit, @Nullable String accessToken, String article,
String commentId, String sortType, boolean expandChildren,
String commentId, String sortType, String contextNumber, boolean expandChildren,
Locale locale, FetchCommentListener fetchCommentListener) {
RedditAPI api = retrofit.create(RedditAPI.class);
Call<String> comments;
@ -23,13 +23,13 @@ public class FetchComment {
if (commentId == null) {
comments = api.getPostAndCommentsById(article, sortType);
} else {
comments = api.getPostAndCommentsSingleThreadById(article, commentId, sortType);
comments = api.getPostAndCommentsSingleThreadById(article, commentId, sortType, contextNumber);
}
} else {
if (commentId == null) {
comments = api.getPostAndCommentsByIdOauth(article, sortType, APIUtils.getOAuthHeader(accessToken));
} else {
comments = api.getPostAndCommentsSingleThreadByIdOauth(article, commentId, sortType,
comments = api.getPostAndCommentsSingleThreadByIdOauth(article, commentId, sortType, contextNumber,
APIUtils.getOAuthHeader(accessToken));
}
}

View File

@ -70,13 +70,18 @@ public class ParseComment {
}
actualCommentLength = comments.length() - 1;
if (moreChildrenFullnames.isEmpty() && comments.getJSONObject(comments.length() - 1).getString(JSONUtils.KIND_KEY).equals(JSONUtils.KIND_VALUE_MORE)) {
newCommentData.add(new Comment(more.getString(JSONUtils.PARENT_ID_KEY), more.getInt(JSONUtils.DEPTH_KEY), Comment.PLACEHOLDER_CONTINUE_THREAD));
return;
}
} else {
actualCommentLength = comments.length();
}
for (int i = 0; i < actualCommentLength; i++) {
JSONObject data = comments.getJSONObject(i).getJSONObject(JSONUtils.DATA_KEY);
Comment singleComment = parseSingleComment(data, depth, locale);
Comment singleComment = parseSingleComment(data, depth);
if (data.get(JSONUtils.REPLIES_KEY) instanceof JSONObject) {
JSONArray childrenArray = data.getJSONObject(JSONUtils.REPLIES_KEY)
@ -107,14 +112,14 @@ public class ParseComment {
}
if (c.hasMoreChildrenFullnames() && c.getMoreChildrenFullnames().size() > c.getMoreChildrenStartingIndex()) {
//Add a load more placeholder
Comment placeholder = new Comment(c.getFullName(), c.getDepth() + 1);
Comment placeholder = new Comment(c.getFullName(), c.getDepth() + 1, Comment.PLACEHOLDER_LOAD_MORE_COMMENTS);
visibleComments.add(placeholder);
c.addChild(placeholder, c.getChildren().size());
}
}
}
static Comment parseSingleComment(JSONObject singleCommentData, int depth, Locale locale) throws JSONException {
static Comment parseSingleComment(JSONObject singleCommentData, int depth) throws JSONException {
String id = singleCommentData.getString(JSONUtils.ID_KEY);
String fullName = singleCommentData.getString(JSONUtils.NAME_KEY);
String author = singleCommentData.getString(JSONUtils.AUTHOR_KEY);
@ -262,6 +267,7 @@ public class ParseComment {
expandChildren(newComments, expandedNewComments, expandChildren);
} catch (JSONException e) {
parseFailed = true;
e.printStackTrace();
}
return null;
}
@ -302,7 +308,7 @@ public class ParseComment {
protected Void doInBackground(Void... voids) {
try {
JSONObject sentCommentData = new JSONObject(response);
comment = parseSingleComment(sentCommentData, depth, locale);
comment = parseSingleComment(sentCommentData, depth);
} catch (JSONException e) {
e.printStackTrace();
errorMessage = parseSentCommentErrorMessage(response);

View File

@ -117,6 +117,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
public static final String EXTRA_POST_DATA = "EPD";
public static final String EXTRA_POST_ID = "EPI";
public static final String EXTRA_SINGLE_COMMENT_ID = "ESCI";
public static final String EXTRA_CONTEXT_NUMBER = "ECN";
public static final String EXTRA_MESSAGE_FULLNAME = "EMF";
public static final String EXTRA_POST_LIST_POSITION = "EPLP";
private static final int EDIT_POST_REQUEST_CODE = 2;
@ -202,6 +203,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
private String mAccountName;
private int postListPosition = -1;
private String mSingleCommentId;
private String mContextNumber;
private boolean showToast = false;
private boolean isSortingComments = false;
private boolean mIsSmoothScrolling = false;
@ -461,6 +463,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
};
mSingleCommentId = getArguments().getString(EXTRA_SINGLE_COMMENT_ID);
mContextNumber = getArguments().getString(EXTRA_CONTEXT_NUMBER, "8");
if (savedInstanceState == null) {
if (mSingleCommentId != null) {
isSingleCommentThreadMode = true;
@ -1055,7 +1059,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
if (mAccessToken == null) {
if (isSingleCommentThreadMode && mSingleCommentId != null) {
postAndComments = mRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadById(
subredditId, mSingleCommentId, sortType);
subredditId, mSingleCommentId, sortType, mContextNumber);
} else {
postAndComments = mRetrofit.create(RedditAPI.class).getPostAndCommentsById(subredditId,
sortType);
@ -1063,7 +1067,7 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
} else {
if (isSingleCommentThreadMode && mSingleCommentId != null) {
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsSingleThreadByIdOauth(subredditId,
mSingleCommentId, sortType, APIUtils.getOAuthHeader(mAccessToken));
mSingleCommentId, sortType, mContextNumber, APIUtils.getOAuthHeader(mAccessToken));
} else {
postAndComments = mOauthRetrofit.create(RedditAPI.class).getPostAndCommentsByIdOauth(subredditId,
sortType, APIUtils.getOAuthHeader(mAccessToken));
@ -1240,8 +1244,8 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic
}
Retrofit retrofit = mAccessToken == null ? mRetrofit : mOauthRetrofit;
FetchComment.fetchComments(retrofit, mAccessToken, mPost.getId(), commentId, sortType, mExpandChildren,
mLocale, new FetchComment.FetchCommentListener() {
FetchComment.fetchComments(retrofit, mAccessToken, mPost.getId(), commentId, sortType,
mContextNumber, mExpandChildren, mLocale, new FetchComment.FetchCommentListener() {
@Override
public void onFetchCommentSuccess(ArrayList<Comment> expandedComments,
String parentId, ArrayList<String> children) {

View File

@ -6,6 +6,7 @@ package ml.docilealligator.infinityforreddit.utils;
public class JSONUtils {
public static final String KIND_KEY = "kind";
public static final String KIND_VALUE_MORE = "more";
public static final String DATA_KEY = "data";
public static final String AFTER_KEY = "after";
public static final String CHILDREN_KEY = "children";

View File

@ -20,7 +20,6 @@
android:layout_height="wrap_content"
android:gravity="center"
android:padding="8dp"
android:text="@string/comment_load_more_comments"
android:textColor="?attr/primaryTextColor"
android:textSize="?attr/font_default"
android:fontFamily="?attr/font_family" />

View File

@ -193,6 +193,7 @@
<string name="comment_load_more_comments">Load more comments</string>
<string name="comment_load_more_comments_failed">Load failed. Tap to retry.</string>
<string name="comment_continue_thread">Continue thread</string>
<string name="loading">Loading</string>