pull/60/head
kunfei 5 years ago
parent 9620189b24
commit f1bca15552
  1. 17
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 7
      app/src/main/java/io/legado/app/base/VMBaseActivity.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  4. 2
      app/src/main/res/values/styles.xml

@ -19,8 +19,11 @@ import kotlinx.coroutines.MainScope
import kotlinx.coroutines.cancel import kotlinx.coroutines.cancel
abstract class BaseActivity(private val layoutID: Int, private val fullScreen: Boolean = true) : abstract class BaseActivity(
AppCompatActivity(), private val layoutID: Int,
private val fullScreen: Boolean = true,
private val initTheme: Boolean = true
) : AppCompatActivity(),
CoroutineScope by MainScope() { CoroutineScope by MainScope() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@ -73,10 +76,12 @@ abstract class BaseActivity(private val layoutID: Int, private val fullScreen: B
private fun initTheme() { private fun initTheme() {
ATH.applyBackgroundTint(window.decorView) ATH.applyBackgroundTint(window.decorView)
if (ColorUtils.isColorLight(primaryColor)) { if (initTheme) {
setTheme(R.style.AppTheme_Light) if (ColorUtils.isColorLight(primaryColor)) {
} else { setTheme(R.style.AppTheme_Light)
setTheme(R.style.AppTheme_Dark) } else {
setTheme(R.style.AppTheme_Dark)
}
} }
} }

@ -2,8 +2,11 @@ package io.legado.app.base
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
abstract class VMBaseActivity<VM : ViewModel>(layoutID: Int, fullScreen: Boolean = true) : abstract class VMBaseActivity<VM : ViewModel>(
BaseActivity(layoutID, fullScreen) { layoutID: Int,
fullScreen: Boolean = true,
initTheme: Boolean = true
) : BaseActivity(layoutID, fullScreen, initTheme) {
protected abstract val viewModel: VM protected abstract val viewModel: VM

@ -36,7 +36,8 @@ import org.jetbrains.anko.startActivity
import org.jetbrains.anko.toast import org.jetbrains.anko.toast
class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info), class BookInfoActivity :
VMBaseActivity<BookInfoViewModel>(R.layout.activity_book_info, initTheme = false),
GroupSelectDialog.CallBack, GroupSelectDialog.CallBack,
ChapterListAdapter.CallBack, ChapterListAdapter.CallBack,
ChangeSourceDialog.CallBack { ChangeSourceDialog.CallBack {

@ -25,7 +25,7 @@
<!-- BookInfo主题 --> <!-- BookInfo主题 -->
<style name="AppTheme.BookInfo" parent="Base.AppTheme"> <style name="AppTheme.BookInfo" parent="Base.AppTheme">
<item name="actionBarStyle">@style/AppTheme.AppBarOverlay.Light</item> <item name="actionBarStyle">@style/AppTheme.AppBarOverlay.Dark</item>
<item name="elevation">0dp</item><!--去掉toolbar阴影,去线留白--> <item name="elevation">0dp</item><!--去掉toolbar阴影,去线留白-->
</style> </style>

Loading…
Cancel
Save