Java Code Examples for android.view.View#cancelLongPress()

The following examples show how to use android.view.View#cancelLongPress() . 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: CellLayout.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example 2
Source File: PagedViewCellLayout.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 3
Source File: VerticalPager.java    From freepager with Apache License 2.0 5 votes vote down vote up
private void checkStartScroll(float x, float y) {
	/*
	 * Locally do absolute value. mLastMotionX is set to the y value of the
	 * down event.
	 */
	final int xDiff = (int) Math.abs(x - mLastMotionX);
	final int yDiff = (int) Math.abs(y - mLastMotionY);

	boolean xMoved = xDiff > mTouchSlop;
	boolean yMoved = yDiff > mTouchSlop;

	if (xMoved || yMoved) {

		if (yMoved) {
			// Scroll if the user moved far enough along the X axis
			mTouchState = TOUCH_STATE_SCROLLING;
			enableChildrenCache();
		}
		// Either way, cancel any pending longpress
		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 currentScreen = getChildAt(mCurrentPage);
			currentScreen.cancelLongPress();
		}
	}
}
 
Example 4
Source File: PagedView.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
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();
        }
    }
}
 
Example 5
Source File: CellLayout.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 6
Source File: PagedViewWithDraggableItems.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
protected void determineDraggingStart(MotionEvent ev) {
   
    final int pointerIndex = ev.findPointerIndex(mActivePointerId);
    final float x = ev.getX(pointerIndex);
    final float y = ev.getY(pointerIndex);
    final int xDiff = (int) Math.abs(x - mLastMotionX);
    final int yDiff = (int) Math.abs(y - mLastMotionY);

    final int touchSlop = mTouchSlop;
    boolean yMoved = yDiff > touchSlop;
    boolean isUpwardMotion = (yDiff / (float) xDiff) > mDragSlopeThreshold;

    if (isUpwardMotion && yMoved && mLastTouchedItem != null) {
        // Drag if the user moved far enough along the Y axis
        beginDragging(mLastTouchedItem);

        // Cancel any pending long press
        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();
            }
        }
    }
}
 
Example 7
Source File: ShortcutAndWidgetContainer.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 8
Source File: CellLayout.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 9
Source File: PagedViewCellLayoutChildren.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 10
Source File: PagedViewCellLayout.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@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();
    }
}
 
Example 11
Source File: PagedView.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
protected void cancelCurrentPageLongPress() {
    // 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();
    }
}
 
Example 12
Source File: CellLayout.java    From Trebuchet with GNU General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example 13
Source File: PagedViewWithDraggableItems.java    From LB-Launcher with Apache License 2.0 5 votes vote down vote up
protected void determineDraggingStart(MotionEvent ev) {
    /*
     * Locally do absolute value. mLastMotionX is set to the y value
     * of the down event.
     */
    final int pointerIndex = ev.findPointerIndex(mActivePointerId);
    final float x = ev.getX(pointerIndex);
    final float y = ev.getY(pointerIndex);
    final int xDiff = (int) Math.abs(x - mLastMotionX);
    final int yDiff = (int) Math.abs(y - mLastMotionY);

    final int touchSlop = mTouchSlop;
    boolean yMoved = yDiff > touchSlop;
    boolean isUpwardMotion = (yDiff / (float) xDiff) > mDragSlopeThreshold;

    if (isUpwardMotion && yMoved && mLastTouchedItem != null) {
        // Drag if the user moved far enough along the Y axis
        beginDragging(mLastTouchedItem);

        // Cancel any pending long press
        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();
            }
        }
    }
}
 
Example 14
Source File: PagedView.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@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);
}
 
Example 15
Source File: ShortcutAndWidgetContainer.java    From LaunchEnr with GNU General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example 16
Source File: SearchView.java    From zhangshangwuda with Apache License 2.0 4 votes vote down vote up
public boolean onKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions
    if (mSearchable == null) {
        return false;
    }

    if (DBG) {
        Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
                + mQueryTextView.getListSelection());
    }

    // If a suggestion is selected, handle enter, search key, and action keys
    // as presses on the selected suggestion
    if (mQueryTextView.isPopupShowing()
            && mQueryTextView.getListSelection() != ListView.INVALID_POSITION) {
        return onSuggestionsKey(v, keyCode, event);
    }

    // If there is text in the query box, handle enter, and action keys
    // The search key is handled by the dialog's onKeyDown().
    if (!mQueryTextView.isEmpty() && KeyEventCompat.hasNoModifiers(event)) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                v.cancelLongPress();

                // Launch as a regular search.
                launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mQueryTextView.getText()
                        .toString());
                return true;
            }
        }
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
            // TODO if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
            // TODO     launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView
            // TODO             .getText().toString());
            // TODO     return true;
            // TODO }
        }
    }
    return false;
}
 
Example 17
Source File: SearchView.java    From Libraries-for-Android-Developers with MIT License 4 votes vote down vote up
public boolean onKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions
    if (mSearchable == null) {
        return false;
    }

    if (DBG) {
        Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
                + mQueryTextView.getListSelection());
    }

    // If a suggestion is selected, handle enter, search key, and action keys
    // as presses on the selected suggestion
    if (mQueryTextView.isPopupShowing()
            && mQueryTextView.getListSelection() != ListView.INVALID_POSITION) {
        return onSuggestionsKey(v, keyCode, event);
    }

    // If there is text in the query box, handle enter, and action keys
    // The search key is handled by the dialog's onKeyDown().
    if (!mQueryTextView.isEmpty() && KeyEventCompat.hasNoModifiers(event)) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                v.cancelLongPress();

                // Launch as a regular search.
                launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mQueryTextView.getText()
                        .toString());
                return true;
            }
        }
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
            // TODO if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
            // TODO     launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView
            // TODO             .getText().toString());
            // TODO     return true;
            // TODO }
        }
    }
    return false;
}
 
Example 18
Source File: SearchView.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
public boolean onKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions
    if (mSearchable == null) {
        return false;
    }

    if (DBG) {
        Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
                + mQueryTextView.getListSelection());
    }

    // If a suggestion is selected, handle enter, search key, and action keys
    // as presses on the selected suggestion
    if (mQueryTextView.isPopupShowing()
            && mQueryTextView.getListSelection() != ListView.INVALID_POSITION) {
        return onSuggestionsKey(v, keyCode, event);
    }

    // If there is text in the query box, handle enter, and action keys
    // The search key is handled by the dialog's onKeyDown().
    if (!mQueryTextView.isEmpty() && KeyEventCompat.hasNoModifiers(event)) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                v.cancelLongPress();

                // Launch as a regular search.
                launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mQueryTextView.getText()
                        .toString());
                return true;
            }
        }
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
            // TODO if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
            // TODO     launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView
            // TODO             .getText().toString());
            // TODO     return true;
            // TODO }
        }
    }
    return false;
}
 
Example 19
Source File: SearchView.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
public boolean onKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions
    if (mSearchable == null) {
        return false;
    }

    if (DBG) {
        Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
                + mSearchSrcTextView.getListSelection());
    }

    // If a suggestion is selected, handle enter, search key, and action keys
    // as presses on the selected suggestion
    if (mSearchSrcTextView.isPopupShowing()
            && mSearchSrcTextView.getListSelection() != ListView.INVALID_POSITION) {
        return onSuggestionsKey(v, keyCode, event);
    }

    // If there is text in the query box, handle enter, and action keys
    // The search key is handled by the dialog's onKeyDown().
    if (!mSearchSrcTextView.isEmpty() && event.hasNoModifiers()) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                v.cancelLongPress();

                // Launch as a regular search.
                launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mSearchSrcTextView.getText()
                        .toString());
                return true;
            }
        }
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
            if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
                launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mSearchSrcTextView
                        .getText().toString());
                return true;
            }
        }
    }
    return false;
}
 
Example 20
Source File: SearchView.java    From zen4android with MIT License 4 votes vote down vote up
public boolean onKey(View v, int keyCode, KeyEvent event) {
    // guard against possible race conditions
    if (mSearchable == null) {
        return false;
    }

    if (DBG) {
        Log.d(LOG_TAG, "mTextListener.onKey(" + keyCode + "," + event + "), selection: "
                + mQueryTextView.getListSelection());
    }

    // If a suggestion is selected, handle enter, search key, and action keys
    // as presses on the selected suggestion
    if (mQueryTextView.isPopupShowing()
            && mQueryTextView.getListSelection() != ListView.INVALID_POSITION) {
        return onSuggestionsKey(v, keyCode, event);
    }

    // If there is text in the query box, handle enter, and action keys
    // The search key is handled by the dialog's onKeyDown().
    if (!mQueryTextView.isEmpty() && KeyEventCompat.hasNoModifiers(event)) {
        if (event.getAction() == KeyEvent.ACTION_UP) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                v.cancelLongPress();

                // Launch as a regular search.
                launchQuerySearch(KeyEvent.KEYCODE_UNKNOWN, null, mQueryTextView.getText()
                        .toString());
                return true;
            }
        }
        if (event.getAction() == KeyEvent.ACTION_DOWN) {
            // TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
            // TODO if ((actionKey != null) && (actionKey.getQueryActionMsg() != null)) {
            // TODO     launchQuerySearch(keyCode, actionKey.getQueryActionMsg(), mQueryTextView
            // TODO             .getText().toString());
            // TODO     return true;
            // TODO }
        }
    }
    return false;
}