List of usage examples for android.util SparseIntArray append
public void append(int key, int value)
From source file:com.tct.fw.ex.photo.adapters.BaseCursorPagerAdapter.java
/** * Sets the {@link #mItemPosition} instance variable with the current mapping of * row id to cursor position./*from w w w. j ava 2s . co m*/ */ private void setItemPosition() { if (mCursor == null || mCursor.isClosed()) { mItemPosition = null; return; } SparseIntArray itemPosition = new SparseIntArray(mCursor.getCount()); mCursor.moveToPosition(-1); while (mCursor.moveToNext()) { final int rowId = mCursor.getString(mRowIDColumn).hashCode(); final int position = mCursor.getPosition(); itemPosition.append(rowId, position); } mItemPosition = itemPosition; }
From source file:com.google.android.flexbox.FlexboxHelper.java
private int[] sortOrdersIntoReorderedIndices(int childCount, List<Order> orders, SparseIntArray orderCache) { Collections.sort(orders);/* w w w. j av a2s . c om*/ orderCache.clear(); int[] reorderedIndices = new int[childCount]; int i = 0; for (Order order : orders) { reorderedIndices[i] = order.index; orderCache.append(order.index, order.order); i++; } return reorderedIndices; }