Fix issue #79 - Delete & redraft for replies lose reference to initial message

pull/95/head
Thomas 3 years ago
parent 321021c9dd
commit 8a1e6240b7

@ -174,16 +174,13 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
statusDraftList.add(status);
if (statusReplyId != null && statusDraft != null) {//Delete and redraft
ArrayList<Status> statusDraftListDR = new ArrayList<>();
statusDraftListDR.add(statusDraft.statusDraftList.get(0));
statusList.addAll(statusDraftListDR);
composeAdapter = new ComposeAdapter(statusList, 0, account, accountMention, visibility);
composeAdapter.manageDrafts = this;
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
binding.recyclerView.setLayoutManager(mLayoutManager);
binding.recyclerView.setAdapter(composeAdapter);
statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
.observe(ComposeActivity.this, this::initializeContextView);
statusesVM.getStatus(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
.observe(ComposeActivity.this, status1 -> {
statusesVM.getContext(BaseMainActivity.currentInstance, BaseMainActivity.currentToken, statusReplyId)
.observe(ComposeActivity.this, statusContext -> {
initializeContextRedraftView(statusContext, status1);
});
});
} else if (statusDraft != null) {//Restore a draft with all messages
new Thread(() -> {
if (statusDraft.statusReplyList != null) {
@ -321,6 +318,32 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
}
/**
* Intialize the common view for the context
*
* @param context {@link Context}
*/
private void initializeContextRedraftView(final Context context, Status initialStatus) {
if (context == null) {
return;
}
//Build the array of statuses
statusList.addAll(0, context.ancestors);
statusList.add(initialStatus);
statusList.add(statusDraft.statusDraftList.get(0));
composeAdapter = new ComposeAdapter(statusList, context.ancestors.size(), account, accountMention, visibility);
composeAdapter.manageDrafts = this;
LinearLayoutManager mLayoutManager = new LinearLayoutManager(ComposeActivity.this);
binding.recyclerView.setLayoutManager(mLayoutManager);
binding.recyclerView.setAdapter(composeAdapter);
composeAdapter.setStatusCount(context.ancestors.size() + 1);
binding.recyclerView.addItemDecoration(new DividerDecorationSimple(ComposeActivity.this, statusList));
binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1);
}
@Override
public boolean onCreateOptionsMenu(@NonNull Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.

Loading…
Cancel
Save