From 90a989f00a2ab6d6981cedb48aae17114bc35c8a Mon Sep 17 00:00:00 2001 From: Thodoris1999 Date: Sat, 1 Sep 2018 19:51:02 +0300 Subject: [PATCH] fix bug when text would be deleted on emoji keyboard close --- .../mthmmy/activities/topic/TopicActivity.java | 14 ++++++++++---- .../mthmmy/activities/topic/TopicAdapter.java | 5 ++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java index 38a14b43..dca30b72 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java @@ -261,10 +261,16 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo return; } else if (emojiKeyboard.getVisibility() == View.VISIBLE) { emojiKeyboard.setVisibility(View.GONE); - if (viewModel.isEditingPost()) - topicAdapter.notifyItemChanged(viewModel.getPostBeingEditedPosition()); - if (viewModel.isWritingReply()) - topicAdapter.notifyItemChanged(viewModel.postCount()); + if (viewModel.isEditingPost()) { + TopicAdapter.EditMessageViewHolder vh = (TopicAdapter.EditMessageViewHolder) + recyclerView.findViewHolderForAdapterPosition(viewModel.getPostBeingEditedPosition()); + vh.editEditor.updateEmojiKeyboardVisibility(); + } + if (viewModel.isWritingReply()) { + TopicAdapter.QuickReplyViewHolder vh = (TopicAdapter.QuickReplyViewHolder) + recyclerView.findViewHolderForAdapterPosition(viewModel.postCount()); + vh.replyEditor.updateEmojiKeyboardVisibility(); + } return; } else if (viewModel.isWritingReply()) { postsList.remove(postsList.size() - 1); diff --git a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java index 2b06ffa9..2efb86c7 100644 --- a/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java +++ b/app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java @@ -485,7 +485,6 @@ class TopicAdapter extends RecyclerView.Adapter { }); holder.replyEditor.setOnClickListener(view -> holder.replyEditor.setError(null)); - if (backPressHidden) { holder.replyEditor.requestFocus(); backPressHidden = false; @@ -601,7 +600,7 @@ class TopicAdapter extends RecyclerView.Adapter { /** * Custom {@link RecyclerView.ViewHolder} implementation */ - private static class QuickReplyViewHolder extends RecyclerView.ViewHolder { + static class QuickReplyViewHolder extends RecyclerView.ViewHolder { final ImageView thumbnail; final TextView username; final EditText quickReplySubject; @@ -616,7 +615,7 @@ class TopicAdapter extends RecyclerView.Adapter { } } - private static class EditMessageViewHolder extends RecyclerView.ViewHolder { + static class EditMessageViewHolder extends RecyclerView.ViewHolder { final ImageView thumbnail; final TextView username; final EditText editSubject;