From 99ddec7c4bcc14418ecc0623abdba7fbc6ebdbc8 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sat, 19 Aug 2023 16:52:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BB=8E=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=88=B0=E6=8E=92=E8=A1=8C=E6=A6=9C=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=E7=9A=84=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/coldmint/rust/pro/fragments/RankingFragment.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt b/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt index fa53236..5b42ef1 100644 --- a/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt +++ b/app/src/main/java/com/coldmint/rust/pro/fragments/RankingFragment.kt @@ -30,12 +30,11 @@ class RankingFragment : BaseFragment() { var webModAdapter: WebModAdapter? = null var lastOffset = 0 var lastPosition = 0 - val linearLayoutManager by lazy { - StableLinearLayoutManager(requireContext()) - } + var linearLayoutManager: StableLinearLayoutManager? = null private var sortMode: WebMod.SortMode = WebMod.SortMode.Download_Number override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { + linearLayoutManager = StableLinearLayoutManager(requireContext()) viewBinding.recyclerView.layoutManager = linearLayoutManager viewBinding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { @@ -100,7 +99,7 @@ class RankingFragment : BaseFragment() { viewBinding.swipeRefreshLayout.isVisible = true val adapter = createAdapter(list) viewBinding.recyclerView.adapter = adapter - linearLayoutManager.scrollToPositionWithOffset( + linearLayoutManager?.scrollToPositionWithOffset( lastPosition, lastOffset )