Fix issue #719 - Wrong instance emojis with cross compose

This commit is contained in:
Thomas 2023-01-03 09:07:41 +01:00
parent 537bb3f622
commit df5354ec1e
2 changed files with 6 additions and 6 deletions

View File

@ -534,10 +534,10 @@ public class ComposeActivity extends BaseActivity implements ComposeAdapter.Mana
if (token == null) { if (token == null) {
token = account.token; token = account.token;
} }
if (emojis == null || !emojis.containsKey(currentInstance)) { if (emojis == null || !emojis.containsKey(instance)) {
new Thread(() -> { new Thread(() -> {
try { try {
emojis.put(currentInstance, new EmojiInstance(ComposeActivity.this).getEmojiList(currentInstance)); emojis.put(instance, new EmojiInstance(ComposeActivity.this).getEmojiList(instance));
} catch (DBException e) { } catch (DBException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -1488,7 +1488,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
holder.binding.buttonEmoji.setOnClickListener(v -> { holder.binding.buttonEmoji.setOnClickListener(v -> {
try { try {
displayEmojiPicker(holder); displayEmojiPicker(holder, account.instance);
} catch (DBException e) { } catch (DBException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1875,7 +1875,7 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
* @param holder - view for the message {@link ComposeViewHolder} * @param holder - view for the message {@link ComposeViewHolder}
* @throws DBException * @throws DBException
*/ */
private void displayEmojiPicker(ComposeViewHolder holder) throws DBException { private void displayEmojiPicker(ComposeViewHolder holder, String instance) throws DBException {
final AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle()); final AlertDialog.Builder builder = new AlertDialog.Builder(context, Helper.dialogStyle());
int paddingPixel = 15; int paddingPixel = 15;
@ -1885,10 +1885,10 @@ public class ComposeAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder
builder.setTitle(R.string.insert_emoji); builder.setTitle(R.string.insert_emoji);
if (emojis != null && emojis.size() > 0) { if (emojis != null && emojis.size() > 0) {
GridView gridView = new GridView(context); GridView gridView = new GridView(context);
gridView.setAdapter(new EmojiAdapter(emojis.get(BaseMainActivity.currentInstance))); gridView.setAdapter(new EmojiAdapter(emojis.get(instance)));
gridView.setNumColumns(5); gridView.setNumColumns(5);
gridView.setOnItemClickListener((parent, view, position, id) -> { gridView.setOnItemClickListener((parent, view, position, id) -> {
holder.binding.content.getText().insert(holder.binding.content.getSelectionStart(), " :" + emojis.get(BaseMainActivity.currentInstance).get(position).shortcode + ": "); holder.binding.content.getText().insert(holder.binding.content.getSelectionStart(), " :" + emojis.get(instance).get(position).shortcode + ": ");
alertDialogEmoji.dismiss(); alertDialogEmoji.dismiss();
}); });
gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp); gridView.setPadding(paddingDp, paddingDp, paddingDp, paddingDp);