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() {
if (emojiKeyboard.getVisibility() == View.VISIBLE) {
emojiKeyboard.setVisibility(View.GONE);
editorView.setEmojiKeyboardVisible(false);
editorView.updateEmojiKeyboardVisibility();
} else {
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);
InputConnection ic = holder.replyEditor.getInputConnection();
emojiKeyboardOwner.setEmojiKeyboardInputConnection(ic);
holder.replyEditor.setEmojiKeyboardVisible(emojiKeyboardOwner.isEmojiKeyboardVisible());
holder.replyEditor.updateEmojiKeyboardVisibility();
holder.replyEditor.setText(viewModel.getBuildedQuotes());
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 submitButton;
private EmojiKeyboard.EmojiKeyboardOwner emojiKeyboardOwner;
private boolean emojiKeyboardVisible = false;
public EditorView(Context context) {
super(context);
@ -74,14 +73,14 @@ public class EditorView extends LinearLayout {
emojiButton = findViewById(R.id.emoji_keyboard_button);
editText.setOnTouchListener((v, event) -> {
if (emojiKeyboardVisible) return true;
if (emojiKeyboardOwner.isEmojiKeyboardVisible()) return true;
return false;
});
emojiButton.setOnClickListener(view -> {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
assert imm != null;
if (emojiKeyboardVisible) {
if (emojiKeyboardOwner.isEmojiKeyboardVisible()) {
editText.requestFocus();
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp);
@ -90,8 +89,7 @@ public class EditorView extends LinearLayout {
view.clearFocus();
emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp);
}
emojiKeyboardVisible = !emojiKeyboardVisible;
emojiKeyboardOwner.setEmojiKeyboardVisible(emojiKeyboardVisible);
emojiKeyboardOwner.setEmojiKeyboardVisible(!emojiKeyboardOwner.isEmojiKeyboardVisible());
});
submitButton = findViewById(R.id.submit_button);
@ -271,11 +269,10 @@ public class EditorView extends LinearLayout {
return editText.onCreateInputConnection(new EditorInfo());
}
public void setEmojiKeyboardVisible(boolean visible) {
if (visible)
public void updateEmojiKeyboardVisibility() {
if (emojiKeyboardOwner.isEmojiKeyboardVisible())
emojiButton.setImageResource(R.drawable.ic_keyboard_grey_24dp);
else
emojiButton.setImageResource(R.drawable.ic_tag_faces_grey_24dp);
emojiKeyboardVisible = visible;
}
}

Loading…
Cancel
Save