android.support.v4.view.MotionEventCompat#ACTION_HOVER_ENTER源码实例Demo

下面列出了android.support.v4.view.MotionEventCompat#ACTION_HOVER_ENTER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

/**
 * 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;
    }
}
 
/**
 * 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;
    }
}
 
源代码3 项目: V.FlyoutTest   文件: ExploreByTouchHelper.java
/**
 * 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;
    }
}
 
源代码4 项目: guideshow   文件: ExploreByTouchHelper.java
/**
 * 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;
    }
}