android.view.MotionEvent#ACTION_HOVER_MOVE源码实例Demo

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

源代码1 项目: walt   文件: UsMotionEvent.java
public static String actionToString(int action) {
    switch (action) {
        case MotionEvent.ACTION_DOWN:
            return "ACTION_DOWN";
        case MotionEvent.ACTION_UP:
            return "ACTION_UP";
        case MotionEvent.ACTION_CANCEL:
            return "ACTION_CANCEL";
        case MotionEvent.ACTION_OUTSIDE:
            return "ACTION_OUTSIDE";
        case MotionEvent.ACTION_MOVE:
            return "ACTION_MOVE";
        case MotionEvent.ACTION_HOVER_MOVE:
            return "ACTION_HOVER_MOVE";
        case MotionEvent.ACTION_SCROLL:
            return "ACTION_SCROLL";
        case MotionEvent.ACTION_HOVER_ENTER:
            return "ACTION_HOVER_ENTER";
        case MotionEvent.ACTION_HOVER_EXIT:
            return "ACTION_HOVER_EXIT";
    }
    return "UNKNOWN_ACTION";
}
 
源代码2 项目: GestureLock   文件: LockPatternView.java
@Override
public boolean onHoverEvent(MotionEvent event) {
    AccessibilityManager accessibilityManager =
                (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
源代码3 项目: MHViewer   文件: LockPatternView.java
@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
    AccessibilityManager accessibilityManager =
            (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
源代码4 项目: android-lockpattern   文件: LockPatternView.java
@Override
public boolean onHoverEvent(MotionEvent event) {
    if (AccessibilityManager.getInstance(mContext).isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
源代码5 项目: libcommon   文件: KeyboardView.java
@Override
public boolean onHoverEvent(MotionEvent event) {
	if (mAccessibilityManager.isTouchExplorationEnabled() && event.getPointerCount() == 1) {
		final int action = event.getAction();
		switch (action) {
		case MotionEvent.ACTION_HOVER_ENTER: {
			event.setAction(MotionEvent.ACTION_DOWN);
		}
		break;
		case MotionEvent.ACTION_HOVER_MOVE: {
			event.setAction(MotionEvent.ACTION_MOVE);
		}
		break;
		case MotionEvent.ACTION_HOVER_EXIT: {
			event.setAction(MotionEvent.ACTION_UP);
		}
		break;
		}
		return onTouchEvent(event);
	}
	return true;
}
 
@Override
public void onEyeHitIn(MDHitEvent hitEvent) {
    super.onEyeHitIn(hitEvent);

    MDHitPoint point = hitEvent.getHitPoint();
    if (point == null || mAttachedView == null) {
        return;
    }
    int action = mTouchStatus == TouchStatus.NOP ? MotionEvent.ACTION_HOVER_ENTER : MotionEvent.ACTION_HOVER_MOVE;
    float x = mAttachedView.getLeft() + mAttachedView.getWidth() * point.getU();
    float y = mAttachedView.getTop() + mAttachedView.getHeight() * point.getV();

    MotionEvent motionEvent = MotionEvent.obtain(hitEvent.getTimestamp(), System.currentTimeMillis(), action, x, y, 0);
    motionEvent.setSource(InputDevice.SOURCE_CLASS_POINTER);
    mAttachedView.dispatchGenericMotionEvent(motionEvent);
    motionEvent.recycle();
    mTouchStatus = TouchStatus.DOWN;

    invalidate();
}
 
源代码7 项目: EhViewer   文件: LockPatternView.java
@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
    AccessibilityManager accessibilityManager =
            (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    if (accessibilityManager.isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
源代码8 项目: CSipSimple   文件: GlowPadView.java
@Override
public boolean onHoverEvent(MotionEvent event) {
    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER:
                event.setAction(MotionEvent.ACTION_DOWN);
                break;
            case MotionEvent.ACTION_HOVER_MOVE:
                event.setAction(MotionEvent.ACTION_MOVE);
                break;
            case MotionEvent.ACTION_HOVER_EXIT:
                event.setAction(MotionEvent.ACTION_UP);
                break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    super.onHoverEvent(event);
    return true;
}
 
源代码9 项目: talkback   文件: RadialMenuView.java
@Override
public boolean onTouchEvent(@NonNull MotionEvent event) {
  switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
    case MotionEvent.ACTION_HOVER_ENTER:
      onEnter(event.getX(), event.getY());
      // Fall-through to movement events.
    case MotionEvent.ACTION_MOVE:
    case MotionEvent.ACTION_HOVER_MOVE:
      onMove(event.getX(), event.getY());
      break;
    case MotionEvent.ACTION_UP:
    case MotionEvent.ACTION_HOVER_EXIT:
      onUp(event.getX(), event.getY());
      break;
    default:
      // Don't handle other types of events.
      return false;
  }

  handler.onTouch(this, event);

  return true;
}
 
源代码10 项目: android-lockpattern   文件: LockPatternView.java
@Override
public boolean onHoverEvent(MotionEvent event) {
    if (((AccessibilityManager) getContext().getSystemService(
            Context.ACCESSIBILITY_SERVICE)).isTouchExplorationEnabled()) {
        final int action = event.getAction();
        switch (action) {
        case MotionEvent.ACTION_HOVER_ENTER:
            event.setAction(MotionEvent.ACTION_DOWN);
            break;
        case MotionEvent.ACTION_HOVER_MOVE:
            event.setAction(MotionEvent.ACTION_MOVE);
            break;
        case MotionEvent.ACTION_HOVER_EXIT:
            event.setAction(MotionEvent.ACTION_UP);
            break;
        }
        onTouchEvent(event);
        event.setAction(action);
    }
    return super.onHoverEvent(event);
}
 
源代码11 项目: FreeFlow   文件: TouchDebugUtils.java
public static String getMotionEventString(int action){
	switch(action){
		case(MotionEvent.ACTION_DOWN): return "action_down";
		case(MotionEvent.ACTION_UP): return "action_down";
		case(MotionEvent.ACTION_CANCEL): return "action_down";
		case(MotionEvent.ACTION_MOVE): return "action_move";
		case(MotionEvent.ACTION_OUTSIDE): return "action_outside";
		case(MotionEvent.ACTION_HOVER_ENTER): return "action_hover_enter";
		case(MotionEvent.ACTION_HOVER_EXIT): return "action_hover_exit";
		case(MotionEvent.ACTION_HOVER_MOVE): return "action_hover_move";
		case(MotionEvent.ACTION_MASK): return "action_mask";
	}
	return "unknown action event";
}
 
源代码12 项目: android_9.0.0_r45   文件: DropDownListView.java
@Override
public boolean onHoverEvent(@NonNull MotionEvent ev) {
    final int action = ev.getActionMasked();
    if (action == MotionEvent.ACTION_HOVER_EXIT && mResolveHoverRunnable == null) {
        // This may be transitioning to TOUCH_DOWN. Postpone drawable state
        // updates until either the next frame or the next touch event.
        mResolveHoverRunnable = new ResolveHoverRunnable();
        mResolveHoverRunnable.post();
    }

    // Allow the super class to handle hover state management first.
    final boolean handled = super.onHoverEvent(ev);

    if (action == MotionEvent.ACTION_HOVER_ENTER
            || action == MotionEvent.ACTION_HOVER_MOVE) {
        final int position = pointToPosition((int) ev.getX(), (int) ev.getY());
        if (position != INVALID_POSITION && position != mSelectedPosition) {
            final View hoveredItem = getChildAt(position - getFirstVisiblePosition());
            if (hoveredItem.isEnabled()) {
                // Force a focus so that the proper selector state gets
                // used when we update.
                requestFocus();

                positionSelector(position, hoveredItem);
                setSelectedPositionInt(position);
                setNextSelectedPositionInt(position);
            }
            updateSelectorState();
        }
    } else {
        // Do not cancel the selected position if the selection is visible
        // by other means.
        if (!super.shouldShowSelector()) {
            setSelectedPositionInt(INVALID_POSITION);
            setNextSelectedPositionInt(INVALID_POSITION);
        }
    }

    return handled;
}
 
源代码13 项目: BaldPhone   文件: BaldButtonInterface.java
@SuppressLint("ClickableViewAccessibility")
@Override
public boolean onTouch(final View v, final MotionEvent event) {

    if (event.getAction() == MotionEvent.ACTION_DOWN) {
        longPressHandler.postDelayed(longPressedRunnable, MEDIUM_PRESS_TIMEOUT);
    } else if (event.getAction() == MotionEvent.ACTION_MOVE || event.getAction() == MotionEvent.ACTION_HOVER_MOVE) {
        if (!isActionMoveEventStored) {
            isActionMoveEventStored = true;
            lastActionMoveEventBeforeUpX = event.getX();
            lastActionMoveEventBeforeUpY = event.getY();
        } else {
            final float currentX = event.getX();
            final float currentY = event.getY();
            final float firstX = lastActionMoveEventBeforeUpX;
            final float firstY = lastActionMoveEventBeforeUpY;
            final double distance = Math.sqrt(
                    (currentY - firstY) * (currentY - firstY) + ((currentX - firstX) * (currentX - firstX)));
            if (distance > MEDIUM_PRESS_DISTANCE) {
                longPressHandler.removeCallbacks(longPressedRunnable);
            }
        }
    } else if (event.getAction() == MotionEvent.ACTION_UP) {
        isActionMoveEventStored = false;
        longPressHandler.removeCallbacks(longPressedRunnable);
        if (isLongPressHandlerActivated) {
            Log.d(TAG, "Long Press detected; halting propagation of motion event");
            isLongPressHandlerActivated = false;
            return consumeOthers(v, event);
        } else {
            BaldToast.longer(v.getContext());
            return consumeOthers(v, event);
        }

    }
    return consumeOthers(v, event);
}
 
源代码14 项目: FirefoxReality   文件: CustomScrollView.java
private boolean onHoverEventInternal(@NonNull MotionEvent event) {
    final int action = event.getActionMasked();
    switch (action) {
        case MotionEvent.ACTION_HOVER_ENTER:
        case MotionEvent.ACTION_HOVER_MOVE: {
            setHoveredThumb(true);
            return true;
        }
        case MotionEvent.ACTION_HOVER_EXIT: {
            setHoveredThumb(false);
            return true;
        }
    }
    return false;
}
 
@Override
public void onPointerEvent(MotionEvent event) {
    if (mGestureDetector != null && event.isTouchEvent()) {
        mGestureDetector.onTouchEvent(event);
    }
    switch (event.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mSwipeFireable = true;
            mDebugFireable = true;
            mDownPointers = 0;
            captureDown(event, 0);
            if (mMouseHoveringAtEdge) {
                mMouseHoveringAtEdge = false;
                mCallbacks.onMouseLeaveFromEdge();
            }
            mCallbacks.onDown();
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            captureDown(event, event.getActionIndex());
            if (mDebugFireable) {
                mDebugFireable = event.getPointerCount() < 5;
                if (!mDebugFireable) {
                    if (DEBUG) Slog.d(TAG, "Firing debug");
                    mCallbacks.onDebug();
                }
            }
            break;
        case MotionEvent.ACTION_MOVE:
            if (mSwipeFireable) {
                final int swipe = detectSwipe(event);
                mSwipeFireable = swipe == SWIPE_NONE;
                if (swipe == SWIPE_FROM_TOP) {
                    if (DEBUG) Slog.d(TAG, "Firing onSwipeFromTop");
                    mCallbacks.onSwipeFromTop();
                } else if (swipe == SWIPE_FROM_BOTTOM) {
                    if (DEBUG) Slog.d(TAG, "Firing onSwipeFromBottom");
                    mCallbacks.onSwipeFromBottom();
                } else if (swipe == SWIPE_FROM_RIGHT) {
                    if (DEBUG) Slog.d(TAG, "Firing onSwipeFromRight");
                    mCallbacks.onSwipeFromRight();
                } else if (swipe == SWIPE_FROM_LEFT) {
                    if (DEBUG) Slog.d(TAG, "Firing onSwipeFromLeft");
                    mCallbacks.onSwipeFromLeft();
                }
            }
            break;
        case MotionEvent.ACTION_HOVER_MOVE:
            if (event.isFromSource(InputDevice.SOURCE_MOUSE)) {
                if (!mMouseHoveringAtEdge && event.getY() == 0) {
                    mCallbacks.onMouseHoverAtTop();
                    mMouseHoveringAtEdge = true;
                } else if (!mMouseHoveringAtEdge && event.getY() >= screenHeight - 1) {
                    mCallbacks.onMouseHoverAtBottom();
                    mMouseHoveringAtEdge = true;
                } else if (mMouseHoveringAtEdge
                        && (event.getY() > 0 && event.getY() < screenHeight - 1)) {
                    mCallbacks.onMouseLeaveFromEdge();
                    mMouseHoveringAtEdge = false;
                }
            }
            break;
        case MotionEvent.ACTION_UP:
        case MotionEvent.ACTION_CANCEL:
            mSwipeFireable = false;
            mDebugFireable = false;
            mCallbacks.onUpOrCancel();
            break;
        default:
            if (DEBUG) Slog.d(TAG, "Ignoring " + event);
    }
}
 
源代码16 项目: GifAssistant   文件: TextPicker.java
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
    if (!mHasSelectorWheel) {
        return super.dispatchHoverEvent(event);
    }

    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) {
        final int eventY = (int) event.getY();
        final int hoveredVirtualViewId;
        if (eventY < mTopSelectionDividerTop) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
        } else if (eventY > mBottomSelectionDividerBottom) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
        } else {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
        }
        final int action = event.getAction() & MotionEvent.ACTION_MASK;
        SupportAccessibilityNodeProvider provider = getSupportAccessibilityNodeProvider();

        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                provider.performAction(hoveredVirtualViewId,
                        AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
            } break;
            case MotionEvent.ACTION_HOVER_MOVE: {
                if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
                        && mLastHoveredChildVirtualViewId != View.NO_ID) {
                    provider.sendAccessibilityEventForVirtualView(
                            mLastHoveredChildVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                    provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                    mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                    provider.performAction(hoveredVirtualViewId,
                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
                }
            } break;
            case MotionEvent.ACTION_HOVER_EXIT: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                mLastHoveredChildVirtualViewId = View.NO_ID;
            } break;
        }
    }
    return false;
}
 
源代码17 项目: spline   文件: DocumentView.java
/**
 * Adds support for different mouse pointer icons depending on document state and mouse position
 */
@Override
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) {
    int icon = PointerIcon.TYPE_DEFAULT;
    Layer l = mCurrentLayer;
    float x = event.getX() - getViewportX();
    float y = event.getY() - getViewportY();

    if (mMode == MODE_LAYER_DRAG || mMode == MODE_LAYER_PRE_DRAG) {
        icon = PointerIcon.TYPE_GRABBING;
    } else {
        if (l != null) {
            if (inPointTouchRadius(x, y, l.getTopLeft())
                    || inPointTouchRadius(x, y, l.getBottomRight())) {
                icon = PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW;
            } else if (inPointTouchRadius(x, y, l.getTopRight())
                    || inPointTouchRadius(x, y, l.getBottomLeft())) {
                icon = PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW;
            } else if (inPointTouchRadius(x, y, l.getMidTop())
                    || inPointTouchRadius(x, y, l.getMidBottom())) {
                icon = PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW;
            } else if (inPointTouchRadius(x, y, l.getMidLeft())
                    || inPointTouchRadius(x, y, l.getMidRight())) {
                icon = PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW;
            } else if (l.inBounds(x, y)) {
                switch (event.getActionMasked()) {
                    case MotionEvent.ACTION_DOWN:
                    case MotionEvent.ACTION_MOVE:
                        // Only change to hand if this is a primary button click
                        if (event.getActionButton() == MotionEvent.BUTTON_PRIMARY) {
                            icon = PointerIcon.TYPE_GRABBING;
                        } else {
                            icon = PointerIcon.TYPE_DEFAULT;
                        }
                        break;
                    case MotionEvent.ACTION_HOVER_MOVE:
                        icon = PointerIcon.TYPE_GRAB;
                        break;
                    case MotionEvent.ACTION_UP:
                    default:
                        if (event.getActionButton() == MotionEvent.BUTTON_PRIMARY) {
                            icon = PointerIcon.TYPE_GRAB;
                        } else {
                            icon = PointerIcon.TYPE_DEFAULT;
                        }
                }
            }
        }
    }
    return PointerIcon.getSystemIcon(getContext(), icon);
}
 
源代码18 项目: Trebuchet   文件: DragLayer.java
@Override
public boolean onInterceptHoverEvent(MotionEvent ev) {
    if (mLauncher == null || mLauncher.getWorkspace() == null) {
        return false;
    }
    Folder currentFolder = mLauncher.getWorkspace().getOpenFolder();
    if (currentFolder == null) {
        return false;
    } else {
            AccessibilityManager accessibilityManager = (AccessibilityManager)
                    getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
        if (accessibilityManager.isTouchExplorationEnabled()) {
            final int action = ev.getAction();
            boolean isOverFolderOrSearchBar;
            switch (action) {
                case MotionEvent.ACTION_HOVER_ENTER:
                    isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
                        (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
                    if (!isOverFolderOrSearchBar) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    }
                    mHoverPointClosesFolder = false;
                    break;
                case MotionEvent.ACTION_HOVER_MOVE:
                    isOverFolderOrSearchBar = isEventOverFolder(currentFolder, ev) ||
                        (isInAccessibleDrag() && isEventOverDropTargetBar(ev));
                    if (!isOverFolderOrSearchBar && !mHoverPointClosesFolder) {
                        sendTapOutsideFolderAccessibilityEvent(currentFolder.isEditingName());
                        mHoverPointClosesFolder = true;
                        return true;
                    } else if (!isOverFolderOrSearchBar) {
                        return true;
                    }
                    mHoverPointClosesFolder = false;
            }
        }
    }
    return false;
}
 
源代码19 项目: DateTimePicker   文件: NumberPicker.java
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
    if (!mHasSelectorWheel) {
        return super.dispatchHoverEvent(event);
    }
    AccessibilityManager accessibilityManager = (AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
    //if (AccessibilityManager.getInstance(mContext).isEnabled()) {
    if (accessibilityManager != null && accessibilityManager.isEnabled()) {
        final int eventY = (int) event.getY();
        final int hoveredVirtualViewId;
        if (eventY < mTopSelectionDividerTop) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
        } else if (eventY > mBottomSelectionDividerBottom) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
        } else {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
        }
        final int action = event.getActionMasked();
        AccessibilityNodeProviderImpl provider =
                (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                provider.performAction(hoveredVirtualViewId,
                        AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
            }
            break;
            case MotionEvent.ACTION_HOVER_MOVE: {
                if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
                        && mLastHoveredChildVirtualViewId != View.NO_ID) {
                    provider.sendAccessibilityEventForVirtualView(
                            mLastHoveredChildVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                    provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                    mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                    provider.performAction(hoveredVirtualViewId,
                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
                }
            }
            break;
            case MotionEvent.ACTION_HOVER_EXIT: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                mLastHoveredChildVirtualViewId = View.NO_ID;
            }
            break;
        }
    }
    return false;
}
 
源代码20 项目: ticdesign   文件: NumberPicker.java
@Override
protected boolean dispatchHoverEvent(MotionEvent event) {
    if (!mHasSelectorWheel) {
        return super.dispatchHoverEvent(event);
    }
    if (((AccessibilityManager) getContext().getSystemService(Context.ACCESSIBILITY_SERVICE)).isEnabled()) {
        final int eventY = (int) event.getY();
        final int hoveredVirtualViewId;
        if (eventY < mTopSelectionDividerTop) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_DECREMENT;
        } else if (eventY > mBottomSelectionDividerBottom) {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INCREMENT;
        } else {
            hoveredVirtualViewId = AccessibilityNodeProviderImpl.VIRTUAL_VIEW_ID_INPUT;
        }
        final int action = event.getActionMasked();
        AccessibilityNodeProviderImpl provider =
            (AccessibilityNodeProviderImpl) getAccessibilityNodeProvider();
        switch (action) {
            case MotionEvent.ACTION_HOVER_ENTER: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                provider.performAction(hoveredVirtualViewId,
                        AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
            } break;
            case MotionEvent.ACTION_HOVER_MOVE: {
                if (mLastHoveredChildVirtualViewId != hoveredVirtualViewId
                        && mLastHoveredChildVirtualViewId != View.NO_ID) {
                    provider.sendAccessibilityEventForVirtualView(
                            mLastHoveredChildVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                    provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                            AccessibilityEvent.TYPE_VIEW_HOVER_ENTER);
                    mLastHoveredChildVirtualViewId = hoveredVirtualViewId;
                    provider.performAction(hoveredVirtualViewId,
                            AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS, null);
                }
            } break;
            case MotionEvent.ACTION_HOVER_EXIT: {
                provider.sendAccessibilityEventForVirtualView(hoveredVirtualViewId,
                        AccessibilityEvent.TYPE_VIEW_HOVER_EXIT);
                mLastHoveredChildVirtualViewId = View.NO_ID;
            } break;
        }
    }
    return false;
}