This commit is contained in:
Horis 2023-07-16 21:01:50 +08:00
parent b2bf49f2a4
commit efcec85614
4 changed files with 17 additions and 7 deletions

View File

@ -41,6 +41,7 @@ abstract class BaseActivity<VB : ViewBinding>(
protected abstract val binding: VB
val isInMultiWindow: Boolean
@SuppressLint("ObsoleteSdkInt")
get() {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
isInMultiWindowMode

View File

@ -415,7 +415,10 @@ class ReadView(context: Context, attrs: AttributeSet) :
*/
private fun click(action: Int) {
when (action) {
0 -> callBack.showActionMenu()
0 -> {
pageDelegate?.dismissSnackBar()
callBack.showActionMenu()
}
1 -> pageDelegate?.nextPageByAnim(defaultAnimationSpeed)
2 -> pageDelegate?.prevPageByAnim(defaultAnimationSpeed)
3 -> ReadBook.moveToNextChapter(true)

View File

@ -26,12 +26,14 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
curBitmap?.recycle()
curBitmap = curPage.screenshot()
}
PageDirection.NEXT -> {
nextBitmap?.recycle()
nextBitmap = nextPage.screenshot()
curBitmap?.recycle()
curBitmap = curPage.screenshot()
}
else -> Unit
}
}
@ -41,9 +43,11 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
MotionEvent.ACTION_DOWN -> {
abortAnim()
}
MotionEvent.ACTION_MOVE -> {
onScroll(event)
}
MotionEvent.ACTION_CANCEL, MotionEvent.ACTION_UP -> {
onAnimStart(readView.defaultAnimationSpeed)
}
@ -120,7 +124,7 @@ abstract class HorizontalPageDelegate(readView: ReadView) : PageDelegate(readVie
if (!hasNext()) return
setDirection(PageDirection.NEXT)
val y = when {
viewHeight / 2 < startY -> viewHeight.toFloat() * 0.9f
startY > viewHeight / 2 -> viewHeight.toFloat() * 0.9f
else -> 1f
}
readView.setStartPoint(viewWidth.toFloat() * 0.9f, y, false)

View File

@ -141,11 +141,6 @@ abstract class PageDelegate(protected val readView: ReadView) {
* 按下
*/
fun onDown() {
// 判断snackBar是否显示并关闭
if (snackBar.isShown) {
snackBar.dismiss()
}
//是否移动
isMoved = false
//是否存在下一章
@ -187,6 +182,13 @@ abstract class PageDelegate(protected val readView: ReadView) {
return hasNext
}
fun dismissSnackBar() {
// 判断snackBar是否显示并关闭
if (snackBar.isShown) {
snackBar.dismiss()
}
}
open fun onDestroy() {
// run on destroy
}