From 913cc1a4d7dfb827a11761bdcdc42f4a5afa6245 Mon Sep 17 00:00:00 2001 From: muqing <1966944300@qq.com> Date: Mon, 15 Jul 2024 16:02:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E8=A1=A8?= =?UTF-8?q?=EF=BC=8C=E6=96=87=E6=9C=AC=E5=8F=AF=E5=A4=8D=E5=88=B6=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 5 +++ .../coldmint/rust/pro/CodeTableActivity.kt | 5 +-- .../rust/pro/fragments/RankingFragment.kt | 28 +++++++++------ app/src/main/res/layout/activity_login.xml | 17 +++++----- app/src/main/res/layout/dialog_bottom.xml | 34 ++++++++++--------- app/src/main/res/layout/fragment_ranking.xml | 20 +++++++---- .../java/com/coldmint/rust/core/web/WebMod.kt | 3 +- 7 files changed, 69 insertions(+), 43 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d10fb7a..a082f6b 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -178,4 +178,9 @@ dependencies { 它基于 CSS 的 Flexbox 布局模型,能够帮助开发者更容易地创建复杂的布局结构,并实现各种灵活的布局需求。*/ implementation 'com.google.android.flexbox:flexbox:3.0.0' +// Android智能下拉刷新框架-SmartRefreshLayout + implementation 'io.github.scwang90:refresh-layout-kernel:2.1.0' //核心必须依赖 + implementation 'io.github.scwang90:refresh-header-classics:2.1.0' //经典刷新头 + implementation 'io.github.scwang90:refresh-footer-classics:2.1.0' //经典加载 + } \ No newline at end of file diff --git a/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt b/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt index b94560e..f85428b 100644 --- a/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt @@ -68,7 +68,7 @@ class CodeTableActivity : BaseActivity() { } false } - viewBinding.back.setOnClickListener { finish() } + viewBinding.back.setOnClickListener { moveTaskToBack(true) } } } @@ -208,7 +208,8 @@ class CodeTableActivity : BaseActivity() { } override fun onBackPressed() { - finish() + //显示桌面 + moveTaskToBack(true); // ifNeedFinish() } override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityCodeTableBinding { 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 b29759c..112bfda 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 @@ -17,6 +17,7 @@ import com.coldmint.rust.pro.databinding.FragmentRankingBinding import com.coldmint.rust.pro.ui.StableLinearLayoutManager import me.zhanghai.android.fastscroll.FastScrollerBuilder + /** * 排行榜 */ @@ -30,7 +31,7 @@ class RankingFragment : BaseFragment() { override fun whenViewCreated(inflater: LayoutInflater, savedInstanceState: Bundle?) { linearLayoutManager = StableLinearLayoutManager(requireContext()) viewBinding.recyclerView.layoutManager = linearLayoutManager - viewBinding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { +/* viewBinding.recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) { super.onScrollStateChanged(recyclerView, newState) val layoutManager = viewBinding.recyclerView.layoutManager @@ -43,11 +44,18 @@ class RankingFragment : BaseFragment() { } } } - }) - viewBinding.swipeRefreshLayout.setOnRefreshListener { + })*/ + viewBinding.refreshLayout.setOnRefreshListener { + it.finishRefresh(true)//传入false表示刷新失败 + loadMods() + } + viewBinding.refreshLayout.setOnLoadMoreListener { + it.finishLoadMore(false) //传入false表示加载失败 + } +/* viewBinding.swipeRefreshLayout.setOnRefreshListener { loadMods() viewBinding.swipeRefreshLayout.isRefreshing = false - } + }*/ viewBinding.downloadChip.setOnCheckedChangeListener { _, isChecked -> if (isChecked) { sortMode = WebMod.SortMode.Download_Number @@ -79,7 +87,7 @@ class RankingFragment : BaseFragment() { private fun loadMods() { viewBinding.progressBar.isVisible = true viewBinding.textview.isVisible = false - viewBinding.swipeRefreshLayout.isVisible = false +// viewBinding.swipeRefreshLayout.isVisible = false WebMod.instance.list(object : ApiCallBack { override fun onResponse(t: WebModListData) { if (!isAdded) { @@ -90,15 +98,15 @@ class RankingFragment : BaseFragment() { if (!list.isNullOrEmpty()) { viewBinding.progressBar.isVisible = false viewBinding.textview.isVisible = false - viewBinding.swipeRefreshLayout.isVisible = true +// viewBinding.swipeRefreshLayout.isVisible = true val adapter = createAdapter(list) viewBinding.recyclerView.adapter = adapter linearLayoutManager?.scrollToPositionWithOffset( lastPosition, lastOffset ) - FastScrollerBuilder(viewBinding.recyclerView).useMd2Style() - .setPopupTextProvider(adapter).build() + /* FastScrollerBuilder(viewBinding.recyclerView).useMd2Style() + .setPopupTextProvider(adapter).build()*/ } else { showInfoToView(R.string.network_error) } @@ -111,7 +119,7 @@ class RankingFragment : BaseFragment() { showInfoToView(R.string.network_error) } - }, sortMode = sortMode, limit = "100") + }, sortMode = sortMode, limit = "10", sum = "0") } @@ -148,7 +156,7 @@ class RankingFragment : BaseFragment() { */ fun showInfoToView(textRes: Int? = null, text: String? = null) { viewBinding.progressBar.isVisible = false - viewBinding.swipeRefreshLayout.isVisible = false +// viewBinding.swipeRefreshLayout.isVisible = false viewBinding.textview.isVisible = true if (textRes == null) { viewBinding.textview.text = textRes diff --git a/app/src/main/res/layout/activity_login.xml b/app/src/main/res/layout/activity_login.xml index 28557d5..c271ebf 100644 --- a/app/src/main/res/layout/activity_login.xml +++ b/app/src/main/res/layout/activity_login.xml @@ -1,6 +1,7 @@ - @@ -93,20 +94,20 @@