示例#1
0
 @Override
 public boolean dispatchTouchEvent(MotionEvent m) {
     if (mZoomButtonsController.isVisible()) {
         scheduleDismissOnScreenControls();
     }
     return super.dispatchTouchEvent(m);
 }
示例#2
0
    @Override
    protected void onDestroy() {
        // This is necessary to make the ZoomButtonsController unregister
        // its configuration change receiver.
        if (mZoomButtonsController != null) {
            mZoomButtonsController.setVisible(false);
        }

        super.onDestroy();
    }
示例#3
0
    private void setupZoomButtonController(final View ownerView) {
        mZoomButtonsController = new ZoomButtonsController(ownerView);
        mZoomButtonsController.setAutoDismissed(false);
        mZoomButtonsController.setZoomSpeed(100);
        mZoomButtonsController.setOnZoomListener(
                new ZoomButtonsController.OnZoomListener() {
            public void onVisibilityChanged(boolean visible) {
                if (visible) {
                    updateZoomButtonsEnabled();
                }
            }

            public void onZoom(boolean zoomIn) {
                if (zoomIn) {
                    mImageView.zoomIn();
                } else {
                    mImageView.zoomOut();
                }
                mZoomButtonsController.setVisible(true);
                updateZoomButtonsEnabled();
            }
        });
    }
示例#4
0
    private void showOnScreenControls() {

        // If the view has not been attached to the window yet, the
        // zoomButtonControls will not able to show up. So delay it until the
        // view has attached to window.
        if (mRootView.getWindowToken() == null) {
            mHandler.postGetterCallback(new Runnable() {
                public void run() {
                    showOnScreenControls();
                }
            });
            return;
        }

        // we may need to update the next/prev button due to index changing
        updateNextPrevControls();

        if (ImageManager.isImage(mAllImages.getImageAt(mCurrentPosition))) {
            updateZoomButtonsEnabled();
            mZoomButtonsController.setVisible(true);
        } else {
            mZoomButtonsController.setVisible(false);
        }
    }
示例#5
0
    private void hideOnScreenControls() {
        if (mNextImageView.getVisibility() == View.VISIBLE) {
            Animation a = mHideNextImageViewAnimation;
            a.setDuration(500);
            mNextImageView.startAnimation(a);
            mNextImageView.setVisibility(View.INVISIBLE);
        }

        if (mPrevImageView.getVisibility() == View.VISIBLE) {
            Animation a = mHidePrevImageViewAnimation;
            a.setDuration(500);
            mPrevImageView.startAnimation(a);
            mPrevImageView.setVisibility(View.INVISIBLE);
        }

        mZoomButtonsController.setVisible(false);
    }
示例#6
0
 private void updateZoomButtonsEnabled() {
     ImageViewTouch2 imageView = mImageView;
     float scale = imageView.getScale();
     mZoomButtonsController.setZoomInEnabled(scale < imageView.mMaxZoom);
     mZoomButtonsController.setZoomOutEnabled(scale > 1);
 }