在代码表内添加了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 {
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.setOnClickListener {
GlobalMethod.copyText(context, codeInfo.code, it)

View File

@ -32,18 +32,29 @@
android:layout_marginTop="5dp"
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
style="@style/TextAppearance.Material3.BodySmall"
android:id="@+id/valueTypeView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/descriptionView"
android:layout_below="@id/demoView"
android:layout_marginTop="5dp"
android:text="值类型" />
<TextView
android:id="@+id/versionView"
android:layout_width="wrap_content"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_height="wrap_content"
android:layout_alignBottom="@id/valueTypeView"
android:layout_marginLeft="8dp"

View File

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

View File

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