Merge remote-tracking branch 'origin/master'

This commit is contained in:
kunfei 2023-07-16 22:29:14 +08:00
commit a4eb2a1408
5 changed files with 20 additions and 10 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ object ChapterProvider {
private var titleBottomSpacing = 0 private var titleBottomSpacing = 0
@JvmStatic @JvmStatic
var typeface: Typeface = Typeface.DEFAULT var typeface: Typeface? = Typeface.DEFAULT
private set private set
@JvmStatic @JvmStatic
@ -637,7 +637,7 @@ object ChapterProvider {
upLayout() upLayout()
} }
private fun getTypeface(fontPath: String): Typeface { private fun getTypeface(fontPath: String): Typeface? {
return kotlin.runCatching { return kotlin.runCatching {
when { when {
fontPath.isContentScheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> { fontPath.isContentScheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> {
@ -666,7 +666,7 @@ object ChapterProvider {
} ?: Typeface.DEFAULT } ?: Typeface.DEFAULT
} }
private fun getPaints(typeface: Typeface): Pair<TextPaint, TextPaint> { private fun getPaints(typeface: Typeface?): Pair<TextPaint, TextPaint> {
// 字体统一处理 // 字体统一处理
val bold = Typeface.create(typeface, Typeface.BOLD) val bold = Typeface.create(typeface, Typeface.BOLD)
val normal = Typeface.create(typeface, Typeface.NORMAL) val normal = Typeface.create(typeface, Typeface.NORMAL)