Rabbit-R1/original r1/smali/smali_classes2/androidx/viewpager2/widget/FakeDrag.smali
2024-05-21 17:08:36 -04:00

385 lines
9.4 KiB
Smali

.class final Landroidx/viewpager2/widget/FakeDrag;
.super Ljava/lang/Object;
.source "FakeDrag.java"
# instance fields
.field private mActualDraggedDistance:I
.field private mFakeDragBeginTime:J
.field private mMaximumVelocity:I
.field private final mRecyclerView:Landroidx/recyclerview/widget/RecyclerView;
.field private mRequestedDragDistance:F
.field private final mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.field private mVelocityTracker:Landroid/view/VelocityTracker;
.field private final mViewPager:Landroidx/viewpager2/widget/ViewPager2;
# direct methods
.method constructor <init>(Landroidx/viewpager2/widget/ViewPager2;Landroidx/viewpager2/widget/ScrollEventAdapter;Landroidx/recyclerview/widget/RecyclerView;)V
.locals 0
.line 44
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Landroidx/viewpager2/widget/FakeDrag;->mViewPager:Landroidx/viewpager2/widget/ViewPager2;
iput-object p2, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
iput-object p3, p0, Landroidx/viewpager2/widget/FakeDrag;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView;
return-void
.end method
.method private addFakeMotionEvent(JIFF)V
.locals 8
iget-wide v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mFakeDragBeginTime:J
const/4 v7, 0x0
move-wide v2, p1
move v4, p3
move v5, p4
move v6, p5
.line 134
invoke-static/range {v0 .. v7}, Landroid/view/MotionEvent;->obtain(JJIFFI)Landroid/view/MotionEvent;
move-result-object p1
iget-object p0, p0, Landroidx/viewpager2/widget/FakeDrag;->mVelocityTracker:Landroid/view/VelocityTracker;
.line 135
invoke-virtual {p0, p1}, Landroid/view/VelocityTracker;->addMovement(Landroid/view/MotionEvent;)V
.line 136
invoke-virtual {p1}, Landroid/view/MotionEvent;->recycle()V
return-void
.end method
.method private beginFakeVelocityTracker()V
.locals 1
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mVelocityTracker:Landroid/view/VelocityTracker;
if-nez v0, :cond_0
.line 125
invoke-static {}, Landroid/view/VelocityTracker;->obtain()Landroid/view/VelocityTracker;
move-result-object v0
iput-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mVelocityTracker:Landroid/view/VelocityTracker;
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mViewPager:Landroidx/viewpager2/widget/ViewPager2;
.line 126
invoke-virtual {v0}, Landroidx/viewpager2/widget/ViewPager2;->getContext()Landroid/content/Context;
move-result-object v0
invoke-static {v0}, Landroid/view/ViewConfiguration;->get(Landroid/content/Context;)Landroid/view/ViewConfiguration;
move-result-object v0
.line 127
invoke-virtual {v0}, Landroid/view/ViewConfiguration;->getScaledMaximumFlingVelocity()I
move-result v0
iput v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mMaximumVelocity:I
goto :goto_0
.line 129
:cond_0
invoke-virtual {v0}, Landroid/view/VelocityTracker;->clear()V
:goto_0
return-void
.end method
# virtual methods
.method beginFakeDrag()Z
.locals 7
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 56
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->isDragging()Z
move-result v0
const/4 v1, 0x0
if-eqz v0, :cond_0
return v1
:cond_0
iput v1, p0, Landroidx/viewpager2/widget/FakeDrag;->mActualDraggedDistance:I
int-to-float v0, v1
iput v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mRequestedDragDistance:F
.line 60
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v0
iput-wide v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mFakeDragBeginTime:J
.line 61
invoke-direct {p0}, Landroidx/viewpager2/widget/FakeDrag;->beginFakeVelocityTracker()V
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 63
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->notifyBeginFakeDrag()V
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 64
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->isIdle()Z
move-result v0
if-nez v0, :cond_1
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView;
.line 66
invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->stopScroll()V
:cond_1
iget-wide v2, p0, Landroidx/viewpager2/widget/FakeDrag;->mFakeDragBeginTime:J
const/4 v4, 0x0
const/4 v5, 0x0
const/4 v6, 0x0
move-object v1, p0
.line 68
invoke-direct/range {v1 .. v6}, Landroidx/viewpager2/widget/FakeDrag;->addFakeMotionEvent(JIFF)V
const/4 p0, 0x1
return p0
.end method
.method endFakeDrag()Z
.locals 3
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 102
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->isFakeDragging()Z
move-result v0
if-nez v0, :cond_0
const/4 p0, 0x0
return p0
:cond_0
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 107
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->notifyEndFakeDrag()V
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mVelocityTracker:Landroid/view/VelocityTracker;
iget v1, p0, Landroidx/viewpager2/widget/FakeDrag;->mMaximumVelocity:I
int-to-float v1, v1
const/16 v2, 0x3e8
.line 112
invoke-virtual {v0, v2, v1}, Landroid/view/VelocityTracker;->computeCurrentVelocity(IF)V
.line 113
invoke-virtual {v0}, Landroid/view/VelocityTracker;->getXVelocity()F
move-result v1
float-to-int v1, v1
.line 114
invoke-virtual {v0}, Landroid/view/VelocityTracker;->getYVelocity()F
move-result v0
float-to-int v0, v0
iget-object v2, p0, Landroidx/viewpager2/widget/FakeDrag;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView;
.line 116
invoke-virtual {v2, v1, v0}, Landroidx/recyclerview/widget/RecyclerView;->fling(II)Z
move-result v0
if-nez v0, :cond_1
iget-object p0, p0, Landroidx/viewpager2/widget/FakeDrag;->mViewPager:Landroidx/viewpager2/widget/ViewPager2;
.line 118
invoke-virtual {p0}, Landroidx/viewpager2/widget/ViewPager2;->snapToPage()V
:cond_1
const/4 p0, 0x1
return p0
.end method
.method fakeDragBy(F)Z
.locals 9
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 74
invoke-virtual {v0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->isFakeDragging()Z
move-result v0
const/4 v1, 0x0
if-nez v0, :cond_0
return v1
:cond_0
iget v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mRequestedDragDistance:F
sub-float/2addr v0, p1
iput v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mRequestedDragDistance:F
iget p1, p0, Landroidx/viewpager2/widget/FakeDrag;->mActualDraggedDistance:I
int-to-float p1, p1
sub-float/2addr v0, p1
.line 82
invoke-static {v0}, Ljava/lang/Math;->round(F)I
move-result p1
iget v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mActualDraggedDistance:I
add-int/2addr v0, p1
iput v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mActualDraggedDistance:I
.line 85
invoke-static {}, Landroid/os/SystemClock;->uptimeMillis()J
move-result-wide v3
iget-object v0, p0, Landroidx/viewpager2/widget/FakeDrag;->mViewPager:Landroidx/viewpager2/widget/ViewPager2;
.line 87
invoke-virtual {v0}, Landroidx/viewpager2/widget/ViewPager2;->getOrientation()I
move-result v0
const/4 v8, 0x1
if-nez v0, :cond_1
move v0, v8
goto :goto_0
:cond_1
move v0, v1
:goto_0
if-eqz v0, :cond_2
move v2, p1
goto :goto_1
:cond_2
move v2, v1
:goto_1
if-eqz v0, :cond_3
goto :goto_2
:cond_3
move v1, p1
:goto_2
const/4 p1, 0x0
if-eqz v0, :cond_4
iget v5, p0, Landroidx/viewpager2/widget/FakeDrag;->mRequestedDragDistance:F
move v6, v5
goto :goto_3
:cond_4
move v6, p1
:goto_3
if-eqz v0, :cond_5
goto :goto_4
:cond_5
iget p1, p0, Landroidx/viewpager2/widget/FakeDrag;->mRequestedDragDistance:F
:goto_4
move v7, p1
iget-object p1, p0, Landroidx/viewpager2/widget/FakeDrag;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView;
.line 95
invoke-virtual {p1, v2, v1}, Landroidx/recyclerview/widget/RecyclerView;->scrollBy(II)V
const/4 v5, 0x2
move-object v2, p0
.line 96
invoke-direct/range {v2 .. v7}, Landroidx/viewpager2/widget/FakeDrag;->addFakeMotionEvent(JIFF)V
return v8
.end method
.method isFakeDragging()Z
.locals 0
iget-object p0, p0, Landroidx/viewpager2/widget/FakeDrag;->mScrollEventAdapter:Landroidx/viewpager2/widget/ScrollEventAdapter;
.line 51
invoke-virtual {p0}, Landroidx/viewpager2/widget/ScrollEventAdapter;->isFakeDragging()Z
move-result p0
return p0
.end method