.class public abstract Landroidx/recyclerview/widget/SnapHelper; .super Landroidx/recyclerview/widget/RecyclerView$OnFlingListener; .source "SnapHelper.java" # static fields .field static final MILLISECONDS_PER_INCH:F = 100.0f # instance fields .field private mGravityScroller:Landroid/widget/Scroller; .field mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .field private final mScrollListener:Landroidx/recyclerview/widget/RecyclerView$OnScrollListener; # direct methods .method public constructor ()V .locals 1 .line 35 invoke-direct {p0}, Landroidx/recyclerview/widget/RecyclerView$OnFlingListener;->()V .line 43 new-instance v0, Landroidx/recyclerview/widget/SnapHelper$1; invoke-direct {v0, p0}, Landroidx/recyclerview/widget/SnapHelper$1;->(Landroidx/recyclerview/widget/SnapHelper;)V iput-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mScrollListener:Landroidx/recyclerview/widget/RecyclerView$OnScrollListener; return-void .end method .method private destroyCallbacks()V .locals 2 iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; iget-object v1, p0, Landroidx/recyclerview/widget/SnapHelper;->mScrollListener:Landroidx/recyclerview/widget/RecyclerView$OnScrollListener; .line 124 invoke-virtual {v0, v1}, Landroidx/recyclerview/widget/RecyclerView;->removeOnScrollListener(Landroidx/recyclerview/widget/RecyclerView$OnScrollListener;)V iget-object p0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; const/4 v0, 0x0 .line 125 invoke-virtual {p0, v0}, Landroidx/recyclerview/widget/RecyclerView;->setOnFlingListener(Landroidx/recyclerview/widget/RecyclerView$OnFlingListener;)V return-void .end method .method private setupCallbacks()V .locals 2 .annotation system Ldalvik/annotation/Throws; value = { Ljava/lang/IllegalStateException; } .end annotation iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 113 invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->getOnFlingListener()Landroidx/recyclerview/widget/RecyclerView$OnFlingListener; move-result-object v0 if-nez v0, :cond_0 iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; iget-object v1, p0, Landroidx/recyclerview/widget/SnapHelper;->mScrollListener:Landroidx/recyclerview/widget/RecyclerView$OnScrollListener; .line 116 invoke-virtual {v0, v1}, Landroidx/recyclerview/widget/RecyclerView;->addOnScrollListener(Landroidx/recyclerview/widget/RecyclerView$OnScrollListener;)V iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 117 invoke-virtual {v0, p0}, Landroidx/recyclerview/widget/RecyclerView;->setOnFlingListener(Landroidx/recyclerview/widget/RecyclerView$OnFlingListener;)V return-void .line 114 :cond_0 new-instance p0, Ljava/lang/IllegalStateException; const-string v0, "An instance of OnFlingListener already set." invoke-direct {p0, v0}, Ljava/lang/IllegalStateException;->(Ljava/lang/String;)V throw p0 .end method .method private snapFromFling(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;II)Z .locals 2 .line 159 instance-of v0, p1, Landroidx/recyclerview/widget/RecyclerView$SmoothScroller$ScrollVectorProvider; const/4 v1, 0x0 if-nez v0, :cond_0 return v1 .line 163 :cond_0 invoke-virtual {p0, p1}, Landroidx/recyclerview/widget/SnapHelper;->createScroller(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroidx/recyclerview/widget/RecyclerView$SmoothScroller; move-result-object v0 if-nez v0, :cond_1 return v1 .line 168 :cond_1 invoke-virtual {p0, p1, p2, p3}, Landroidx/recyclerview/widget/SnapHelper;->findTargetSnapPosition(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;II)I move-result p0 const/4 p2, -0x1 if-ne p0, p2, :cond_2 return v1 .line 173 :cond_2 invoke-virtual {v0, p0}, Landroidx/recyclerview/widget/RecyclerView$SmoothScroller;->setTargetPosition(I)V .line 174 invoke-virtual {p1, v0}, Landroidx/recyclerview/widget/RecyclerView$LayoutManager;->startSmoothScroll(Landroidx/recyclerview/widget/RecyclerView$SmoothScroller;)V const/4 p0, 0x1 return p0 .end method # virtual methods .method public attachToRecyclerView(Landroidx/recyclerview/widget/RecyclerView;)V .locals 2 .annotation system Ldalvik/annotation/Throws; value = { Ljava/lang/IllegalStateException; } .end annotation iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; if-ne v0, p1, :cond_0 return-void :cond_0 if-eqz v0, :cond_1 .line 98 invoke-direct {p0}, Landroidx/recyclerview/widget/SnapHelper;->destroyCallbacks()V :cond_1 iput-object p1, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; if-eqz p1, :cond_2 .line 102 invoke-direct {p0}, Landroidx/recyclerview/widget/SnapHelper;->setupCallbacks()V .line 103 new-instance p1, Landroid/widget/Scroller; iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->getContext()Landroid/content/Context; move-result-object v0 new-instance v1, Landroid/view/animation/DecelerateInterpolator; invoke-direct {v1}, Landroid/view/animation/DecelerateInterpolator;->()V invoke-direct {p1, v0, v1}, Landroid/widget/Scroller;->(Landroid/content/Context;Landroid/view/animation/Interpolator;)V iput-object p1, p0, Landroidx/recyclerview/widget/SnapHelper;->mGravityScroller:Landroid/widget/Scroller; .line 105 invoke-virtual {p0}, Landroidx/recyclerview/widget/SnapHelper;->snapToTargetExistingView()V :cond_2 return-void .end method .method public abstract calculateDistanceToFinalSnap(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;Landroid/view/View;)[I .end method .method public calculateScrollDistance(II)[I .locals 9 iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mGravityScroller:Landroid/widget/Scroller; const/4 v1, 0x0 const/4 v2, 0x0 const/high16 v5, -0x80000000 const v6, 0x7fffffff const/high16 v7, -0x80000000 const v8, 0x7fffffff move v3, p1 move v4, p2 .line 140 invoke-virtual/range {v0 .. v8}, Landroid/widget/Scroller;->fling(IIIIIIII)V iget-object p1, p0, Landroidx/recyclerview/widget/SnapHelper;->mGravityScroller:Landroid/widget/Scroller; .line 142 invoke-virtual {p1}, Landroid/widget/Scroller;->getFinalX()I move-result p1 iget-object p0, p0, Landroidx/recyclerview/widget/SnapHelper;->mGravityScroller:Landroid/widget/Scroller; .line 143 invoke-virtual {p0}, Landroid/widget/Scroller;->getFinalY()I move-result p0 filled-new-array {p1, p0}, [I move-result-object p0 return-object p0 .end method .method protected createScroller(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroidx/recyclerview/widget/RecyclerView$SmoothScroller; .locals 0 .line 212 invoke-virtual {p0, p1}, Landroidx/recyclerview/widget/SnapHelper;->createSnapScroller(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroidx/recyclerview/widget/LinearSmoothScroller; move-result-object p0 return-object p0 .end method .method protected createSnapScroller(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroidx/recyclerview/widget/LinearSmoothScroller; .locals 1 .annotation runtime Ljava/lang/Deprecated; .end annotation .line 228 instance-of p1, p1, Landroidx/recyclerview/widget/RecyclerView$SmoothScroller$ScrollVectorProvider; if-nez p1, :cond_0 const/4 p0, 0x0 return-object p0 .line 231 :cond_0 new-instance p1, Landroidx/recyclerview/widget/SnapHelper$2; iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->getContext()Landroid/content/Context; move-result-object v0 invoke-direct {p1, p0, v0}, Landroidx/recyclerview/widget/SnapHelper$2;->(Landroidx/recyclerview/widget/SnapHelper;Landroid/content/Context;)V return-object p1 .end method .method public abstract findSnapView(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroid/view/View; .end method .method public abstract findTargetSnapPosition(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;II)I .end method .method public onFling(II)Z .locals 4 iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 66 invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->getLayoutManager()Landroidx/recyclerview/widget/RecyclerView$LayoutManager; move-result-object v0 const/4 v1, 0x0 if-nez v0, :cond_0 return v1 :cond_0 iget-object v2, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 70 invoke-virtual {v2}, Landroidx/recyclerview/widget/RecyclerView;->getAdapter()Landroidx/recyclerview/widget/RecyclerView$Adapter; move-result-object v2 if-nez v2, :cond_1 return v1 :cond_1 iget-object v2, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 74 invoke-virtual {v2}, Landroidx/recyclerview/widget/RecyclerView;->getMinFlingVelocity()I move-result v2 .line 75 invoke-static {p2}, Ljava/lang/Math;->abs(I)I move-result v3 if-gt v3, v2, :cond_2 invoke-static {p1}, Ljava/lang/Math;->abs(I)I move-result v3 if-le v3, v2, :cond_3 .line 76 :cond_2 invoke-direct {p0, v0, p1, p2}, Landroidx/recyclerview/widget/SnapHelper;->snapFromFling(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;II)Z move-result p0 if-eqz p0, :cond_3 const/4 v1, 0x1 :cond_3 return v1 .end method .method snapToTargetExistingView()V .locals 4 iget-object v0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; if-nez v0, :cond_0 return-void .line 187 :cond_0 invoke-virtual {v0}, Landroidx/recyclerview/widget/RecyclerView;->getLayoutManager()Landroidx/recyclerview/widget/RecyclerView$LayoutManager; move-result-object v0 if-nez v0, :cond_1 return-void .line 191 :cond_1 invoke-virtual {p0, v0}, Landroidx/recyclerview/widget/SnapHelper;->findSnapView(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;)Landroid/view/View; move-result-object v1 if-nez v1, :cond_2 return-void .line 195 :cond_2 invoke-virtual {p0, v0, v1}, Landroidx/recyclerview/widget/SnapHelper;->calculateDistanceToFinalSnap(Landroidx/recyclerview/widget/RecyclerView$LayoutManager;Landroid/view/View;)[I move-result-object v0 const/4 v1, 0x0 .line 196 aget v1, v0, v1 const/4 v2, 0x1 if-nez v1, :cond_3 aget v3, v0, v2 if-eqz v3, :cond_4 :cond_3 iget-object p0, p0, Landroidx/recyclerview/widget/SnapHelper;->mRecyclerView:Landroidx/recyclerview/widget/RecyclerView; .line 197 aget v0, v0, v2 invoke-virtual {p0, v1, v0}, Landroidx/recyclerview/widget/RecyclerView;->smoothScrollBy(II)V :cond_4 return-void .end method