|
|
|
@ -3,7 +3,6 @@ package io.legado.app.ui.welcome |
|
|
|
|
import android.content.Intent |
|
|
|
|
import android.graphics.drawable.BitmapDrawable |
|
|
|
|
import android.os.Bundle |
|
|
|
|
import com.github.liuyueyi.quick.transfer.ChineseUtils |
|
|
|
|
import io.legado.app.base.BaseActivity |
|
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
|
import io.legado.app.constant.Theme |
|
|
|
@ -13,12 +12,10 @@ import io.legado.app.help.config.AppConfig |
|
|
|
|
import io.legado.app.help.coroutine.Coroutine |
|
|
|
|
import io.legado.app.help.storage.AppWebDav |
|
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
|
import io.legado.app.model.BookCover |
|
|
|
|
import io.legado.app.ui.book.read.ReadBookActivity |
|
|
|
|
import io.legado.app.ui.main.MainActivity |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
|
import java.util.concurrent.TimeUnit |
|
|
|
|
|
|
|
|
|
open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() { |
|
|
|
|
|
|
|
|
@ -27,16 +24,8 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() { |
|
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) { |
|
|
|
|
binding.ivBook.setColorFilter(accentColor) |
|
|
|
|
binding.vwTitleLine.setBackgroundColor(accentColor) |
|
|
|
|
// 避免从桌面启动程序后,会重新实例化入口类的activity |
|
|
|
|
if (intent.flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT != 0) { |
|
|
|
|
finish() |
|
|
|
|
} else { |
|
|
|
|
init() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun init() { |
|
|
|
|
Coroutine.async { |
|
|
|
|
//同步阅读记录 |
|
|
|
|
if (!AppConfig.syncBookProgress) return@async |
|
|
|
|
val books = appDb.bookDao.all |
|
|
|
|
books.forEach { book -> |
|
|
|
@ -54,23 +43,12 @@ open class WelcomeActivity : BaseActivity<ActivityWelcomeBinding>() { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
Coroutine.async { |
|
|
|
|
//初始化封面 |
|
|
|
|
BookCover.toString() |
|
|
|
|
//清除过期数据 |
|
|
|
|
appDb.cacheDao.clearDeadline(System.currentTimeMillis()) |
|
|
|
|
if (getPrefBoolean(PreferKey.autoClearExpired, true)) { |
|
|
|
|
appDb.searchBookDao |
|
|
|
|
.clearExpired(System.currentTimeMillis() - TimeUnit.DAYS.toMillis(1)) |
|
|
|
|
} |
|
|
|
|
//初始化简繁转换引擎 |
|
|
|
|
when (AppConfig.chineseConverterType) { |
|
|
|
|
1 -> ChineseUtils.t2s("初始化") |
|
|
|
|
2 -> ChineseUtils.s2t("初始化") |
|
|
|
|
else -> null |
|
|
|
|
} |
|
|
|
|
// 避免从桌面启动程序后,会重新实例化入口类的activity |
|
|
|
|
if (intent.flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT != 0) { |
|
|
|
|
finish() |
|
|
|
|
} else { |
|
|
|
|
binding.root.postDelayed({ startMainActivity() }, 500) |
|
|
|
|
} |
|
|
|
|
binding.root.postDelayed({ startMainActivity() }, 500) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun upBackgroundImage() { |
|
|
|
|