sk.baka.ambient.views.gesturelist
Class GesturesListView

java.lang.Object
  extended by android.view.View
      extended by android.view.ViewGroup
          extended by android.widget.AdapterView<ListAdapter>
              extended by android.widget.AbsListView
                  extended by android.widget.ListView
                      extended by sk.baka.ambient.views.gesturelist.GesturesListView
All Implemented Interfaces:
Drawable.Callback, TextWatcher, KeyEvent.Callback, ViewManager, ViewParent, ViewTreeObserver.OnGlobalLayoutListener, ViewTreeObserver.OnTouchModeChangeListener, Filter.FilterListener

public class GesturesListView
extends ListView

Captures the motion events and generates more high-level gesture events.

To configure the view you may need to set the two properties:

The view offers a lot simplified API than the classical ListView, at the price of disabling support for other adapters. For example, there is no need to set the ListAdapter and evade the minefield of list-scrollposition-resetting functions like ListView.getAdapter()

To work with this modified list view, you just need to modify model using the model holder.

Author:
Martin Vysny

Nested Class Summary
 
Nested classes/interfaces inherited from class android.widget.AbsListView
AbsListView.LayoutParams, AbsListView.OnScrollListener, AbsListView.RecyclerListener
 
Nested classes/interfaces inherited from class android.widget.AdapterView
AdapterView.AdapterContextMenuInfo, AdapterView.OnItemClickListener, AdapterView.OnItemLongClickListener, AdapterView.OnItemSelectedListener
 
Nested classes/interfaces inherited from class android.view.ViewGroup
ViewGroup.MarginLayoutParams, ViewGroup.OnHierarchyChangeListener
 
Nested classes/interfaces inherited from class android.view.View
View.BaseSavedState, View.MeasureSpec, View.OnClickListener, View.OnCreateContextMenuListener, View.OnFocusChangeListener, View.OnKeyListener, View.OnLongClickListener, View.OnTouchListener
 
Field Summary
 List<GesturesListView> dragDropViews
          If not empty then the LU/LD gestures will drag'n'drop selected items to these views.
 int hintDeleteCopyMoveId
          The string id of the "Delete/Copy/Move" (touchpad L?) gesture.
 int hintDeleteId
          The string id of the "Delete" (L, LL) gesture.
 int hintDeleteMovePasteId
          The string id of the "Delete/Move/Paste" (keyboard L?) gesture.
(package private)  int itemLayoutId
          Layout ID for each item in the list.
(package private)  KeypadController keyController
          Handles the touchpad events and controls this view.
 IGestureListViewListener listener
          The gesture listener.
(package private)  TouchPadController touchController
          Handles the touchpad events and controls this view.
 
Fields inherited from class android.widget.ListView
CHOICE_MODE_MULTIPLE, CHOICE_MODE_NONE, CHOICE_MODE_SINGLE
 
Fields inherited from class android.widget.AbsListView
TRANSCRIPT_MODE_ALWAYS_SCROLL, TRANSCRIPT_MODE_DISABLED, TRANSCRIPT_MODE_NORMAL
 
Fields inherited from class android.widget.AdapterView
INVALID_POSITION, INVALID_ROW_ID, ITEM_VIEW_TYPE_HEADER_OR_FOOTER, ITEM_VIEW_TYPE_IGNORE
 
Fields inherited from class android.view.ViewGroup
CLIP_TO_PADDING_MASK, FLAG_USE_CHILD_DRAWING_ORDER, FOCUS_AFTER_DESCENDANTS, FOCUS_BEFORE_DESCENDANTS, FOCUS_BLOCK_DESCENDANTS, PERSISTENT_ALL_CACHES, PERSISTENT_ANIMATION_CACHE, PERSISTENT_NO_CACHE, PERSISTENT_SCROLLING_CACHE
 
Fields inherited from class android.view.View
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_HIGH, DRAWING_CACHE_QUALITY_LOW, EMPTY_STATE_SET, ENABLED_FOCUSED_SELECTED_STATE_SET, ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_FOCUSED_STATE_SET, ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, ENABLED_SELECTED_STATE_SET, ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, ENABLED_STATE_SET, ENABLED_WINDOW_FOCUSED_STATE_SET, FOCUS_BACKWARD, FOCUS_DOWN, FOCUS_FORWARD, FOCUS_LEFT, FOCUS_RIGHT, FOCUS_UP, FOCUSED_SELECTED_STATE_SET, FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, FOCUSED_STATE_SET, FOCUSED_WINDOW_FOCUSED_STATE_SET, GONE, INVISIBLE, KEEP_SCREEN_ON, NO_ID, PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET, PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_STATE_SET, PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_SELECTED_STATE_SET, PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_ENABLED_STATE_SET, PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_SELECTED_STATE_SET, PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_FOCUSED_STATE_SET, PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET, PRESSED_SELECTED_STATE_SET, PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET, PRESSED_WINDOW_FOCUSED_STATE_SET, SCROLLBARS_INSIDE_INSET, SCROLLBARS_INSIDE_OVERLAY, SCROLLBARS_OUTSIDE_INSET, SCROLLBARS_OUTSIDE_OVERLAY, SELECTED_STATE_SET, SELECTED_WINDOW_FOCUSED_STATE_SET, SOUND_EFFECTS_ENABLED, VIEW_LOG_TAG, VISIBLE, WINDOW_FOCUSED_STATE_SET
 
Constructor Summary
GesturesListView(Context context, AttributeSet attrs)
          Creates new view.
GesturesListView(Context context, AttributeSet attrs, int defStyle)
          Creates new view.
GesturesListView(Context context, int itemLayoutId)
          Creates new view.
 
Method Summary
 boolean canMove()
          Checks if the move events ( IGestureListViewListener.moveItems(Interval, int) and IGestureListViewListener.moveItemsByOne(Interval, boolean)) can be invoked.
(package private)  void clearMode(Object controller)
          Clears the mode and dismisses the window.
 void clipboardChanged()
          Invoke to let the listview know that the clipboard was modified.
 GesturesListView findView(Point point)
          Finds a view from the registered list of views that contains given point.
(package private)  TrackListClipboardObject getClipboard()
          Returns the clipboard contents.
 Interval getHighlight()
          Returns current highlight.
 int getItemIndex(MotionEvent event)
          Returns item index the event coordinates is pointing to.
 ModelHolder getModel()
          Returns the model holder.
 boolean isEOP(int position)
          Checks if given item is the EOP item.
protected  void onAttachedToWindow()
           
protected  void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect)
           
 boolean onKeyDown(int keyCode, KeyEvent event)
           
 boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event)
           
 boolean onKeyUp(int keyCode, KeyEvent event)
           
 boolean onTouchEvent(MotionEvent event)
           
 int pointToPosition(int x, int y)
           
(package private)  void restoreSelector()
          Restores the original selector.
 void setAdapter(ListAdapter adapter)
           
(package private)  void setMode(int resId, Object controller, boolean persistent)
          Sets the mode tooltip the view is currently in.
 void setOnItemClickListener(AdapterView.OnItemClickListener l)
           
 void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener)
           
(package private)  void transparentSelector()
          Remembers the original selector and sets a transparent (non-visible) selector.
 void zoom(boolean zoom)
          Zooms or un-zooms the items.
 
Methods inherited from class android.widget.ListView
addFooterView, addFooterView, addHeaderView, addHeaderView, canAnimate, clearChoices, dispatchDraw, dispatchKeyEvent, findViewTraversal, findViewWithTagTraversal, getAdapter, getCheckedItemPosition, getCheckedItemPositions, getChoiceMode, getDivider, getDividerHeight, getFooterViewsCount, getHeaderViewsCount, getItemsCanFocus, getMaxScrollAmount, isItemChecked, layoutChildren, onFinishInflate, onMeasure, onRestoreInstanceState, onSaveInstanceState, performItemClick, removeFooterView, removeHeaderView, requestChildRectangleOnScreen, setChoiceMode, setDivider, setDividerHeight, setItemChecked, setItemsCanFocus, setSelection, setSelectionAfterHeaderView, setSelectionFromTop
 
Methods inherited from class android.widget.AbsListView
addTouchables, afterTextChanged, beforeTextChanged, checkLayoutParams, clearTextFilter, computeVerticalScrollExtent, computeVerticalScrollOffset, computeVerticalScrollRange, dispatchSetPressed, drawableStateChanged, generateLayoutParams, generateLayoutParams, getBottomFadingEdgeStrength, getCacheColorHint, getContextMenuInfo, getFocusedRect, getListPaddingBottom, getListPaddingLeft, getListPaddingRight, getListPaddingTop, getSelectedView, getSelector, getSolidColor, getTopFadingEdgeStrength, getTranscriptMode, handleDataChanged, hasTextFilter, invalidateViews, isInFilterMode, isScrollingCacheEnabled, isStackFromBottom, isTextFilterEnabled, onCreateDrawableState, onDetachedFromWindow, onFilterComplete, onGlobalLayout, onInterceptTouchEvent, onLayout, onSizeChanged, onTextChanged, onTouchModeChanged, onWindowFocusChanged, pointToRowId, reclaimViews, requestLayout, setCacheColorHint, setDrawSelectorOnTop, setFilterText, setOnScrollListener, setRecyclerListener, setScrollIndicators, setScrollingCacheEnabled, setSelector, setSelector, setStackFromBottom, setTextFilterEnabled, setTranscriptMode, showContextMenuForChild, verifyDrawable
 
Methods inherited from class android.widget.AdapterView
addView, addView, addView, addView, dispatchRestoreInstanceState, dispatchSaveInstanceState, getCount, getEmptyView, getFirstVisiblePosition, getItemAtPosition, getItemIdAtPosition, getLastVisiblePosition, getOnItemClickListener, getOnItemLongClickListener, getOnItemSelectedListener, getPositionForView, getSelectedItem, getSelectedItemId, getSelectedItemPosition, removeAllViews, removeView, removeViewAt, setEmptyView, setFocusable, setFocusableInTouchMode, setOnClickListener, setOnItemLongClickListener
 
Methods inherited from class android.view.ViewGroup
addFocusables, addStatesFromChildren, addView, addViewInLayout, addViewInLayout, attachLayoutAnimationParameters, attachViewToParent, bringChildToFront, childDrawableStateChanged, cleanupLayoutState, clearChildFocus, clearDisappearingChildren, clearFocus, debug, detachAllViewsFromParent, detachViewFromParent, detachViewFromParent, detachViewsFromParent, dispatchFreezeSelfOnly, dispatchSetSelected, dispatchThawSelfOnly, dispatchTouchEvent, dispatchTrackballEvent, dispatchUnhandledMove, dispatchWindowFocusChanged, dispatchWindowVisibilityChanged, drawChild, findFocus, fitSystemWindows, focusableViewAvailable, focusSearch, gatherTransparentRegion, generateDefaultLayoutParams, getChildAt, getChildCount, getChildDrawingOrder, getChildMeasureSpec, getChildStaticTransformation, getChildVisibleRect, getDescendantFocusability, getFocusedChild, getLayoutAnimation, getLayoutAnimationListener, getPersistentDrawingCache, hasFocus, hasFocusable, indexOfChild, invalidateChild, invalidateChildInParent, isAlwaysDrawnWithCacheEnabled, isAnimationCacheEnabled, isChildrenDrawnWithCacheEnabled, measureChild, measureChildren, measureChildWithMargins, offsetDescendantRectToMyCoords, offsetRectIntoDescendantCoords, onAnimationEnd, onAnimationStart, onRequestFocusInDescendants, recomputeViewAttributes, removeAllViewsInLayout, removeDetachedView, removeViewInLayout, removeViews, removeViewsInLayout, requestChildFocus, requestDisallowInterceptTouchEvent, requestFocus, requestTransparentRegion, scheduleLayoutAnimation, setAddStatesFromChildren, setAlwaysDrawnWithCacheEnabled, setAnimationCacheEnabled, setChildrenDrawingCacheEnabled, setChildrenDrawnWithCacheEnabled, setClipChildren, setClipToPadding, setDescendantFocusability, setLayoutAnimation, setLayoutAnimationListener, setOnHierarchyChangeListener, setPadding, setPersistentDrawingCache, startLayoutAnimation, updateViewLayout
 
Methods inherited from class android.view.View
bringToFront, buildDrawingCache, cancelLongPress, clearAnimation, computeHorizontalScrollExtent, computeHorizontalScrollOffset, computeHorizontalScrollRange, computeScroll, createContextMenu, destroyDrawingCache, dispatchKeyShortcutEvent, draw, finalize, findViewById, findViewWithTag, focusSearch, forceLayout, getAnimation, getApplicationWindowToken, getBackground, getBaseline, getBottom, getContext, getDefaultSize, getDrawableState, getDrawingCache, getDrawingCacheBackgroundColor, getDrawingCacheQuality, getDrawingRect, getDrawingTime, getFocusables, getGlobalVisibleRect, getGlobalVisibleRect, getHandler, getHeight, getHitRect, getHorizontalFadingEdgeLength, getHorizontalScrollbarHeight, getId, getKeepScreenOn, getLayoutParams, getLeft, getLeftFadingEdgeStrength, getLocalVisibleRect, getLocationInWindow, getLocationOnScreen, getMeasuredHeight, getMeasuredWidth, getNextFocusDownId, getNextFocusLeftId, getNextFocusRightId, getNextFocusUpId, getOnFocusChangeListener, getPaddingBottom, getPaddingLeft, getPaddingRight, getPaddingTop, getParent, getResources, getRight, getRightFadingEdgeStrength, getRootView, getScrollBarStyle, getScrollX, getScrollY, getSuggestedMinimumHeight, getSuggestedMinimumWidth, getTag, getTop, getTouchables, getTouchDelegate, getVerticalFadingEdgeLength, getVerticalScrollbarWidth, getViewTreeObserver, getVisibility, getWidth, getWindowAttachCount, getWindowToken, getWindowVisibility, hasWindowFocus, inflate, initializeFadingEdge, initializeScrollbars, invalidate, invalidate, invalidate, invalidateDrawable, isClickable, isDrawingCacheEnabled, isDuplicateParentStateEnabled, isEnabled, isFocusable, isFocusableInTouchMode, isFocused, isHorizontalFadingEdgeEnabled, isHorizontalScrollBarEnabled, isInTouchMode, isLayoutRequested, isLongClickable, isPressed, isSaveEnabled, isSelected, isShown, isSoundEffectsEnabled, isVerticalFadingEdgeEnabled, isVerticalScrollBarEnabled, layout, measure, mergeDrawableStates, offsetLeftAndRight, offsetTopAndBottom, onCreateContextMenu, onDraw, onKeyShortcut, onScrollChanged, onSetAlpha, onTrackballEvent, onWindowVisibilityChanged, performClick, performLongClick, playSoundEffect, post, postDelayed, postInvalidate, postInvalidate, postInvalidateDelayed, postInvalidateDelayed, refreshDrawableState, removeCallbacks, requestFocus, requestFocus, requestFocusFromTouch, requestRectangleOnScreen, requestRectangleOnScreen, resolveSize, restoreHierarchyState, saveHierarchyState, scheduleDrawable, scrollBy, scrollTo, setAnimation, setBackgroundColor, setBackgroundDrawable, setBackgroundResource, setClickable, setDrawingCacheBackgroundColor, setDrawingCacheEnabled, setDrawingCacheQuality, setDuplicateParentStateEnabled, setEnabled, setFadingEdgeLength, setHorizontalFadingEdgeEnabled, setHorizontalScrollBarEnabled, setId, setKeepScreenOn, setLayoutParams, setLongClickable, setMeasuredDimension, setMinimumHeight, setMinimumWidth, setNextFocusDownId, setNextFocusLeftId, setNextFocusRightId, setNextFocusUpId, setOnCreateContextMenuListener, setOnFocusChangeListener, setOnKeyListener, setOnLongClickListener, setOnTouchListener, setPressed, setSaveEnabled, setScrollBarStyle, setSelected, setSoundEffectsEnabled, setTag, setTouchDelegate, setVerticalFadingEdgeEnabled, setVerticalScrollBarEnabled, setVisibility, setWillNotCacheDrawing, setWillNotDraw, showContextMenu, startAnimation, unscheduleDrawable, unscheduleDrawable, willNotCacheDrawing, willNotDraw
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface android.view.ViewParent
createContextMenu, getParent, isLayoutRequested
 

Field Detail

itemLayoutId

int itemLayoutId
Layout ID for each item in the list.


hintDeleteId

public int hintDeleteId
The string id of the "Delete" (L, LL) gesture.


hintDeleteCopyMoveId

public int hintDeleteCopyMoveId
The string id of the "Delete/Copy/Move" (touchpad L?) gesture.


hintDeleteMovePasteId

public int hintDeleteMovePasteId
The string id of the "Delete/Move/Paste" (keyboard L?) gesture.


dragDropViews

public final List<GesturesListView> dragDropViews
If not empty then the LU/LD gestures will drag'n'drop selected items to these views. The view is able to drag'n'drop items onto itself - in this case the items are moved to new location.


touchController

final TouchPadController touchController
Handles the touchpad events and controls this view.


keyController

final KeypadController keyController
Handles the touchpad events and controls this view.


listener

public IGestureListViewListener listener
The gesture listener.

Constructor Detail

GesturesListView

public GesturesListView(Context context,
                        int itemLayoutId)
Creates new view.

Parameters:
context - the context
itemLayoutId - layout ID for each item in the list.

GesturesListView

public GesturesListView(Context context,
                        AttributeSet attrs,
                        int defStyle)
Creates new view.

Parameters:
context -
attrs -
defStyle -

GesturesListView

public GesturesListView(Context context,
                        AttributeSet attrs)
Creates new view.

Parameters:
context -
attrs -
Method Detail

getClipboard

TrackListClipboardObject getClipboard()
Returns the clipboard contents.

Returns:
the clipboard contents, null if the clipboard is incompatible or empty.

clipboardChanged

public void clipboardChanged()
Invoke to let the listview know that the clipboard was modified.


getModel

public ModelHolder getModel()
Returns the model holder.

Returns:
a holder of live list of item data.

getHighlight

public Interval getHighlight()
Returns current highlight.

Returns:
current highlight, never null.

onAttachedToWindow

protected void onAttachedToWindow()
Overrides:
onAttachedToWindow in class AbsListView

setOnItemClickListener

public void setOnItemClickListener(AdapterView.OnItemClickListener l)
Overrides:
setOnItemClickListener in class AdapterView<ListAdapter>

setAdapter

public void setAdapter(ListAdapter adapter)
Overrides:
setAdapter in class ListView

canMove

public boolean canMove()
Checks if the move events ( IGestureListViewListener.moveItems(Interval, int) and IGestureListViewListener.moveItemsByOne(Interval, boolean)) can be invoked.

Returns:
true if this list view can drag'n'drop items onto itself, false otherwise.

onTouchEvent

public boolean onTouchEvent(MotionEvent event)
Overrides:
onTouchEvent in class ListView

onKeyDown

public boolean onKeyDown(int keyCode,
                         KeyEvent event)
Specified by:
onKeyDown in interface KeyEvent.Callback
Overrides:
onKeyDown in class ListView

onKeyMultiple

public boolean onKeyMultiple(int keyCode,
                             int repeatCount,
                             KeyEvent event)
Specified by:
onKeyMultiple in interface KeyEvent.Callback
Overrides:
onKeyMultiple in class ListView

onKeyUp

public boolean onKeyUp(int keyCode,
                       KeyEvent event)
Specified by:
onKeyUp in interface KeyEvent.Callback
Overrides:
onKeyUp in class ListView

transparentSelector

void transparentSelector()
Remembers the original selector and sets a transparent (non-visible) selector.


restoreSelector

void restoreSelector()
Restores the original selector.


pointToPosition

public int pointToPosition(int x,
                           int y)
Overrides:
pointToPosition in class AbsListView

findView

public GesturesListView findView(Point point)
Finds a view from the registered list of views that contains given point.

Parameters:
point - the point in this view's coordinate system
Returns:
view containing given point or null if no such view exists.

getItemIndex

public int getItemIndex(MotionEvent event)
Returns item index the event coordinates is pointing to.

Parameters:
event - the event
Returns:
the item index.

setMode

void setMode(int resId,
             Object controller,
             boolean persistent)
Sets the mode tooltip the view is currently in.

Parameters:
resId - the string to show
controller - callee
persistent - if false then the mode hint will disappear automatically after 2 seconds.

clearMode

void clearMode(Object controller)
Clears the mode and dismisses the window.

Parameters:
controller - callee

setOnItemSelectedListener

public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener)
Overrides:
setOnItemSelectedListener in class AdapterView<ListAdapter>

onFocusChanged

protected void onFocusChanged(boolean gainFocus,
                              int direction,
                              Rect previouslyFocusedRect)
Overrides:
onFocusChanged in class ListView

isEOP

public boolean isEOP(int position)
Checks if given item is the EOP item.

Parameters:
position - the item index
Returns:
true if it is EOP, false otherwise.

zoom

public void zoom(boolean zoom)
Zooms or un-zooms the items.

Parameters:
zoom - true if zoom the view.


Copyright © 2007-2008. All Rights Reserved.