This commit is contained in:
Thomas 2022-07-01 18:29:32 +02:00
parent f5486a3232
commit aae5c8e3ca
2 changed files with 14 additions and 5 deletions

View File

@ -60,6 +60,8 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import app.fedilab.android.BaseMainActivity; import app.fedilab.android.BaseMainActivity;
@ -166,6 +168,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
accountMention = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION); accountMention = (app.fedilab.android.client.entities.api.Account) b.getSerializable(Helper.ARG_ACCOUNT_MENTION);
} }
binding.toolbar.setPopupTheme(Helper.popupStyle()); binding.toolbar.setPopupTheme(Helper.popupStyle());
//Edit a scheduled status from server //Edit a scheduled status from server
if (scheduledStatus != null) { if (scheduledStatus != null) {
statusDraft = new StatusDraft(); statusDraft = new StatusDraft();
@ -240,7 +243,6 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
if (statusDraft.statusReplyList != null) { if (statusDraft.statusReplyList != null) {
statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList); statusDraft.statusReplyList = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusDraft.statusReplyList);
} }
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
if (statusDraft.statusReplyList != null) { if (statusDraft.statusReplyList != null) {
statusList.addAll(statusDraft.statusReplyList); statusList.addAll(statusDraft.statusReplyList);
@ -255,13 +257,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
binding.recyclerView.setAdapter(composeAdapter); binding.recyclerView.setAdapter(composeAdapter);
binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1); binding.recyclerView.scrollToPosition(composeAdapter.getItemCount() - 1);
}; };
mainHandler.post(myRunnable); myRunnable.run();
}).start(); }).start();
} else if (statusReply != null) { } else if (statusReply != null) {
new Thread(() -> { new Thread(() -> {
statusReply = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusReply); statusReply = SpannableHelper.convertStatus(getApplication().getApplicationContext(), statusReply);
Handler mainHandler = new Handler(Looper.getMainLooper());
Runnable myRunnable = () -> { Runnable myRunnable = () -> {
statusList.add(statusReply); statusList.add(statusReply);
int statusCount = statusList.size(); int statusCount = statusList.size();
@ -314,7 +315,7 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id) statusesVM.getContext(currentInstance, BaseMainActivity.currentToken, statusReply.id)
.observe(ComposeActivity.this, this::initializeContextView); .observe(ComposeActivity.this, this::initializeContextView);
}; };
mainHandler.post(myRunnable); myRunnable.run();
}).start(); }).start();
} else { } else {
//Compose without replying //Compose without replying
@ -334,6 +335,12 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
.registerReceiver(imageReceiver, .registerReceiver(imageReceiver,
new IntentFilter(Helper.INTENT_SEND_MODIFIED_IMAGE)); new IntentFilter(Helper.INTENT_SEND_MODIFIED_IMAGE));
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
storeDraft(false);
}
}, 0, 10000);
} }
@Override @Override

View File

@ -1153,7 +1153,9 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
addAttachment(position, uris); addAttachment(position, uris);
} }
}); });
holder.binding.content.setSelection(statusDraft.cursorPosition); if (statusDraft.cursorPosition < holder.binding.content.length()) {
holder.binding.content.setSelection(statusDraft.cursorPosition);
}
if (statusDraft.setCursorToEnd) { if (statusDraft.setCursorToEnd) {
statusDraft.setCursorToEnd = false; statusDraft.setCursorToEnd = false;
holder.binding.content.setSelection(holder.binding.content.getText().length()); holder.binding.content.setSelection(holder.binding.content.getText().length());