From e2cef38c2eada799aff146c1f1394204476b10ba Mon Sep 17 00:00:00 2001 From: muqing <1966944300@qq.com> Date: Mon, 22 Jul 2024 19:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E8=A1=A8?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coldmint/rust/pro/CodeTableActivity.kt | 19 ++++++------------- .../rust/pro/adapters/CodeTableAdapter.kt | 18 ++++++++---------- .../rust/pro/adapters/CodeTableItemAdapter.kt | 2 ++ 3 files changed, 16 insertions(+), 23 deletions(-) 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 cf8dd26..9fcecb5 100644 --- a/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt +++ b/app/src/main/java/com/coldmint/rust/pro/CodeTableActivity.kt @@ -1,5 +1,6 @@ package com.coldmint.rust.pro +import android.annotation.SuppressLint import android.graphics.Color import android.os.Bundle import android.text.Editable @@ -21,8 +22,6 @@ import com.coldmint.rust.pro.adapters.CodeTableAdapter import com.coldmint.rust.pro.adapters.CodeTableItemAdapter import com.coldmint.rust.pro.base.BaseActivity import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding -import com.google.rpc.Code -import com.muqing.gj import java.util.concurrent.Executors class CodeTableActivity : BaseActivity() { @@ -48,10 +47,10 @@ class CodeTableActivity : BaseActivity() { (viewBinding.codeRecyclerB.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(get, 0) } viewBinding.listButtom.setOnClickListener { - val size = CodeTableAdapter.picklist.size if (CodeTableAdapter.picklist.isEmpty()) { return@setOnClickListener } + val size = CodeTableAdapter.picklist.size if (++CodeTableAdapter.pick == size - 1) { CodeTableAdapter.pick = 0 @@ -72,7 +71,7 @@ class CodeTableActivity : BaseActivity() { loadData(a.toString())*/ if (a.isNullOrEmpty()) { viewBinding.searchPick.isVisible = false -// loadData() + loadData() } } @@ -112,14 +111,6 @@ class CodeTableActivity : BaseActivity() { */ - private fun ifNeedFinish() { - if (filterMode) { - loadData() - } else { - finish() - } - } - /** * 加载数据 * @param key String? 键 @@ -215,6 +206,7 @@ class CodeTableActivity : BaseActivity() { * 没有找到节 * @param key String? */ + @SuppressLint("StringFormatInvalid") private fun notFindKey(key: String?) { if (!key.isNullOrBlank()) { val tip = String.format(getString(R.string.not_find_code_name), key) @@ -245,9 +237,10 @@ class CodeTableActivity : BaseActivity() { return true } + @Deprecated("Deprecated in Java", ReplaceWith("moveTaskToBack(true)")) override fun onBackPressed() { //显示桌面 - moveTaskToBack(true); + moveTaskToBack(true) // ifNeedFinish() } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableAdapter.kt index 65c9b7e..caa1428 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableAdapter.kt @@ -2,10 +2,8 @@ package com.coldmint.rust.pro.adapters import android.annotation.SuppressLint import android.content.Context -import android.graphics.Color import android.view.LayoutInflater import android.view.ViewGroup -import androidx.core.content.ContextCompat import androidx.recyclerview.widget.RecyclerView import com.coldmint.rust.core.database.code.CodeInfo import com.coldmint.rust.core.database.code.SectionInfo @@ -205,32 +203,32 @@ class CodeTableAdapter( lineParser.symbol = "," } - @SuppressLint("StringFormatInvalid") + @SuppressLint("NotifyDataSetChanged", "StringFormatInvalid") override fun onBindViewHolder(holder: VH, position: Int) { holder.binging.title.text = group[position].translate val format = String.format( - context.getString(R.string.filenum), - itemList[position].size + context.getString(R.string.filenum), + itemList[position].size ) holder.binging.message.text = format holder.itemView.setOnClickListener { i = group[position].translate + pick = 0 + pickString = "" + picklist.clear() if (item != null) { item!!.list = itemList[position] binding.codeRecyclerB.adapter = item notifyDataSetChanged() } - if (!binding.edittext.text.isNullOrEmpty()) - binding.edittext.setText("") - // notifyItemChanged(p) } if (Objects.equal(group[position].translate, i)) { //背景高亮 - holder.binging.root.setCardBackgroundColor(GlobalMethod.getThemeColor(context,R.attr.colorPrimaryContainer)) + holder.binging.root.setCardBackgroundColor(GlobalMethod.getThemeColor(context, R.attr.colorPrimaryContainer)) } else { //背景恢复 - holder.binging.root.setCardBackgroundColor(GlobalMethod.getThemeColor(context,R.attr.colorSurface)) + holder.binging.root.setCardBackgroundColor(GlobalMethod.getThemeColor(context, R.attr.colorSurface)) } } diff --git a/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableItemAdapter.kt b/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableItemAdapter.kt index d45c19b..3ec7a06 100644 --- a/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableItemAdapter.kt +++ b/app/src/main/java/com/coldmint/rust/pro/adapters/CodeTableItemAdapter.kt @@ -52,6 +52,8 @@ class CodeTableItemAdapter(val recyclerView: RecyclerView, //在list查找是否有这个关键字 fun search(keyword: String) { CodeTableAdapter.pickString = keyword + CodeTableAdapter.pick = 0 + CodeTableAdapter.picklist.clear() for (i in list.indices) { if (list[i].translate.contains(keyword) || list[i].description.contains(keyword) || list[i].code.contains(keyword)) { CodeTableAdapter.picklist.add(i)