mirror of
https://github.com/gedoor/legado.git
synced 2024-09-01 09:34:25 +08:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a4eb2a1408
@ -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
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ object ChapterProvider {
|
||||
private var titleBottomSpacing = 0
|
||||
|
||||
@JvmStatic
|
||||
var typeface: Typeface = Typeface.DEFAULT
|
||||
var typeface: Typeface? = Typeface.DEFAULT
|
||||
private set
|
||||
|
||||
@JvmStatic
|
||||
@ -637,7 +637,7 @@ object ChapterProvider {
|
||||
upLayout()
|
||||
}
|
||||
|
||||
private fun getTypeface(fontPath: String): Typeface {
|
||||
private fun getTypeface(fontPath: String): Typeface? {
|
||||
return kotlin.runCatching {
|
||||
when {
|
||||
fontPath.isContentScheme() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O -> {
|
||||
@ -666,7 +666,7 @@ object ChapterProvider {
|
||||
} ?: 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 normal = Typeface.create(typeface, Typeface.NORMAL)
|
||||
|
Loading…
Reference in New Issue
Block a user