@Override public boolean dispatchTouchEvent(MotionEvent m) { if (mZoomButtonsController.isVisible()) { scheduleDismissOnScreenControls(); } return super.dispatchTouchEvent(m); }
@Override protected void onDestroy() { // This is necessary to make the ZoomButtonsController unregister // its configuration change receiver. if (mZoomButtonsController != null) { mZoomButtonsController.setVisible(false); } super.onDestroy(); }
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(); } }); }
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); } }
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); }
private void updateZoomButtonsEnabled() { ImageViewTouch2 imageView = mImageView; float scale = imageView.getScale(); mZoomButtonsController.setZoomInEnabled(scale < imageView.mMaxZoom); mZoomButtonsController.setZoomOutEnabled(scale > 1); }