Code example for ZoomButtonsController

Methods: getZoomControls, isVisible, setOnZoomListener, setVisible

0
        } 
    } 
 
    void dismissZoomPicker() { 
        ZoomButtonsController zoomControls = getZoomControls();
        if (zoomControls != null && zoomControls.isVisible()) {
            zoomControls.setVisible(false);
        } 
    } 
 
    boolean isMultiTouchZoomSupported() { 
        return !mMultiTouchListener.getPermanentlyIgnoreDetectorEvents();
    } 
 
    boolean isScaleGestureDetectionInProgress() { 
        return isMultiTouchZoomSupported() 
                && mMultiTouchDetector.isInProgress();
    } 
 
    // Passes the touch event to ScaleGestureDetector so that its internal 
    // state won't go wrong, but instructs the listener to ignore the result 
    // of processing, if any. 
    void passTouchEventThrough(MotionEvent event) {
        mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(true);
        try { 
            mMultiTouchDetector.onTouchEvent(event);
        } catch (Exception e) {
            Log.e(TAG, "ScaleGestureDetector got into a bad state!", e);
            assert(false); 
        } 
    } 
 
    // Passes the touch event to ScaleGestureDetector so that its internal state 
    // won't go wrong. ScaleGestureDetector needs two pointers in a MotionEvent 
    // to recognize a zoom gesture. 
    boolean processTouchEvent(MotionEvent event) {
        // TODO: Need to deal with multi-touch transition 
        mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(false);
        try { 
            return mMultiTouchDetector.onTouchEvent(event);
        } catch (Exception e) {
            Log.e(TAG, "ScaleGestureDetector got into a bad state!", e);
            assert(false); 
        } 
        return false; 
    } 
 
    void updateMultiTouchSupport() { 
        mMultiTouchListener.setPermanentlyIgnoreDetectorEvents(
            !mContentViewCore.getContentSettings().supportsMultiTouchZoom());
    } 
 
    private ZoomButtonsController getZoomControls() {
        if (mZoomButtonsController == null &&
            mContentViewCore.getContentSettings().shouldDisplayZoomControls()) {
            mZoomButtonsController = new ZoomButtonsController(
                    mContentViewCore.getContainerView());
            mZoomButtonsController.setOnZoomListener(new ZoomListener());
            // ZoomButtonsController positions the buttons at the bottom, but in 
            // the middle. Change their layout parameters so they appear on the 
            // right. 
            View controls = mZoomButtonsController.getZoomControls();
            ViewGroup.LayoutParams params = controls.getLayoutParams();
            if (params instanceof FrameLayout.LayoutParams) {
                ((FrameLayout.LayoutParams) params).gravity = Gravity.RIGHT;
            } 
        } 
        return mZoomButtonsController;
    }