/** * setting up a new instance to data; * * @param data */ public void setNewData(List<T> data) { this.mData = data == null ? new ArrayList<T>() : data; if (mRequestLoadMoreListener != null) { mNextLoadEnable = true; mLoadMoreEnable = true; mLoading = false; mLoadMoreView.setLoadMoreStatus(LoadMoreView.STATUS_DEFAULT); } mLastPosition = -1; notifyDataSetChanged(); }
@Override public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { default: case 0: mAdapter.isFirstOnly(true); break; case 1: mAdapter.isFirstOnly(false); break; } tvIsFirstOnly.setText(stringItems[position]); mAdapter.notifyDataSetChanged(); dialog.dismiss(); } });
/** * @param position */ public void setItemChecked(int position) { if (mLastCheckedPosition == position) return; mBooleanArray.put(position, true); if (mLastCheckedPosition > -1) { mBooleanArray.put(mLastCheckedPosition, false); mAdapter.notifyItemChanged(mLastCheckedPosition); } mAdapter.notifyDataSetChanged(); mLastCheckedPosition = position; }
@Override public void onOperItemClick(AdapterView<?> parent, View view, int position, long id) { switch (position) { default: case 0: mAdapter.setLoadMoreType(LoadMoreType.APAY); break; case 1: mAdapter.setLoadMoreType(LoadMoreType.BALL_BEAT); break; case 2: mAdapter.setLoadMoreType(LoadMoreType.BALL_CLIP_ROTATE); break; case 3: mAdapter.setLoadMoreType(LoadMoreType.BALL_SCALE); break; } btnLoadType.setText(stringItems[position]); mAdapter.notifyDataSetChanged(); dialog.dismiss(); } });
/** * Collapse an expandable item that has been expanded.. * * @param position the position of the item, which includes the header layout count. * @param animate collapse with animation or not. * @param notify notify the recyclerView refresh UI or not. * @return the number of subItems collapsed. */ public int collapse(@IntRange(from = 0) int position, boolean animate, boolean notify) { position -= getHeaderLayoutCount(); IExpandable expandable = getExpandableItem(position); if (expandable == null) { return 0; } int subItemCount = recursiveCollapse(position); expandable.setExpanded(false); int parentPos = position + getHeaderLayoutCount(); if (notify) { if (animate) { notifyItemChanged(parentPos); notifyItemRangeRemoved(parentPos + 1, subItemCount); } else { notifyDataSetChanged(); } } return subItemCount; }
notifyItemRangeInserted(parentPos + 1, subItemCount); } else { notifyDataSetChanged();
public int expandAll(int position, boolean animate, boolean notify) { position -= getHeaderLayoutCount(); T endItem = null; if (position + 1 < this.mData.size()) { endItem = getItem(position + 1); } IExpandable expandable = getExpandableItem(position); if (!hasSubItems(expandable)) { return 0; } int count = expand(position + getHeaderLayoutCount(), false, false); for (int i = position + 1; i < this.mData.size(); i++) { T item = getItem(i); if (item == endItem) { break; } if (isExpandable(item)) { count += expand(i + getHeaderLayoutCount(), false, false); } } if (notify) { if (animate) { notifyItemRangeInserted(position + getHeaderLayoutCount() + 1, count); } else { notifyDataSetChanged(); } } return count; }
mAdapter.notifyDataSetChanged(); dialog.dismiss();