pull/32/head
kunfei 5 years ago
parent 195c681818
commit 56d3acb6a0
  1. 22
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt

@ -95,7 +95,7 @@ object ReadBookConfig {
} }
data class Config( data class Config(
var bgStr: String = "#015A86", var bgStr: String = "#EEEEEE",
var bgStrNight: String = "#000000", var bgStrNight: String = "#000000",
var bgType: Int = 0, var bgType: Int = 0,
var bgTypeNight: Int = 0, var bgTypeNight: Int = 0,
@ -164,15 +164,17 @@ object ReadBookConfig {
fun bgDrawable(): Drawable { fun bgDrawable(): Drawable {
var bgDrawable: Drawable? = null var bgDrawable: Drawable? = null
when (bgType()) { kotlin.runCatching {
0 -> bgDrawable = ColorDrawable(Color.parseColor(bgStr())) when (bgType()) {
1 -> bgDrawable = 0 -> bgDrawable = ColorDrawable(Color.parseColor(bgStr()))
Drawable.createFromStream( 1 -> bgDrawable =
App.INSTANCE.assets.open("bg" + File.separator + bgStr), Drawable.createFromStream(
"bg" App.INSTANCE.assets.open("bg" + File.separator + bgStr),
) "bg"
else -> runCatching { )
bgDrawable = Drawable.createFromPath(bgStr) else -> runCatching {
bgDrawable = Drawable.createFromPath(bgStr)
}
} }
} }
return bgDrawable ?: ColorDrawable(Color.parseColor("#015A86")) return bgDrawable ?: ColorDrawable(Color.parseColor("#015A86"))

Loading…
Cancel
Save