mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-24 18:08:23 +01:00
Fixed sending child comments.
This commit is contained in:
parent
70f4a7fc4c
commit
8092c07ea0
@ -98,6 +98,7 @@ public class CommentActivity extends AppCompatActivity {
|
||||
public void sendCommentSuccess(CommentData commentData) {
|
||||
Intent returnIntent = new Intent();
|
||||
returnIntent.putExtra(EXTRA_COMMENT_DATA_KEY, commentData);
|
||||
returnIntent.putExtra(EXTRA_PARENT_FULLNAME_KEY, parentFullname);
|
||||
if(isReplying) {
|
||||
returnIntent.putExtra(EXTRA_PARENT_POSITION_KEY, parentPosition);
|
||||
}
|
||||
|
@ -171,6 +171,13 @@ class CommentData implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
public void addChild(CommentData comment) {
|
||||
if(children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
children.add(0, comment);
|
||||
}
|
||||
|
||||
public ArrayList<String> getMoreChildrenIds() {
|
||||
return moreChildrenIds;
|
||||
}
|
||||
|
@ -334,16 +334,25 @@ class CommentRecyclerViewAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||
notifyItemInserted(0);
|
||||
}
|
||||
|
||||
//Need proper implementation
|
||||
void addChildComment(CommentData comment, int parentPosition) {
|
||||
ArrayList<CommentData> childComments = mCommentData.get(parentPosition).getChildren();
|
||||
if(childComments == null) {
|
||||
childComments = new ArrayList<>();
|
||||
void addChildComment(CommentData comment, String parentFullname, int parentPosition) {
|
||||
if(parentFullname.equals(mVisibleComments.get(parentPosition).getFullName())) {
|
||||
for(int i = 0; i < mVisibleComments.size(); i++) {
|
||||
if(parentFullname.equals(mVisibleComments.get(i).getFullName())) {
|
||||
parentPosition = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mVisibleComments.get(parentPosition).addChild(comment);
|
||||
mVisibleComments.get(parentPosition).setHasReply(true);
|
||||
if(!mVisibleComments.get(parentPosition).isExpanded()) {
|
||||
expandChildren(parentPosition);
|
||||
notifyItemChanged(parentPosition);
|
||||
} else {
|
||||
mVisibleComments.add(parentPosition + 1, comment);
|
||||
notifyItemInserted(parentPosition + 1);
|
||||
}
|
||||
childComments.add(0, comment);
|
||||
mCommentData.get(parentPosition).addChildren(childComments);
|
||||
mCommentData.get(parentPosition).setHasReply(true);
|
||||
notifyItemChanged(parentPosition);
|
||||
}
|
||||
|
||||
void clearData() {
|
||||
|
@ -694,8 +694,9 @@ public class ViewPostDetailActivity extends AppCompatActivity {
|
||||
if(comment.getDepth() == 0) {
|
||||
mAdapter.addComment(comment);
|
||||
} else {
|
||||
String parentFullname = data.getExtras().getString(CommentActivity.EXTRA_PARENT_FULLNAME_KEY);
|
||||
int parentPosition = data.getExtras().getInt(CommentActivity.EXTRA_PARENT_POSITION_KEY);
|
||||
mAdapter.addChildComment(comment, parentPosition);
|
||||
mAdapter.addChildComment(comment, parentFullname, parentPosition);
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, R.string.send_comment_failed, Toast.LENGTH_SHORT).show();
|
||||
|
Loading…
Reference in New Issue
Block a user