Java Code Examples for android.view.View.hasFocusable()

The following are Jave code examples for showing how to use hasFocusable() of the android.view.View class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RLibrary   File: RLinearLayoutManager.java   Source Code and License Vote up 7 votes
protected void layoutChunk(View view, RecyclerView.LayoutParams params, RecyclerView.Recycler recycler,
                           RecyclerView.State state, LayoutState layoutState, LayoutChunkResult result) {
    layoutChunkAddView(view, recycler, params, layoutState);
    /**
     * 布局第2步:
     * 测量View的大小
     * */
    measureChildWithMargins(view, 0, 0);
    /**mConsumed 保存了view的高度, 用来计算下一个view的位置*/
    result.mConsumed = mOrientationHelper.getDecoratedMeasurement(view);
    layoutChunkLayoutChild(view, params, layoutState, result);
    // Consume the available space if the view is not removed OR changed
    if (params.isItemRemoved() || params.isItemChanged()) {
        result.mIgnoreConsumed = true;
    }
    result.mFocusable = view.hasFocusable();
}
 
Example 2
Project: letv   File: AbsHListView.java   Source Code and License Vote up 6 votes
protected void keyPressed() {
    if (isEnabled() && isClickable()) {
        Drawable selector = this.mSelector;
        Rect selectorRect = this.mSelectorRect;
        if (selector == null) {
            return;
        }
        if ((isFocused() || touchModeDrawsInPressedState()) && !selectorRect.isEmpty()) {
            View v = getChildAt(this.mSelectedPosition - this.mFirstPosition);
            if (v != null) {
                if (!v.hasFocusable()) {
                    v.setPressed(true);
                } else {
                    return;
                }
            }
            setPressed(true);
            boolean longClickable = isLongClickable();
            Drawable d = selector.getCurrent();
            if (d != null && (d instanceof TransitionDrawable)) {
                if (longClickable) {
                    ((TransitionDrawable) d).startTransition(ViewConfiguration.getLongPressTimeout());
                } else {
                    ((TransitionDrawable) d).resetTransition();
                }
            }
            if (longClickable && !this.mDataChanged) {
                if (this.mPendingCheckForKeyLongPress == null) {
                    this.mPendingCheckForKeyLongPress = new CheckForKeyLongPress(this, null);
                }
                this.mPendingCheckForKeyLongPress.rememberWindowAttachCount();
                postDelayed(this.mPendingCheckForKeyLongPress, (long) ViewConfiguration.getLongPressTimeout());
            }
        }
    }
}
 
Example 3
Project: exciting-app   File: AbsHListView.java   Source Code and License Vote up 6 votes
/**
 * Sets the selector state to "pressed" and posts a CheckForKeyLongPress to
 * see if this is a long press.
 */
protected void keyPressed() {
	if (!isEnabled() || !isClickable()) {
		return;
	}

	Drawable selector = mSelector;
	Rect selectorRect = mSelectorRect;
	if (selector != null && (isFocused() || touchModeDrawsInPressedState())
			&& !selectorRect.isEmpty()) {

		final View v = getChildAt(mSelectedPosition - mFirstPosition);

		if (v != null) {
			if (v.hasFocusable())
				return;
			v.setPressed(true);
		}
		setPressed(true);

		final boolean longClickable = isLongClickable();
		Drawable d = selector.getCurrent();
		if (d != null && d instanceof TransitionDrawable) {
			if (longClickable) {
				((TransitionDrawable) d).startTransition(ViewConfiguration
						.getLongPressTimeout());
			} else {
				((TransitionDrawable) d).resetTransition();
			}
		}
		if (longClickable && !mDataChanged) {
			if (mPendingCheckForKeyLongPress == null) {
				mPendingCheckForKeyLongPress = new CheckForKeyLongPress();
			}
			mPendingCheckForKeyLongPress.rememberWindowAttachCount();
			postDelayed(mPendingCheckForKeyLongPress,
					ViewConfiguration.getLongPressTimeout());
		}
	}
}
 
Example 4
Project: boohee_v5.6   File: PLA_AbsListView$CheckForTap.java   Source Code and License Vote up 6 votes
public void run() {
    if (this.this$0.mTouchMode == 0) {
        this.this$0.mTouchMode = 1;
        View child = this.this$0.getChildAt(this.this$0.mMotionPosition - this.this$0
                .mFirstPosition);
        if (child != null && !child.hasFocusable()) {
            this.this$0.mLayoutMode = 0;
            if (this.this$0.mDataChanged) {
                this.this$0.mTouchMode = 2;
                return;
            }
            this.this$0.layoutChildren();
            child.setPressed(true);
            this.this$0.positionSelector(child);
            this.this$0.setPressed(true);
            int longPressTimeout = ViewConfiguration.getLongPressTimeout();
            boolean longClickable = this.this$0.isLongClickable();
            if (this.this$0.mSelector != null) {
                Drawable d = this.this$0.mSelector.getCurrent();
                if (d != null && (d instanceof TransitionDrawable)) {
                    if (longClickable) {
                        ((TransitionDrawable) d).startTransition(longPressTimeout);
                    } else {
                        ((TransitionDrawable) d).resetTransition();
                    }
                }
            }
            if (!longClickable) {
                this.this$0.mTouchMode = 2;
            }
        }
    }
}
 
Example 5
Project: Swap   File: PLA_AbsListView.java   Source Code and License Vote up 6 votes
public void run() {
    if (mTouchMode == TOUCH_MODE_DOWN) {
        mTouchMode = TOUCH_MODE_TAP;
        final View child = getChildAt(mMotionPosition - mFirstPosition);
        if (child != null && !child.hasFocusable()) {
            mLayoutMode = LAYOUT_NORMAL;

            if (!mDataChanged) {
                layoutChildren();
                child.setPressed(true);
                positionSelector(child);
                setPressed(true);

                final int longPressTimeout = ViewConfiguration.getLongPressTimeout();
                final boolean longClickable = isLongClickable();

                if (mSelector != null) {
                    Drawable d = mSelector.getCurrent();
                    if (d != null && d instanceof TransitionDrawable) {
                        if (longClickable) {
                            ((TransitionDrawable) d).startTransition(longPressTimeout);
                        } else {
                            ((TransitionDrawable) d).resetTransition();
                        }
                    }
                }

                if (longClickable) {
                } else {
                    mTouchMode = TOUCH_MODE_DONE_WAITING;
                }
            } else {
                mTouchMode = TOUCH_MODE_DONE_WAITING;
            }
        }
    }
}
 
Example 6
Project: exciting-app   File: AbsHListView.java   Source Code and License Vote up 5 votes
@Override
public void run() {
	if (mTouchMode == TOUCH_MODE_DOWN) {
		mTouchMode = TOUCH_MODE_TAP;
		final View child = getChildAt(mMotionPosition - mFirstPosition);
		if (child != null && !child.hasFocusable()) {
			mLayoutMode = LAYOUT_NORMAL;

			if (!mDataChanged) {
				child.setPressed(true);
				setPressed(true);
				layoutChildren();
				positionSelector(mMotionPosition, child);
				refreshDrawableState();

				final int longPressTimeout = ViewConfiguration
						.getLongPressTimeout();
				final boolean longClickable = isLongClickable();

				if (mSelector != null) {
					Drawable d = mSelector.getCurrent();
					if (d != null && d instanceof TransitionDrawable) {
						if (longClickable) {
							((TransitionDrawable) d)
									.startTransition(longPressTimeout);
						} else {
							((TransitionDrawable) d).resetTransition();
						}
					}
				}

				if (longClickable) {
					if (mPendingCheckForLongPress == null) {
						mPendingCheckForLongPress = new CheckForLongPress();
					}
					mPendingCheckForLongPress
							.rememberWindowAttachCount();
					postDelayed(mPendingCheckForLongPress,
							longPressTimeout);
				} else {
					mTouchMode = TOUCH_MODE_DONE_WAITING;
				}
			} else {
				mTouchMode = TOUCH_MODE_DONE_WAITING;
			}
		}
	}
}