當前位置: 首頁>>代碼示例>>Java>>正文


Java View.drawableHotspotChanged方法代碼示例

本文整理匯總了Java中android.view.View.drawableHotspotChanged方法的典型用法代碼示例。如果您正苦於以下問題:Java View.drawableHotspotChanged方法的具體用法?Java View.drawableHotspotChanged怎麽用?Java View.drawableHotspotChanged使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.View的用法示例。


在下文中一共展示了View.drawableHotspotChanged方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setPressedItem

import android.view.View; //導入方法依賴的package包/類
private void setPressedItem(View child, int position, float x, float y) {
    this.mDrawsInPressedState = true;
    if (VERSION.SDK_INT >= 21) {
        drawableHotspotChanged(x, y);
    }
    if (!isPressed()) {
        setPressed(true);
    }
    layoutChildren();
    if (this.mMotionPosition != -1) {
        View motionView = getChildAt(this.mMotionPosition - getFirstVisiblePosition());
        if (!(motionView == null || motionView == child || !motionView.isPressed())) {
            motionView.setPressed(false);
        }
    }
    this.mMotionPosition = position;
    float childX = x - ((float) child.getLeft());
    float childY = y - ((float) child.getTop());
    if (VERSION.SDK_INT >= 21) {
        child.drawableHotspotChanged(childX, childY);
    }
    if (!child.isPressed()) {
        child.setPressed(true);
    }
    positionSelectorLikeTouchCompat(position, child, x, y);
    setSelectorEnabled(false);
    refreshDrawableState();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:29,代碼來源:ListPopupWindow.java

示例2: onTouchEvent

import android.view.View; //導入方法依賴的package包/類
@Override
public boolean onTouchEvent(MotionEvent event) {
    if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
        if (hasSubMenu() && (popupWindow == null || popupWindow != null && !popupWindow.isShowing())) {
            showMenuRunnable = new Runnable() {
                @Override
                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);
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:77,代碼來源:ActionBarMenuItem.java


注:本文中的android.view.View.drawableHotspotChanged方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。