-
Notifications
You must be signed in to change notification settings - Fork 88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add onChipAddListener #76
base: master
Are you sure you want to change the base?
Add onChipAddListener #76
Conversation
harshsoni1110
commented
Dec 17, 2018
- Callback for new chip added.
- Callback for new chip added.
@@ -53,12 +57,28 @@ public int findAndHandleChipTerminators(@NonNull ChipTokenizer tokenizer, @NonNu | |||
switch (behavior) { | |||
case BEHAVIOR_CHIPIFY_ALL: | |||
selectionIndex = handleChipifyAll(textIterator, tokenizer); | |||
if (mOnChipAddListener != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@harhsoni1110 it seems that these 3 blocks do the same thing. Why not put it into a private method?
|
||
@Override | ||
public void setChipAddListener(NachoTextView.OnChipAddListener onChipAddListener) { | ||
this.mOnChipAddListener = onChipAddListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need a this
since the names of the fields are different.
@@ -1127,4 +1139,8 @@ public boolean onSingleTapUp(MotionEvent e) { | |||
return true; | |||
} | |||
} | |||
|
|||
public interface OnChipAddListener { | |||
void onChipAdded(Chip chip); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you provide the documentation and contract of when and what the onChipAdded
is supposed to adhere to? It can be similar to the onChipRemove
@@ -796,6 +805,9 @@ public void onItemClick(AdapterView<?> adapterView, View view, int position, lon | |||
|
|||
editable.replace(start, end, mChipTokenizer.terminateToken(text, data)); | |||
|
|||
if (onChipAddListener != null){ | |||
onChipAddListener.onChipAdded(getAllChips().get(getAllChips().size()-1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remember to format your code with Android Studio's code formatting. The -1
would be spread out to make it look nicer
@@ -150,6 +150,8 @@ | |||
|
|||
// Text entry | |||
@Nullable | |||
private OnChipAddListener onChipAddListener; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to stay consistent, please use mOnChipAddListener