feat: 优化代码

pull/121/head
kunfei 5 years ago
parent ae3581d29c
commit dee067557e
  1. 4
      app/src/main/java/io/legado/app/help/ReadBookConfig.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/config/ReadStyleDialog.kt
  3. 7
      app/src/main/java/io/legado/app/utils/BitmapUtils.kt

@ -215,7 +215,7 @@ object ReadBookConfig {
class Config(
private var bgStr: String = "#EEEEEE",//白天背景
private var bgStrNight: String = "#000000",//夜间背景
private var bgType: Int = 0,//白天背景类型
private var bgType: Int = 0,//白天背景类型 0:颜色, 1:assets图片, 2其它图片
private var bgTypeNight: Int = 0,//夜间背景类型
private var darkStatusIcon: Boolean = true,//白天是否暗色状态栏
private var darkStatusIconNight: Boolean = false,//晚上是否暗色状态栏
@ -299,7 +299,7 @@ object ReadBookConfig {
1 -> {
BitmapDrawable(
resources,
BitmapUtils.decodeBitmap(
BitmapUtils.decodeAssetsBitmap(
App.INSTANCE,
"bg" + File.separator + bgStr(),
width,

@ -12,7 +12,6 @@ import io.legado.app.R
import io.legado.app.constant.EventBus
import io.legado.app.constant.PreferKey
import io.legado.app.help.BookHelp
import io.legado.app.help.ImageLoader
import io.legado.app.help.ReadBookConfig
import io.legado.app.lib.dialogs.selector
import io.legado.app.lib.theme.accentColor
@ -219,12 +218,7 @@ class ReadStyleDialog : DialogFragment(), FontSelectDialog.CallBack {
4 -> bg4
else -> bg0
}
ReadBookConfig.getConfig(i).apply {
when (bgType()) {
2 -> ImageLoader.load(requireContext(), bgStr()).centerCrop().into(iv)
else -> iv.setImageDrawable(bgDrawable(100, 150))
}
}
iv.setImageDrawable(ReadBookConfig.getConfig(i).bgDrawable(100, 150))
}
}

@ -121,7 +121,12 @@ object BitmapUtils {
* @throws IOException
*/
@Throws(IOException::class)
fun decodeBitmap(context: Context, fileNameInAssets: String, width: Int, height: Int): Bitmap? {
fun decodeAssetsBitmap(
context: Context,
fileNameInAssets: String,
width: Int,
height: Int
): Bitmap? {
var inputStream = context.assets.open(fileNameInAssets)
val op = BitmapFactory.Options()

Loading…
Cancel
Save