public Attacher(DraweeView<GenericDraweeHierarchy> draweeView) { mDraweeView = new WeakReference<DraweeView<GenericDraweeHierarchy>>(draweeView); draweeView.getHierarchy().setActualImageScaleType(ScalingUtils.ScaleType.FIT_CENTER); draweeView.setOnTouchListener(this); mScaleDragDetector = new ScaleDragDetector(draweeView.getContext(), this); mGestureDetector = new GestureDetectorCompat( draweeView.getContext(), new GestureDetector.SimpleOnGestureListener() { @Override public void onLongPress(MotionEvent e) { super.onLongPress(e); if (null != mLongClickListener) { mLongClickListener.onLongClick(getDraweeView()); } } }); mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this)); }
@Override public void onFling(float startX, float startY, float velocityX, float velocityY) { DraweeView<GenericDraweeHierarchy> draweeView = getDraweeView(); if (draweeView == null) { return; } mCurrentFlingRunnable = new FlingRunnable(draweeView.getContext()); mCurrentFlingRunnable.fling(getViewWidth(), getViewHeight(), (int) velocityX, (int) velocityY); draweeView.post(mCurrentFlingRunnable); }