Java Code Examples for android.view.PointerIcon#getSystemIcon()
The following examples show how to use
android.view.PointerIcon#getSystemIcon() .
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: BottomNavigationViewTest.java From material-components-android with Apache License 2.0 | 6 votes |
@UiThreadTest @Test @SmallTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) @TargetApi(Build.VERSION_CODES.N) public void testPointerIcon() throws Throwable { final Activity activity = activityTestRule.getActivity(); final PointerIcon expectedIcon = PointerIcon.getSystemIcon(activity, PointerIcon.TYPE_HAND); final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0); final Menu menu = bottomNavigation.getMenu(); for (int i = 0; i < menu.size(); i++) { final MenuItem item = menu.getItem(i); assertTrue(item.isEnabled()); final View itemView = activity.findViewById(item.getItemId()); assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0)); item.setEnabled(false); assertEquals(null, itemView.onResolvePointerIcon(event, 0)); item.setEnabled(true); assertEquals(expectedIcon, itemView.onResolvePointerIcon(event, 0)); } }
Example 2
Source File: TabLayoutTest.java From material-components-android with Apache License 2.0 | 6 votes |
@Test @UiThreadTest @SdkSuppress(minSdkVersion = Build.VERSION_CODES.N) @TargetApi(Build.VERSION_CODES.N) public void testPointerIcon() { final LayoutInflater inflater = LayoutInflater.from(activityTestRule.getActivity()); final TabLayout tabLayout = (TabLayout) inflater.inflate(R.layout.design_tabs_items, null); final PointerIcon expectedIcon = PointerIcon.getSystemIcon(activityTestRule.getActivity(), PointerIcon.TYPE_HAND); final int tabCount = tabLayout.getTabCount(); assertEquals(3, tabCount); final MotionEvent event = MotionEvent.obtain(0, 0, MotionEvent.ACTION_HOVER_MOVE, 0, 0, 0); for (int i = 0; i < tabCount; i++) { assertEquals(expectedIcon, tabLayout.getTabAt(i).view.onResolvePointerIcon(event, 0)); } }
Example 3
Source File: Button.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (getPointerIcon() == null && isClickable() && isEnabled()) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 4
Source File: RadialTimePickerView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (!isEnabled()) { return null; } final int degrees = getDegreesFromXY(event.getX(), event.getY(), false); if (degrees != -1) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 5
Source File: Spinner.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (getPointerIcon() == null && isClickable() && isEnabled()) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 6
Source File: SimpleMonthView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (!isEnabled()) { return null; } // Add 0.5f to event coordinates to match the logic in onTouchEvent. final int x = (int) (event.getX() + 0.5f); final int y = (int) (event.getY() + 0.5f); final int dayUnderPointer = getDayAtLocation(x, y); if (dayUnderPointer >= 0) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 7
Source File: ImageButton.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (getPointerIcon() == null && isClickable() && isEnabled()) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 8
Source File: RadialTimePickerView.java From DateTimePicker with Apache License 2.0 | 5 votes |
@TargetApi(Build.VERSION_CODES.N) @Override public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (!isEnabled()) { return null; } final int degrees = getDegreesFromXY(event.getX(), event.getY(), false); if (degrees != -1) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return super.onResolvePointerIcon(event, pointerIndex); }
Example 9
Source File: Chip.java From material-components-android with Apache License 2.0 | 5 votes |
@Nullable @Override @TargetApi(VERSION_CODES.N) public PointerIcon onResolvePointerIcon(@NonNull MotionEvent event, int pointerIndex) { if (getCloseIconTouchBounds().contains(event.getX(), event.getY()) && isEnabled()) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return null; }
Example 10
Source File: FastScroller.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (mState == STATE_DRAGGING || isPointInside(event.getX(), event.getY())) { return PointerIcon.getSystemIcon(mList.getContext(), PointerIcon.TYPE_ARROW); } return null; }
Example 11
Source File: DocumentView.java From spline with Apache License 2.0 | 4 votes |
/** * 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); }