/** * Invalidates wheel * @param clearCaches if true then cached views will be clear */ public void invalidateWheel(boolean clearCaches) { if (clearCaches) { recycle.clearAll(); if (itemsLayout != null) { itemsLayout.removeAllViews(); } scrollingOffset = 0; } else if (itemsLayout != null) { // cache all items recycle.recycleItems(itemsLayout, firstItem, new ItemsRange()); } invalidate(); }
/** * Invalidates wheel * * @param clearCaches * if true then cached views will be clear */ public void invalidateWheel(boolean clearCaches) { if (clearCaches) { recycle.clearAll(); if (itemsLayout != null) { itemsLayout.removeAllViews(); } scrollingOffset = 0; } else if (itemsLayout != null) { // cache all items recycle.recycleItems(itemsLayout, firstItem, new ItemsRange()); } invalidate(); }
/** * Builds view for measuring */ private void buildViewForMeasuring() { // clear all items if (itemsLayout != null) { recycle.recycleItems(itemsLayout, firstItem, new ItemsRange()); } else { createItemsLayout(); } // add views int addItems = visibleItems / 2; for (int i = currentItem + addItems; i >= currentItem - addItems; i--) { if (addViewItem(i, true)) { firstItem = i; } } }
/** * Builds view for measuring */ private void buildViewForMeasuring() { // clear all items if (itemsLayout != null) { recycle.recycleItems(itemsLayout, firstItem, new ItemsRange()); } else { createItemsLayout(); } // add views int addItems = visibleItems / 2; for (int i = currentItem + addItems; i >= currentItem - addItems; i--) { if (addViewItem(i, true)) { firstItem = i; } } }
/** * Calculates range for wheel items * @return the items range */ private ItemsRange getItemsRange() { if (getItemHeight() == 0) { return null; } int first = currentItem; int count = 1; while (count * getItemHeight() < getHeight()) { first--; count += 2; // top + bottom items } if (scrollingOffset != 0) { if (scrollingOffset > 0) { first--; } count++; // process empty items above the first or below the second int emptyItems = scrollingOffset / getItemHeight(); first -= emptyItems; count += Math.asin(emptyItems); } return new ItemsRange(first, count); }
/** * Calculates range for wheel items * * @return the items range */ private ItemsRange getItemsRange() { if (getItemHeight() == 0) { return null; } int first = currentItem; int count = 1; while (count * getItemHeight() < getHeight()) { first--; count += 2; // top + bottom items } if (scrollingOffset != 0) { if (scrollingOffset > 0) { first--; } count++; // process empty items above the first or below the second int emptyItems = scrollingOffset / getItemHeight(); first -= emptyItems; count += Math.asin(emptyItems); } return new ItemsRange(first, count); }