android.view.MotionEvent#BUTTON_TERTIARY源码实例Demo

下面列出了android.view.MotionEvent#BUTTON_TERTIARY 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 365browser   文件: StripLayoutHelper.java
/**
 * Called on click. This is called before the onUpOrCancel event.
 * @param time      The current time of the app in ms.
 * @param x         The x coordinate of the position of the click.
 * @param y         The y coordinate of the position of the click.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that were pressed when onDown was invoked.
 */
public void click(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.click(x, y)) {
        mNewTabButton.handleClick(time);
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    if (clickedTab == null || clickedTab.isDying()) return;
    if (clickedTab.checkCloseHitTest(x, y)
            || (fromMouse && (buttons & MotionEvent.BUTTON_TERTIARY) != 0)) {
        clickedTab.getCloseButton().handleClick(time);
    } else {
        clickedTab.handleClick(time);
    }
}
 
源代码2 项目: delion   文件: StripLayoutHelper.java
/**
 * Called on onDown event.
 * @param time      The time stamp in millisecond of the event.
 * @param x         The x position of the event.
 * @param y         The y position of the event.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that are pressed.
 */
public void onDown(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.onDown(x, y)) {
        mRenderHost.requestRender();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    final int index = clickedTab != null
            ? TabModelUtils.getTabIndexById(mModel, clickedTab.getId())
            : TabModel.INVALID_TAB_INDEX;
    // http://crbug.com/472186 : Needs to handle a case that index is invalid.
    // The case could happen when the current tab is touched while we're inflating the rest of
    // the tabs from disk.
    mInteractingTab = index != TabModel.INVALID_TAB_INDEX && index < mStripTabs.length
            ? mStripTabs[index]
            : null;
    boolean clickedClose = clickedTab != null
                           && clickedTab.checkCloseHitTest(x, y);
    if (clickedClose) {
        clickedTab.setClosePressed(true);
        mLastPressedCloseButton = clickedTab.getCloseButton();
        mRenderHost.requestRender();
    }

    if (!mScroller.isFinished()) {
        mScroller.forceFinished(true);
        mInteractingTab = null;
    }

    if (fromMouse && !clickedClose && clickedTab != null
            && clickedTab.getVisiblePercentage() >= 1.f
            && (buttons & MotionEvent.BUTTON_TERTIARY) == 0) {
        startReorderMode(time, x, x);
    }
}
 
源代码3 项目: delion   文件: StripLayoutHelper.java
/**
 * Called on click. This is called before the onUpOrCancel event.
 * @param time      The current time of the app in ms.
 * @param x         The x coordinate of the position of the click.
 * @param y         The y coordinate of the position of the click.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that were pressed when onDown was invoked.
 */
public void click(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.click(x, y) && mModel != null) {
        mTabCreator.launchNTP();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    if (clickedTab == null || clickedTab.isDying()) return;
    if (clickedTab.checkCloseHitTest(x, y)
            || (fromMouse && (buttons & MotionEvent.BUTTON_TERTIARY) != 0)) {
        // 1. Start the close animation.
        startAnimation(buildTabClosedAnimation(clickedTab), true);

        // 2. Set the dying state of the tab.
        clickedTab.setIsDying(true);

        // 3. Fake a selection on the next tab now.
        Tab nextTab = mModel.getNextTabIfClosed(clickedTab.getId());
        if (nextTab != null) tabSelected(time, nextTab.getId(), clickedTab.getId());

        // 4. Find out if we're closing the last tab.  This determines if we resize immediately.
        boolean lastTab = mStripTabs.length == 0
                || mStripTabs[mStripTabs.length - 1].getId() == clickedTab.getId();

        // 5. Resize the tabs appropriately.
        resizeTabStrip(!lastTab);
    } else {
        int newIndex = TabModelUtils.getTabIndexById(mModel, clickedTab.getId());
        TabModelUtils.setIndex(mModel, newIndex);
    }
}
 
源代码4 项目: AndroidChromium   文件: StripLayoutHelper.java
/**
 * Called on onDown event.
 * @param time      The time stamp in millisecond of the event.
 * @param x         The x position of the event.
 * @param y         The y position of the event.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that are pressed.
 */
public void onDown(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.onDown(x, y)) {
        mRenderHost.requestRender();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    final int index = clickedTab != null
            ? TabModelUtils.getTabIndexById(mModel, clickedTab.getId())
            : TabModel.INVALID_TAB_INDEX;
    // http://crbug.com/472186 : Needs to handle a case that index is invalid.
    // The case could happen when the current tab is touched while we're inflating the rest of
    // the tabs from disk.
    mInteractingTab = index != TabModel.INVALID_TAB_INDEX && index < mStripTabs.length
            ? mStripTabs[index]
            : null;
    boolean clickedClose = clickedTab != null
                           && clickedTab.checkCloseHitTest(x, y);
    if (clickedClose) {
        clickedTab.setClosePressed(true);
        mLastPressedCloseButton = clickedTab.getCloseButton();
        mRenderHost.requestRender();
    }

    if (!mScroller.isFinished()) {
        mScroller.forceFinished(true);
        mInteractingTab = null;
    }

    if (fromMouse && !clickedClose && clickedTab != null
            && clickedTab.getVisiblePercentage() >= 1.f
            && (buttons & MotionEvent.BUTTON_TERTIARY) == 0) {
        startReorderMode(time, x, x);
    }
}
 
源代码5 项目: AndroidChromium   文件: StripLayoutHelper.java
/**
 * Called on click. This is called before the onUpOrCancel event.
 * @param time      The current time of the app in ms.
 * @param x         The x coordinate of the position of the click.
 * @param y         The y coordinate of the position of the click.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that were pressed when onDown was invoked.
 */
public void click(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.click(x, y) && mModel != null) {
        if (!mModel.isIncognito()) mModel.commitAllTabClosures();
        mTabCreator.launchNTP();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    if (clickedTab == null || clickedTab.isDying()) return;
    if (clickedTab.checkCloseHitTest(x, y)
            || (fromMouse && (buttons & MotionEvent.BUTTON_TERTIARY) != 0)) {
        // 1. Start the close animation.
        startAnimation(buildTabClosedAnimation(clickedTab), true);

        // 2. Set the dying state of the tab.
        clickedTab.setIsDying(true);

        // 3. Fake a selection on the next tab now.
        Tab nextTab = mModel.getNextTabIfClosed(clickedTab.getId());
        if (nextTab != null) tabSelected(time, nextTab.getId(), clickedTab.getId());

        // 4. Find out if we're closing the last tab.  This determines if we resize immediately.
        boolean lastTab = mStripTabs.length == 0
                || mStripTabs[mStripTabs.length - 1].getId() == clickedTab.getId();

        // 5. Resize the tabs appropriately.
        resizeTabStrip(!lastTab);
    } else {
        int newIndex = TabModelUtils.getTabIndexById(mModel, clickedTab.getId());
        TabModelUtils.setIndex(mModel, newIndex);
    }
}
 
源代码6 项目: 365browser   文件: StripLayoutHelper.java
/**
 * Called on onDown event.
 * @param time      The time stamp in millisecond of the event.
 * @param x         The x position of the event.
 * @param y         The y position of the event.
 * @param fromMouse Whether the event originates from a mouse.
 * @param buttons   State of all buttons that are pressed.
 */
public void onDown(long time, float x, float y, boolean fromMouse, int buttons) {
    resetResizeTimeout(false);

    if (mNewTabButton.onDown(x, y)) {
        mRenderHost.requestRender();
        return;
    }

    final StripLayoutTab clickedTab = getTabAtPosition(x);
    final int index = clickedTab != null
            ? TabModelUtils.getTabIndexById(mModel, clickedTab.getId())
            : TabModel.INVALID_TAB_INDEX;
    // http://crbug.com/472186 : Needs to handle a case that index is invalid.
    // The case could happen when the current tab is touched while we're inflating the rest of
    // the tabs from disk.
    mInteractingTab = index != TabModel.INVALID_TAB_INDEX && index < mStripTabs.length
            ? mStripTabs[index]
            : null;
    boolean clickedClose = clickedTab != null
                           && clickedTab.checkCloseHitTest(x, y);
    if (clickedClose) {
        clickedTab.setClosePressed(true);
        mLastPressedCloseButton = clickedTab.getCloseButton();
        mRenderHost.requestRender();
    }

    if (!mScroller.isFinished()) {
        mScroller.forceFinished(true);
        mInteractingTab = null;
    }

    if (fromMouse && !clickedClose && clickedTab != null
            && clickedTab.getVisiblePercentage() >= 1.f
            && (buttons & MotionEvent.BUTTON_TERTIARY) == 0) {
        startReorderMode(time, x, x);
    }
}
 
源代码7 项目: codeexamples-android   文件: TouchPaint.java
private boolean onTouchOrHoverEvent(MotionEvent event, boolean isTouch) {
    final int buttonState = event.getButtonState();
    int pressedButtons = buttonState & ~mOldButtonState;
    mOldButtonState = buttonState;

    if ((pressedButtons & MotionEvent.BUTTON_SECONDARY) != 0) {
        // Advance color when the right mouse button or first stylus button
        // is pressed.
        advanceColor();
    }

    PaintMode mode;
    if ((buttonState & MotionEvent.BUTTON_TERTIARY) != 0) {
        // Splat paint when the middle mouse button or second stylus button is pressed.
        mode = PaintMode.Splat;
    } else if (isTouch || (buttonState & MotionEvent.BUTTON_PRIMARY) != 0) {
        // Draw paint when touching or if the primary button is pressed.
        mode = PaintMode.Draw;
    } else {
        // Otherwise, do not paint anything.
        return false;
    }

    final int action = event.getActionMasked();
    if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_MOVE
            || action == MotionEvent.ACTION_HOVER_MOVE) {
        final int N = event.getHistorySize();
        final int P = event.getPointerCount();
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < P; j++) {
                paint(getPaintModeForTool(event.getToolType(j), mode),
                        event.getHistoricalX(j, i),
                        event.getHistoricalY(j, i),
                        event.getHistoricalPressure(j, i),
                        event.getHistoricalTouchMajor(j, i),
                        event.getHistoricalTouchMinor(j, i),
                        event.getHistoricalOrientation(j, i),
                        event.getHistoricalAxisValue(MotionEvent.AXIS_DISTANCE, j, i),
                        event.getHistoricalAxisValue(MotionEvent.AXIS_TILT, j, i));
            }
        }
        for (int j = 0; j < P; j++) {
            paint(getPaintModeForTool(event.getToolType(j), mode),
                    event.getX(j),
                    event.getY(j),
                    event.getPressure(j),
                    event.getTouchMajor(j),
                    event.getTouchMinor(j),
                    event.getOrientation(j),
                    event.getAxisValue(MotionEvent.AXIS_DISTANCE, j),
                    event.getAxisValue(MotionEvent.AXIS_TILT, j));
        }
        mCurX = event.getX();
        mCurY = event.getY();
    }
    return true;
}