Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Jul 16, 2023
1 parent b2bf49f commit efcec85
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/io/legado/app/base/BaseActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,6 @@ abstract class PageDelegate(protected val readView: ReadView) {
* 按下
*/
fun onDown() {
// 判断snackBar是否显示,并关闭
if (snackBar.isShown) {
snackBar.dismiss()
}

//是否移动
isMoved = false
//是否存在下一章
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit efcec85

Please sign in to comment.