mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -79,19 +79,18 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
||||
|
||||
private val mLayoutManager by lazy {
|
||||
LinearLayoutManager(
|
||||
this@ReadMangaActivity,
|
||||
if (AppConfig.enableMangaHorizontalScroll) LinearLayoutManager.HORIZONTAL else LinearLayoutManager.VERTICAL,
|
||||
this,
|
||||
if (AppConfig.enableMangaHorizontalScroll) LinearLayoutManager.HORIZONTAL
|
||||
else LinearLayoutManager.VERTICAL,
|
||||
false
|
||||
)
|
||||
}
|
||||
private val mAdapter: MangaAdapter by lazy {
|
||||
MangaAdapter(this@ReadMangaActivity)
|
||||
MangaAdapter(this)
|
||||
}
|
||||
|
||||
private val mSizeProvider by lazy {
|
||||
FixedPreloadSizeProvider<Any>(
|
||||
this@ReadMangaActivity.resources.displayMetrics.widthPixels, SIZE_ORIGINAL
|
||||
)
|
||||
FixedPreloadSizeProvider<Any>(resources.displayMetrics.widthPixels, SIZE_ORIGINAL)
|
||||
}
|
||||
|
||||
private val mPagerSnapHelper: PagerSnapHelper by lazy {
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.legado.app.ui.book.read
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
@@ -15,12 +14,8 @@ import io.legado.app.R
|
||||
import io.legado.app.databinding.ViewMangaMenuBinding
|
||||
import io.legado.app.help.IntentData
|
||||
import io.legado.app.help.config.AppConfig
|
||||
import io.legado.app.help.config.ReadBookConfig
|
||||
import io.legado.app.lib.dialogs.alert
|
||||
import io.legado.app.lib.theme.bottomBackground
|
||||
import io.legado.app.lib.theme.getPrimaryTextColor
|
||||
import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.lib.theme.primaryTextColor
|
||||
import io.legado.app.model.ReadManga
|
||||
import io.legado.app.ui.browser.WebViewActivity
|
||||
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
||||
@@ -57,22 +52,7 @@ class MangaMenu @JvmOverloads constructor(
|
||||
loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
||||
}
|
||||
private var isMenuOutAnimating = false
|
||||
private val immersiveMenu: Boolean
|
||||
get() = AppConfig.readBarStyleFollowPage && ReadBookConfig.durConfig.curBgType() == 0
|
||||
|
||||
private var bgColor: Int = if (immersiveMenu) {
|
||||
kotlin.runCatching {
|
||||
Color.parseColor(ReadBookConfig.durConfig.curBgStr())
|
||||
}.getOrDefault(context.bottomBackground)
|
||||
} else {
|
||||
context.bottomBackground
|
||||
}
|
||||
|
||||
private var textColor: Int = if (immersiveMenu) {
|
||||
ReadBookConfig.durConfig.curTextColor()
|
||||
} else {
|
||||
context.getPrimaryTextColor(ColorUtils.isColorLight(bgColor))
|
||||
}
|
||||
private var bgColor = context.bottomBackground
|
||||
|
||||
private val menuOutListener = object : Animation.AnimationListener {
|
||||
override fun onAnimationStart(animation: Animation) {
|
||||
@@ -110,28 +90,12 @@ class MangaMenu @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
init {
|
||||
initView(true)
|
||||
initView()
|
||||
bindEvent()
|
||||
}
|
||||
|
||||
private fun initView(reset: Boolean = false) = binding.run {
|
||||
private fun initView() = binding.run {
|
||||
initAnimation()
|
||||
if (immersiveMenu) {
|
||||
val lightTextColor = ColorUtils.withAlpha(ColorUtils.lightenColor(textColor), 0.75f)
|
||||
titleBar.setTextColor(textColor)
|
||||
titleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setColorFilter(textColor)
|
||||
tvChapterName.setTextColor(lightTextColor)
|
||||
tvChapterUrl.setTextColor(lightTextColor)
|
||||
} else if (reset) {
|
||||
val bgColor = context.primaryColor
|
||||
val textColor = context.primaryTextColor
|
||||
titleBar.setTextColor(textColor)
|
||||
titleBar.setBackgroundColor(bgColor)
|
||||
titleBar.setColorFilter(textColor)
|
||||
tvChapterName.setTextColor(textColor)
|
||||
tvChapterUrl.setTextColor(textColor)
|
||||
}
|
||||
val brightnessBackground = GradientDrawable()
|
||||
brightnessBackground.cornerRadius = 5F.dpToPx()
|
||||
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
||||
|
||||
Reference in New Issue
Block a user