refactor(app): 重构代码表页面布局和功能
- 更新 activity_code_table.xml 布局,简化结构并添加工具栏 - 重写 CodeTableAdapter,改为使用 BaseExpandableListAdapter -移除 CodeTableItemAdapter,直接在 CodeTableAdapter 中处理条目布局 - 更新代码表项布局,使用新的 code_table_group.xml 文件 - 优化搜索和过滤功能,使用 InputDialog 替代原有的搜索框 - 改进代码示例展示方式,使用 MaterialAlertDialog 替代底部对话框 - 优化类型信息展示,根据开发者模式显示不同内容
This commit is contained in:
parent
5f137e0469
commit
5d4b9c7d29
|
@ -1,25 +1,18 @@
|
||||||
package com.coldmint.rust.pro
|
package com.coldmint.rust.pro
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.text.Editable
|
|
||||||
import android.text.Spannable
|
import android.text.Spannable
|
||||||
import android.text.SpannableString
|
import android.text.SpannableString
|
||||||
import android.text.TextWatcher
|
|
||||||
import android.text.method.LinkMovementMethod
|
import android.text.method.LinkMovementMethod
|
||||||
import android.text.style.ClickableSpan
|
import android.text.style.ClickableSpan
|
||||||
import android.view.LayoutInflater
|
import android.view.*
|
||||||
import android.view.Menu
|
|
||||||
import android.view.View
|
|
||||||
import android.view.inputmethod.EditorInfo
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import com.coldmint.dialog.InputDialog
|
||||||
import com.coldmint.rust.core.database.code.CodeDataBase
|
import com.coldmint.rust.core.database.code.CodeDataBase
|
||||||
import com.coldmint.rust.core.database.code.CodeInfo
|
import com.coldmint.rust.core.database.code.CodeInfo
|
||||||
import com.coldmint.rust.core.database.code.SectionInfo
|
import com.coldmint.rust.core.database.code.SectionInfo
|
||||||
import com.coldmint.rust.pro.adapters.CodeTableAdapter
|
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.base.BaseActivity
|
||||||
import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding
|
import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
|
@ -30,94 +23,35 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
|
||||||
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
|
override fun whenCreateActivity(savedInstanceState: Bundle?, canUseView: Boolean) {
|
||||||
if (canUseView) {
|
if (canUseView) {
|
||||||
title = getString(R.string.code_table)
|
title = getString(R.string.code_table)
|
||||||
viewBinding.edittext.hint = title
|
|
||||||
|
|
||||||
setReturnButton()
|
setReturnButton()
|
||||||
loadData()
|
loadData()
|
||||||
//设置上下选择按钮
|
|
||||||
viewBinding.listTop.setOnClickListener {
|
|
||||||
if (CodeTableAdapter.picklist.isEmpty()) {
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
|
|
||||||
if (--CodeTableAdapter.pick < 0) {
|
|
||||||
CodeTableAdapter.pick = 0
|
|
||||||
}
|
|
||||||
val get = CodeTableAdapter.picklist[CodeTableAdapter.pick]
|
|
||||||
(viewBinding.codeRecyclerB.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(get, 0)
|
|
||||||
}
|
|
||||||
viewBinding.listButtom.setOnClickListener {
|
|
||||||
if (CodeTableAdapter.picklist.isEmpty()) {
|
|
||||||
return@setOnClickListener
|
|
||||||
}
|
|
||||||
val size = CodeTableAdapter.picklist.size
|
|
||||||
|
|
||||||
if (++CodeTableAdapter.pick == size - 1) {
|
|
||||||
CodeTableAdapter.pick = 0
|
|
||||||
}
|
|
||||||
val get = CodeTableAdapter.picklist[CodeTableAdapter.pick]
|
|
||||||
(viewBinding.codeRecyclerB.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(get,
|
|
||||||
0)
|
|
||||||
}
|
|
||||||
viewBinding.edittext.addTextChangedListener(object : TextWatcher {
|
|
||||||
override fun beforeTextChanged(a: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onTextChanged(a: CharSequence?, p1: Int, p2: Int, p3: Int) {
|
|
||||||
/* if (a.isNullOrEmpty()) {
|
|
||||||
loadData()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loadData(a.toString())*/
|
|
||||||
if (a.isNullOrEmpty()) {
|
|
||||||
viewBinding.searchPick.isVisible = false
|
|
||||||
loadData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun afterTextChanged(a: Editable?) {
|
|
||||||
}
|
|
||||||
})
|
|
||||||
viewBinding.edittext.setOnEditorActionListener { v, p1, _ ->
|
|
||||||
if (p1 == EditorInfo.IME_ACTION_SEARCH) {
|
|
||||||
if (v?.text.isNullOrEmpty()) {
|
|
||||||
loadData()
|
|
||||||
} else {
|
|
||||||
var toString = v?.text.toString()
|
|
||||||
if (toString.startsWith("/")) {
|
|
||||||
toString = toString.substring(1)
|
|
||||||
loadData(toString)
|
|
||||||
} else {
|
|
||||||
viewBinding.searchPick.isVisible = true
|
|
||||||
adapter.item?.search(toString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
viewBinding.back.setOnClickListener { moveTaskToBack(true) }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
|
||||||
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
if (keyCode == KeyEvent.KEYCODE_BACK && event.action == KeyEvent.ACTION_DOWN) {
|
||||||
ifNeedFinish()
|
ifNeedFinish()
|
||||||
return true
|
return true
|
||||||
}
|
|
||||||
return super.onKeyDown(keyCode, event)
|
|
||||||
}
|
}
|
||||||
*/
|
return super.onKeyDown(keyCode, event)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun ifNeedFinish() {
|
||||||
|
if (filterMode) {
|
||||||
|
loadData()
|
||||||
|
} else {
|
||||||
|
finish()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加载数据
|
* 加载数据
|
||||||
* @param key String? 键
|
* @param key String? 键
|
||||||
* @param section String? 节
|
* @param section String? 节
|
||||||
*/
|
*/
|
||||||
fun loadData(key: String? = null, section: String? = null) {
|
fun loadData(key: String? = null, section: String? = null) {
|
||||||
//如果 key start 有 / 则取后的string
|
|
||||||
executorService.submit {
|
executorService.submit {
|
||||||
filterMode = key != null || section != null
|
filterMode = key != null || section != null
|
||||||
val sectionMap = HashMap<String, String>()
|
val sectionMap = HashMap<String, String>()
|
||||||
|
@ -156,9 +90,9 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
|
||||||
codeDataBase.getCodeDao().findCodeBySection(section.code)
|
codeDataBase.getCodeDao().findCodeBySection(section.code)
|
||||||
} else {
|
} else {
|
||||||
codeDataBase.getCodeDao()
|
codeDataBase.getCodeDao()
|
||||||
.findCodeByCodeOrTranslateFromSection(key, section.code)
|
.findCodeByCodeOrTranslateFromSection(key, section.code)
|
||||||
}
|
}
|
||||||
if (list.isNullOrEmpty()) {
|
if (list == null || list.isEmpty()) {
|
||||||
group.remove(section)
|
group.remove(section)
|
||||||
} else {
|
} else {
|
||||||
item.add(list)
|
item.add(list)
|
||||||
|
@ -166,33 +100,18 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group.isNotEmpty()) {
|
if (group.isNotEmpty()) {
|
||||||
adapter = CodeTableAdapter(this, group, item, viewBinding)
|
val adapter = CodeTableAdapter(this, group, item)
|
||||||
adapter.setVersionMap(versionMap)
|
adapter.setVersionMap(versionMap)
|
||||||
adapter.setTypeNameMap(typeNameMap)
|
adapter.setTypeNameMap(typeNameMap)
|
||||||
adapter.setSectionMap(sectionMap)
|
adapter.setSectionMap(sectionMap)
|
||||||
if (adapter.item == null) {
|
|
||||||
|
|
||||||
adapter.item = CodeTableItemAdapter(viewBinding.codeRecyclerB, item[0])
|
|
||||||
adapter.item!!.versionMap = versionMap
|
|
||||||
adapter.item!!.typeNameMap = typeNameMap
|
|
||||||
adapter.item!!.sectionMap = sectionMap
|
|
||||||
CodeTableAdapter.i = group[0].translate
|
|
||||||
}
|
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
viewBinding.codeRecyclerB.adapter = adapter.item
|
adapter.labelFunction = { index, view, string ->
|
||||||
/* adapter.labelFunction = { _, _, string ->
|
loadData(section = string)
|
||||||
// section = string
|
}
|
||||||
if (string.isEmpty()) {
|
|
||||||
loadData()
|
|
||||||
}
|
|
||||||
loadData(string)
|
|
||||||
}*/
|
|
||||||
viewBinding.displayView.isVisible = false
|
viewBinding.displayView.isVisible = false
|
||||||
viewBinding.progressBar.isVisible = false
|
viewBinding.progressBar.isVisible = false
|
||||||
viewBinding.expandableListView.isVisible = true
|
viewBinding.expandableListView.isVisible = true
|
||||||
viewBinding.expandableListView.layoutManager = LinearLayoutManager(this)
|
viewBinding.expandableListView.setAdapter(adapter)
|
||||||
viewBinding.expandableListView.adapter = adapter
|
|
||||||
// viewBinding.expandableListView.swapAdapter(adapter, true)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
notFindKey(key)
|
notFindKey(key)
|
||||||
|
@ -200,30 +119,27 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var adapter: CodeTableAdapter
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 没有找到节
|
* 没有找到节
|
||||||
* @param key String?
|
* @param key String?
|
||||||
*/
|
*/
|
||||||
@SuppressLint("StringFormatInvalid")
|
fun notFindKey(key: String?) {
|
||||||
private fun notFindKey(key: String?) {
|
if (key != null && key.isNotBlank()) {
|
||||||
if (!key.isNullOrBlank()) {
|
|
||||||
val tip = String.format(getString(R.string.not_find_code_name), key)
|
val tip = String.format(getString(R.string.not_find_code_name), key)
|
||||||
val action = getString(R.string.not_find_units_action)
|
val action = getString(R.string.not_find_units_action)
|
||||||
val start = tip.indexOf(action)
|
val start = tip.indexOf(action)
|
||||||
val spannableString = SpannableString(tip)
|
val spannableString = SpannableString(tip)
|
||||||
if (start > -1) {
|
if (start > -1) {
|
||||||
spannableString.setSpan(
|
spannableString.setSpan(
|
||||||
object : ClickableSpan() {
|
object : ClickableSpan() {
|
||||||
override fun onClick(p0: View) {
|
override fun onClick(p0: View) {
|
||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
}, start, start + action.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
}, start, start + action.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
viewBinding.displayView.movementMethod = LinkMovementMethod.getInstance()
|
viewBinding.displayView.movementMethod = LinkMovementMethod.getInstance();
|
||||||
viewBinding.displayView.highlightColor = Color.parseColor("#36969696")
|
viewBinding.displayView.highlightColor = Color.parseColor("#36969696");
|
||||||
viewBinding.displayView.text = spannableString
|
viewBinding.displayView.text = spannableString
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -232,16 +148,36 @@ class CodeTableActivity : BaseActivity<ActivityCodeTableBinding>() {
|
||||||
viewBinding.progressBar.isVisible = false
|
viewBinding.progressBar.isVisible = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
override fun onCreateOptionsMenu(menu: Menu): Boolean {
|
||||||
menuInflater.inflate(R.menu.menu_code_table, menu)
|
val inflater = menuInflater
|
||||||
|
inflater.inflate(R.menu.menu_code_table, menu)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated("Deprecated in Java", ReplaceWith("moveTaskToBack(true)"))
|
|
||||||
override fun onBackPressed() {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
//显示桌面
|
when (item.itemId) {
|
||||||
moveTaskToBack(true)
|
R.id.filter_units -> {
|
||||||
// ifNeedFinish()
|
InputDialog(this).setTitle(R.string.filter).setMessage(R.string.filter_tip)
|
||||||
|
.setInputCanBeEmpty(false).setMaxNumber(20)
|
||||||
|
.setPositiveButton(R.string.dialog_ok) { text ->
|
||||||
|
var key = text
|
||||||
|
if (key.length > 20) {
|
||||||
|
key = key.substring(0, 20)
|
||||||
|
}
|
||||||
|
loadData(key)
|
||||||
|
true
|
||||||
|
}.setNegativeButton(R.string.dialog_close) {
|
||||||
|
|
||||||
|
}.show()
|
||||||
|
}
|
||||||
|
android.R.id.home -> {
|
||||||
|
ifNeedFinish()
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityCodeTableBinding {
|
override fun getViewBindingObject(layoutInflater: LayoutInflater): ActivityCodeTableBinding {
|
||||||
|
|
|
@ -1,30 +1,55 @@
|
||||||
package com.coldmint.rust.pro.adapters
|
package com.coldmint.rust.pro.adapters
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import android.widget.BaseExpandableListAdapter
|
||||||
|
import androidx.core.view.isVisible
|
||||||
|
import com.afollestad.materialdialogs.MaterialDialog
|
||||||
|
import com.coldmint.rust.core.database.code.CodeDataBase
|
||||||
import com.coldmint.rust.core.database.code.CodeInfo
|
import com.coldmint.rust.core.database.code.CodeInfo
|
||||||
import com.coldmint.rust.core.database.code.SectionInfo
|
import com.coldmint.rust.core.database.code.SectionInfo
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
import com.coldmint.rust.core.tool.LineParser
|
||||||
import com.coldmint.rust.pro.R
|
import com.coldmint.rust.pro.R
|
||||||
import com.coldmint.rust.pro.base.BaseVh
|
import com.coldmint.rust.pro.databinding.CodeTableGroupBinding
|
||||||
import com.coldmint.rust.pro.databinding.ActivityCodeTableBinding
|
import com.coldmint.rust.pro.databinding.CodeTableItemBinding
|
||||||
import com.coldmint.rust.pro.databinding.ItemCodetableBinding
|
import com.coldmint.rust.pro.tool.AppSettings
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
import com.coldmint.rust.pro.tool.GlobalMethod
|
||||||
|
import com.google.android.material.chip.Chip
|
||||||
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
|
||||||
class CodeTableAdapter(
|
class CodeTableAdapter(
|
||||||
val context: Context,
|
val context: Context,
|
||||||
private val group: List<SectionInfo>,
|
private val group: List<SectionInfo>,
|
||||||
private val itemList: List<List<CodeInfo>>,
|
private val itemList: List<List<CodeInfo>>
|
||||||
private val binding: ActivityCodeTableBinding
|
) : BaseExpandableListAdapter() {
|
||||||
) : RecyclerView.Adapter<BaseVh<ItemCodetableBinding>>() {
|
|
||||||
|
private val layoutInflater = LayoutInflater.from(context)
|
||||||
|
|
||||||
private var versionMap: HashMap<Int, String>? = null
|
private var versionMap: HashMap<Int, String>? = null
|
||||||
private var typeNameMap: HashMap<String, String>? = null
|
private var typeNameMap: HashMap<String, String>? = null
|
||||||
private var sectionMap: HashMap<String, String>? = null
|
private var sectionMap: HashMap<String, String>? = null
|
||||||
|
private val executorService by lazy {
|
||||||
|
Executors.newSingleThreadExecutor()
|
||||||
|
}
|
||||||
private val lineParser = LineParser()
|
private val lineParser = LineParser()
|
||||||
|
|
||||||
|
//Label点击事件
|
||||||
|
var labelFunction: ((Int, View, String) -> Unit)? = null
|
||||||
|
private val developerMode by lazy {
|
||||||
|
AppSettings
|
||||||
|
.getValue(AppSettings.Setting.DeveloperMode, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
lineParser.symbol = ","
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 节名映射
|
* 节名映射
|
||||||
* @param sectionMap HashMap<String, String>
|
* @param sectionMap HashMap<String, String>
|
||||||
|
@ -33,6 +58,7 @@ class CodeTableAdapter(
|
||||||
this.sectionMap = sectionMap
|
this.sectionMap = sectionMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置类型名称映射
|
* 设置类型名称映射
|
||||||
* @param typeNameMap HashMap<String, String>?
|
* @param typeNameMap HashMap<String, String>?
|
||||||
|
@ -49,73 +75,174 @@ class CodeTableAdapter(
|
||||||
this.versionMap = versionMap
|
this.versionMap = versionMap
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun getGroupCount(): Int {
|
||||||
parent: ViewGroup,
|
|
||||||
viewType: Int
|
|
||||||
): BaseVh<ItemCodetableBinding> {
|
|
||||||
return BaseVh(
|
|
||||||
ItemCodetableBinding.inflate(
|
|
||||||
LayoutInflater.from(parent.context),
|
|
||||||
parent,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return group.size
|
return group.size
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
override fun getChildrenCount(groupPosition: Int): Int {
|
||||||
var i: String = null.toString()
|
return itemList[groupPosition].size
|
||||||
var pick: Int = 0
|
|
||||||
var pickString: String = ""
|
|
||||||
var picklist: MutableList<Int> = mutableListOf()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var item: CodeTableItemAdapter? = null
|
override fun getGroup(groupPosition: Int): Any {
|
||||||
|
return group[groupPosition]
|
||||||
init {
|
|
||||||
lineParser.symbol = ","
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressLint("NotifyDataSetChanged", "StringFormatInvalid")
|
override fun getChild(groupPosition: Int, childPosition: Int): Any {
|
||||||
override fun onBindViewHolder(holder: BaseVh<ItemCodetableBinding>, position: Int) {
|
return itemList[groupPosition][childPosition]
|
||||||
holder.binging.title.text = group[position].translate
|
}
|
||||||
val format = String.format(
|
|
||||||
context.getString(R.string.filenum),
|
override fun getGroupId(groupPosition: Int): Long {
|
||||||
itemList[position].size
|
return groupPosition.toLong()
|
||||||
)
|
}
|
||||||
holder.binging.message.text = format
|
|
||||||
holder.itemView.setOnClickListener {
|
override fun getChildId(groupPosition: Int, childPosition: Int): Long {
|
||||||
val finalPosition = holder.layoutPosition
|
return childPosition.toLong()
|
||||||
i = group[finalPosition].translate
|
}
|
||||||
pick = 0
|
|
||||||
pickString = ""
|
override fun hasStableIds(): Boolean {
|
||||||
picklist.clear()
|
return false
|
||||||
if (item != null) {
|
}
|
||||||
item!!.list = itemList[position]
|
|
||||||
binding.codeRecyclerB.adapter = item
|
override fun getGroupView(
|
||||||
|
groupPosition: Int,
|
||||||
|
isExpanded: Boolean,
|
||||||
|
convertView: View?,
|
||||||
|
parent: ViewGroup
|
||||||
|
): View {
|
||||||
|
val resultView: CodeTableGroupBinding =
|
||||||
|
CodeTableGroupBinding.inflate(layoutInflater, parent, false)
|
||||||
|
val info =
|
||||||
|
String.format(
|
||||||
|
context.getString(R.string.filenum),
|
||||||
|
itemList[groupPosition].size
|
||||||
|
)
|
||||||
|
resultView.nameView.text = group[groupPosition].translate
|
||||||
|
resultView.numView.text = info
|
||||||
|
return resultView.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getChildView(
|
||||||
|
groupPosition: Int,
|
||||||
|
childPosition: Int,
|
||||||
|
isLastChild: Boolean,
|
||||||
|
convertView: View?,
|
||||||
|
parent: ViewGroup
|
||||||
|
): View {
|
||||||
|
val resultView: CodeTableItemBinding =
|
||||||
|
CodeTableItemBinding.inflate(layoutInflater, parent, false)
|
||||||
|
val codeInfo = itemList[groupPosition][childPosition]
|
||||||
|
|
||||||
|
// resultView.belongStackLabelView.onLabelClickListener = OnLabelClickListener { index, v, s ->
|
||||||
|
// }
|
||||||
|
resultView.descriptionView.text = codeInfo.description
|
||||||
|
resultView.descriptionView.setOnClickListener {
|
||||||
|
GlobalMethod.copyText(context, codeInfo.description, it)
|
||||||
|
}
|
||||||
|
resultView.titleView.text = codeInfo.translate
|
||||||
|
resultView.titleView.setOnClickListener {
|
||||||
|
GlobalMethod.copyText(context, codeInfo.translate, it)
|
||||||
|
}
|
||||||
|
|
||||||
|
val demo = codeInfo.demo
|
||||||
|
resultView.imageView.isVisible = demo.isNotBlank()
|
||||||
|
resultView.imageView.setOnClickListener {
|
||||||
|
val dialog = MaterialAlertDialogBuilder(context);
|
||||||
|
dialog.setTitle(R.string.code_demo)
|
||||||
|
dialog.setMessage(demo)
|
||||||
|
dialog.setPositiveButton(R.string.dialog_ok){
|
||||||
|
v,a->
|
||||||
}
|
}
|
||||||
notifyItemChanged(finalPosition)
|
dialog.show()
|
||||||
}
|
|
||||||
if (group[position].translate == i) {
|
|
||||||
//背景高亮
|
|
||||||
holder.binging.root.setCardBackgroundColor(
|
|
||||||
GlobalMethod.getThemeColor(
|
|
||||||
context,
|
|
||||||
com.google.android.material.R.attr.colorPrimaryContainer
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
//背景恢复
|
|
||||||
holder.binging.root.setCardBackgroundColor(
|
|
||||||
GlobalMethod.getThemeColor(
|
|
||||||
context,
|
|
||||||
com.google.android.material.R.attr.colorSurface
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resultView.subTitleView.text = codeInfo.code
|
||||||
|
resultView.subTitleView.setOnClickListener {
|
||||||
|
GlobalMethod.copyText(context, codeInfo.code, it)
|
||||||
|
}
|
||||||
|
resultView.valueTypeView.text = typeNameMap?.get(codeInfo.type) ?: codeInfo.type
|
||||||
|
lineParser.text = codeInfo.section
|
||||||
|
resultView.chipGroup.removeAllViews()
|
||||||
|
var isNotEmpty = false
|
||||||
|
lineParser.analyse { lineNum, lineData, isEnd ->
|
||||||
|
isNotEmpty = true
|
||||||
|
val text = sectionMap?.get(lineData) ?: lineData
|
||||||
|
val chip = Chip(context)
|
||||||
|
chip.text = text
|
||||||
|
chip.setOnClickListener {
|
||||||
|
labelFunction?.invoke(lineNum, it, text)
|
||||||
|
}
|
||||||
|
resultView.chipGroup.addView(chip)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
resultView.chipGroup.isVisible = isNotEmpty
|
||||||
|
resultView.valueTypeView.setOnClickListener {
|
||||||
|
val handler = Handler(Looper.getMainLooper())
|
||||||
|
executorService.submit {
|
||||||
|
val codeDataBase = CodeDataBase.getInstance(context)
|
||||||
|
val typeInfo = codeDataBase.getValueTypeDao().findTypeByType(codeInfo.type)
|
||||||
|
if (typeInfo == null) {
|
||||||
|
handler.post {
|
||||||
|
handler.post {
|
||||||
|
MaterialDialog(context).show {
|
||||||
|
title(text = codeInfo.type).message(
|
||||||
|
text = String.format(
|
||||||
|
context.getString(
|
||||||
|
R.string.unknown_type
|
||||||
|
), codeInfo.type
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.positiveButton(R.string.dialog_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (developerMode) {
|
||||||
|
val stringBuilder = StringBuilder()
|
||||||
|
stringBuilder.append("介绍:")
|
||||||
|
stringBuilder.append(typeInfo.describe)
|
||||||
|
stringBuilder.append("\n附加信息:")
|
||||||
|
stringBuilder.append(typeInfo.external)
|
||||||
|
stringBuilder.append("\n关联的自动提示:")
|
||||||
|
stringBuilder.append(typeInfo.list)
|
||||||
|
stringBuilder.append("\n光标偏差:")
|
||||||
|
stringBuilder.append(typeInfo.offset)
|
||||||
|
stringBuilder.append("\n标签:")
|
||||||
|
stringBuilder.append(typeInfo.tag)
|
||||||
|
stringBuilder.append("\n数据规则:")
|
||||||
|
stringBuilder.append(typeInfo.rule)
|
||||||
|
handler.post {
|
||||||
|
MaterialDialog(context).show {
|
||||||
|
title(text = typeInfo.name + "(开发者模式)").message(text = stringBuilder.toString())
|
||||||
|
.positiveButton(R.string.dialog_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (typeInfo.describe == "@search(code)") {
|
||||||
|
handler.post {
|
||||||
|
MaterialDialog(context).show {
|
||||||
|
title(text = typeInfo.name).message(text = codeInfo.description)
|
||||||
|
.positiveButton(R.string.dialog_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
handler.post {
|
||||||
|
MaterialDialog(context).show {
|
||||||
|
title(text = typeInfo.name).message(text = typeInfo.describe)
|
||||||
|
.positiveButton(R.string.dialog_ok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resultView.versionView.text =
|
||||||
|
versionMap?.get(codeInfo.addVersion) ?: codeInfo.addVersion.toString()
|
||||||
|
return resultView.root
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun isChildSelectable(groupPosition: Int, childPosition: Int): Boolean {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,225 +0,0 @@
|
||||||
package com.coldmint.rust.pro.adapters
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint
|
|
||||||
import android.graphics.Color
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.text.SpannableStringBuilder
|
|
||||||
import android.text.Spanned
|
|
||||||
import android.text.style.BackgroundColorSpan
|
|
||||||
import android.text.style.ForegroundColorSpan
|
|
||||||
import android.view.LayoutInflater
|
|
||||||
import android.view.View
|
|
||||||
import android.view.ViewGroup
|
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.core.view.isVisible
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog
|
|
||||||
import com.coldmint.rust.core.database.code.CodeDataBase
|
|
||||||
import com.coldmint.rust.core.database.code.CodeInfo
|
|
||||||
import com.coldmint.rust.core.tool.LineParser
|
|
||||||
import com.coldmint.rust.pro.R
|
|
||||||
import com.coldmint.rust.pro.base.BaseVh
|
|
||||||
import com.coldmint.rust.pro.databinding.CodeTableItemBinding
|
|
||||||
import com.coldmint.rust.pro.dialog.MaterialBottomDialog
|
|
||||||
import com.coldmint.rust.pro.tool.AppSettings
|
|
||||||
import com.coldmint.rust.pro.tool.GlobalMethod
|
|
||||||
import com.google.android.material.chip.Chip
|
|
||||||
import java.util.concurrent.Executors
|
|
||||||
|
|
||||||
class CodeTableItemAdapter(val recyclerView: RecyclerView,
|
|
||||||
var list: List<CodeInfo>) : RecyclerView.Adapter<BaseVh<CodeTableItemBinding>>() {
|
|
||||||
|
|
||||||
private val lineParser = LineParser()
|
|
||||||
|
|
||||||
init {
|
|
||||||
lineParser.symbol = ","
|
|
||||||
}
|
|
||||||
|
|
||||||
var labelFunction: ((Int, View, String) -> Unit)? = null
|
|
||||||
var versionMap: HashMap<Int, String>? = null
|
|
||||||
var typeNameMap: HashMap<String, String>? = null
|
|
||||||
var sectionMap: HashMap<String, String>? = null
|
|
||||||
private val executorService by lazy {
|
|
||||||
Executors.newSingleThreadExecutor()
|
|
||||||
}
|
|
||||||
private val developerMode by lazy {
|
|
||||||
AppSettings
|
|
||||||
.getValue(AppSettings.Setting.DeveloperMode, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
//在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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(recyclerView.layoutManager as LinearLayoutManager).scrollToPositionWithOffset(CodeTableAdapter.pick, 0)
|
|
||||||
notifyDataSetChanged()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseVh<CodeTableItemBinding> {
|
|
||||||
return BaseVh(CodeTableItemBinding.inflate(LayoutInflater.from(parent.context), parent, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
|
||||||
return list.size
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun contains(string: String, textView: TextView) {
|
|
||||||
if (string.contains(CodeTableAdapter.pickString)) {
|
|
||||||
val spannableText = SpannableStringBuilder(string)
|
|
||||||
val highlightWord = CodeTableAdapter.pickString
|
|
||||||
val start = string.indexOf(highlightWord)
|
|
||||||
val end = start + highlightWord.length
|
|
||||||
if (start != -1) {
|
|
||||||
// 设置文字颜色
|
|
||||||
val colorSpan = ForegroundColorSpan(Color.RED)
|
|
||||||
spannableText.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
||||||
// 设置背景颜色
|
|
||||||
val backgroundSpan = BackgroundColorSpan(Color.YELLOW)
|
|
||||||
spannableText.setSpan(backgroundSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
||||||
}
|
|
||||||
textView.text = spannableText
|
|
||||||
} else {
|
|
||||||
textView.text = string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun containsB(string: String, textView: TextView) {
|
|
||||||
if (string.contains(CodeTableAdapter.pickString)) {
|
|
||||||
val spannableText = SpannableStringBuilder(string)
|
|
||||||
val highlightWord = CodeTableAdapter.pickString
|
|
||||||
val start = string.indexOf(highlightWord)
|
|
||||||
val end = start + highlightWord.length
|
|
||||||
if (start != -1) {
|
|
||||||
// 设置文字颜色
|
|
||||||
val colorSpan = ForegroundColorSpan(Color.RED)
|
|
||||||
spannableText.setSpan(colorSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
||||||
// 设置背景颜色
|
|
||||||
val backgroundSpan = BackgroundColorSpan(Color.BLUE)
|
|
||||||
spannableText.setSpan(backgroundSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
||||||
}
|
|
||||||
textView.text = spannableText
|
|
||||||
} else {
|
|
||||||
textView.text = string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("StringFormatInvalid")
|
|
||||||
override fun onBindViewHolder(holder: BaseVh<CodeTableItemBinding>, position: Int) {
|
|
||||||
val context = holder.itemView.context
|
|
||||||
val resultView: CodeTableItemBinding = holder.binging
|
|
||||||
val codeInfo = list[position]
|
|
||||||
|
|
||||||
contains(codeInfo.description, resultView.descriptionView)
|
|
||||||
resultView.descriptionView.setOnClickListener {
|
|
||||||
GlobalMethod.copyText(it.context, codeInfo.description, it)
|
|
||||||
}
|
|
||||||
contains(codeInfo.translate, resultView.titleView)
|
|
||||||
resultView.titleView.setOnClickListener {
|
|
||||||
GlobalMethod.copyText(it.context, codeInfo.translate, it)
|
|
||||||
}
|
|
||||||
val demo = codeInfo.demo
|
|
||||||
resultView.imageView.isVisible = demo.isNotBlank()
|
|
||||||
resultView.imageView.setOnClickListener {
|
|
||||||
val materialBottomDialog = MaterialBottomDialog(it.context)
|
|
||||||
materialBottomDialog.setTitle(R.string.code_demo)
|
|
||||||
materialBottomDialog.setMessage(demo)
|
|
||||||
materialBottomDialog.show()
|
|
||||||
}
|
|
||||||
contains(codeInfo.code, resultView.subTitleView)
|
|
||||||
resultView.subTitleView.setOnClickListener {
|
|
||||||
GlobalMethod.copyText(it.context, codeInfo.code, it)
|
|
||||||
}
|
|
||||||
|
|
||||||
resultView.valueTypeView.text = typeNameMap?.get(codeInfo.type) ?: codeInfo.type
|
|
||||||
lineParser.text = codeInfo.section
|
|
||||||
|
|
||||||
var isNotEmpty = false
|
|
||||||
lineParser.analyse { lineNum, lineData, isEnd ->
|
|
||||||
isNotEmpty = true
|
|
||||||
val text = sectionMap?.get(lineData) ?: lineData
|
|
||||||
val chip = Chip(context)
|
|
||||||
chip.text = text
|
|
||||||
chip.setOnClickListener {
|
|
||||||
labelFunction?.invoke(lineNum, it, text)
|
|
||||||
}
|
|
||||||
// resultView.chipGroup.addView(chip)
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
// resultView.chipGroup.isVisible = isNotEmpty
|
|
||||||
resultView.valueTypeView.setOnClickListener {
|
|
||||||
val handler = Handler(Looper.getMainLooper())
|
|
||||||
executorService.submit {
|
|
||||||
val codeDataBase = CodeDataBase.getInstance(context)
|
|
||||||
val typeInfo = codeDataBase.getValueTypeDao().findTypeByType(codeInfo.type)
|
|
||||||
|
|
||||||
if (typeInfo == null) {
|
|
||||||
handler.post {
|
|
||||||
handler.post {
|
|
||||||
MaterialDialog(context).show {
|
|
||||||
title(text = codeInfo.type).message(
|
|
||||||
text = String.format(
|
|
||||||
context.getString(
|
|
||||||
R.string.unknown_type
|
|
||||||
), codeInfo.type
|
|
||||||
)
|
|
||||||
)
|
|
||||||
.positiveButton(R.string.dialog_ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (developerMode) {
|
|
||||||
val stringBuilder = StringBuilder()
|
|
||||||
stringBuilder.append("介绍:")
|
|
||||||
stringBuilder.append(typeInfo.describe)
|
|
||||||
stringBuilder.append("\n附加信息:")
|
|
||||||
stringBuilder.append(typeInfo.external)
|
|
||||||
stringBuilder.append("\n关联的自动提示:")
|
|
||||||
stringBuilder.append(typeInfo.list)
|
|
||||||
stringBuilder.append("\n光标偏差:")
|
|
||||||
stringBuilder.append(typeInfo.offset)
|
|
||||||
stringBuilder.append("\n标签:")
|
|
||||||
stringBuilder.append(typeInfo.tag)
|
|
||||||
stringBuilder.append("\n数据规则:")
|
|
||||||
stringBuilder.append(typeInfo.rule)
|
|
||||||
handler.post {
|
|
||||||
MaterialDialog(context).show {
|
|
||||||
title(text = typeInfo.name + "(开发者模式)").message(text = stringBuilder.toString())
|
|
||||||
.positiveButton(R.string.dialog_ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (typeInfo.describe == "@search(code)") {
|
|
||||||
handler.post {
|
|
||||||
MaterialDialog(context).show {
|
|
||||||
title(text = typeInfo.name).message(text = codeInfo.description)
|
|
||||||
.positiveButton(R.string.dialog_ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
handler.post {
|
|
||||||
MaterialDialog(context).show {
|
|
||||||
title(text = typeInfo.name).message(text = typeInfo.describe)
|
|
||||||
.positiveButton(R.string.dialog_ok)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resultView.versionView.text =
|
|
||||||
versionMap?.get(codeInfo.addVersion) ?: codeInfo.addVersion.toString()
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,97 +1,32 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:card_view="http://schemas.android.com/tools"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true"
|
||||||
|
tools:context=".ActivateActivity">
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:fitsSystemWindows="true">
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<com.google.android.material.card.MaterialCardView
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
style="@style/Widget.Material3.CardView.Elevated"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="?attr/actionBarSize" />
|
||||||
android:layout_margin="12dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="6dp"
|
|
||||||
android:gravity="center">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/back"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?android:selectableItemBackgroundBorderless"
|
|
||||||
android:focusable="true"
|
|
||||||
android:src="@drawable/md_nav_back"
|
|
||||||
android:tint="?android:attr/colorForeground"
|
|
||||||
tools:ignore="ContentDescription" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/edittext"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:autofillHints="text"
|
|
||||||
android:background="@null"
|
|
||||||
android:drawableEnd="@drawable/ic_search_black_24dp"
|
|
||||||
android:hint="@string/search"
|
|
||||||
android:imeOptions="actionSearch"
|
|
||||||
android:inputType="text"
|
|
||||||
android:minHeight="48dp"
|
|
||||||
android:padding="10dp"
|
|
||||||
android:singleLine="true"
|
|
||||||
tools:ignore="TextContrastCheck,VisualLintTextFieldSize" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/search_pick"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginHorizontal="6dp"
|
|
||||||
android:gravity="end"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible">
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/listTop"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginEnd="3dp"
|
|
||||||
android:padding="9dp"
|
|
||||||
android:background="?selectableItemBackground"
|
|
||||||
android:src="@drawable/animator_expand_on" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/listButtom"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:background="?selectableItemBackground"
|
|
||||||
android:padding="9dp"
|
|
||||||
android:src="@drawable/animator_expand_off" />
|
|
||||||
</LinearLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginHorizontal="6dp"
|
android:layout_marginLeft="16dp"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_marginTop="8dp"
|
||||||
|
android:layout_marginRight="16dp"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
||||||
|
|
||||||
|
@ -99,52 +34,22 @@
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progressBar"
|
android:id="@+id/progressBar"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content" />
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/displayView"
|
android:id="@+id/displayView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/unable_open_database"
|
android:text="@string/unable_open_database"
|
||||||
android:visibility="gone"
|
android:visibility="gone" />
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/progressBar"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<LinearLayout
|
<ExpandableListView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/expandableListView"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
android:layout_gravity="top"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:visibility="gone" />
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toTopOf="parent">
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/expandableListView"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1" />
|
|
||||||
|
|
||||||
<com.google.android.material.divider.MaterialDivider
|
</LinearLayout>
|
||||||
android:layout_width="1dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginHorizontal="3dp"
|
|
||||||
android:layout_marginVertical="3dp" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/code_recycler_b"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="3"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
22
app/src/main/res/layout/code_table_group.xml
Normal file
22
app/src/main/res/layout/code_table_group.xml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/nameView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="16dp"
|
||||||
|
android:text="表名"
|
||||||
|
android:textSize="16dp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/numView"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="代码数" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
|
@ -61,7 +61,7 @@
|
||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:layout_toRightOf="@id/valueTypeView"
|
android:layout_toRightOf="@id/valueTypeView"
|
||||||
android:text="版本信息" />
|
android:text="版本信息" />
|
||||||
<!--
|
|
||||||
<com.google.android.material.chip.ChipGroup
|
<com.google.android.material.chip.ChipGroup
|
||||||
android:id="@+id/chipGroup"
|
android:id="@+id/chipGroup"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -69,7 +69,8 @@
|
||||||
android:layout_below="@id/valueTypeView"
|
android:layout_below="@id/valueTypeView"
|
||||||
android:layout_marginTop="8dp"
|
android:layout_marginTop="8dp"
|
||||||
app:singleLine="false">
|
app:singleLine="false">
|
||||||
</com.google.android.material.chip.ChipGroup>-->
|
|
||||||
|
</com.google.android.material.chip.ChipGroup>
|
||||||
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
Loading…
Reference in New Issue
Block a user