Java Code Examples for android.support.v4.view.MotionEventCompat#ACTION_HOVER_ENTER

The following examples show how to use android.support.v4.view.MotionEventCompat#ACTION_HOVER_ENTER . 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: ExploreByTouchHelper.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>&#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isEnabled()
            || !AccessibilityManagerCompat.isTouchExplorationEnabled(mManager)) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEventCompat.ACTION_HOVER_MOVE:
        case MotionEventCompat.ACTION_HOVER_ENTER:
            final int virtualViewId = getVirtualViewAt(event.getX(), event.getY());
            updateHoveredVirtualView(virtualViewId);
            return (virtualViewId != INVALID_ID);
        case MotionEventCompat.ACTION_HOVER_EXIT:
            if (mFocusedVirtualViewId != INVALID_ID) {
                updateHoveredVirtualView(INVALID_ID);
                return true;
            }
            return false;
        default:
            return false;
    }
}
 
Example 2
Source File: ExploreByTouchHelper.java    From android-recipes-app with Apache License 2.0 6 votes vote down vote up
/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>&#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isEnabled()
            || !AccessibilityManagerCompat.isTouchExplorationEnabled(mManager)) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEventCompat.ACTION_HOVER_MOVE:
        case MotionEventCompat.ACTION_HOVER_ENTER:
            final int virtualViewId = getVirtualViewAt(event.getX(), event.getY());
            updateHoveredVirtualView(virtualViewId);
            return (virtualViewId != INVALID_ID);
        case MotionEventCompat.ACTION_HOVER_EXIT:
            if (mFocusedVirtualViewId != INVALID_ID) {
                updateHoveredVirtualView(INVALID_ID);
                return true;
            }
            return false;
        default:
            return false;
    }
}
 
Example 3
Source File: ExploreByTouchHelper.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>&#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isEnabled()
            || !AccessibilityManagerCompat.isTouchExplorationEnabled(mManager)) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEventCompat.ACTION_HOVER_MOVE:
        case MotionEventCompat.ACTION_HOVER_ENTER:
            final int virtualViewId = getVirtualViewAt(event.getX(), event.getY());
            updateHoveredVirtualView(virtualViewId);
            return (virtualViewId != INVALID_ID);
        case MotionEventCompat.ACTION_HOVER_EXIT:
            if (mFocusedVirtualViewId != INVALID_ID) {
                updateHoveredVirtualView(INVALID_ID);
                return true;
            }
            return false;
        default:
            return false;
    }
}
 
Example 4
Source File: ExploreByTouchHelper.java    From guideshow with MIT License 6 votes vote down vote up
/**
 * Dispatches hover {@link MotionEvent}s to the virtual view hierarchy when
 * the Explore by Touch feature is enabled.
 * <p>
 * This method should be called by overriding
 * {@link View#dispatchHoverEvent}:
 *
 * <pre>&#64;Override
 * public boolean dispatchHoverEvent(MotionEvent event) {
 *   if (mHelper.dispatchHoverEvent(this, event) {
 *     return true;
 *   }
 *   return super.dispatchHoverEvent(event);
 * }
 * </pre>
 *
 * @param event The hover event to dispatch to the virtual view hierarchy.
 * @return Whether the hover event was handled.
 */
public boolean dispatchHoverEvent(MotionEvent event) {
    if (!mManager.isEnabled()
            || !AccessibilityManagerCompat.isTouchExplorationEnabled(mManager)) {
        return false;
    }

    switch (event.getAction()) {
        case MotionEventCompat.ACTION_HOVER_MOVE:
        case MotionEventCompat.ACTION_HOVER_ENTER:
            final int virtualViewId = getVirtualViewAt(event.getX(), event.getY());
            updateHoveredVirtualView(virtualViewId);
            return (virtualViewId != INVALID_ID);
        case MotionEventCompat.ACTION_HOVER_EXIT:
            if (mFocusedVirtualViewId != INVALID_ID) {
                updateHoveredVirtualView(INVALID_ID);
                return true;
            }
            return false;
        default:
            return false;
    }
}