Example usage for android.view View cancelLongPress

List of usage examples for android.view View cancelLongPress

Introduction

In this page you can find the example usage for android.view View cancelLongPress.

Prototype

public void cancelLongPress() 

Source Link

Document

Cancels a pending long press.

Usage

From source file:com.android.launcher2.PagedView.java

protected void cancelCurrentPageLongPress() {
    if (mAllowLongPress) {
        mAllowLongPress = false;/* w ww.  j ava2 s  .  c  o m*/
        // Try canceling the long press. It could also have been scheduled
        // by a distant descendant, so use the mAllowLongPress flag to block
        // everything
        final View currentPage = getPageAt(mCurrentPage);
        if (currentPage != null) {
            currentPage.cancelLongPress();
        }
    }
}

From source file:cc.flydev.launcher.Page.java

/**
 * {@inheritDoc}//from  w ww .j  a v  a2  s .  c  o  m
 */
@Override
public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
    if (disallowIntercept) {
        // We need to make sure to cancel our long press if
        // a scrollable widget takes over touch events
        final View currentPage = getPageAt(mCurrentPage);
        currentPage.cancelLongPress();
    }
    super.requestDisallowInterceptTouchEvent(disallowIntercept);
}

From source file:cc.flydev.launcher.Page.java

protected void cancelCurrentPageLongPress() {
    if (mAllowLongPress) {
        //mAllowLongPress = false;
        // Try canceling the long press. It could also have been scheduled
        // by a distant descendant, so use the mAllowLongPress flag to block
        // everything
        final View currentPage = getPageAt(mCurrentPage);
        if (currentPage != null) {
            currentPage.cancelLongPress();
        }// w w w .  j  av a  2s .  com
    }
}

From source file:com.android.launcher3.CellLayout.java

@Override
public void cancelLongPress() {
    super.cancelLongPress();

    // Cancel long press for all children
    final int count = getChildCount();
    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        child.cancelLongPress();
    }/*w ww.j  a  v  a 2 s .  c o  m*/
}

From source file:com.n2hsu.launcher.Page.java

protected void cancelCurrentPageLongPress() {
    if (mAllowLongPress) {
        // mAllowLongPress = false;
        // Try canceling the long press. It could also have been scheduled
        // by a distant descendant, so use the mAllowLongPress flag to block
        // everything
        final View currentPage = getPageAt(mCurrentPage);
        if (currentPage != null) {
            currentPage.cancelLongPress();
        }/*from  w  w w  .j a va  2  s .com*/
    }
}

From source file:com.android.app.MediaPlaybackActivity.java

public boolean onTouch(View v, MotionEvent event) {
    int action = event.getAction();
    TextView tv = textViewForContainer(v);
    if (tv == null) {
        return false;
    }/*from   w  w  w  . j a va 2 s  .  co m*/
    if (action == MotionEvent.ACTION_DOWN) {
        v.setBackgroundColor(0xff606060);
        mInitialX = mLastX = (int) event.getX();
        mDraggingLabel = false;
    } else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
        v.setBackgroundColor(0);
        if (mDraggingLabel) {
            Message msg = mLabelScroller.obtainMessage(0, tv);
            mLabelScroller.sendMessageDelayed(msg, 1000);
        }
    } else if (action == MotionEvent.ACTION_MOVE) {
        if (mDraggingLabel) {
            int scrollx = tv.getScrollX();
            int x = (int) event.getX();
            int delta = mLastX - x;
            if (delta != 0) {
                mLastX = x;
                scrollx += delta;
                if (scrollx > mTextWidth) {
                    // scrolled the text completely off the view to the left
                    scrollx -= mTextWidth;
                    scrollx -= mViewWidth;
                }
                if (scrollx < -mViewWidth) {
                    // scrolled the text completely off the view to the right
                    scrollx += mViewWidth;
                    scrollx += mTextWidth;
                }
                tv.scrollTo(scrollx, 0);
            }
            return true;
        }
        int delta = mInitialX - (int) event.getX();
        if (Math.abs(delta) > mTouchSlop) {
            // start moving
            mLabelScroller.removeMessages(0, tv);

            // Only turn ellipsizing off when it's not already off, because it
            // causes the scroll position to be reset to 0.
            if (tv.getEllipsize() != null) {
                tv.setEllipsize(null);
            }
            Layout ll = tv.getLayout();
            // layout might be null if the text just changed, or ellipsizing
            // was just turned off
            if (ll == null) {
                return false;
            }
            // get the non-ellipsized line width, to determine whether scrolling
            // should even be allowed
            mTextWidth = (int) tv.getLayout().getLineWidth(0);
            mViewWidth = tv.getWidth();
            if (mViewWidth > mTextWidth) {
                tv.setEllipsize(TruncateAt.END);
                v.cancelLongPress();
                return false;
            }
            mDraggingLabel = true;
            tv.setHorizontalFadingEdgeEnabled(true);
            v.cancelLongPress();
            return true;
        }
    }
    return false;
}