CupcakeGestureDetector.smali

.class public Lio/rong/photoview/gestures/CupcakeGestureDetector;
.super Ljava/lang/Object;
.source "CupcakeGestureDetector.java"

# interfaces
.implements Lio/rong/photoview/gestures/GestureDetector;


# static fields
.field private static final LOG_TAG:Ljava/lang/String; = "CupcakeGestureDetector"


# instance fields
.field private mIsDragging:Z

.field mLastTouchX:F

.field mLastTouchY:F

.field protected mListener:Lio/rong/photoview/gestures/OnGestureListener;

.field final mMinimumVelocity:F

.field final mTouchSlop:F

.field private mVelocityTracker:Landroid/view/VelocityTracker;


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    invoke-static {p1}, Landroid/view/ViewConfiguration;->get(Landroid/content/Context;)Landroid/view/ViewConfiguration;

    move-result-object p1

    .line 3
    invoke-virtual {p1}, Landroid/view/ViewConfiguration;->getScaledMinimumFlingVelocity()I

    move-result v0

    int-to-float v0, v0

    iput v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mMinimumVelocity:F

    .line 4
    invoke-virtual {p1}, Landroid/view/ViewConfiguration;->getScaledTouchSlop()I

    move-result p1

    int-to-float p1, p1

    iput p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mTouchSlop:F

    return-void
.end method


# virtual methods
.method getActiveX(Landroid/view/MotionEvent;)F
    .registers 2

    .line 1
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getX()F

    move-result p1

    return p1
.end method

.method getActiveY(Landroid/view/MotionEvent;)F
    .registers 2

    .line 1
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getY()F

    move-result p1

    return p1
.end method

.method public isDragging()Z
    .registers 2

    .line 1
    iget-boolean v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    return v0
.end method

.method public isScaling()Z
    .registers 2

    const/4 v0, 0x0

    return v0
.end method

.method public onTouchEvent(Landroid/view/MotionEvent;)Z
    .registers 13

    .line 1
    invoke-virtual {p1}, Landroid/view/MotionEvent;->getAction()I

    move-result v0

    const/4 v1, 0x0

    const/4 v2, 0x1

    if-eqz v0, :cond_af

    const/4 v3, 0x0

    if-eq v0, v2, :cond_5c

    const/4 v4, 0x2

    if-eq v0, v4, :cond_1e

    const/4 p1, 0x3

    if-eq v0, p1, :cond_13

    goto/16 :goto_d6

    .line 2
    :cond_13
    iget-object p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    if-eqz p1, :cond_d6

    .line 3
    invoke-virtual {p1}, Landroid/view/VelocityTracker;->recycle()V

    .line 4
    iput-object v3, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    goto/16 :goto_d6

    .line 5
    :cond_1e
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveX(Landroid/view/MotionEvent;)F

    move-result v0

    .line 6
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveY(Landroid/view/MotionEvent;)F

    move-result v3

    .line 7
    iget v4, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchX:F

    sub-float v4, v0, v4

    iget v5, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchY:F

    sub-float v5, v3, v5

    .line 8
    iget-boolean v6, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    if-nez v6, :cond_46

    mul-float v6, v4, v4

    mul-float v7, v5, v5

    add-float/2addr v6, v7

    float-to-double v6, v6

    .line 9
    invoke-static {v6, v7}, Ljava/lang/Math;->sqrt(D)D

    move-result-wide v6

    iget v8, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mTouchSlop:F

    float-to-double v8, v8

    cmpl-double v10, v6, v8

    if-ltz v10, :cond_44

    const/4 v1, 0x1

    :cond_44
    iput-boolean v1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    .line 10
    :cond_46
    iget-boolean v1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    if-eqz v1, :cond_d6

    .line 11
    iget-object v1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mListener:Lio/rong/photoview/gestures/OnGestureListener;

    invoke-interface {v1, v4, v5}, Lio/rong/photoview/gestures/OnGestureListener;->onDrag(FF)V

    .line 12
    iput v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchX:F

    .line 13
    iput v3, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchY:F

    .line 14
    iget-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    if-eqz v0, :cond_d6

    .line 15
    invoke-virtual {v0, p1}, Landroid/view/VelocityTracker;->addMovement(Landroid/view/MotionEvent;)V

    goto/16 :goto_d6

    .line 16
    :cond_5c
    iget-boolean v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    if-eqz v0, :cond_a5

    .line 17
    iget-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    if-eqz v0, :cond_a5

    .line 18
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveX(Landroid/view/MotionEvent;)F

    move-result v0

    iput v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchX:F

    .line 19
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveY(Landroid/view/MotionEvent;)F

    move-result v0

    iput v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchY:F

    .line 20
    iget-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    invoke-virtual {v0, p1}, Landroid/view/VelocityTracker;->addMovement(Landroid/view/MotionEvent;)V

    .line 21
    iget-object p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    const/16 v0, 0x3e8

    invoke-virtual {p1, v0}, Landroid/view/VelocityTracker;->computeCurrentVelocity(I)V

    .line 22
    iget-object p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    invoke-virtual {p1}, Landroid/view/VelocityTracker;->getXVelocity()F

    move-result p1

    iget-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    .line 23
    invoke-virtual {v0}, Landroid/view/VelocityTracker;->getYVelocity()F

    move-result v0

    .line 24
    invoke-static {p1}, Ljava/lang/Math;->abs(F)F

    move-result v1

    invoke-static {v0}, Ljava/lang/Math;->abs(F)F

    move-result v4

    invoke-static {v1, v4}, Ljava/lang/Math;->max(FF)F

    move-result v1

    iget v4, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mMinimumVelocity:F

    cmpl-float v1, v1, v4

    if-ltz v1, :cond_a5

    .line 25
    iget-object v1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mListener:Lio/rong/photoview/gestures/OnGestureListener;

    iget v4, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchX:F

    iget v5, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchY:F

    neg-float p1, p1

    neg-float v0, v0

    invoke-interface {v1, v4, v5, p1, v0}, Lio/rong/photoview/gestures/OnGestureListener;->onFling(FFFF)V

    .line 26
    :cond_a5
    iget-object p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    if-eqz p1, :cond_d6

    .line 27
    invoke-virtual {p1}, Landroid/view/VelocityTracker;->recycle()V

    .line 28
    iput-object v3, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    goto :goto_d6

    .line 29
    :cond_af
    invoke-static {}, Landroid/view/VelocityTracker;->obtain()Landroid/view/VelocityTracker;

    move-result-object v0

    iput-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    .line 30
    iget-object v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mVelocityTracker:Landroid/view/VelocityTracker;

    if-eqz v0, :cond_bd

    .line 31
    invoke-virtual {v0, p1}, Landroid/view/VelocityTracker;->addMovement(Landroid/view/MotionEvent;)V

    goto :goto_c8

    .line 32
    :cond_bd
    invoke-static {}, Lio/rong/photoview/log/LogManager;->getLogger()Lio/rong/photoview/log/Logger;

    move-result-object v0

    const-string v3, "CupcakeGestureDetector"

    const-string v4, "Velocity tracker is null"

    invoke-interface {v0, v3, v4}, Lio/rong/photoview/log/Logger;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 33
    :goto_c8
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveX(Landroid/view/MotionEvent;)F

    move-result v0

    iput v0, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchX:F

    .line 34
    invoke-virtual {p0, p1}, Lio/rong/photoview/gestures/CupcakeGestureDetector;->getActiveY(Landroid/view/MotionEvent;)F

    move-result p1

    iput p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mLastTouchY:F

    .line 35
    iput-boolean v1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mIsDragging:Z

    :cond_d6
    :goto_d6
    return v2
.end method

.method public setOnGestureListener(Lio/rong/photoview/gestures/OnGestureListener;)V
    .registers 2

    .line 1
    iput-object p1, p0, Lio/rong/photoview/gestures/CupcakeGestureDetector;->mListener:Lio/rong/photoview/gestures/OnGestureListener;

    return-void
.end method