public PhotoViewAttacher(ImageView imageView, bool fromChatActivity, Context context) { mImageView = new WeakReference <ImageView>(imageView); mFromChatActivity = fromChatActivity; mContext = context; imageView.SetOnTouchListener(this); mViewTreeObserver = imageView.ViewTreeObserver; mViewTreeObserver.AddOnGlobalLayoutListener(this); // Make sure we using MATRIX Scale Type SetImageViewScaleTypeMatrix(imageView); if (!imageView.IsInEditMode) { // Create Gesture Detectors... mScaleDragDetector = VersionedGestureDetector.NewInstance(imageView.Context, this); mGestureDetector = new GestureDetector(imageView.Context, new MySimpleOnGestureListener(mLongClickListener)); mGestureDetector.SetOnDoubleTapListener(this); // Finally, update the UI so that we're zoomable SetZoomable(true); Update(); } }
public static VersionedGestureDetector NewInstance(Context context, IOnGestureListener listener) { int sdkVersion = (int)Build.VERSION.SdkInt; VersionedGestureDetector detector = null; if (sdkVersion < (int)BuildVersionCodes.Eclair) { detector = new CupcakeDetector(context); } else if (sdkVersion < (int)BuildVersionCodes.Froyo) { detector = new EclairDetector(context); } else { detector = new FroyoDetector(context); } detector.mListener = listener; return(detector); }