Jave notify item range inserted
22 Jave code examples are found related to "
notify item range inserted".
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: StickyHeaderGridAdapter.java From Sticky-Header-Grid with MIT License | 6 votes |
public void notifySectionItemRangeInserted(int section, int position, int count) { calculateSections(); if (mSections == null) { notifyAllSectionsDataSetChanged(); } else { final Section sectionObject = mSections.get(section); if (position < 0 || position >= sectionObject.itemNumber) { throw new IndexOutOfBoundsException("Invalid index " + position + ", size is " + sectionObject.itemNumber); } if (position + count > sectionObject.itemNumber) { throw new IndexOutOfBoundsException("Invalid index " + (position + count) + ", size is " + sectionObject.itemNumber); } notifyItemRangeInserted(sectionObject.position + position + 1, count); } }
Example 2
Source File: NestedAdapter.java From expandable-recyclerview with MIT License | 6 votes |
public final void notifyChildItemRangeInserted(int groupIndex, int childIndex, int itemCount) { if (itemCount <= 0 || groupIndex < 0 || childIndex < 0) { return; } int groupCount = getSafeGroupCount(); if (groupIndex >= groupCount) { return; } int childCount = getSafeChildCount(groupIndex); if (childCount < childIndex) { return; } int position = 0; int i = 0; while (i < groupIndex) { position++; position += getSafeChildCount(i); i++; } position += childIndex; position++; notifyItemRangeInserted(position, itemCount); }
Example 3
Source File: BrickDataManagerTest.java From brickkit-android with Apache License 2.0 | 6 votes |
@Test public void testSafeNotifyItemRangeInserted() { // Given List<BaseBrick> items = new LinkedList<>(); for (int i = 0; i < 5; i++) { items.add(brickTestHelper.generateBrick()); } // When manager.setItems(items); manager.safeNotifyItemRangeInserted(items.get(3), 3); // Verify assertEquals(3, observer.getItemRangeInsertedPositionStart()); assertEquals(3, observer.getItemRangeInsertedItemCount()); }
Example 4
Source File: SectioningAdapter.java From StickyHeaders with MIT License | 6 votes |
private void notifySectionItemRangeInserted(int sectionIndex, int fromPosition, int number, boolean updateSelectionState) { if (sections == null) { buildSectionIndex(); notifyAllSectionsDataSetChanged(); } else { buildSectionIndex(); Section section = this.sections.get(sectionIndex); // 0 is a valid position to insert from if (fromPosition > section.numberOfItems) { throw new IndexOutOfBoundsException("itemIndex adapterPosition: " + fromPosition + " exceeds sectionIndex numberOfItems: " + section.numberOfItems); } int offset = fromPosition; if (section.hasHeader) { offset += 2; } notifyItemRangeInserted(section.adapterPosition + offset, number); } if (updateSelectionState) { // update selection state by inserting unselected spaces updateSectionItemRangeSelectionState(sectionIndex, fromPosition, +number); } }
Example 5
Source File: HeaderFooterRecyclerAdapter.java From Android-Next with Apache License 2.0 | 5 votes |
/** * Notifies that multiple footer items are inserted. * * @param positionStart the position. * @param itemCount the item count. */ public final void notifyFooterItemRangeInserted(int positionStart, int itemCount) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); int newFooterItemCount = getFooterItemCount(); if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooterItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - " + (newFooterItemCount - 1) + "]."); } notifyItemRangeInserted(positionStart + newHeaderItemCount + newContentItemCount, itemCount); }
Example 6
Source File: HeaderFooterRecyclerViewAdapter.java From droidddle with Apache License 2.0 | 5 votes |
/** * Notifies that multiple footer items are inserted. * * @param positionStart the position. * @param itemCount the item count. */ public final void notifyFooterItemRangeInserted(int positionStart, int itemCount) { int newHeaderItemCount = getHeaderItemCount(); int newContentItemCount = getContentItemCount(); int newFooterItemCount = getFooterItemCount(); if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newFooterItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for footer items [0 - " + (newFooterItemCount - 1) + "]."); } notifyItemRangeInserted(positionStart + newHeaderItemCount + newContentItemCount, itemCount); }
Example 7
Source File: RecyclerView.java From kripton with Apache License 2.0 | 5 votes |
public void notifyItemRangeInserted(int positionStart, int itemCount) { // since onItemRangeInserted() is implemented by the app, it could do anything, // including removing itself from {@link mObservers} - and that could cause problems if // an iterator is used on the ArrayList {@link mObservers}. // to avoid such problems, just march thru the list in the reverse order. for (int i = mObservers.size() - 1; i >= 0; i--) { mObservers.get(i).onItemRangeInserted(positionStart, itemCount); } }
Example 8
Source File: HeaderFooterRecyclerViewAdapter.java From droidddle with Apache License 2.0 | 5 votes |
/** * Notifies that multiple header items are inserted. * * @param positionStart the position. * @param itemCount the item count. */ public final void notifyHeaderItemRangeInserted(int positionStart, int itemCount) { int newHeaderItemCount = getHeaderItemCount(); if (positionStart < 0 || itemCount < 0 || positionStart + itemCount > newHeaderItemCount) { throw new IndexOutOfBoundsException("The given range [" + positionStart + " - " + (positionStart + itemCount - 1) + "] is not within the position bounds for header items [0 - " + (newHeaderItemCount - 1) + "]."); } notifyItemRangeInserted(positionStart, itemCount); }
Example 9
Source File: ExpandableAdapter.java From ExpandableRecyclerView with Apache License 2.0 | 5 votes |
/** * 通知任何注册的监视器当前在 {@code parentPosition,childPositionStart} 位置有 {@code childItemCount} 个子列表项插入, * 之前在该位置存在的子列表项将被移动到 {@code childPositionStart + childItemCount} 位置。 * <p> * 这是数据结构上的变化,尽管位置变化了,但是之前存在的所有列表项在数据集里的数据都会被认为最新, * 因此这些列表项不会被重新绑定数据 * </p> * * @param parentPosition 要插入多个新子列表项所属的父列表项位置 * @param childPositionStart 要插入多个新子列表项的位置 * @param childItemCount 要插入的子列表项的个数 * @param forceExpandParent 是否强制展开已插入的子列表项所属的父列表项,如果当前父列表项没有展开 * @see #notifyChildItemInserted(int, int, boolean) */ public void notifyChildItemRangeInserted(int parentPosition, int childPositionStart, int childItemCount, boolean forceExpandParent) { int parentAdapterPos = getParentAdapterPosition(parentPosition); if (parentAdapterPos == RecyclerView.NO_POSITION) return; ItemWrapper<P, C> itemWrapper = getItem(parentAdapterPos); //这里判断如果父列表项已展开才添加数据并通知刷新列表界面 //注意:这里的数据添加和 {@code expandParentItem } 数据添加有冲突,因为 expandParentItem //获取子列表数据然后再添加到模型数据层再刷新界面的,这里如果判断没展开就不能添加数据,否则有重复数据显示 if (!itemWrapper.isExpanded()) { if (itemWrapper.isInitiallyExpandable() && itemWrapper.setExpandable(itemWrapper.hasChildren())) { syncParentExpandableState(parentPosition); } if (forceExpandParent) { expandView(parentPosition, true, false); } return; } List<C> children = itemWrapper.getChildren(); if (!itemWrapper.hasChildren(children)) return; List<C> insertedChildren = children .subList(childPositionStart, childItemCount + childPositionStart); int childAdapterPos = RecyclerView.NO_POSITION; if (childPositionStart >= 0 && childPositionStart < children.size() - childItemCount) { childAdapterPos = getChildAdapterPosition(parentPosition, childPositionStart); } else if (childPositionStart == children.size() - childItemCount) { childAdapterPos = parentAdapterPos + children.size() - childItemCount + 1; } if (childAdapterPos == RecyclerView.NO_POSITION) return; childItemCount = addChildWrapper(parentPosition, childPositionStart, insertedChildren); notifyItemRangeInserted(childAdapterPos, childItemCount); }
Example 10
Source File: ExpandableAdapter.java From ExpandableRecyclerView with Apache License 2.0 | 5 votes |
/** * 通知任何注册的监视器当前在 {@code parentPositionStart} 位置有 {@code parentItemCount} 个父列表项插入, * 之前在该位置存在的父列表项将被移动到 {@code parentPosition + parentItemCount} 位置。 * <p> * 这是数据结构上的变化,尽管位置变化了,但是之前存在的所有列表项在数据集里的数据都会被认为最新, * 因此这些列表项不会被重新绑定数据 * </p> * * @param parentPositionStart 要插入多个新父列表项的位置 * @param parentItemCount 要插入新父列表项的个数 * @see #notifyParentItemInserted(int) */ public void notifyParentItemRangeInserted(int parentPositionStart, int parentItemCount) { final int endInsertPos = mParents.size() - parentItemCount; int parentAdapterPos = RecyclerView.NO_POSITION; if (parentPositionStart >= 0 && parentPositionStart < endInsertPos) { parentAdapterPos = getParentAdapterPosition(parentPositionStart); } else if (parentPositionStart == endInsertPos) { parentAdapterPos = mItems.size(); } if (parentAdapterPos == RecyclerView.NO_POSITION) return; int index = 0; int[] insertedItemCounts = new int[parentItemCount]; int totalInsertedItemCount = 0; for (int i = parentPositionStart, c = parentPositionStart + parentItemCount; i < c; i++) { int insertItemCount = addParentWrapper(parentAdapterPos + totalInsertedItemCount, i); totalInsertedItemCount += insertItemCount; insertedItemCounts[index++] = insertItemCount; } notifyItemRangeInserted(parentAdapterPos, totalInsertedItemCount); //这里如果有 parent 初始化是展开的 默认 notifyParentExpanded 通知客户端,以防万一 parent 展开状态没有同步到 view 层 //注意:通知客户端通知的前提是当前所有的 Parent 已经 notifyItemRangeInserted 通知 recyclerView 了 index = 0; for (int j = parentPositionStart, c = parentPositionStart + parentItemCount; j < c; j++) { syncParentExpandableState(j); if (insertedItemCounts[index++] > 1) syncViewExpansionState(j, false); } }
Example 11
Source File: ThumbSpanHelper.java From MHViewer with Apache License 2.0 | 5 votes |
protected void notifyItemRangeInserted(int positionStart, int itemCount) { if (!mEnable || mSpanCount <= 0) { return; } if (mAttachedCount == positionStart) { append(); } else { rebuild(); } }
Example 12
Source File: RecyclePagerAdapter.java From ProjectX with Apache License 2.0 | 5 votes |
/** * 通知区间子项插入 * * @param positionStart 开始位置 * @param itemCount 子项总数 */ public final void notifyItemRangeInserted(int positionStart, int itemCount) { if (itemCount <= 0) return; if (mItemsInLayout.isEmpty()) return; for (PagerViewHolder holder : mItemsInLayout) { final int position = holder.mPosition; if (position >= positionStart) { holder.mPosition = position + itemCount; holder.mPositionChanged = true; } } super.notifyDataSetChanged(); }
Example 13
Source File: BrickRecyclerAdapterTest.java From brickkit-android with Apache License 2.0 | 5 votes |
@Test public void testSafeNotifyItemRangeInsertedComputingLayout() { when(recyclerView.isComputingLayout()).thenReturn(true); adapter.safeNotifyItemRangeInserted(POSITION, COUNT); assertEquals(-1, observer.getItemRangeInsertedPositionStart()); assertEquals(-1, observer.getItemRangeInsertedItemCount()); }
Example 14
Source File: ChannelAdminLogActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void notifyItemRangeInserted(int positionStart, int itemCount) { updateRows(); try { super.notifyItemRangeInserted(positionStart, itemCount); } catch (Exception e) { FileLog.e(e); } }
Example 15
Source File: AdapterManager.java From android-common-utils with Apache License 2.0 | 4 votes |
public final void notifyItemRangeInserted(int positionStart, int itemCount){ checkIfSupport(); positionStart += getHeaderSize(); mCallback2.notifyItemRangeInserted(positionStart, itemCount); }
Example 16
Source File: RecyclerViewHelper.java From Android-RecyclerViewHelper with Apache License 2.0 | 4 votes |
public void notifyItemRangeInserted(int positionStart, int itemCount) { if (helperAdapter != null) { helperAdapter.notifyItemRangeInserted(helperAdapter.getHeaderCount() + positionStart, helperAdapter.getHeaderCount() + itemCount); } }
Example 17
Source File: PagingUtils.java From TikTok with Apache License 2.0 | 4 votes |
private static void notifyItemRangeInserted(BaseQuickAdapter adapter, List alllist, List nowlist) { int preEndIndex = alllist.size(); alllist.addAll(nowlist); adapter.notifyItemRangeInserted(preEndIndex, nowlist.size()); }
Example 18
Source File: SingleItemAdapter.java From QuickDevFramework with Apache License 2.0 | 4 votes |
public void notifyDataRangeInserted(int dataPosition, int itemCount) { notifyItemRangeInserted(getRealPosition(dataPosition), itemCount); }
Example 19
Source File: DataBinder.java From UltimateRecyclerView with Apache License 2.0 | 4 votes |
public final void notifyBinderItemRangeInserted(int positionStart, int itemCount) { mDataBindAdapter.notifyBinderItemRangeInserted(this, positionStart, itemCount); }
Example 20
Source File: ChildNode.java From 365browser with Apache License 2.0 | 4 votes |
protected void notifyItemRangeInserted(int index, int count) { mNumItems += count; assert mNumItems == getItemCountForDebugging(); assert isRangeValid(index, count); if (mParent != null) mParent.onItemRangeInserted(this, index, count); }
Example 21
Source File: BrickRecyclerAdapter.java From brickkit-android with Apache License 2.0 | 2 votes |
/** * Constructor. * * @param adapter {@link BrickRecyclerAdapter} to notify * @param positionStart Position of the first item that has inserted * @param itemCount Number of items that have inserted */ NotifyItemRangeInsertedRunnable(BrickRecyclerAdapter adapter, final int positionStart, final int itemCount) { this.adapter = adapter; this.positionStart = positionStart; this.itemCount = itemCount; }
Example 22
Source File: BaseSectionAdapter.java From sectioned-recycler-view with MIT License | 2 votes |
/** * Notifies SectionDataManager that <code>cnt</code> items starting at <code>startPos</code> * in this section have been inserted. * <p> * Similar to {@link android.support.v7.widget.RecyclerView.Adapter#notifyItemRangeInserted(int, int)}. * * @param startPos Position of the first item that was inserted. * @param cnt Number of items inserted. */ public final void notifyItemRangeInserted(int startPos, int cnt) { if (itemManager != null) { itemManager.notifyRangeInserted(section, startPos, cnt); } }