优化
This commit is contained in:
@@ -79,19 +79,18 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
|
|
||||||
private val mLayoutManager by lazy {
|
private val mLayoutManager by lazy {
|
||||||
LinearLayoutManager(
|
LinearLayoutManager(
|
||||||
this@ReadMangaActivity,
|
this,
|
||||||
if (AppConfig.enableMangaHorizontalScroll) LinearLayoutManager.HORIZONTAL else LinearLayoutManager.VERTICAL,
|
if (AppConfig.enableMangaHorizontalScroll) LinearLayoutManager.HORIZONTAL
|
||||||
|
else LinearLayoutManager.VERTICAL,
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
private val mAdapter: MangaAdapter by lazy {
|
private val mAdapter: MangaAdapter by lazy {
|
||||||
MangaAdapter(this@ReadMangaActivity)
|
MangaAdapter(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mSizeProvider by lazy {
|
private val mSizeProvider by lazy {
|
||||||
FixedPreloadSizeProvider<Any>(
|
FixedPreloadSizeProvider<Any>(resources.displayMetrics.widthPixels, SIZE_ORIGINAL)
|
||||||
this@ReadMangaActivity.resources.displayMetrics.widthPixels, SIZE_ORIGINAL
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mPagerSnapHelper: PagerSnapHelper by lazy {
|
private val mPagerSnapHelper: PagerSnapHelper by lazy {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package io.legado.app.ui.book.read
|
|||||||
|
|
||||||
import android.annotation.SuppressLint
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Color
|
|
||||||
import android.graphics.drawable.GradientDrawable
|
import android.graphics.drawable.GradientDrawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@@ -15,12 +14,8 @@ import io.legado.app.R
|
|||||||
import io.legado.app.databinding.ViewMangaMenuBinding
|
import io.legado.app.databinding.ViewMangaMenuBinding
|
||||||
import io.legado.app.help.IntentData
|
import io.legado.app.help.IntentData
|
||||||
import io.legado.app.help.config.AppConfig
|
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.dialogs.alert
|
||||||
import io.legado.app.lib.theme.bottomBackground
|
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.model.ReadManga
|
||||||
import io.legado.app.ui.browser.WebViewActivity
|
import io.legado.app.ui.browser.WebViewActivity
|
||||||
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
import io.legado.app.ui.widget.seekbar.SeekBarChangeListener
|
||||||
@@ -57,22 +52,7 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
loadAnimation(context, R.anim.anim_readbook_bottom_out)
|
||||||
}
|
}
|
||||||
private var isMenuOutAnimating = false
|
private var isMenuOutAnimating = false
|
||||||
private val immersiveMenu: Boolean
|
private var bgColor = context.bottomBackground
|
||||||
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 val menuOutListener = object : Animation.AnimationListener {
|
private val menuOutListener = object : Animation.AnimationListener {
|
||||||
override fun onAnimationStart(animation: Animation) {
|
override fun onAnimationStart(animation: Animation) {
|
||||||
@@ -110,28 +90,12 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
initView(true)
|
initView()
|
||||||
bindEvent()
|
bindEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initView(reset: Boolean = false) = binding.run {
|
private fun initView() = binding.run {
|
||||||
initAnimation()
|
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()
|
val brightnessBackground = GradientDrawable()
|
||||||
brightnessBackground.cornerRadius = 5F.dpToPx()
|
brightnessBackground.cornerRadius = 5F.dpToPx()
|
||||||
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
||||||
|
|||||||
Reference in New Issue
Block a user