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)