@@ -67,6 +67,7 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
var rateLimiter = ConcurrentRateLimiter(null)
|
var rateLimiter = ConcurrentRateLimiter(null)
|
||||||
val mangaContents get() = buildContentList()
|
val mangaContents get() = buildContentList()
|
||||||
val hasNextChapter get() = durChapterIndex < simulatedChapterSize - 1
|
val hasNextChapter get() = durChapterIndex < simulatedChapterSize - 1
|
||||||
|
val mSeekParPos = mutableMapOf<Int, MutableMap<Int, Int>>()
|
||||||
|
|
||||||
fun resetData(book: Book) {
|
fun resetData(book: Book) {
|
||||||
ReadManga.book = book
|
ReadManga.book = book
|
||||||
@@ -583,6 +584,32 @@ object ReadManga : CoroutineScope by MainScope() {
|
|||||||
return MangaChapter(chapter, contentList, imageCount)
|
return MangaChapter(chapter, contentList, imageCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun recordMangaPosition(dataList: MutableList<Any>) {
|
||||||
|
Coroutine.async {
|
||||||
|
var globalPosition = 0
|
||||||
|
val mangaList = mutableListOf<MangaContent>()
|
||||||
|
dataList.forEach {
|
||||||
|
if (it is MangaContent) {
|
||||||
|
mangaList.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dataList.groupBy { if (it is MangaContent) it.mChapterIndex else (it as ReaderLoading).mChapterIndex }
|
||||||
|
.forEach { (chapterIndex, items) ->
|
||||||
|
val itemMap = mutableMapOf<Int, Int>()
|
||||||
|
for (i in items.indices) {
|
||||||
|
val item = items[i]
|
||||||
|
if (item is MangaContent) {
|
||||||
|
itemMap[item.index] = globalPosition++
|
||||||
|
} else {
|
||||||
|
globalPosition++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mSeekParPos[chapterIndex] = itemMap
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
interface Callback {
|
interface Callback {
|
||||||
fun upContent()
|
fun upContent()
|
||||||
fun loadFail(msg: String)
|
fun loadFail(msg: String)
|
||||||
|
|||||||
@@ -227,6 +227,7 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
ReadManga.durChapterPos = content.index
|
ReadManga.durChapterPos = content.index
|
||||||
ReadManga.curPageChanged()
|
ReadManga.curPageChanged()
|
||||||
}
|
}
|
||||||
|
binding.mangaMenu.upSeekBar(content.index, content.imageCount)
|
||||||
upInfoBar(
|
upInfoBar(
|
||||||
content.mChapterIndex,
|
content.mChapterIndex,
|
||||||
content.chapterSize,
|
content.chapterSize,
|
||||||
@@ -277,6 +278,8 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
val curFinish = data.curFinish
|
val curFinish = data.curFinish
|
||||||
val nextFinish = data.nextFinish
|
val nextFinish = data.nextFinish
|
||||||
mAdapter.submitList(list) {
|
mAdapter.submitList(list) {
|
||||||
|
binding.mangaMenu.upSeekBar(ReadManga.durChapterPos, ReadManga.durChapterImageCount)
|
||||||
|
ReadManga.recordMangaPosition(mAdapter.getCurrentList())
|
||||||
if (loadingViewVisible && curFinish) {
|
if (loadingViewVisible && curFinish) {
|
||||||
binding.infobar.isVisible = true
|
binding.infobar.isVisible = true
|
||||||
upInfoBar(
|
upInfoBar(
|
||||||
@@ -564,6 +567,12 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
toggleSystemBar(menuIsVisible)
|
toggleSystemBar(menuIsVisible)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun moveToTargetIndex(isNext: Boolean) {
|
||||||
|
var targetIndex =
|
||||||
|
if (isNext) ReadManga.durChapterIndex + 1 else ReadManga.durChapterIndex - 1
|
||||||
|
viewModel.openChapter(if (isNext) targetIndex else targetIndex, 0)
|
||||||
|
}
|
||||||
|
|
||||||
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
override fun dispatchKeyEvent(event: KeyEvent): Boolean {
|
||||||
val keyCode = event.keyCode
|
val keyCode = event.keyCode
|
||||||
val action = event.action
|
val action = event.action
|
||||||
@@ -746,4 +755,11 @@ class ReadMangaActivity : VMBaseActivity<ActivityMangaBinding, ReadMangaViewMode
|
|||||||
// 强制刷新屏幕
|
// 强制刷新屏幕
|
||||||
window.decorView.postInvalidate()
|
window.decorView.postInvalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun seekValue(pos: Int) {
|
||||||
|
val mangaIndex = ReadManga.mSeekParPos[ReadManga.durChapterIndex]
|
||||||
|
if (mangaIndex != null && mangaIndex[pos] != null) {
|
||||||
|
binding.mRecyclerManga.scrollToPosition(mangaIndex[pos]!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ import android.util.AttributeSet
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.animation.Animation
|
import android.view.animation.Animation
|
||||||
import android.widget.FrameLayout
|
import android.widget.FrameLayout
|
||||||
|
import android.widget.SeekBar
|
||||||
import androidx.core.view.isGone
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import io.legado.app.R
|
import io.legado.app.R
|
||||||
@@ -22,6 +23,7 @@ import io.legado.app.lib.theme.primaryColor
|
|||||||
import io.legado.app.lib.theme.primaryTextColor
|
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.utils.ColorUtils
|
import io.legado.app.utils.ColorUtils
|
||||||
import io.legado.app.utils.ConstraintModify
|
import io.legado.app.utils.ConstraintModify
|
||||||
import io.legado.app.utils.activity
|
import io.legado.app.utils.activity
|
||||||
@@ -81,6 +83,7 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
override fun onAnimationEnd(animation: Animation) {
|
override fun onAnimationEnd(animation: Animation) {
|
||||||
this@MangaMenu.invisible()
|
this@MangaMenu.invisible()
|
||||||
binding.titleBar.invisible()
|
binding.titleBar.invisible()
|
||||||
|
binding.bottomMenu.invisible()
|
||||||
isMenuOutAnimating = false
|
isMenuOutAnimating = false
|
||||||
canShowMenu = false
|
canShowMenu = false
|
||||||
callBack.upSystemUiVisibility(false)
|
callBack.upSystemUiVisibility(false)
|
||||||
@@ -134,6 +137,9 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
brightnessBackground.setColor(ColorUtils.adjustAlpha(bgColor, 0.5f))
|
||||||
if (AppConfig.isEInkMode) {
|
if (AppConfig.isEInkMode) {
|
||||||
titleBar.setBackgroundResource(R.drawable.bg_eink_border_bottom)
|
titleBar.setBackgroundResource(R.drawable.bg_eink_border_bottom)
|
||||||
|
bottomMenu.setBackgroundResource(R.drawable.bg_eink_border_top)
|
||||||
|
} else {
|
||||||
|
bottomMenu.setBackgroundColor(bgColor)
|
||||||
}
|
}
|
||||||
if (AppConfig.showReadTitleBarAddition) {
|
if (AppConfig.showReadTitleBarAddition) {
|
||||||
titleBarAddition.visible()
|
titleBarAddition.visible()
|
||||||
@@ -173,6 +179,7 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
if (this.isVisible) {
|
if (this.isVisible) {
|
||||||
if (anim) {
|
if (anim) {
|
||||||
binding.titleBar.startAnimation(menuTopOut)
|
binding.titleBar.startAnimation(menuTopOut)
|
||||||
|
binding.bottomMenu.startAnimation(menuBottomOut)
|
||||||
} else {
|
} else {
|
||||||
menuOutListener.onAnimationStart(menuBottomOut)
|
menuOutListener.onAnimationStart(menuBottomOut)
|
||||||
menuOutListener.onAnimationEnd(menuBottomOut)
|
menuOutListener.onAnimationEnd(menuBottomOut)
|
||||||
@@ -183,8 +190,10 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
fun runMenuIn(anim: Boolean = !AppConfig.isEInkMode) {
|
fun runMenuIn(anim: Boolean = !AppConfig.isEInkMode) {
|
||||||
this.visible()
|
this.visible()
|
||||||
binding.titleBar.visible()
|
binding.titleBar.visible()
|
||||||
|
binding.bottomMenu.visible()
|
||||||
if (anim) {
|
if (anim) {
|
||||||
binding.titleBar.startAnimation(menuTopIn)
|
binding.titleBar.startAnimation(menuTopIn)
|
||||||
|
binding.bottomMenu.startAnimation(menuBottomIn)
|
||||||
} else {
|
} else {
|
||||||
menuInListener.onAnimationStart(menuBottomIn)
|
menuInListener.onAnimationStart(menuBottomIn)
|
||||||
menuInListener.onAnimationEnd(menuBottomIn)
|
menuInListener.onAnimationEnd(menuBottomIn)
|
||||||
@@ -225,11 +234,33 @@ class MangaMenu @JvmOverloads constructor(
|
|||||||
tvChapterName.setOnLongClickListener(chapterViewLongClickListener)
|
tvChapterName.setOnLongClickListener(chapterViewLongClickListener)
|
||||||
tvChapterUrl.setOnClickListener(chapterViewClickListener)
|
tvChapterUrl.setOnClickListener(chapterViewClickListener)
|
||||||
tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener)
|
tvChapterUrl.setOnLongClickListener(chapterViewLongClickListener)
|
||||||
|
|
||||||
|
tvNext.setOnClickListener {
|
||||||
|
callBack.moveToTargetIndex(true)
|
||||||
|
}
|
||||||
|
tvPre.setOnClickListener {
|
||||||
|
callBack.moveToTargetIndex(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
seekReadPage.setOnSeekBarChangeListener(object : SeekBarChangeListener {
|
||||||
|
override fun onStopTrackingTouch(seekBar: SeekBar) {
|
||||||
|
callBack.seekValue(seekBar.progress)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fun upSeekBar(value: Int, count: Int) {
|
||||||
|
binding.seekReadPage.apply {
|
||||||
|
max = count.minus(1)
|
||||||
|
progress = value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CallBack {
|
interface CallBack {
|
||||||
fun openBookInfoActivity()
|
fun openBookInfoActivity()
|
||||||
fun upSystemUiVisibility(menuIsVisible: Boolean)
|
fun upSystemUiVisibility(menuIsVisible: Boolean)
|
||||||
|
fun moveToTargetIndex(isNext: Boolean)
|
||||||
|
fun seekValue(pos: Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -73,4 +73,60 @@
|
|||||||
|
|
||||||
</io.legado.app.ui.widget.TitleBar>
|
</io.legado.app.ui.widget.TitleBar>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/bottom_menu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@color/background_menu"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:orientation="vertical"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="20dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:layout_marginRight="20dp"
|
||||||
|
android:layout_marginBottom="10dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_pre"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:text="@string/previous_chapter"
|
||||||
|
android:textColor="@color/primaryText"
|
||||||
|
android:textSize="14sp"
|
||||||
|
tools:ignore="TouchTargetSizeCheck" />
|
||||||
|
|
||||||
|
<io.legado.app.lib.theme.view.ThemeSeekBar
|
||||||
|
android:id="@+id/seek_read_page"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="25dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_next"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
android:paddingTop="10dp"
|
||||||
|
android:paddingBottom="10dp"
|
||||||
|
android:text="@string/next_chapter"
|
||||||
|
android:textColor="@color/primaryText"
|
||||||
|
android:textSize="14sp"
|
||||||
|
tools:ignore="TouchTargetSizeCheck" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
Reference in New Issue
Block a user