Java Code Examples for android.view.PointerIcon
The following are top voted examples for showing how to use
android.view.PointerIcon. These examples are extracted from open source projects.
You can vote up the examples you like and your votes will be used in our system to generate
more good examples.
Example 1
Project: material-components-android File: BottomNavigationViewTest.java View source code | 7 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 = mBottomNavigation.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
Project: FPlayAndroid File: BgSeekBar.java View source code | 7 votes |
private void init() { state = UI.STATE_SELECTED; text = ""; max = 100; sliderMode = false; thumbWidth = (UI.defaultControlContentsSize * 3) >> 2; trackingOffset = Integer.MIN_VALUE; setTextSizeIndex(1); setInsideList(false); super.setDrawingCacheEnabled(false); super.setClickable(true); super.setFocusableInTouchMode(!UI.hasTouch); super.setFocusable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) super.setDefaultFocusHighlightEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) super.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND)); }
Example 3
Project: material-components-android File: TabLayoutTest.java View source code | 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 4
Project: FPlayAndroid File: BgButton.java View source code | 6 votes |
private void init() { super.setBackgroundResource(0); super.setDrawingCacheEnabled(false); super.setTextColor(UI.colorState_text_reactive); super.setTypeface(UI.defaultTypeface); super.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._18sp); super.setGravity(Gravity.CENTER); super.setPadding(UI.controlMargin, UI.controlMargin, UI.controlMargin, UI.controlMargin); super.setFocusableInTouchMode(!UI.hasTouch); super.setFocusable(true); super.setMinimumWidth(UI.defaultControlSize); super.setMinimumHeight(UI.defaultControlSize); super.setLongClickable(true); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) super.setDefaultFocusHighlightEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) super.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND)); //Seriously?! Feature?!?!? :P //http://stackoverflow.com/questions/26958909/why-is-my-button-text-coerced-to-all-caps-on-lollipop super.setTransformationMethod(null); if (selected == null) selected = getContext().getText(R.string.selected).toString(); if (unselected == null) unselected = getContext().getText(R.string.unselected).toString(); }
Example 5
Project: FPlayAndroid File: BgSpinner.java View source code | 6 votes |
private void init() { spinnerList = new SpinnerList<>(); spinnerList.setItemClickListener(this); selectedPosition = -1; super.setBackgroundResource(0); super.setDrawingCacheEnabled(false); super.setSingleLine(true); super.setEllipsize(TextUtils.TruncateAt.END); super.setTextColor(UI.colorState_text_listitem_static); super.setTypeface(UI.defaultTypeface); super.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._18sp); super.setGravity(Gravity.CENTER_VERTICAL); super.setPadding(UI.controlLargeMargin, 0, UI.controlLargeMargin, 0); super.setFocusableInTouchMode(!UI.hasTouch); super.setFocusable(true); super.setMinimumWidth(UI.defaultControlSize); super.setMinimumHeight(UI.defaultControlSize); super.setOnClickListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) super.setDefaultFocusHighlightEnabled(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) super.setPointerIcon(PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND)); }
Example 6
Project: DateTimePicker File: RadialTimePickerView.java View source code | 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 7
Project: material-components-android File: Chip.java View source code | 5 votes |
@Override @TargetApi(VERSION_CODES.N) public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { if (getCloseIconTouchBounds().contains(event.getX(), event.getY()) && isEnabled()) { return PointerIcon.getSystemIcon(getContext(), PointerIcon.TYPE_HAND); } return null; }
Example 8
Project: moonlight-android File: AndroidPointerIconCaptureProvider.java View source code | 5 votes |
private void setPointerIconOnAllViews(PointerIcon icon) { for (int i = 0; i < rootViewGroup.getChildCount(); i++) { View view = rootViewGroup.getChildAt(i); view.setPointerIcon(icon); } rootViewGroup.setPointerIcon(icon); }
Example 9
Project: spline File: DocumentView.java View source code | 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); }
Example 10
Project: moonlight-android File: AndroidPointerIconCaptureProvider.java View source code | 4 votes |
@Override public void enableCapture() { super.enableCapture(); setPointerIconOnAllViews(PointerIcon.getSystemIcon(context, PointerIcon.TYPE_NULL)); }