Skip to content

Commit

Permalink
Merge pull request #1713 from AllenCoder/master
Browse files Browse the repository at this point in the history
1.Decoupling click events
  • Loading branch information
CymChad authored Nov 8, 2017
2 parents ee6500e + d36408f commit 45a4a6c
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,20 +953,39 @@ private void bindViewClickListener(final BaseViewHolder baseViewHolder) {
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getOnItemClickListener().onItemClick(BaseQuickAdapter.this, v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
setOnItemClick(v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
}
});
}
if (getOnItemLongClickListener() != null) {
view.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
return getOnItemLongClickListener().onItemLongClick(BaseQuickAdapter.this, v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
return setOnItemLongClick(v, baseViewHolder.getLayoutPosition() - getHeaderLayoutCount());
}
});
}
}

/**
* override this method if you want to override click event logic
* @param v
* @param position
*/
public void setOnItemClick(View v, int position) {
getOnItemClickListener().onItemClick(BaseQuickAdapter.this, v, position);
}

/**
* override this method if you want to override longClick event logic
* @param v
* @param position
* @return
*/
public boolean setOnItemLongClick(View v, int position) {
return getOnItemLongClickListener().onItemLongClick(BaseQuickAdapter.this, v, position);
}

private MultiTypeDelegate<T> mMultiTypeDelegate;

public void setMultiTypeDelegate(MultiTypeDelegate<T> multiTypeDelegate) {
Expand Down Expand Up @@ -1687,7 +1706,7 @@ public int expandAll(int position, boolean animate, boolean notify) {
return 0;
}

if(!hasSubItems(expandable)){
if (!hasSubItems(expandable)) {
expandable.setExpanded(true);
notifyItemChanged(position);
return 0;
Expand Down Expand Up @@ -1744,7 +1763,7 @@ private int recursiveCollapse(@IntRange(from = 0) int position) {
int subItemCount = 0;
if (expandable.isExpanded()) {
List<T> subItems = expandable.getSubItems();
if(null == subItems) return 0;
if (null == subItems) return 0;

for (int i = subItems.size() - 1; i >= 0; i--) {
T subItem = subItems.get(i);
Expand Down

0 comments on commit 45a4a6c

Please sign in to comment.