Java 类android.view.PointerIcon 实例源码
项目:material-components-android
文件:BottomNavigationViewTest.java
@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));
}
}
项目:material-components-android
文件:TabLayoutTest.java
@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));
}
}
项目:FPlayAndroid
文件:BgSeekBar.java
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));
}
项目:FPlayAndroid
文件:BgButton.java
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();
}
项目:FPlayAndroid
文件:BgSpinner.java
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));
}
项目:DateTimePicker
文件:RadialTimePickerView.java
@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);
}
项目:material-components-android
文件:Chip.java
@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;
}
项目:moonlight-android
文件:AndroidPointerIconCaptureProvider.java
private void setPointerIconOnAllViews(PointerIcon icon) {
for (int i = 0; i < rootViewGroup.getChildCount(); i++) {
View view = rootViewGroup.getChildAt(i);
view.setPointerIcon(icon);
}
rootViewGroup.setPointerIcon(icon);
}
项目: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);
}
项目:moonlight-android
文件:AndroidPointerIconCaptureProvider.java
@Override
public void enableCapture() {
super.enableCapture();
setPointerIconOnAllViews(PointerIcon.getSystemIcon(context, PointerIcon.TYPE_NULL));
}