pull/32/head
kunfei 5 years ago
parent cc2d7be337
commit cdb4bcf5df
  1. 4
      app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt
  2. 10
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  3. 10
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt

@ -237,8 +237,8 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_rea
private fun bookLoadFinish() { private fun bookLoadFinish() {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
viewModel.loadContent(it, it.durChapterIndex) viewModel.loadContent(it, it.durChapterIndex)
viewModel.loadContent(it, it.durChapterIndex + 1) // viewModel.loadContent(it, it.durChapterIndex + 1)
viewModel.loadContent(it, it.durChapterIndex - 1) // viewModel.loadContent(it, it.durChapterIndex - 1)
} }
} }

@ -4,6 +4,9 @@ import android.content.Context
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.FrameLayout import android.widget.FrameLayout
import io.legado.app.R import io.legado.app.R
import io.legado.app.utils.dp
import kotlinx.android.synthetic.main.view_book_page.view.*
import org.jetbrains.anko.horizontalPadding
class ContentView : FrameLayout { class ContentView : FrameLayout {
@ -16,5 +19,12 @@ class ContentView : FrameLayout {
init { init {
inflate(context, R.layout.view_book_page, this) inflate(context, R.layout.view_book_page, this)
page_panel.horizontalPadding = 16.dp
}
fun setContent(text: CharSequence?) {
content_text_view.text = text
} }
} }

@ -7,13 +7,10 @@ import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.view.MotionEvent import android.view.MotionEvent
import android.widget.FrameLayout import android.widget.FrameLayout
import io.legado.app.R
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.PageDelegate import io.legado.app.ui.widget.page.delegate.PageDelegate
import io.legado.app.utils.dp
import kotlinx.android.synthetic.main.view_book_page.view.* import kotlinx.android.synthetic.main.view_book_page.view.*
import org.jetbrains.anko.backgroundColor import org.jetbrains.anko.backgroundColor
import org.jetbrains.anko.horizontalPadding
class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), PageDelegate.PageInterface { class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), PageDelegate.PageInterface {
@ -25,14 +22,13 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
private var nextPage: ContentView? = null private var nextPage: ContentView? = null
init { init {
inflate(context, R.layout.view_book_page, this) curPage = ContentView(context)
addView(curPage)
setWillNotDraw(false) setWillNotDraw(false)
page_panel.backgroundColor = Color.WHITE page_panel.backgroundColor = Color.WHITE
page_panel.horizontalPadding = 16.dp
pageDelegate = CoverPageDelegate(this) pageDelegate = CoverPageDelegate(this)
} }
@ -61,7 +57,7 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att
fun chapterLoadFinish() { fun chapterLoadFinish() {
callBack?.textChapter()?.let { callBack?.textChapter()?.let {
content_text_view.text = it.page(0)?.stringBuilder curPage?.setContent(it.page(0)?.stringBuilder)
} }
} }

Loading…
Cancel
Save