Browse Source

remove redundant variable in editor view

pull/45/head
Thodoris1999 6 years ago
parent
commit
242020c254
  1. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java
  3. 13
      app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java

2
app/src/main/java/gr/thmmy/mthmmy/activities/TestEditView.java

@ -45,7 +45,7 @@ public class TestEditView extends AppCompatActivity implements EmojiKeyboard.Emo
public void onBackPressed() { public void onBackPressed() {
if (emojiKeyboard.getVisibility() == View.VISIBLE) { if (emojiKeyboard.getVisibility() == View.VISIBLE) {
emojiKeyboard.setVisibility(View.GONE); emojiKeyboard.setVisibility(View.GONE);
editorView.setEmojiKeyboardVisible(false); editorView.updateEmojiKeyboardVisibility();
} else { } else {
super.onBackPressed(); super.onBackPressed();
} }

2
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicAdapter.java

@ -462,7 +462,7 @@ class TopicAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
holder.replyEditor.setEmojiKeyboardOwner(emojiKeyboardOwner); holder.replyEditor.setEmojiKeyboardOwner(emojiKeyboardOwner);
InputConnection ic = holder.replyEditor.getInputConnection(); InputConnection ic = holder.replyEditor.getInputConnection();
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic); emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic);
holder.replyEditor.setEmojiKeyboardVisible(emojiKeyboardOwner.isEmojiKeyboardVisible()); holder.replyEditor.updateEmojiKeyboardVisibility();
holder.replyEditor.setText(viewModel.getBuildedQuotes()); holder.replyEditor.setText(viewModel.getBuildedQuotes());
holder.replyEditor.setOnSubmitListener(view -> { holder.replyEditor.setOnSubmitListener(view -> {

13
app/src/main/java/gr/thmmy/mthmmy/utils/EditorView.java

@ -34,7 +34,6 @@ public class EditorView extends LinearLayout {
private AppCompatImageButton emojiButton; private AppCompatImageButton emojiButton;
private AppCompatImageButton submitButton; private AppCompatImageButton submitButton;
private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner; private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner;
private boolean emojiKeyboardVisible = false;
public EditorView(Context context) { public EditorView(Context context) {
super(context); super(context);
@ -74,14 +73,14 @@ public class EditorView extends LinearLayout {
emojiButton = findViewById(R.id.emoji_keyboard_button); emojiButton = findViewById(R.id.emoji_keyboard_button);
editText.setOnTouchListener((v, event) -> { editText.setOnTouchListener((v, event) -> {
if (emojiKeyboardVisible) return true; if (emojiKeyboardOwner.isEmojiKeyboardVisible()) return true;
return false; return false;
}); });
emojiButton.setOnClickListener(view -> { emojiButton.setOnClickListener(view -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE); InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
assert imm != null; assert imm != null;
if (emojiKeyboardVisible) { if (emojiKeyboardOwner.isEmojiKeyboardVisible()) {
editText.requestFocus(); editText.requestFocus();
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT); imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp); emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp);
@ -90,8 +89,7 @@ public class EditorView extends LinearLayout {
view.clearFocus(); view.clearFocus();
emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp); emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp);
} }
emojiKeyboardVisible = !emojiKeyboardVisible; emojiKeyboardOwner.setEmojiKeyboardVisible(!emojiKeyboardOwner.isEmojiKeyboardVisible());
emojiKeyboardOwner.setEmojiKeyboardVisible(emojiKeyboardVisible);
}); });
submitButton = findViewById(R.id.submit_button); submitButton = findViewById(R.id.submit_button);
@ -271,11 +269,10 @@ public class EditorView extends LinearLayout {
return editText.onCreateInputConnection(new EditorInfo()); return editText.onCreateInputConnection(new EditorInfo());
} }
public void setEmojiKeyboardVisible(boolean visible) { public void updateEmojiKeyboardVisibility() {
if (visible) if (emojiKeyboardOwner.isEmojiKeyboardVisible())
emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp); emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp);
else else
emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp); emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp);
emojiKeyboardVisible = visible;
} }
} }

Loading…
Cancel
Save