Package totalcross.ui
Class DynamicScrollContainer
- java.lang.Object
-
- totalcross.ui.gfx.GfxSurface
-
- totalcross.ui.Control
-
- totalcross.ui.Container
-
- totalcross.ui.ScrollContainer
-
- totalcross.ui.DynamicScrollContainer
-
- All Implemented Interfaces:
Scrollable
public class DynamicScrollContainer extends ScrollContainer
DynamicScrollContaineris a specialized type of Scroll Container intended for high performance
where hundreds or thousands of views need to be displayed in a scrollable list.The performance is achieved by only every having the visible views on the screen occupy memory at a given time. When a view is scrolled out of the visible area of the scroll container it is immediately destroyed and removed from memory. When a view is scrolled into the visible area of the scroll container it is created if not already visible.
Views are created by aDynamicScrollContainer.DataSourceOnly vertical scrolling is supported.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDynamicScrollContainer.AbstractViewRepresents a view to be displayed on aDynamicScrollContainer.static classDynamicScrollContainer.DataSourceThis class is responsible for serving up theDynamicScrollContainer.AbstractViews to display on aDynamicScrollContainer.-
Nested classes/interfaces inherited from class totalcross.ui.Control
Control.TranslucentShape
-
-
Field Summary
Fields Modifier and Type Field Description protected static intSCROLL_DOWNprotected static intSCROLL_UNKNOWNprotected static intSCROLL_UP-
Fields inherited from class totalcross.ui.ScrollContainer
autoScroll, bag, bag0, flick, hsIgnoreAutoScroll, lastH, lastV, sbH, sbV, shrink2size
-
Fields inherited from class totalcross.ui.Container
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastScreenWidth, lastW, lastX, lastY, started, tabOrder, tail, TRANSITION_CLOSE, TRANSITION_FADE, TRANSITION_NONE, TRANSITION_OPEN, TRANSITION_TIME, transitionEffect
-
Fields inherited from class totalcross.ui.Control
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, nextTabControl, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
-
-
Constructor Summary
Constructors Constructor Description DynamicScrollContainer()DynamicScrollContainer(DynamicScrollContainer.DataSource datasource)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DynamicScrollContainer.AbstractViewgetTopMostVisibleView()Returns the top mostDynamicScrollContainer.AbstractViewthat starts within the viewable areabooleanisViewVisible(DynamicScrollContainer.AbstractView view)Returns true if the view is in the currently visible part of the scroll containervoidonEvent(Event event)Called to process key, pen, control and other posted events.voidreposition()Reposition this control, calling again setRect with the original parameters.voidresize(int maxX, int maxY)This method resizes the control to the needed bounds, based on the given maximum width and heights.booleanscrollContent(int dx, int dy, boolean fromFlick)Performs a relative move.voidscrollToView(DynamicScrollContainer.AbstractView view)voidsetDataSource(DynamicScrollContainer.DataSource datasource)Set theDynamicScrollContainer.DataSourceto be used with this containervoidstopFlick()Stops any triggered flick eventsprotected voidupdateVisibleViews(int scrollDirection)-
Methods inherited from class totalcross.ui.ScrollContainer
add, bagSetRect, canScrollContent, canShowScrollBars, flickEnded, flickStarted, getBagChildren, getBagInitialHeight, getBagInitialWidth, getClientRect, getFlick, getPreferredHeight, getPreferredWidth, getRealClientRect, getScrollDistance, getScrollPosition, moveFocusToNextControl, onBoundsChanged, onColorsChanged, onFontChanged, onPaint, remove, removeAll, resize, scrollPage, scrollToControl, scrollToOrigin, scrollToPage, setBorderStyle, setHValue, setScrollBars, setVValue, wasScrolled
-
Methods inherited from class totalcross.ui.Container
add, add, add, add, applyTransitionEffect, broadcastEvent, clear, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderStyle, getChildren, getChildrenCount, getClientRect, getFirstChild, getFocusableControls, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resizeHeight, resizeWidth, setEnabled, setFocusTraversable, setHighlighting, setInsets, setNextTransitionEffect, setPressColor, setPressed, swapToTopmostWindow
-
Methods inherited from class totalcross.ui.Control
_onEvent, addEnabledStateListener, addFocusListener, addGridListener, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addTimer, addTimer, addTimerListener, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, handleGeographicalFocusChangeKeys, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, repositionChildren, requestFocus, resetSetPositions, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
-
-
-
-
Field Detail
-
SCROLL_UP
protected static final int SCROLL_UP
- See Also:
- Constant Field Values
-
SCROLL_UNKNOWN
protected static final int SCROLL_UNKNOWN
- See Also:
- Constant Field Values
-
SCROLL_DOWN
protected static final int SCROLL_DOWN
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DynamicScrollContainer
public DynamicScrollContainer(DynamicScrollContainer.DataSource datasource)
-
DynamicScrollContainer
public DynamicScrollContainer()
-
-
Method Detail
-
onEvent
public void onEvent(Event event)
Description copied from class:ControlCalled to process key, pen, control and other posted events.- Overrides:
onEventin classScrollContainer- Parameters:
event- the event to process- See Also:
Event,KeyEvent,PenEvent
-
updateVisibleViews
protected void updateVisibleViews(int scrollDirection)
-
getTopMostVisibleView
public DynamicScrollContainer.AbstractView getTopMostVisibleView()
Returns the top mostDynamicScrollContainer.AbstractViewthat starts within the viewable area
-
isViewVisible
public boolean isViewVisible(DynamicScrollContainer.AbstractView view)
Returns true if the view is in the currently visible part of the scroll container- Parameters:
view-
-
reposition
public void reposition()
Description copied from class:ControlReposition this control, calling again setRect with the original parameters.- Overrides:
repositionin classScrollContainer
-
setDataSource
public void setDataSource(DynamicScrollContainer.DataSource datasource)
Set theDynamicScrollContainer.DataSourceto be used with this container- Parameters:
datasource-
-
scrollContent
public boolean scrollContent(int dx, int dy, boolean fromFlick)Description copied from interface:ScrollablePerforms a relative move.- Specified by:
scrollContentin interfaceScrollable- Overrides:
scrollContentin classScrollContainer- Parameters:
dx- The relative amount of pixels to move in the X axis.dy- The relative amount of pixels to move in the Y axis.
-
scrollToView
public void scrollToView(DynamicScrollContainer.AbstractView view)
-
resize
public void resize(int maxX, int maxY)Description copied from class:ScrollContainerThis method resizes the control to the needed bounds, based on the given maximum width and heights.- Overrides:
resizein classScrollContainer
-
stopFlick
public void stopFlick()
Stops any triggered flick events
-
-