feat: 优化代码

pull/182/head
kunfei 5 years ago
parent 5a179e1659
commit ac19392725
  1. 2
      app/src/main/java/io/legado/app/data/AppDatabase.kt
  2. 8
      app/src/main/java/io/legado/app/data/entities/Book.kt
  3. 1
      app/src/main/java/io/legado/app/data/entities/RssSource.kt
  4. 2
      app/src/main/java/io/legado/app/ui/rss/source/edit/RssSourceEditActivity.kt
  5. 1
      app/src/main/res/values/strings.xml

@ -18,7 +18,7 @@ import kotlinx.coroutines.launch
ReplaceRule::class, SearchBook::class, SearchKeyword::class, Cookie::class,
RssSource::class, Bookmark::class, RssArticle::class, RssReadRecord::class,
RssStar::class, TxtTocRule::class],
version = 8,
version = 9,
exportSchema = true
)
abstract class AppDatabase : RoomDatabase() {

@ -4,7 +4,6 @@ import android.os.Parcelable
import androidx.room.Entity
import androidx.room.Ignore
import androidx.room.Index
import androidx.room.PrimaryKey
import io.legado.app.constant.AppPattern
import io.legado.app.constant.BookType
import io.legado.app.utils.GSON
@ -15,9 +14,12 @@ import java.nio.charset.Charset
import kotlin.math.max
@Parcelize
@Entity(tableName = "books", indices = [(Index(value = ["bookUrl"], unique = true))])
@Entity(
tableName = "books",
primaryKeys = ["name", "author"],
indices = [(Index(value = ["bookUrl"], unique = true))]
)
data class Book(
@PrimaryKey
override var bookUrl: String = "", // 详情页Url(本地书源存储完整文件路径)
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
var origin: String = BookType.local, // 书源URL(默认BookType.local)

@ -23,6 +23,7 @@ data class RssSource(
var sourceIcon: String = "",
var sourceGroup: String? = null,
var enabled: Boolean = true,
var sortUrl: String? = null,
//列表规则
var ruleArticles: String? = null,
var ruleNextPage: String? = null,

@ -135,6 +135,7 @@ class RssSourceEditActivity :
add(EditEntity("sourceUrl", rssSource?.sourceUrl, R.string.source_url))
add(EditEntity("sourceIcon", rssSource?.sourceIcon, R.string.source_icon))
add(EditEntity("sourceGroup", rssSource?.sourceGroup, R.string.source_group))
add(EditEntity("sortUrl", rssSource?.sortUrl, R.string.sort_url))
add(EditEntity("ruleArticles", rssSource?.ruleArticles, R.string.r_articles))
add(EditEntity("ruleNextPage", rssSource?.ruleNextPage, R.string.r_next))
add(EditEntity("ruleTitle", rssSource?.ruleTitle, R.string.r_title))
@ -159,6 +160,7 @@ class RssSourceEditActivity :
"sourceUrl" -> source.sourceUrl = it.value ?: ""
"sourceIcon" -> source.sourceIcon = it.value ?: ""
"sourceGroup" -> source.sourceGroup = it.value
"sortUrl" -> source.sortUrl = it.value
"ruleArticles" -> source.ruleArticles = it.value
"ruleNextPage" -> source.ruleNextPage = it.value
"ruleTitle" -> source.ruleTitle = it.value

@ -376,6 +376,7 @@
<string name="source_name">源名称(sourceName)</string>
<string name="source_url">源URL(sourceUrl)</string>
<string name="source_group">源分组(sourceGroup)</string>
<string name="sort_url">分类Url</string>
<string name="login_url">登录URL(loginUrl)</string>
<string name="r_search_url">搜索地址(url)</string>
<string name="r_find_url">发现地址规则(url)</string>

Loading…
Cancel
Save