在代码表内添加了demo字段的显示视图,代码表格式支持demo字段。

This commit is contained in:
Cold-Mint 2023-02-01 14:57:07 +08:00
parent b65159f499
commit 0fc4c85237
5 changed files with 32 additions and 7 deletions

View File

@ -142,6 +142,11 @@ class CodeTableAdapter(
resultView.titleView.setOnClickListener { resultView.titleView.setOnClickListener {
GlobalMethod.copyText(context, codeInfo.translate, it) GlobalMethod.copyText(context, codeInfo.translate, it)
} }
val demo = codeInfo.demo
resultView.demoView.isVisible = demo.isNotBlank()
resultView.demoView.text = demo
resultView.subTitleView.text = codeInfo.code resultView.subTitleView.text = codeInfo.code
resultView.subTitleView.setOnClickListener { resultView.subTitleView.setOnClickListener {
GlobalMethod.copyText(context, codeInfo.code, it) GlobalMethod.copyText(context, codeInfo.code, it)
@ -156,7 +161,7 @@ class CodeTableAdapter(
val chip = Chip(context) val chip = Chip(context)
chip.text = text chip.text = text
chip.setOnClickListener { chip.setOnClickListener {
labelFunction?.invoke(lineNum, it, text ) labelFunction?.invoke(lineNum, it, text)
} }
resultView.chipGroup.addView(chip) resultView.chipGroup.addView(chip)
true true

View File

@ -32,18 +32,29 @@
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:text="描述" /> android:text="描述" />
<TextView
android:id="@+id/demoView"
android:visibility="gone"
android:layout_width="wrap_content"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_height="wrap_content"
android:layout_below="@id/descriptionView"
android:layout_marginTop="5dp"
android:text="demo" />
<TextView <TextView
style="@style/TextAppearance.Material3.BodySmall" style="@style/TextAppearance.Material3.BodySmall"
android:id="@+id/valueTypeView" android:id="@+id/valueTypeView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@id/descriptionView" android:layout_below="@id/demoView"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:text="值类型" /> android:text="值类型" />
<TextView <TextView
android:id="@+id/versionView" android:id="@+id/versionView"
android:layout_width="wrap_content" android:layout_width="wrap_content"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@id/valueTypeView" android:layout_alignBottom="@id/valueTypeView"
android:layout_marginLeft="8dp" android:layout_marginLeft="8dp"

View File

@ -3,9 +3,14 @@ package com.coldmint.rust.core.database.code
import android.content.Context import android.content.Context
import android.database.sqlite.SQLiteConstraintException import android.database.sqlite.SQLiteConstraintException
import android.util.Log import android.util.Log
import androidx.room.AutoMigration
import androidx.room.Database import androidx.room.Database
import androidx.room.Index
import androidx.room.RenameColumn
import androidx.room.RenameTable
import androidx.room.Room import androidx.room.Room
import androidx.room.RoomDatabase import androidx.room.RoomDatabase
import androidx.room.migration.AutoMigrationSpec
import com.coldmint.rust.core.DataSet import com.coldmint.rust.core.DataSet
import com.coldmint.rust.core.dataBean.dataset.* import com.coldmint.rust.core.dataBean.dataset.*
import com.coldmint.rust.core.database.file.FileDataBase import com.coldmint.rust.core.database.file.FileDataBase
@ -20,13 +25,14 @@ import java.util.concurrent.Executors
*/ */
@Database( @Database(
entities = [ChainInspection::class, CodeInfo::class, SectionInfo::class, ValueTypeInfo::class, Version::class], entities = [ChainInspection::class, CodeInfo::class, SectionInfo::class, ValueTypeInfo::class, Version::class],
version = 2, version = 3,
exportSchema = false exportSchema = false
) )
abstract class CodeDataBase : RoomDatabase() { abstract class CodeDataBase : RoomDatabase() {
companion object { companion object {
private var instance: CodeDataBase? = null private var instance: CodeDataBase? = null
fun getInstance( fun getInstance(
context: Context, context: Context,
name: String = "codeDataTable", name: String = "codeDataTable",
@ -36,6 +42,7 @@ abstract class CodeDataBase : RoomDatabase() {
instance!!.close() instance!!.close()
instance = instance =
Room.databaseBuilder(context.applicationContext, CodeDataBase::class.java, name) Room.databaseBuilder(context.applicationContext, CodeDataBase::class.java, name)
.fallbackToDestructiveMigration()
.build() .build()
return instance!! return instance!!
} }
@ -48,7 +55,7 @@ abstract class CodeDataBase : RoomDatabase() {
context.applicationContext, context.applicationContext,
CodeDataBase::class.java, CodeDataBase::class.java,
name name
).build() ).fallbackToDestructiveMigration().build()
} }
} }
} }

View File

@ -17,5 +17,5 @@ data class CodeInfo(
@ColumnInfo(name = "add_version") val addVersion: Int, @ColumnInfo(name = "add_version") val addVersion: Int,
@ColumnInfo(name = "remove_version") val removeVersion: Int = 1, @ColumnInfo(name = "remove_version") val removeVersion: Int = 1,
@ColumnInfo(name = "section") val section: String, @ColumnInfo(name = "section") val section: String,
@ColumnInfo(name = "demo") val demo: String = "", @ColumnInfo(name = "demo") val demo: String = " ",
) )

View File

@ -35,7 +35,8 @@ abstract class FileDataBase : RoomDatabase() {
if (openNewDataBase && instance != null) { if (openNewDataBase && instance != null) {
instance!!.close() instance!!.close()
instance = instance =
Room.databaseBuilder(context, FileDataBase::class.java, name).build() Room.databaseBuilder(context, FileDataBase::class.java, name)
.fallbackToDestructiveMigration().build()
return instance!! return instance!!
} }
if (instance == null) { if (instance == null) {
@ -43,7 +44,8 @@ abstract class FileDataBase : RoomDatabase() {
{ {
if (instance == null) { if (instance == null) {
instance = instance =
Room.databaseBuilder(context, FileDataBase::class.java, name).build() Room.databaseBuilder(context, FileDataBase::class.java, name)
.fallbackToDestructiveMigration().build()
} }
} }
} }