fix preselecting multiple encryption recipients
This commit is contained in:
@@ -45,7 +45,6 @@ public abstract class ChipsInput<T extends FilterableItem> extends ScrollViewMax
|
||||
private boolean mShowChipDetailed = true;
|
||||
|
||||
private List<ChipsListener<T>> mChipsListenerList = new ArrayList<>();
|
||||
private ChipValidator<T> mChipValidator;
|
||||
|
||||
private ChipsAdapter<T, ?> chipsAdapter;
|
||||
private RecyclerView chipsRecyclerView;
|
||||
@@ -187,8 +186,8 @@ public abstract class ChipsInput<T extends FilterableItem> extends ScrollViewMax
|
||||
});
|
||||
}
|
||||
|
||||
public void addChip(T chip) {
|
||||
chipsAdapter.addChip(chip);
|
||||
public void addChips(List<T> chips) {
|
||||
chipsAdapter.addChipsProgrammatically(chips);
|
||||
}
|
||||
|
||||
public ChipsInputEditText getEditText() {
|
||||
@@ -317,14 +316,6 @@ public abstract class ChipsInput<T extends FilterableItem> extends ScrollViewMax
|
||||
}));
|
||||
}
|
||||
|
||||
public ChipValidator<T> getChipValidator() {
|
||||
return mChipValidator;
|
||||
}
|
||||
|
||||
public void setChipValidator(ChipValidator<T> mChipValidator) {
|
||||
this.mChipValidator = mChipValidator;
|
||||
}
|
||||
|
||||
public interface ChipsListener<T extends FilterableItem> {
|
||||
void onChipAdded(T chip, int newSize);
|
||||
void onChipRemoved(T chip, int newSize);
|
||||
@@ -338,8 +329,4 @@ public abstract class ChipsInput<T extends FilterableItem> extends ScrollViewMax
|
||||
public void onTextChanged(CharSequence text) { }
|
||||
public void onActionDone(CharSequence text) { }
|
||||
}
|
||||
|
||||
public interface ChipValidator<T extends FilterableItem> {
|
||||
boolean areEquals(T chip1, T chip2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,17 +202,19 @@ public abstract class ChipsAdapter<T extends FilterableItem, VH extends Recycler
|
||||
}
|
||||
|
||||
public void addChip(T chip) {
|
||||
if (!listContains(chipList, chip)) {
|
||||
chipList.add(chip);
|
||||
// notify listener
|
||||
chipsInput.onChipAdded(chip, chipList.size());
|
||||
// hide hint
|
||||
editText.setHint(null);
|
||||
// reset text
|
||||
editText.setText(null);
|
||||
// refresh data
|
||||
notifyItemInserted(chipList.size());
|
||||
if (chipList.contains(chip)) {
|
||||
return;
|
||||
}
|
||||
|
||||
chipList.add(chip);
|
||||
// notify listener
|
||||
chipsInput.onChipAdded(chip, chipList.size());
|
||||
// hide hint
|
||||
editText.setHint(null);
|
||||
// reset text
|
||||
editText.setText(null);
|
||||
// refresh data
|
||||
notifyItemInserted(chipList.size() -1);
|
||||
}
|
||||
|
||||
public void removeChip(T chip) {
|
||||
@@ -289,16 +291,4 @@ public abstract class ChipsAdapter<T extends FilterableItem, VH extends Recycler
|
||||
editText = (EditText) view;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean listContains(List<T> contactList, T chip) {
|
||||
if (chipsInput.getChipValidator() != null) {
|
||||
for (T item : contactList) {
|
||||
if (chipsInput.getChipValidator().areEquals(item, chip)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user