|
|
@ -8,11 +8,13 @@ import android.view.MotionEvent |
|
|
|
import android.widget.FrameLayout |
|
|
|
import android.widget.FrameLayout |
|
|
|
import io.legado.app.help.ReadBookConfig |
|
|
|
import io.legado.app.help.ReadBookConfig |
|
|
|
import io.legado.app.ui.widget.page.delegate.CoverPageDelegate |
|
|
|
import io.legado.app.ui.widget.page.delegate.CoverPageDelegate |
|
|
|
|
|
|
|
import io.legado.app.ui.widget.page.delegate.NoAnmiPageDelegate |
|
|
|
import io.legado.app.ui.widget.page.delegate.PageDelegate |
|
|
|
import io.legado.app.ui.widget.page.delegate.PageDelegate |
|
|
|
import io.legado.app.ui.widget.page.delegate.SlidePageDelegate |
|
|
|
import io.legado.app.ui.widget.page.delegate.SlidePageDelegate |
|
|
|
import io.legado.app.utils.getPrefInt |
|
|
|
import io.legado.app.utils.getPrefInt |
|
|
|
|
|
|
|
|
|
|
|
class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), PageDelegate.PageInterface { |
|
|
|
class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), |
|
|
|
|
|
|
|
PageDelegate.PageInterface { |
|
|
|
|
|
|
|
|
|
|
|
var callback: CallBack? = null |
|
|
|
var callback: CallBack? = null |
|
|
|
private var pageDelegate: PageDelegate? = null |
|
|
|
private var pageDelegate: PageDelegate? = null |
|
|
@ -44,7 +46,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun isPrepared(): Boolean { |
|
|
|
override fun isPrepared(): Boolean { |
|
|
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. |
|
|
|
return true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun getChapterPosition(): Int { |
|
|
|
override fun getChapterPosition(): Int { |
|
|
@ -123,14 +125,10 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
it.moveToNext() |
|
|
|
it.moveToNext() |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
prevPage?.setContent(it.previousPage()) |
|
|
|
|
|
|
|
curPage?.setContent(it.currentPage()) |
|
|
|
|
|
|
|
nextPage?.setContent(it.nextPage()) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
upContent() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun setPageFactory(factory: TextPageFactory) { |
|
|
|
private fun setPageFactory(factory: TextPageFactory) { |
|
|
@ -143,6 +141,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
fun upPageAnim() { |
|
|
|
fun upPageAnim() { |
|
|
|
pageDelegate = when (context.getPrefInt("pageAnim")) { |
|
|
|
pageDelegate = when (context.getPrefInt("pageAnim")) { |
|
|
|
1 -> SlidePageDelegate(this) |
|
|
|
1 -> SlidePageDelegate(this) |
|
|
|
|
|
|
|
2 -> NoAnmiPageDelegate(this) |
|
|
|
else -> CoverPageDelegate(this) |
|
|
|
else -> CoverPageDelegate(this) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -155,12 +154,17 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun hasNext(): Boolean { |
|
|
|
fun moveToPrevPage(noAnim: Boolean = true) { |
|
|
|
return pageFactory?.hasNext() == true |
|
|
|
if (noAnim) { |
|
|
|
|
|
|
|
fillPage(PageDelegate.Direction.PREV) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun hasPrev(): Boolean { |
|
|
|
fun moveToNextPage(noAnim: Boolean = true) { |
|
|
|
return pageFactory?.hasPrev() == true |
|
|
|
if (noAnim) { |
|
|
|
|
|
|
|
fillPage(PageDelegate.Direction.NEXT) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun upStyle() { |
|
|
|
fun upStyle() { |
|
|
@ -190,6 +194,14 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
nextPage?.upBattery(battery) |
|
|
|
nextPage?.upBattery(battery) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun hasNext(): Boolean { |
|
|
|
|
|
|
|
return pageFactory?.hasNext() == true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun hasPrev(): Boolean { |
|
|
|
|
|
|
|
return pageFactory?.hasPrev() == true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun clickCenter() { |
|
|
|
override fun clickCenter() { |
|
|
|
callback?.clickCenter() |
|
|
|
callback?.clickCenter() |
|
|
|
} |
|
|
|
} |
|
|
@ -198,10 +210,26 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att |
|
|
|
fun chapterSize(): Int |
|
|
|
fun chapterSize(): Int |
|
|
|
fun durChapterIndex(): Int |
|
|
|
fun durChapterIndex(): Int |
|
|
|
fun durChapterPos(): Int |
|
|
|
fun durChapterPos(): Int |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* chapterOnDur: 0为当前页,1为下一页,-1为上一页 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun textChapter(chapterOnDur: Int = 0): TextChapter? |
|
|
|
fun textChapter(chapterOnDur: Int = 0): TextChapter? |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 加载章节内容, index章节序号 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun loadContent(index: Int) |
|
|
|
fun loadContent(index: Int) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 下一页 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun moveToNextChapter() |
|
|
|
fun moveToNextChapter() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 上一页 |
|
|
|
|
|
|
|
*/ |
|
|
|
fun moveToPrevChapter(last: Boolean = true) |
|
|
|
fun moveToPrevChapter(last: Boolean = true) |
|
|
|
|
|
|
|
|
|
|
|
fun setPageIndex(pageIndex: Int) |
|
|
|
fun setPageIndex(pageIndex: Int) |
|
|
|
fun clickCenter() |
|
|
|
fun clickCenter() |
|
|
|
} |
|
|
|
} |
|
|
|