Skip to content

Commit

Permalink
Changing how the EditorActionListener works.
Browse files Browse the repository at this point in the history
  • Loading branch information
milos192 committed Feb 23, 2017
1 parent 9e2eccd commit 14362fb
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions library/src/main/java/com/seraphim/chips/ChipsView.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,15 @@ public void clicked(ChipEntry entry) {

@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (chipsListener == null || !chipsListener.onEditorAction(v, actionId, event)) {
if (mode == Mode.ALL && !editText.getText().toString().isEmpty() && actionId == EditorInfo.IME_ACTION_DONE) {
ChipEntry entry = factory.createChip(editText.getText().toString());
editText.setText("");
addChip(entry);
}
if (mode == Mode.ALL && !editText.getText().toString().isEmpty() && actionId == EditorInfo.IME_ACTION_DONE) {
ChipEntry entry = factory.createChip(editText.getText().toString());
editText.setText("");
addChip(entry);
}
// The upper action can be disabled by setting the Mode, so there's no use in having another way to disable it (via returning false),
// and there is an added benefit from having the factory created Chip in the chips list.
if (chipsListener != null) {
chipsListener.onEditorAction(v, actionId, event);
}
return true;
}
Expand Down

0 comments on commit 14362fb

Please sign in to comment.