Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

harshsoni1110
Copy link

  • Callback for new chip added.

- Callback for new chip added.
@CLAassistant
Copy link

CLAassistant commented Dec 17, 2018

CLA assistant check
All committers have signed the CLA.

@@ -53,12 +57,28 @@ public int findAndHandleChipTerminators(@NonNull ChipTokenizer tokenizer, @NonNu
switch (behavior) {
case BEHAVIOR_CHIPIFY_ALL:
selectionIndex = handleChipifyAll(textIterator, tokenizer);
if (mOnChipAddListener != null) {
Copy link
Contributor

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;
Copy link
Contributor

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);
Copy link
Contributor

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));
Copy link
Contributor

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;
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants