Skip to content

Commit

Permalink
add toggle select tag method
Browse files Browse the repository at this point in the history
  • Loading branch information
anhtuan23 committed Jun 12, 2018
1 parent 7d4e933 commit f578f6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,22 @@ public void setOnTagClickListener(TagView.OnTagClickListener listener) {
invalidateTags();
}

/**
* Toggle select a tag
*
* @param position
*/
public void toggleSelectTagView(int position) {
if (isTagViewSelectable){
TagView tagView = ((TagView)mChildViews.get(position));
if (tagView.getIsViewSelected()){
unselectTagView(position);
} else {
selectTagView(position);
}
}
}

/**
* Select a tag
*
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/java/co/lujun/sample/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void onTagClick(int position, String text) {

@Override
public void onTagLongClick(final int position, String text) {
mTagContainerLayout3.selectTagView(position);
mTagContainerLayout3.toggleSelectTagView(position);

List<Integer> selectedPositions = mTagContainerLayout3.getSelectedTagViewPositions();
Toast.makeText(MainActivity.this, "selected-positions:" + selectedPositions.toString(),
Expand Down

0 comments on commit f578f6a

Please sign in to comment.