Java Code Examples for android.widget.ListAdapter#isEnabled()
The following examples show how to use
android.widget.ListAdapter#isEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbsHListView.java From Klyph with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public void addTouchables( ArrayList<View> views ) { final int count = getChildCount(); final int firstPosition = mFirstPosition; final ListAdapter adapter = mAdapter; if ( adapter == null ) { return; } for ( int i = 0; i < count; i++ ) { final View child = getChildAt( i ); if ( adapter.isEnabled( firstPosition + i ) ) { views.add( child ); } child.addTouchables( views ); } }
Example 2
Source File: TwoWayAbsListView.java From recent-images with MIT License | 6 votes |
/** * {@inheritDoc} */ @Override public void addTouchables(ArrayList<View> views) { final int count = getChildCount(); final int firstPosition = mFirstPosition; final ListAdapter adapter = mAdapter; if (adapter == null) { return; } for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (adapter.isEnabled(firstPosition + i)) { views.add(child); } child.addTouchables(views); } }
Example 3
Source File: ZrcAbsListView.java From AndroidStudyDemo with GNU General Public License v2.0 | 6 votes |
@Override public void addTouchables(ArrayList<View> views) { final int count = getChildCount(); final int firstPosition = mFirstPosition; final ListAdapter adapter = mAdapter; if (adapter == null) { return; } for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (adapter.isEnabled(firstPosition + i)) { views.add(child); } child.addTouchables(views); } }
Example 4
Source File: HListView.java From letv with Apache License 2.0 | 5 votes |
protected int lookForSelectablePosition(int position, boolean lookDown) { ListAdapter adapter = this.mAdapter; if (adapter == null || isInTouchMode()) { return -1; } int count = adapter.getCount(); if (!this.mAreAllItemsSelectable) { if (lookDown) { position = Math.max(0, position); while (position < count && !adapter.isEnabled(position)) { position++; } } else { position = Math.min(position, count - 1); while (position >= 0 && !adapter.isEnabled(position)) { position--; } } if (position < 0 || position >= count) { return -1; } return position; } else if (position < 0 || position >= count) { return -1; } else { return position; } }
Example 5
Source File: IcsSpinner.java From zhangshangwuda with Apache License 2.0 | 5 votes |
/** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. * Otherwise, return true. */ public boolean isEnabled(int position) { final ListAdapter adapter = mListAdapter; if (adapter != null) { return adapter.isEnabled(position); } else { return true; } }
Example 6
Source File: PLAListView.java From Lay-s with MIT License | 5 votes |
/** * Find a position that can be selected (i.e., is not a separator). * * @param position The starting position to look at. * @param lookDown Whether to look down for other positions. * @return The next selectable position starting at position and then searching either up or * down. Returns {@link #INVALID_POSITION} if nothing can be found. */ @Override int lookForSelectablePosition(int position, boolean lookDown) { final ListAdapter adapter = mAdapter; if (adapter == null || isInTouchMode()) { return INVALID_POSITION; } final int count = adapter.getCount(); if (!mAreAllItemsSelectable) { if (lookDown) { position = Math.max(0, position); while (position < count && !adapter.isEnabled(position)) { position++; } } else { position = Math.min(position, count - 1); while (position >= 0 && !adapter.isEnabled(position)) { position--; } } if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } else { if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } }
Example 7
Source File: AbsHListView.java From Klyph with MIT License | 5 votes |
@Override public void onInitializeAccessibilityNodeInfo( View host, AccessibilityNodeInfoCompat info ) { super.onInitializeAccessibilityNodeInfo( host, info ); final int position = getPositionForView( host ); final ListAdapter adapter = getAdapter(); if ( ( position == INVALID_POSITION ) || ( adapter == null ) ) { return; } if ( !isEnabled() || !adapter.isEnabled( position ) ) { return; } if ( position == getSelectedItemPosition() ) { info.setSelected( true ); info.addAction( AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION ); } else { info.addAction( AccessibilityNodeInfoCompat.ACTION_SELECT ); } if ( isClickable() ) { info.addAction( AccessibilityNodeInfoCompat.ACTION_CLICK ); info.setClickable( true ); } if ( isLongClickable() ) { info.addAction( AccessibilityNodeInfoCompat.ACTION_LONG_CLICK ); info.setLongClickable( true ); } }
Example 8
Source File: IcsSpinner.java From android-apps with MIT License | 5 votes |
/** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. * Otherwise, return true. */ public boolean isEnabled(int position) { final ListAdapter adapter = mListAdapter; if (adapter != null) { return adapter.isEnabled(position); } else { return true; } }
Example 9
Source File: PLAListView.java From SimplifyReader with Apache License 2.0 | 5 votes |
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { boolean populated = super.dispatchPopulateAccessibilityEvent(event); // If the item count is less than 15 then subtract disabled items from the count and // position. Otherwise ignore disabled items. if (!populated) { int itemCount = 0; int currentItemIndex = getSelectedItemPosition(); ListAdapter adapter = getAdapter(); if (adapter != null) { final int count = adapter.getCount(); if (count < 15) { for (int i = 0; i < count; i++) { if (adapter.isEnabled(i)) { itemCount++; } else if (i <= currentItemIndex) { currentItemIndex--; } } } else { itemCount = count; } } event.setItemCount(itemCount); event.setCurrentItemIndex(currentItemIndex); } return populated; }
Example 10
Source File: HListView.java From Klyph with MIT License | 5 votes |
/** * Find a position that can be selected (i.e., is not a separator). * * @param position * The starting position to look at. * @param lookDown * Whether to look down for other positions. * @return The next selectable position starting at position and then searching either up or down. Returns * {@link #INVALID_POSITION} if nothing can be found. */ @Override protected int lookForSelectablePosition( int position, boolean lookDown ) { final ListAdapter adapter = mAdapter; if ( adapter == null || isInTouchMode() ) { return INVALID_POSITION; } final int count = adapter.getCount(); if ( !mAreAllItemsSelectable ) { if ( lookDown ) { position = Math.max( 0, position ); while ( position < count && !adapter.isEnabled( position ) ) { position++; } } else { position = Math.min( position, count - 1 ); while ( position >= 0 && !adapter.isEnabled( position ) ) { position--; } } if ( position < 0 || position >= count ) { return INVALID_POSITION; } return position; } else { if ( position < 0 || position >= count ) { return INVALID_POSITION; } return position; } }
Example 11
Source File: IcsSpinner.java From Libraries-for-Android-Developers with MIT License | 5 votes |
/** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. * Otherwise, return true. */ public boolean isEnabled(int position) { final ListAdapter adapter = mListAdapter; if (adapter != null) { return adapter.isEnabled(position); } else { return true; } }
Example 12
Source File: IcsSpinner.java From zen4android with MIT License | 5 votes |
/** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. * Otherwise, return true. */ public boolean isEnabled(int position) { final ListAdapter adapter = mListAdapter; if (adapter != null) { return adapter.isEnabled(position); } else { return true; } }
Example 13
Source File: MergeAdapter.java From Shield with MIT License | 5 votes |
/** * Returns true if the item at the specified position is not a separator. * * @param position Position of the item whose data we want */ @Override public boolean isEnabled(int position) { for (ListAdapter piece : pieces) { int size = piece.getCount(); if (position < size) { return (piece.isEnabled(position)); } position -= size; } return (false); }
Example 14
Source File: PLA_ListView.java From EverMemo with MIT License | 5 votes |
/** * Find a position that can be selected (i.e., is not a separator). * * @param position The starting position to look at. * @param lookDown Whether to look down for other positions. * @return The next selectable position starting at position and then searching either up or * down. Returns {@link #INVALID_POSITION} if nothing can be found. */ @Override int lookForSelectablePosition(int position, boolean lookDown) { final ListAdapter adapter = mAdapter; if (adapter == null || isInTouchMode()) { return INVALID_POSITION; } final int count = adapter.getCount(); if (!mAreAllItemsSelectable) { if (lookDown) { position = Math.max(0, position); while (position < count && !adapter.isEnabled(position)) { position++; } } else { position = Math.min(position, count - 1); while (position >= 0 && !adapter.isEnabled(position)) { position--; } } if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } else { if (position < 0 || position >= count) { return INVALID_POSITION; } return position; } }
Example 15
Source File: PLA_ListView.java From EverMemo with MIT License | 5 votes |
@Override public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { boolean populated = super.dispatchPopulateAccessibilityEvent(event); // If the item count is less than 15 then subtract disabled items from the count and // position. Otherwise ignore disabled items. if (!populated) { int itemCount = 0; int currentItemIndex = getSelectedItemPosition(); ListAdapter adapter = getAdapter(); if (adapter != null) { final int count = adapter.getCount(); if (count < 15) { for (int i = 0; i < count; i++) { if (adapter.isEnabled(i)) { itemCount++; } else if (i <= currentItemIndex) { currentItemIndex--; } } } else { itemCount = count; } } event.setItemCount(itemCount); event.setCurrentItemIndex(currentItemIndex); } return populated; }
Example 16
Source File: AbsHListView.java From Klyph with MIT License | 4 votes |
@Override public boolean performAccessibilityAction( View host, int action, Bundle arguments ) { if ( super.performAccessibilityAction( host, action, arguments ) ) { return true; } final int position = getPositionForView( host ); final ListAdapter adapter = getAdapter(); if ( ( position == INVALID_POSITION ) || ( adapter == null ) ) { // Cannot perform actions on invalid items. return false; } if ( !isEnabled() || !adapter.isEnabled( position ) ) { // Cannot perform actions on disabled items. return false; } final long id = getItemIdAtPosition( position ); switch ( action ) { case AccessibilityNodeInfoCompat.ACTION_CLEAR_SELECTION: { if ( getSelectedItemPosition() == position ) { setSelection( INVALID_POSITION ); return true; } } return false; case AccessibilityNodeInfoCompat.ACTION_SELECT: { if ( getSelectedItemPosition() != position ) { setSelection( position ); return true; } } return false; case AccessibilityNodeInfoCompat.ACTION_CLICK: { if ( isClickable() ) { return performItemClick( host, position, id ); } } return false; case AccessibilityNodeInfoCompat.ACTION_LONG_CLICK: { if ( isLongClickable() ) { return performLongPress( host, position, id ); } } return false; } return false; }
Example 17
Source File: PLA_ListView.java From EverMemo with MIT License | 4 votes |
@Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); if(DEBUG) Log.v("PLA_ListView", "onFocusChanged"); int closetChildIndex = -1; if (gainFocus && previouslyFocusedRect != null) { //previouslyFocusedRect.offset(mScrollX, mScrollY); previouslyFocusedRect.offset(getScrollX(), getScrollY()); final ListAdapter adapter = mAdapter; // Don't cache the result of getChildCount or mFirstPosition here, // it could change in layoutChildren. if (adapter.getCount() < getChildCount() + mFirstPosition) { mLayoutMode = LAYOUT_NORMAL; layoutChildren(); } // figure out which item should be selected based on previously // focused rect Rect otherRect = mTempRect; int minDistance = Integer.MAX_VALUE; final int childCount = getChildCount(); final int firstPosition = mFirstPosition; for (int i = 0; i < childCount; i++) { // only consider selectable views if (!adapter.isEnabled(firstPosition + i)) { continue; } View other = getChildAt(i); other.getDrawingRect(otherRect); offsetDescendantRectToMyCoords(other, otherRect); int distance = getDistance(previouslyFocusedRect, otherRect, direction); if (distance < minDistance) { minDistance = distance; closetChildIndex = i; } } } if (closetChildIndex >= 0) { setSelection(closetChildIndex + mFirstPosition); } else { requestLayout(); } }
Example 18
Source File: Spinner.java From MDPreference with Apache License 2.0 | 4 votes |
/** * If the wrapped SpinnerAdapter is also a ListAdapter, delegate this call. Otherwise, * return true. */ public boolean isEnabled(int position) { final ListAdapter adapter = mListAdapter; return adapter == null || adapter.isEnabled(position); }
Example 19
Source File: HListView.java From letv with Apache License 2.0 | 4 votes |
private int lookForSelectablePositionOnScreen(int direction) { int firstPosition = this.mFirstPosition; int startPos; ListAdapter adapter; int pos; if (direction == 130) { if (this.mSelectedPosition != -1) { startPos = this.mSelectedPosition + 1; } else { startPos = firstPosition; } if (startPos >= this.mAdapter.getCount()) { return -1; } if (startPos < firstPosition) { startPos = firstPosition; } int lastVisiblePos = getLastVisiblePosition(); adapter = getAdapter(); pos = startPos; while (pos <= lastVisiblePos) { if (adapter.isEnabled(pos) && getChildAt(pos - firstPosition).getVisibility() == 0) { return pos; } pos++; } } else { int last = (getChildCount() + firstPosition) - 1; if (this.mSelectedPosition != -1) { startPos = this.mSelectedPosition - 1; } else { startPos = (getChildCount() + firstPosition) - 1; } if (startPos < 0 || startPos >= this.mAdapter.getCount()) { return -1; } if (startPos > last) { startPos = last; } adapter = getAdapter(); pos = startPos; while (pos >= firstPosition) { if (adapter.isEnabled(pos) && getChildAt(pos - firstPosition).getVisibility() == 0) { return pos; } pos--; } } return -1; }
Example 20
Source File: PLAListView.java From Lay-s with MIT License | 4 votes |
@Override protected void onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) { super.onFocusChanged(gainFocus, direction, previouslyFocusedRect); int closetChildIndex = -1; if (gainFocus && previouslyFocusedRect != null) { //previouslyFocusedRect.offset(mScrollX, mScrollY); previouslyFocusedRect.offset(getScrollX(), getScrollY()); final ListAdapter adapter = mAdapter; // Don't cache the result of getChildCount or mFirstPosition here, // it could change in layoutChildren. if (adapter.getCount() < getChildCount() + mFirstPosition) { mLayoutMode = LAYOUT_NORMAL; layoutChildren(); } // figure out which item should be selected based on previously // focused rect Rect otherRect = mTempRect; int minDistance = Integer.MAX_VALUE; final int childCount = getChildCount(); final int firstPosition = mFirstPosition; for (int i = 0; i < childCount; i++) { // only consider selectable views if (!adapter.isEnabled(firstPosition + i)) { continue; } View other = getChildAt(i); other.getDrawingRect(otherRect); offsetDescendantRectToMyCoords(other, otherRect); int distance = getDistance(previouslyFocusedRect, otherRect, direction); if (distance < minDistance) { minDistance = distance; closetChildIndex = i; } } } if (closetChildIndex >= 0) { setSelection(closetChildIndex + mFirstPosition); } else { requestLayout(); } }