Java 类android.support.v4.view.ScaleGestureDetectorCompat 实例源码

项目:zoomage    文件:ZoomageView.java   
public ZoomageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    scaleDetector = new ScaleGestureDetector(context, this);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleDetector, false);
    startScaleType = getScaleType();

    TypedArray values = context.obtainStyledAttributes(attrs, com.jsibbold.zoomage.R.styleable.ZoomageView);

    zoomable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_zoomable, true);
    translatable = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_translatable, true);
    animateOnReset = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_animateOnReset, true);
    autoCenter = values.getBoolean(R.styleable.ZoomageView_zoomage_autoCenter, true);
    restrictBounds = values.getBoolean(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_restrictBounds, false);
    minScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_minScale, MIN_SCALE);
    maxScale = values.getFloat(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_maxScale, MAX_SCALE);
    autoResetMode = AutoResetMode.Parser.fromInt(values.getInt(com.jsibbold.zoomage.R.styleable.ZoomageView_zoomage_autoResetMode, AutoResetMode.UNDER));

    verifyScaleRange();

    values.recycle();
}
项目:android-photoviewer    文件:PhotoView.java   
/**
 * Initializes the header and any static values
 */
private void initialize() {
    Context context = getContext();

    if (!sInitialized) {
        sInitialized = true;

        Resources resources = context.getApplicationContext().getResources();

        sCropSize = resources.getDimensionPixelSize(R.dimen.photo_crop_width);

        sCropDimPaint = new Paint();
        sCropDimPaint.setAntiAlias(true);
        sCropDimPaint.setColor(resources.getColor(R.color.photo_crop_dim_color));
        sCropDimPaint.setStyle(Style.FILL);

        sCropPaint = new Paint();
        sCropPaint.setAntiAlias(true);
        sCropPaint.setColor(resources.getColor(R.color.photo_crop_highlight_color));
        sCropPaint.setStyle(Style.STROKE);
        sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_crop_stroke_width));

        final ViewConfiguration configuration = ViewConfiguration.get(context);
        final int touchSlop = configuration.getScaledTouchSlop();
        sTouchSlopSquare = touchSlop * touchSlop;
    }

    mGestureDetector = new GestureDetectorCompat(context, this, null);
    mScaleGetureDetector = new ScaleGestureDetector(context, this);
    mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector);
    mScaleRunnable = new ScaleRunnable(this);
    mTranslateRunnable = new TranslateRunnable(this);
    mSnapRunnable = new SnapRunnable(this);
    mRotateRunnable = new RotateRunnable(this);
}
项目:FMTech    文件:PhotoView.java   
private void initialize()
{
  Context localContext = getContext();
  if (!sInitialized)
  {
    sInitialized = true;
    Resources localResources = localContext.getApplicationContext().getResources();
    sCropSize = localResources.getDimensionPixelSize(R.dimen.photo_crop_width);
    Paint localPaint1 = new Paint();
    sCropDimPaint = localPaint1;
    localPaint1.setAntiAlias(true);
    sCropDimPaint.setColor(localResources.getColor(R.color.photo_crop_dim_color));
    sCropDimPaint.setStyle(Paint.Style.FILL);
    Paint localPaint2 = new Paint();
    sCropPaint = localPaint2;
    localPaint2.setAntiAlias(true);
    sCropPaint.setColor(localResources.getColor(R.color.photo_crop_highlight_color));
    sCropPaint.setStyle(Paint.Style.STROKE);
    sCropPaint.setStrokeWidth(localResources.getDimension(R.dimen.photo_crop_stroke_width));
    int i = ViewConfiguration.get(localContext).getScaledTouchSlop();
    sTouchSlopSquare = i * i;
  }
  this.mGestureDetector = new GestureDetectorCompat(localContext, this, (byte)0);
  this.mScaleGetureDetector = new ScaleGestureDetector(localContext, this);
  this.mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(this.mScaleGetureDetector);
  this.mScaleRunnable = new ScaleRunnable(this);
  this.mTranslateRunnable = new TranslateRunnable(this);
  this.mSnapRunnable = new SnapRunnable(this);
  this.mRotateRunnable = new RotateRunnable(this);
}
项目:ListItemFold    文件:FoldLayout.java   
@TargetApi(Build.VERSION_CODES.KITKAT)
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    this.velocityTracker = VelocityTracker.obtain();
    this.interpolatorFling = new FoldInterpolator();
    this.interpolatorTap = new AccelerateDecelerateInterpolator();
    this.pinchDetector = new ScaleGestureDetector(getContext(), this);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(pinchDetector, false);
    this.viewConfig = ViewConfiguration.get(getContext());
}
项目:AndroidLiveWallpaperHelloWorld    文件:PanScaleProxyView.java   
public PanScaleProxyView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(true);

    // Sets up interactions
    mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true);
    mGestureDetector = new GestureDetectorCompat(context, mGestureListener);

    mScroller = new OverScroller(context);
    mZoomer = new Zoomer(context);
}
项目:AndroidLiveWallpaperHelloWorld    文件:PanScaleProxyView.java   
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    if (!mPanScaleEnabled || mDragZoomed || e.getActionMasked() != MotionEvent.ACTION_UP) {
        return false;
    }

    mZoomer.forceFinished(true);
    hitTest(e.getX(), e.getY(), mZoomFocalPoint);
    float startZoom;
    if (mRelativeAspectRatio > 1) {
        startZoom = 1 / mCurrentViewport.height();
    } else {
        startZoom = 1 / mCurrentViewport.width();
    }
    boolean zoomIn = (startZoom < 1.5f);
    mZoomer.startZoom(startZoom, zoomIn ? 2f : 1f);
    triggerViewportChangedListener();
    postAnimateTick();
    mNonSingleTapGesture = true;
    mNonSingleTapZoomedOut = !zoomIn;

    // Workaround for 11952668; blow away the entire scale gesture detector after
    // a double tap
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleGestureListener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true);
    return true;
}
项目:ActionLauncherApi    文件:PanScaleProxyView.java   
public PanScaleProxyView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    setWillNotDraw(true);

    // Sets up interactions
    mScaleGestureDetector = new ScaleGestureDetector(context, mScaleGestureListener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true);
    mGestureDetector = new GestureDetectorCompat(context, mGestureListener);

    mScroller = new OverScroller(context);
    mZoomer = new Zoomer(context);
}
项目:ActionLauncherApi    文件:PanScaleProxyView.java   
@Override
public boolean onDoubleTapEvent(MotionEvent e) {
    if (!mPanScaleEnabled || mDragZoomed || e.getActionMasked() != MotionEvent.ACTION_UP) {
        return false;
    }

    mZoomer.forceFinished(true);
    hitTest(e.getX(), e.getY(), mZoomFocalPoint);
    float startZoom;
    if (mRelativeAspectRatio > 1) {
        startZoom = 1 / mCurrentViewport.height();
    } else {
        startZoom = 1 / mCurrentViewport.width();
    }
    boolean zoomIn = (startZoom < 1.5f);
    mZoomer.startZoom(startZoom, zoomIn ? 2f : 1f);
    triggerViewportChangedListener();
    postAnimateTick();
    mNonSingleTapGesture = true;
    mNonSingleTapZoomedOut = !zoomIn;

    // Workaround for 11952668; blow away the entire scale gesture detector after
    // a double tap
    mScaleGestureDetector = new ScaleGestureDetector(getContext(), mScaleGestureListener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, true);
    return true;
}
项目:v2ex-daily-android    文件:PhotoView.java   
/**
 * Initializes the header and any static values
 */
private void initialize() {
    Context context = getContext();

    if (!sInitialized) {
        sInitialized = true;

        Resources resources = context.getApplicationContext().getResources();

        sCropSize = resources.getDimensionPixelSize(R.dimen.photo_crop_width);

        sCropDimPaint = new Paint();
        sCropDimPaint.setAntiAlias(true);
        sCropDimPaint.setColor(resources.getColor(R.color.photo_crop_dim_color));
        sCropDimPaint.setStyle(Style.FILL);

        sCropPaint = new Paint();
        sCropPaint.setAntiAlias(true);
        sCropPaint.setColor(resources.getColor(R.color.photo_crop_highlight_color));
        sCropPaint.setStyle(Style.STROKE);
        sCropPaint.setStrokeWidth(resources.getDimension(R.dimen.photo_crop_stroke_width));

        final ViewConfiguration configuration = ViewConfiguration.get(context);
        final int touchSlop = configuration.getScaledTouchSlop();
        sTouchSlopSquare = touchSlop * touchSlop;
    }

    mGestureDetector = new GestureDetectorCompat(context, this, null);
    mScaleGetureDetector = new ScaleGestureDetector(context, this);
    mQuickScaleEnabled = ScaleGestureDetectorCompat.isQuickScaleEnabled(mScaleGetureDetector);
    mScaleRunnable = new ScaleRunnable(this);
    mTranslateRunnable = new TranslateRunnable(this);
    mSnapRunnable = new SnapRunnable(this);
    mRotateRunnable = new RotateRunnable(this);
}
项目:xpra-client    文件:XYScrollView.java   
private void init() {
    ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleGestureDetector, true);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();
}
项目:AcFun-Area63    文件:TouchGestureDetector.java   
public TouchGestureDetector(Context context, OnTouchGestureListener listener) {
    mGestureDetector = new GestureDetectorCompat(context, listener);
    mGestureDetector.setOnDoubleTapListener(listener);
    mScaleGestureDetector = new ScaleGestureDetector(context, listener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, false);
}
项目:ByakuGallery    文件:TouchGestureDetector.java   
public TouchGestureDetector(Context context, OnTouchGestureListener listener) {
    mGestureDetector = new GestureDetectorCompat(context, listener);
    mGestureDetector.setOnDoubleTapListener(listener);
    mScaleGestureDetector = new ScaleGestureDetector(context, listener);
    ScaleGestureDetectorCompat.setQuickScaleEnabled(mScaleGestureDetector, false);
}
项目:wwmmo    文件:StarfieldGestureDetector.java   
public void create() {
  gestureDetector = new GestureDetectorCompat(view.getContext(), gestureListener);
  scaleGestureDetector = new ScaleGestureDetector(view.getContext(), scaleGestureListener);
  ScaleGestureDetectorCompat.setQuickScaleEnabled(scaleGestureDetector, true);
  view.setOnTouchListener(onTouchListener);
}