修复问题 (#4711)
* 升级RecyclerView适配自适应刷新率 * 减小菜单点击区域 * ... * 修复显示章节位置问题,修复顶部间距问题 * 显示漫画名称 * ... * ...
This commit is contained in:
@@ -37,9 +37,5 @@ class LegadoGlideModule : AppGlideModule() {
|
|||||||
1024 * 1024 * 1000
|
1024 * 1024 * 1000
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setDefaultRequestOptions {
|
|
||||||
RequestOptions().format(DecodeFormat.PREFER_RGB_565)
|
|
||||||
.encodeQuality(90)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
suspend fun contentLoadFinish(
|
suspend fun contentLoadFinish(
|
||||||
chapter: BookChapter,
|
chapter: BookChapter,
|
||||||
content: String,
|
content: String,
|
||||||
book: Book
|
book: Book,
|
||||||
) {
|
) {
|
||||||
if (mTopChapter != null && mTopChapter!!.title != chapterTitle && BookHelp.hasContent(
|
if (mTopChapter != null && mTopChapter!!.title != chapterTitle && BookHelp.hasContent(
|
||||||
book,
|
book,
|
||||||
@@ -299,7 +299,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
}.mapIndexed { index, src ->
|
}.mapIndexed { index, src ->
|
||||||
MangeContent(
|
MangeContent(
|
||||||
mChapterPageCount = durChapterPageCount,
|
mChapterPageCount = durChapterPageCount,
|
||||||
mChapterPagePos = durChapterPagePos,
|
mChapterPagePos = durChapterPagePos.plus(1),
|
||||||
mChapterNextPagePos = durChapterPagePos.plus(1),
|
mChapterNextPagePos = durChapterPagePos.plus(1),
|
||||||
mImageUrl = src,
|
mImageUrl = src,
|
||||||
mDurChapterPos = index.plus(1)
|
mDurChapterPos = index.plus(1)
|
||||||
@@ -308,6 +308,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
this.forEach {
|
this.forEach {
|
||||||
it.mDurChapterCount = this.size
|
it.mDurChapterCount = this.size
|
||||||
}
|
}
|
||||||
|
durChapterCount = this.size
|
||||||
}
|
}
|
||||||
val contentList = mutableListOf<Any>()
|
val contentList = mutableListOf<Any>()
|
||||||
contentList.add(
|
contentList.add(
|
||||||
@@ -318,7 +319,6 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
contentList.addAll(list)
|
contentList.addAll(list)
|
||||||
durChapterCount = contentList.size
|
|
||||||
contentList.add(
|
contentList.add(
|
||||||
ReaderLoading(
|
ReaderLoading(
|
||||||
durChapterPagePos,
|
durChapterPagePos,
|
||||||
@@ -367,7 +367,12 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
val bookSource = bookSource ?: return
|
val bookSource = bookSource ?: return
|
||||||
val book = book ?: return
|
val book = book ?: return
|
||||||
if (!book.canUpdate) return
|
if (!book.canUpdate) return
|
||||||
if (System.currentTimeMillis() - book.lastCheckTime < 600000) return
|
if (System.currentTimeMillis() - book.lastCheckTime < 600000) {
|
||||||
|
runOnUI {
|
||||||
|
mCallback?.noData()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
book.lastCheckTime = System.currentTimeMillis()
|
book.lastCheckTime = System.currentTimeMillis()
|
||||||
WebBook.getChapterList(this, bookSource, book).onSuccess(IO) { cList ->
|
WebBook.getChapterList(this, bookSource, book).onSuccess(IO) { cList ->
|
||||||
if (book.bookUrl == ReadManga.book?.bookUrl
|
if (book.bookUrl == ReadManga.book?.bookUrl
|
||||||
@@ -389,6 +394,10 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
mCallback?.noData()
|
mCallback?.noData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}.onError {
|
||||||
|
runOnUI {
|
||||||
|
mCallback?.noData()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,7 +574,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
fun syncProgress(
|
fun syncProgress(
|
||||||
newProgressAction: ((progress: BookProgress) -> Unit)? = null,
|
newProgressAction: ((progress: BookProgress) -> Unit)? = null,
|
||||||
uploadSuccessAction: (() -> Unit)? = null,
|
uploadSuccessAction: (() -> Unit)? = null,
|
||||||
syncSuccessAction: (() -> Unit)? = null
|
syncSuccessAction: (() -> Unit)? = null,
|
||||||
) {
|
) {
|
||||||
if (!AppConfig.syncBookProgress) return
|
if (!AppConfig.syncBookProgress) return
|
||||||
book?.let {
|
book?.let {
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ import android.os.Looper
|
|||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
|
import android.view.ViewGroup
|
||||||
import androidx.activity.viewModels
|
import androidx.activity.viewModels
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.view.ViewCompat
|
|
||||||
import androidx.core.view.WindowInsetsCompat
|
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
|
import androidx.core.view.updateLayoutParams
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader
|
import com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader
|
||||||
@@ -48,12 +48,12 @@ import io.legado.app.utils.StartActivityContract
|
|||||||
import io.legado.app.utils.getCompatColor
|
import io.legado.app.utils.getCompatColor
|
||||||
import io.legado.app.utils.gone
|
import io.legado.app.utils.gone
|
||||||
import io.legado.app.utils.immersionFullScreen
|
import io.legado.app.utils.immersionFullScreen
|
||||||
|
import io.legado.app.utils.immersionPadding
|
||||||
import io.legado.app.utils.printOnDebug
|
import io.legado.app.utils.printOnDebug
|
||||||
import io.legado.app.utils.showDialogFragment
|
import io.legado.app.utils.showDialogFragment
|
||||||
import io.legado.app.utils.toastOnUi
|
import io.legado.app.utils.toastOnUi
|
||||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||||
import io.legado.app.utils.visible
|
import io.legado.app.utils.visible
|
||||||
import splitties.dimensions.dp
|
|
||||||
|
|
||||||
class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>(),
|
class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>(),
|
||||||
ReadManga.Callback, ChangeBookSourceDialog.CallBack, MangaMenu.CallBack {
|
ReadManga.Callback, ChangeBookSourceDialog.CallBack, MangaMenu.CallBack {
|
||||||
@@ -114,6 +114,13 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
|||||||
|
|
||||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||||
immersionFullScreen(windowInsetsControllerCompat)
|
immersionFullScreen(windowInsetsControllerCompat)
|
||||||
|
immersionPadding(binding.root) { view, insets, _ ->
|
||||||
|
binding.mangaMenu.setTitleBarPadding(insets.top)
|
||||||
|
view.updateLayoutParams<ViewGroup.MarginLayoutParams> {
|
||||||
|
leftMargin = insets.left
|
||||||
|
rightMargin = insets.right
|
||||||
|
}
|
||||||
|
}
|
||||||
ReadManga.register(this)
|
ReadManga.register(this)
|
||||||
binding.mRecyclerMange.run {
|
binding.mRecyclerMange.run {
|
||||||
adapter = mAdapter
|
adapter = mAdapter
|
||||||
@@ -178,11 +185,6 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
loadMoreView.gone()
|
loadMoreView.gone()
|
||||||
binding.mangaMenu.setTitleBarPadding(
|
|
||||||
ViewCompat.getRootWindowInsets(findViewById(android.R.id.content))?.getInsets(
|
|
||||||
WindowInsetsCompat.Type.statusBars()
|
|
||||||
)?.top ?: dp(25)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onNewIntent(intent: Intent) {
|
override fun onNewIntent(intent: Intent) {
|
||||||
@@ -208,14 +210,15 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
|||||||
|
|
||||||
override fun loadContentFinish(list: MutableList<Any>) {
|
override fun loadContentFinish(list: MutableList<Any>) {
|
||||||
if (!this.isDestroyed) {
|
if (!this.isDestroyed) {
|
||||||
|
setTitle(ReadManga.book?.name)
|
||||||
mAdapter.submitList(list) {
|
mAdapter.submitList(list) {
|
||||||
if (!mFirstLoading) {
|
if (!mFirstLoading) {
|
||||||
if (list.size > 1) {
|
if (list.size > 1) {
|
||||||
binding.infobar.isVisible = true
|
binding.infobar.isVisible = true
|
||||||
upText(
|
upText(
|
||||||
ReadManga.durChapterPagePos,
|
ReadManga.durChapterPagePos.plus(1),
|
||||||
ReadManga.durChapterPageCount,
|
ReadManga.durChapterPageCount,
|
||||||
ReadManga.durChapterPos,
|
ReadManga.durChapterPos.plus(1),
|
||||||
ReadManga.durChapterCount
|
ReadManga.durChapterCount
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -247,7 +250,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangeBinding, MangaViewModel>()
|
|||||||
binding.infobar.update(
|
binding.infobar.update(
|
||||||
chapterPagePos,
|
chapterPagePos,
|
||||||
chapterPageCount,
|
chapterPageCount,
|
||||||
chapterPagePos.minus(1f).div(chapterPageCount.minus(1f)),
|
chapterPagePos.times(1f).div(chapterPageCount.times(1f)),
|
||||||
chapterPos,
|
chapterPos,
|
||||||
chapterCount
|
chapterCount
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class WebtoonRecyclerView @JvmOverloads constructor(
|
|||||||
|
|
||||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||||
super.onSizeChanged(w, h, oldw, oldh)
|
super.onSizeChanged(w, h, oldw, oldh)
|
||||||
mcRect.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.66f)
|
mcRect.set(width * 0.33f, height * 0.33f, width * 0.66f, height * 0.46f)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPositionX(positionX: Float): Float {
|
private fun getPositionX(positionX: Float): Float {
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ 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
|
||||||
|
import android.view.View.OnClickListener
|
||||||
|
import android.view.View.OnLongClickListener
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
@@ -232,6 +234,9 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun setTitleBarPadding(top: Int) {
|
fun setTitleBarPadding(top: Int) {
|
||||||
|
if (top <= 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
binding.flTitleBar.run {
|
binding.flTitleBar.run {
|
||||||
setPadding(leftPadding, this.paddingTop.plus(top), rightPadding, bottomPadding)
|
setPadding(leftPadding, this.paddingTop.plus(top), rightPadding, bottomPadding)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import android.view.WindowMetrics
|
|||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.core.view.WindowCompat
|
import androidx.core.view.WindowCompat
|
||||||
import androidx.core.view.WindowInsetsCompat
|
import androidx.core.view.WindowInsetsCompat
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
import androidx.core.view.WindowInsetsControllerCompat
|
||||||
@@ -250,3 +251,10 @@ fun immersionFullScreen(windowInsetsControllerCompat: WindowInsetsControllerComp
|
|||||||
windowInsetsControllerCompat.systemBarsBehavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
windowInsetsControllerCompat.systemBarsBehavior = BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
|
||||||
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars())
|
windowInsetsControllerCompat.hide(WindowInsetsCompat.Type.systemBars())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline fun immersionPadding(root: View, crossinline viewInsets: (v: View, insets: androidx.core.graphics.Insets, gestureInsets: androidx.core.graphics.Insets) -> Unit) {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(root) { view: View, windowInsetsCompat: WindowInsetsCompat ->
|
||||||
|
viewInsets(view, windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemBars()), windowInsetsCompat.getInsets(WindowInsetsCompat.Type.systemGestures()))
|
||||||
|
WindowInsetsCompat.CONSUMED
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user