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

The following are Jave code examples for showing how to use isPressed() 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.
+ Save this method
Example 1
Project: boohee_v5.6   File: ListPopupWindow.java   View Source Code Vote up 6 votes
private void setPressedItem(View child, int position, float x, float y) {
    this.mDrawsInPressedState = true;
    if (VERSION.SDK_INT >= 21) {
        drawableHotspotChanged(x, y);
    }
    if (!isPressed()) {
        setPressed(true);
    }
    layoutChildren();
    if (this.mMotionPosition != -1) {
        View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
        if (!(motionView == null || motionView == child || !motionView.isPressed())) {
            motionView.setPressed(false);
        }
    }
    this.mMotionPosition = position;
    float childX = x - ((float) child.getLeft());
    float childY = y - ((float) child.getTop());
    if (VERSION.SDK_INT >= 21) {
        child.drawableHotspotChanged(childX, childY);
    }
    if (!child.isPressed()) {
        child.setPressed(true);
    }
    positionSelectorLikeTouchCompat(position, child, x, y);
    setSelectorEnabled(false);
    refreshDrawableState();
}
 
Example 2
Project: letv   File: HListView.java   View Source Code Vote up 5 votes
@TargetApi(11)
private void setupChild(View child, int position, int x, boolean flowDown, int childrenTop, boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        p = (LayoutParams) generateDefaultLayoutParams();
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (!(this.mChoiceMode == 0 || this.mCheckStates == null)) {
        if (child instanceof Checkable) {
            ((Checkable) child).setChecked(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        } else if (VERSION.SDK_INT >= 11) {
            child.setActivated(((Boolean) this.mCheckStates.get(position, Boolean.valueOf(false))).booleanValue());
        }
    }
    if (needToMeasure) {
        int childWidthSpec;
        int childHeightSpec = ViewGroup.getChildMeasureSpec(this.mHeightMeasureSpec, this.mListPadding.top + this.mListPadding.bottom, p.height);
        int lpWidth = p.width;
        if (lpWidth > 0) {
            childWidthSpec = MeasureSpec.makeMeasureSpec(lpWidth, 1073741824);
        } else {
            childWidthSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        child.measure(childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childLeft = flowDown ? x : x - w;
    if (needToMeasure) {
        child.layout(childLeft, childrenTop, childLeft + w, childrenTop + h);
    } else {
        child.offsetLeftAndRight(childLeft - child.getLeft());
        child.offsetTopAndBottom(childrenTop - child.getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
    if (VERSION.SDK_INT >= 11 && recycled && ((LayoutParams) child.getLayoutParams()).scrappedFromPosition != position) {
        child.jumpDrawablesToCurrentState();
    }
}
 
Example 3
Project: boohee_v5.6   File: PLA_ListView.java   View Source Code Vote up 5 votes
private void setupChild(View child, int position, int y, boolean flowDown, int childrenLeft,
                        boolean selected, boolean recycled) {
    boolean isSelected = selected && shouldShowSelector();
    boolean updateChildSelected = isSelected != child.isSelected();
    int mode = this.mTouchMode;
    boolean isPressed = mode > 0 && mode < 3 && this.mMotionPosition == position;
    boolean updateChildPressed = isPressed != child.isPressed();
    boolean needToMeasure = !recycled || updateChildSelected || child.isLayoutRequested();
    ViewGroup.LayoutParams p = (LayoutParams) child.getLayoutParams();
    if (p == null) {
        ViewGroup.LayoutParams layoutParams = new LayoutParams(-1, -2, 0);
    }
    p.viewType = this.mAdapter.getItemViewType(position);
    p.scrappedFromPosition = position;
    if ((!recycled || p.forceAdd) && !(p.recycledHeaderFooter && p.viewType == -2)) {
        p.forceAdd = false;
        if (p.viewType == -2) {
            p.recycledHeaderFooter = true;
        }
        addViewInLayout(child, flowDown ? -1 : 0, p, true);
    } else {
        attachViewToParent(child, flowDown ? -1 : 0, p);
    }
    if (updateChildSelected) {
        child.setSelected(isSelected);
    }
    if (updateChildPressed) {
        child.setPressed(isPressed);
    }
    if (needToMeasure) {
        int childHeightSpec;
        int childWidthSpec = ViewGroup.getChildMeasureSpec(this.mWidthMeasureSpec, this
                .mListPadding.left + this.mListPadding.right, p.width);
        int lpHeight = p.height;
        if (lpHeight > 0) {
            childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, 1073741824);
        } else {
            childHeightSpec = MeasureSpec.makeMeasureSpec(0, 0);
        }
        onMeasureChild(child, position, childWidthSpec, childHeightSpec);
    } else {
        cleanupLayoutState(child);
    }
    int w = child.getMeasuredWidth();
    int h = child.getMeasuredHeight();
    int childTop = flowDown ? y : y - h;
    if (needToMeasure) {
        onLayoutChild(child, position, childrenLeft, childTop, childrenLeft + w, childTop + h);
    } else {
        onOffsetChild(child, position, childrenLeft - child.getLeft(), childTop - child
                .getTop());
    }
    if (this.mCachingStarted && !child.isDrawingCacheEnabled()) {
        child.setDrawingCacheEnabled(true);
    }
}