@SmallTest @Test public void adapterSize_nonVisibleRowInserted() { int itemCount = 4; ArrayObjectAdapter adapter = new ArrayObjectAdapter(presenterSelector); adapter.add(new SectionRow("section 1")); for (int i = 0; i < itemCount; i++) { HeaderItem headerItem = new HeaderItem(i, "header "+i); adapter.add(new ListRow(headerItem, createListRowAdapter())); } ListRowDataAdapter listRowDataAdapter = new ListRowDataAdapter(adapter); assertEquals(5, listRowDataAdapter.size()); List<DividerRow> invisibleRows = new ArrayList<>(); invisibleRows.add(new DividerRow()); invisibleRows.add(new DividerRow()); listRowDataAdapter.registerObserver(dataObserver); adapter.addAll(adapter.size(), invisibleRows); verify(dataObserver, times(0)).onItemRangeInserted(anyInt(), anyInt()); assertEquals(5, listRowDataAdapter.size()); adapter.add(new DividerRow()); verify(dataObserver, times(0)).onItemRangeInserted(anyInt(), anyInt()); assertEquals(5, listRowDataAdapter.size()); adapter.add(new ListRow(new HeaderItem(0, "Header 5"), createListRowAdapter())); verify(dataObserver, times(1)).onItemRangeInserted(5, 4); assertEquals(9, listRowDataAdapter.size()); }
@Override public int size() { return mLastVisibleRowIndex + 1; }
ListRowDataAdapter extends ObjectAdapter { @Override public int size() { return mLastVisibleRowIndex + 1; } }
ListRowDataAdapter extends ObjectAdapter { @Override public int size() { return mLastVisibleRowIndex + 1; } ListRowDataAdapter(ObjectAdapter adapter); }
ListRowDataAdapter extends ObjectAdapter { @Override public int size() { return mLastVisibleRowIndex + 1; } ListRowDataAdapter(ObjectAdapter adapter); @Override int size(); @Override Object get(int index); }
ListRowDataAdapter extends ObjectAdapter { @Override public int size() { return mLastVisibleRowIndex + 1; } ListRowDataAdapter(ObjectAdapter adapter); @Override int size(); @Override Object get(int index); static final int ON_ITEM_RANGE_CHANGED; static final int ON_ITEM_RANGE_INSERTED; static final int ON_ITEM_RANGE_REMOVED; static final int ON_CHANGED; }