From 76bec034cc1e415b36b0eeb76c303cb0ac9e31ec Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 30 Mar 2021 14:20:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BC=83=E7=94=A8=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/recycler/scroller/FastScrollRecyclerView.kt | 3 +-- .../app/ui/widget/recycler/scroller/FastScroller.kt | 10 ++++------ 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt index 1c82425b0..a7299f5e6 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScrollRecyclerView.kt @@ -150,8 +150,7 @@ class FastScrollRecyclerView : RecyclerView { super.onAttachedToWindow() mFastScroller.attachRecyclerView(this) val parent = parent - if (parent is ViewGroup) { - parent.removeView(mFastScroller) + if (parent is ViewGroup && parent.indexOfChild(mFastScroller) == -1) { parent.addView(mFastScroller) mFastScroller.setLayoutParams(parent) } diff --git a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt index a8372689e..857035158 100644 --- a/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt +++ b/app/src/main/java/io/legado/app/ui/widget/recycler/scroller/FastScroller.kt @@ -152,12 +152,10 @@ class FastScroller : LinearLayout { fun attachRecyclerView(recyclerView: RecyclerView) { mRecyclerView = recyclerView - if (mRecyclerView != null) { - mRecyclerView!!.addOnScrollListener(mScrollListener) - post { - // set initial positions for bubble and handle - setViewPositions(getScrollProportion(mRecyclerView)) - } + mRecyclerView!!.addOnScrollListener(mScrollListener) + post { + // set initial positions for bubble and handle + setViewPositions(getScrollProportion(mRecyclerView)) } }