pull/49/head
kunfei 5 years ago
parent 270b78f65e
commit ccea3470fd
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  3. 21
      app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt
  4. 7
      app/src/main/res/layout/activity_book_read.xml
  5. 6
      app/src/main/res/layout/activity_main.xml

@ -40,7 +40,6 @@ import io.legado.app.ui.widget.page.TextChapter
import io.legado.app.ui.widget.page.delegate.PageDelegate
import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_book_read.*
import kotlinx.android.synthetic.main.view_book_page.*
import kotlinx.android.synthetic.main.view_read_menu.*
import kotlinx.android.synthetic.main.view_title_bar.*
import kotlinx.coroutines.Dispatchers.IO
@ -272,7 +271,7 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
when (bookChapter.index) {
viewModel.durChapterIndex -> launch {
viewModel.curTextChapter = ChapterProvider
.getTextChapter(content_text_view, bookChapter, content, viewModel.chapterSize)
.getTextChapter(bookChapter, content, viewModel.chapterSize)
page_view.upContent()
curChapterChanged()
if (intent.getBooleanExtra("readAloud", false)) {
@ -282,12 +281,12 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
}
viewModel.durChapterIndex - 1 -> launch {
viewModel.prevTextChapter = ChapterProvider
.getTextChapter(content_text_view, bookChapter, content, viewModel.chapterSize)
.getTextChapter(bookChapter, content, viewModel.chapterSize)
page_view.upContent(-1)
}
viewModel.durChapterIndex + 1 -> launch {
viewModel.nextTextChapter = ChapterProvider
.getTextChapter(content_text_view, bookChapter, content, viewModel.chapterSize)
.getTextChapter(bookChapter, content, viewModel.chapterSize)
page_view.upContent(1)
}
}
@ -560,7 +559,6 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
observeEvent<Boolean>(Bus.UP_CONFIG) {
upSystemUiVisibility()
page_view.upBg()
content_view.upStyle()
page_view.upStyle()
if (it) {
loadContent()

@ -97,6 +97,9 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
observeEvent<String>(Bus.RECREATE) {
recreate()
}
observeEvent<Boolean>(Bus.UP_CONFIG) {
content_view.upStyle()
}
}
private class TabFragmentPageAdapter internal constructor(fm: FragmentManager) :

@ -13,10 +13,13 @@ object ChapterProvider {
var readAloudSpan = ForegroundColorSpan(App.INSTANCE.accentColor)
private val titleSpan = RelativeSizeSpan(1.2f)
var textView: ContentTextView? = null
fun getTextChapter(
textView: ContentTextView, bookChapter: BookChapter,
bookChapter: BookChapter,
content: String, chapterSize: Int
): TextChapter {
textView?.let {
val textPages = arrayListOf<TextPage>()
val pageLines = arrayListOf<Int>()
val pageLengths = arrayListOf<Int>()
@ -35,9 +38,9 @@ object ChapterProvider {
)
}
}
textView.text = spannableStringBuilder
val lastLine = textView.getLineNum()
val lastCharNum = textView.getCharNum(lastLine)
it.text = spannableStringBuilder
val lastLine = it.getLineNum()
val lastCharNum = it.getCharNum(lastLine)
if (lastCharNum == 0) {
break
} else {
@ -71,6 +74,16 @@ object ChapterProvider {
pageLengths,
chapterSize
)
} ?: return TextChapter(
bookChapter.index,
bookChapter.title,
bookChapter.url,
arrayListOf(),
arrayListOf(),
arrayListOf(),
chapterSize
)
}
fun upReadAloudSpan() {

@ -4,18 +4,11 @@
android:layout_height="match_parent"
android:orientation="vertical">
<io.legado.app.ui.widget.page.ContentView
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
<io.legado.app.ui.widget.page.PageView
android:id="@+id/page_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<io.legado.app.ui.book.read.ReadMenu
android:id="@+id/read_menu"
android:layout_width="match_parent"

@ -4,6 +4,12 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.page.ContentView
android:id="@+id/content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation_view"
android:paddingLeft="5dp"

Loading…
Cancel
Save