优化代码表,文本可复制!

This commit is contained in:
muqing 2024-07-15 16:02:03 +08:00
parent a2c71a5e15
commit 913cc1a4d7
7 changed files with 69 additions and 43 deletions

View File

@ -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' //
}

View File

@ -68,7 +68,7 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
}
false
}
viewBinding.back.setOnClickListener { finish() }
viewBinding.back.setOnClickListener { moveTaskToBack(true) }
}
}
@ -208,7 +208,8 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
}
override fun onBackPressed() {
finish()
//显示桌面
moveTaskToBack(true);
// ifNeedFinish()
}
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityCodeTableBinding {

View File

@ -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<FragmentRankingBinding>() {
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<FragmentRankingBinding>() {
}
}
}
})
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<FragmentRankingBinding>() {
private fun loadMods() {
viewBinding.progressBar.isVisible = true
viewBinding.textview.isVisible = false
viewBinding.swipeRefreshLayout.isVisible = false
// viewBinding.swipeRefreshLayout.isVisible = false
WebMod.instance.list(object : ApiCallBack<WebModListData> {
override fun onResponse(t: WebModListData) {
if (!isAdded) {
@ -90,15 +98,15 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
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<FragmentRankingBinding>() {
showInfoToView(R.string.network_error)
}
}, sortMode = sortMode, limit = "100")
}, sortMode = sortMode, limit = "10", sum = "0")
}
@ -148,7 +156,7 @@ class RankingFragment : BaseFragment<FragmentRankingBinding>() {
*/
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

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
@ -77,8 +78,8 @@
android:text="@string/agreement_agreed" />
<RelativeLayout
android:layout_width="wrap_content"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/checkbox"
android:layout_marginTop="8dp">
@ -93,20 +94,20 @@
<Button
android:id="@+id/changeServerView"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_toEndOf="@id/changePasswordView"
android:layout_weight="1"
android:layout_marginHorizontal="6dp"
android:text="@string/changing_the_server"
android:visibility="gone" />
android:visibility="gone"
tools:visibility="visible" />
<Button
android:id="@+id/registerView"
style="@style/Widget.Material3.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="@string/register" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>

View File

@ -1,16 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<!-- Drag handle for accessibility -->
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:id="@+id/drag_handle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:layout_height="wrap_content"/>
<LinearLayout
android:id="@+id/linearLayout4"
@ -18,11 +16,7 @@
android:layout_height="wrap_content"
android:layout_marginHorizontal="9dp"
android:layout_marginBottom="26dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/drag_handle">
android:orientation="vertical">
<TextView
android:id="@+id/title"
@ -31,12 +25,20 @@
android:layout_height="wrap_content"
android:text="Hello World!" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never"
android:fadingEdge="vertical"
android:fadingEdgeLength="30dp"
android:layout_marginTop="6dp">
<TextView
android:id="@+id/message"
style="@style/TextAppearance.Material3.BodyLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:textIsSelectable="true"
android:text="Hello World!" />
</androidx.core.widget.NestedScrollView>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>

View File

@ -74,16 +74,24 @@
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
<com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone">
app:srlEnablePreviewInEditMode="false">
<!--srlEnablePreviewInEditMode 可以开启和关闭预览功能-->
<com.scwang.smart.refresh.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
android:layout_height="match_parent"
android:overScrollMode="never"
android:background="#fff" />
<com.scwang.smart.refresh.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.scwang.smart.refresh.layout.SmartRefreshLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -831,7 +831,8 @@ class WebMod private constructor() {
apiCallBack: ApiCallBack<WebModListData>,
tag: String? = null,
sortMode: SortMode? = null,
limit: String? = null
limit: String? = null,
sum : String?=null
) {
val okHttpClient = ServerConfiguration.initOkHttpClient()
val requestBodyBuilder: FormBody.Builder =