mirror of
https://github.com/gedoor/legado.git
synced 2025-08-10 00:52:30 +00:00
优化
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user