private void moveCursor(int step) { int top = getTopOffset(); int visible = getContentHeight(); // #sijapp cond.if modules_TOUCH is "true"# if (touchUsed) { touchUsed = false; int curr = getCurrItem(); int current = getOffset(curr); if ((current + getItemHeight(curr) < top) || (top + visible < current)) { int offset = (step < 0) ? (top + visible - 1) : (top + 1); setCurrentItemIndex(getItemByOffset(offset)); return; } } // #sijapp cond.end# int next = getCurrItem() + step; if (VirtualList.MP_SELECTABLE_ONLY == getMovingPolicy()) { while (!isItemSelectable(next)) { next += step; if ((next < 0) || (getSize() <= next)) { break; } } } next = Math.max(-1, Math.min(next, getSize())); if (0 < step) { if (getSize() == next) { int end = getFullSize() - visible; if (top < end) { setTopByOffset(Math.min(end, top + visible / 3)); return; } } else { int nextOffset = getOffset(next); if (top + visible < nextOffset) { setTopByOffset(top + visible / 3); return; } } } else { if (-1 == next) { if (0 < top) { setTopByOffset(Math.max(0, top - visible / 3)); return; } } else { if (getOffset(next) + getItemHeight(next) < top) { setTopByOffset(top - visible / 3); return; } } } if ((next < 0) || (getSize() <= next)) { return; } setCurrentItemIndex(next); }
private void setOptimalTopItem() { int size = getSize(); if (0 == size) { setTopByOffset(0); return; } int current = Math.max(0, getCurrItem()); int top = get_Top(); int topOffset = get_TopOffset(); if (current <= top) { top = current; final int contentHeight = getContentHeight(); int maxTopHeight = getOffset(size) - contentHeight; top = Math.min(top, getItemByOffset(maxTopHeight)); setTop(top, Math.max(0, getItemHeight(top) - contentHeight)); } else { top = Math.min(top, size - 1); int height; int offset = getContentHeight(); for (int item = current; top <= item; --item) { height = getItemHeight(item); offset -= height; if (offset <= 0) { offset = -offset; if (item == current) { offset = 0; } if (item < top) { } else if ((item == top) && (offset < topOffset)) { } else { setTop(item, offset); } return; } } } }
private int getBottomVisibleItem() { int size = getSize(); int cur = size; int offset = getContentHeight() + get_TopOffset(); for (int i = get_Top(); i < size; ++i) { int height = getItemHeight(i); if (offset < height) { cur = i; break; } offset -= height; } cur = (size == cur) ? size - 1 : Math.max(get_Top(), cur - 1); return cur; }
private void drawBack(GraphicsEx g, int top, int width, int height) { // Fill background g.setThemeColor(CanvasEx.THEME_BACKGROUND); g.fillRect(0, top, width, height); g.setClip(0, top, width, height); if (null != Scheme.backImage) { int offset = 0; if (0 < getSize()) { offset = Math.max(0, Scheme.backImage.getHeight() - height) * getTopOffset() / getFullSize(); } g.drawImage(Scheme.backImage, 0, top - offset, Graphics.LEFT | Graphics.TOP); } }
private void setCurrItem(int cItem) { currItem = Math.max(0, Math.min(cItem, getSize() - 1)); }
public final void setTopByOffset(int offset) { offset = Math.max(0, Math.min(offset, getFullSize() - getContentHeight())); int top = getItemByOffset(offset); setTop(top, offset - getOffset(top)); }