feat: 优化代码

pull/190/head
kunfei 5 years ago
parent 76979c2295
commit 078b6789ee
  1. 179
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt

@ -27,7 +27,6 @@ object ReadBookConfig {
GSON.fromJsonArray<Config>(json)!! GSON.fromJsonArray<Config>(json)!!
} }
val durConfig get() = getConfig(styleSelect) val durConfig get() = getConfig(styleSelect)
private val shareConfig get() = getConfig(5)
var bg: Drawable? = null var bg: Drawable? = null
var bgMeanColor: Int = 0 var bgMeanColor: Int = 0
@ -139,129 +138,145 @@ object ReadBookConfig {
var bodyIndent = " ".repeat(bodyIndentCount) var bodyIndent = " ".repeat(bodyIndentCount)
var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar) var hideStatusBar = App.INSTANCE.getPrefBoolean(PreferKey.hideStatusBar)
var hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar) var hideNavigationBar = App.INSTANCE.getPrefBoolean(PreferKey.hideNavigationBar)
private val config get() = if (shareLayout) getConfig(5) else durConfig
var textBold: Boolean var textBold: Boolean
get() = if (shareLayout) shareConfig.textBold else durConfig.textBold get() = config.textBold
set(value) = if (shareLayout) shareConfig.textBold = value else durConfig.textBold = value set(value) {
config.textBold = value
}
var textSize: Int var textSize: Int
get() = if (shareLayout) shareConfig.textSize else durConfig.textSize get() = config.textSize
set(value) = if (shareLayout) shareConfig.textSize = value else durConfig.textSize = value set(value) {
config.textSize = value
}
var letterSpacing: Float var letterSpacing: Float
get() = if (shareLayout) shareConfig.letterSpacing else durConfig.letterSpacing get() = config.letterSpacing
set(value) = set(value) {
if (shareLayout) shareConfig.letterSpacing = value else durConfig.letterSpacing = value config.letterSpacing = value
}
var lineSpacingExtra: Int var lineSpacingExtra: Int
get() = if (shareLayout) shareConfig.lineSpacingExtra else durConfig.lineSpacingExtra get() = config.lineSpacingExtra
set(value) = set(value) {
if (shareLayout) shareConfig.lineSpacingExtra = value config.lineSpacingExtra = value
else durConfig.lineSpacingExtra = value }
var paragraphSpacing: Int var paragraphSpacing: Int
get() = if (shareLayout) shareConfig.paragraphSpacing else durConfig.paragraphSpacing get() = config.paragraphSpacing
set(value) = set(value) {
if (shareLayout) shareConfig.paragraphSpacing = value config.paragraphSpacing = value
else durConfig.paragraphSpacing = value }
var titleMode: Int var titleMode: Int
get() = if (shareLayout) shareConfig.titleMode else durConfig.titleMode get() = config.titleMode
set(value) = set(value) {
if (shareLayout) shareConfig.titleMode = value else durConfig.titleMode = value config.titleMode = value
}
var titleSize: Int var titleSize: Int
get() = if (shareLayout) shareConfig.titleSize else durConfig.titleSize get() = config.titleSize
set(value) = set(value) {
if (shareLayout) shareConfig.titleSize = value else durConfig.titleSize = value config.titleSize = value
}
var titleTopSpacing: Int var titleTopSpacing: Int
get() = if (shareLayout) shareConfig.titleTopSpacing else durConfig.titleTopSpacing get() = config.titleTopSpacing
set(value) = set(value) {
if (shareLayout) shareConfig.titleTopSpacing = value config.titleTopSpacing = value
else durConfig.titleTopSpacing = value }
var titleBottomSpacing: Int var titleBottomSpacing: Int
get() = if (shareLayout) shareConfig.titleBottomSpacing else durConfig.titleBottomSpacing get() = config.titleBottomSpacing
set(value) = set(value) {
if (shareLayout) shareConfig.titleBottomSpacing = value config.titleBottomSpacing = value
else durConfig.titleBottomSpacing = value }
var paddingBottom: Int var paddingBottom: Int
get() = if (shareLayout) shareConfig.paddingBottom else durConfig.paddingBottom get() = config.paddingBottom
set(value) = set(value) {
if (shareLayout) shareConfig.paddingBottom = value else durConfig.paddingBottom = value config.paddingBottom = value
}
var paddingLeft: Int var paddingLeft: Int
get() = if (shareLayout) shareConfig.paddingLeft else durConfig.paddingLeft get() = config.paddingLeft
set(value) = set(value) {
if (shareLayout) shareConfig.paddingLeft = value else durConfig.paddingLeft = value config.paddingLeft = value
}
var paddingRight: Int var paddingRight: Int
get() = if (shareLayout) shareConfig.paddingRight else durConfig.paddingRight get() = config.paddingRight
set(value) = set(value) {
if (shareLayout) shareConfig.paddingRight = value else durConfig.paddingRight = value config.paddingRight = value
}
var paddingTop: Int var paddingTop: Int
get() = if (shareLayout) shareConfig.paddingTop else durConfig.paddingTop get() = config.paddingTop
set(value) = set(value) {
if (shareLayout) shareConfig.paddingTop = value else durConfig.paddingTop = value config.paddingTop = value
}
var headerPaddingBottom: Int var headerPaddingBottom: Int
get() = if (shareLayout) shareConfig.headerPaddingBottom else durConfig.headerPaddingBottom get() = config.headerPaddingBottom
set(value) = set(value) {
if (shareLayout) shareConfig.headerPaddingBottom = value config.headerPaddingBottom = value
else durConfig.headerPaddingBottom = value }
var headerPaddingLeft: Int var headerPaddingLeft: Int
get() = if (shareLayout) shareConfig.headerPaddingLeft else durConfig.headerPaddingLeft get() = config.headerPaddingLeft
set(value) = set(value) {
if (shareLayout) shareConfig.headerPaddingLeft = value config.headerPaddingLeft = value
else durConfig.headerPaddingLeft = value }
var headerPaddingRight: Int var headerPaddingRight: Int
get() = if (shareLayout) shareConfig.headerPaddingRight else durConfig.headerPaddingRight get() = config.headerPaddingRight
set(value) = set(value) {
if (shareLayout) shareConfig.headerPaddingRight = value config.headerPaddingRight = value
else durConfig.headerPaddingRight = value }
var headerPaddingTop: Int var headerPaddingTop: Int
get() = if (shareLayout) shareConfig.headerPaddingTop else durConfig.headerPaddingTop get() = config.headerPaddingTop
set(value) = set(value) {
if (shareLayout) shareConfig.headerPaddingTop = value config.headerPaddingTop = value
else durConfig.headerPaddingTop = value }
var footerPaddingBottom: Int var footerPaddingBottom: Int
get() = if (shareLayout) shareConfig.footerPaddingBottom else durConfig.footerPaddingBottom get() = config.footerPaddingBottom
set(value) = set(value) {
if (shareLayout) shareConfig.footerPaddingBottom = value config.footerPaddingBottom = value
else durConfig.footerPaddingBottom = value }
var footerPaddingLeft: Int var footerPaddingLeft: Int
get() = if (shareLayout) shareConfig.footerPaddingLeft else durConfig.footerPaddingLeft get() = config.footerPaddingLeft
set(value) = set(value) {
if (shareLayout) shareConfig.footerPaddingLeft = value config.footerPaddingLeft = value
else durConfig.footerPaddingLeft = value }
var footerPaddingRight: Int var footerPaddingRight: Int
get() = if (shareLayout) shareConfig.footerPaddingRight else durConfig.footerPaddingRight get() = config.footerPaddingRight
set(value) = set(value) {
if (shareLayout) shareConfig.footerPaddingRight = value config.footerPaddingRight = value
else durConfig.footerPaddingRight = value }
var footerPaddingTop: Int var footerPaddingTop: Int
get() = if (shareLayout) shareConfig.footerPaddingTop else durConfig.footerPaddingTop get() = config.footerPaddingTop
set(value) = set(value) {
if (shareLayout) shareConfig.footerPaddingTop = value config.footerPaddingTop = value
else durConfig.footerPaddingTop = value }
var showHeaderLine: Boolean var showHeaderLine: Boolean
get() = if (shareLayout) shareConfig.showHeaderLine else durConfig.showHeaderLine get() = config.showHeaderLine
set(value) = set(value) {
if (shareLayout) shareConfig.showHeaderLine = value config.showHeaderLine = value
else durConfig.showHeaderLine = value }
var showFooterLine: Boolean var showFooterLine: Boolean
get() = if (shareLayout) shareConfig.showFooterLine else durConfig.showFooterLine get() = config.showFooterLine
set(value) = set(value) {
if (shareLayout) shareConfig.showFooterLine = value config.showFooterLine = value
else durConfig.showFooterLine = value }
@Keep @Keep
class Config( class Config(

Loading…
Cancel
Save