|
|
|
@ -1,16 +1,19 @@ |
|
|
|
|
package io.legado.app.data.entities |
|
|
|
|
|
|
|
|
|
import android.os.Parcelable |
|
|
|
|
import androidx.room.ColumnInfo |
|
|
|
|
import androidx.room.Entity |
|
|
|
|
import androidx.room.Index |
|
|
|
|
import androidx.room.PrimaryKey |
|
|
|
|
import androidx.room.* |
|
|
|
|
import io.legado.app.constant.AppUtils.GSON_CONVERTER |
|
|
|
|
import io.legado.app.data.entities.rule.* |
|
|
|
|
import kotlinx.android.parcel.IgnoredOnParcel |
|
|
|
|
import kotlinx.android.parcel.Parcelize |
|
|
|
|
|
|
|
|
|
@Parcelize |
|
|
|
|
@Entity(tableName = "sources", |
|
|
|
|
indices = [(Index(value = ["sourceId"]))]) |
|
|
|
|
data class Source(@PrimaryKey(autoGenerate = true) |
|
|
|
|
@Entity( |
|
|
|
|
tableName = "sources", |
|
|
|
|
indices = [(Index(value = ["sourceId"])), (Index(value = ["origin"], unique = false))] |
|
|
|
|
) |
|
|
|
|
data class Source ( |
|
|
|
|
@PrimaryKey(autoGenerate = true) |
|
|
|
|
@ColumnInfo(name = "sourceId") |
|
|
|
|
var id: Int = 0, // 编号 |
|
|
|
|
var name: String = "", // 名称 |
|
|
|
@ -28,4 +31,59 @@ data class Source(@PrimaryKey(autoGenerate = true) |
|
|
|
|
var bookInfoRule: String? = null, // 书籍信息页规则 |
|
|
|
|
var chapterRule: String? = null, // 目录页规则 |
|
|
|
|
var contentRule: String? = null // 正文页规则 |
|
|
|
|
) : Parcelable |
|
|
|
|
) : Parcelable { |
|
|
|
|
@Transient |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
var parsedExploreRule: ExploreRule? = null |
|
|
|
|
@Transient |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
var parsedSearchRule: SearchRule? = null |
|
|
|
|
@Transient |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
var parsedBookInfoRule: BookInfoRule? = null |
|
|
|
|
@Transient |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
var parsedChapterRule: ChapterRule? = null |
|
|
|
|
@Transient |
|
|
|
|
@IgnoredOnParcel |
|
|
|
|
var parsedContentRule: ContentRule? = null |
|
|
|
|
|
|
|
|
|
fun initAllRules() { |
|
|
|
|
initSearchRule() |
|
|
|
|
initExploreRule() |
|
|
|
|
initBookInfoRule() |
|
|
|
|
initChapterRule() |
|
|
|
|
initContentRule() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun initSearchRule() { |
|
|
|
|
if (searchRule != null) { |
|
|
|
|
parsedSearchRule = GSON_CONVERTER.fromJson(searchRule, SearchRule::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun initExploreRule() { |
|
|
|
|
if (exploreRule != null) { |
|
|
|
|
parsedExploreRule = GSON_CONVERTER.fromJson(exploreRule, ExploreRule::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun initBookInfoRule() { |
|
|
|
|
if (bookInfoRule != null) { |
|
|
|
|
parsedBookInfoRule = GSON_CONVERTER.fromJson(bookInfoRule, BookInfoRule::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun initChapterRule() { |
|
|
|
|
if (chapterRule != null) { |
|
|
|
|
parsedChapterRule = GSON_CONVERTER.fromJson(chapterRule, ChapterRule::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun initContentRule() { |
|
|
|
|
if (contentRule != null) { |
|
|
|
|
parsedContentRule = GSON_CONVERTER.fromJson(contentRule, ContentRule::class.java) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |