List of usage examples for android.view View drawableHotspotChanged
@CallSuper public void drawableHotspotChanged(float x, float y)
From source file:android.support.v7.widget.DropDownListView.java
private void setPressedItem(View child, int position, float x, float y) { mDrawsInPressedState = true;/*from ww w. j av a 2 s . c o m*/ // Ordering is essential. First, update the container's pressed state. if (Build.VERSION.SDK_INT >= 21) { drawableHotspotChanged(x, y); } if (!isPressed()) { setPressed(true); } // Next, run layout to stabilize child positions. layoutChildren(); // Manage the pressed view based on motion position. This allows us to // play nicely with actual touch and scroll events. if (mMotionPosition != INVALID_POSITION) { final View motionView = getChildAt(mMotionPosition - getFirstVisiblePosition()); if (motionView != null && motionView != child && motionView.isPressed()) { motionView.setPressed(false); } } mMotionPosition = position; // Offset for child coordinates. final float childX = x - child.getLeft(); final float childY = y - child.getTop(); if (Build.VERSION.SDK_INT >= 21) { child.drawableHotspotChanged(childX, childY); } if (!child.isPressed()) { child.setPressed(true); } // Ensure that keyboard focus starts from the last touched position. positionSelectorLikeTouchCompat(position, child, x, y); // This needs some explanation. We need to disable the selector for this next call // due to the way that ListViewCompat works. Otherwise both ListView and ListViewCompat // will draw the selector and bad things happen. setSelectorEnabled(false); // Refresh the drawable state to reflect the new pressed state, // which will also update the selector state. refreshDrawableState(); }
From source file:org.telegram.ui.ActionBar.ActionBarMenuItem.java
@Override public boolean onTouchEvent(MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) { showMenuRunnable = new Runnable() { @Override/*from w w w. jav a 2 s . c o m*/ public void run() { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } toggleSubMenu(); } }; AndroidUtilities.runOnUIThread(showMenuRunnable, 200); } } else if (event.getActionMasked() == MotionEvent.ACTION_MOVE) { if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) { if (event.getY() > getHeight()) { if (getParent() != null) { getParent().requestDisallowInterceptTouchEvent(true); } toggleSubMenu(); return true; } } else if (popupWindow != null && popupWindow.isShowing()) { getLocationOnScreen(location); float x = event.getX() + location[0]; float y = event.getY() + location[1]; popupLayout.getLocationOnScreen(location); x -= location[0]; y -= location[1]; selectedMenuView = null; for (int a = 0; a < popupLayout.getItemsCount(); a++) { View child = popupLayout.getItemAt(a); child.getHitRect(rect); if ((Integer) child.getTag() < 100) { if (!rect.contains((int) x, (int) y)) { child.setPressed(false); child.setSelected(false); if (Build.VERSION.SDK_INT == 21) { child.getBackground().setVisible(false, false); } } else { child.setPressed(true); child.setSelected(true); if (Build.VERSION.SDK_INT >= 21) { if (Build.VERSION.SDK_INT == 21) { child.getBackground().setVisible(true, false); } child.drawableHotspotChanged(x, y - child.getTop()); } selectedMenuView = child; } } } } } else if (popupWindow != null && popupWindow.isShowing() && event.getActionMasked() == MotionEvent.ACTION_UP) { if (selectedMenuView != null) { selectedMenuView.setSelected(false); if (parentMenu != null) { parentMenu.onItemClick((Integer) selectedMenuView.getTag()); } else if (delegate != null) { delegate.onItemClick((Integer) selectedMenuView.getTag()); } popupWindow.dismiss(allowCloseAnimation); } else { popupWindow.dismiss(); } } else { if (selectedMenuView != null) { selectedMenuView.setSelected(false); selectedMenuView = null; } } return super.onTouchEvent(event); }
From source file:com.hippo.widget.recyclerview.EasyRecyclerView.java
private void setPressed(View v, boolean pressed, float x, float y) { v.setPressed(pressed);//from w w w . j a va 2 s . c o m if (pressed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { v.drawableHotspotChanged(x, y); } }