diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 5faef48df..ac969136e 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -237,6 +237,14 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea override fun loadContentFinish(bookChapter: BookChapter, content: String) { launch { + if (viewModel.durChapterIndex == bookChapter.index) { + tv_chapter_name.text = bookChapter.title + tv_chapter_name.visible() + if (!viewModel.isLocalBook) { + tv_chapter_url.text = bookChapter.url + tv_chapter_url.visible() + } + } val textChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) content_text_view.text = textChapter.pages[0].stringBuilder } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index faf91f119..978a06ab2 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -7,6 +7,7 @@ import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel +import io.legado.app.constant.BookType import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookChapter import io.legado.app.data.entities.BookSource @@ -17,10 +18,12 @@ import kotlinx.coroutines.Dispatchers.IO class ReadBookViewModel(application: Application) : BaseViewModel(application) { var bookData = MutableLiveData() - var bookSource: BookSource? = null var chapterMaxIndex = MediatorLiveData() + var bookSource: BookSource? = null var webBook: WebBook? = null var callBack: CallBack? = null + var durChapterIndex = 0 + var isLocalBook = true fun initData(intent: Intent) { val bookUrl = intent.getStringExtra("bookUrl") @@ -28,6 +31,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { execute { App.db.bookDao().getBook(bookUrl)?.let { book -> bookData.postValue(book) + durChapterIndex = book.durChapterIndex + isLocalBook = book.origin == BookType.local bookSource = App.db.bookSourceDao().getBookSource(book.origin) bookSource?.let { webBook = WebBook(it) diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt b/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt index 788ecc77e..680627567 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt @@ -8,9 +8,9 @@ import androidx.appcompat.widget.AppCompatTextView class ContentTextView : AppCompatTextView { constructor(context: Context) : super(context) - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) /** * 获取当前页总字数 diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt new file mode 100644 index 000000000..4f8abfa55 --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt @@ -0,0 +1,20 @@ +package io.legado.app.ui.widget.page + +import android.content.Context +import android.util.AttributeSet +import android.widget.FrameLayout +import io.legado.app.R + + +class ContentView : FrameLayout { + + constructor(context: Context) : super(context) + + constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) + + constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) + + init { + inflate(context, R.layout.view_book_page, this) + } +} \ No newline at end of file diff --git a/app/src/main/res/layout/activity_read_book.xml b/app/src/main/res/layout/activity_read_book.xml index e59480522..5c666055d 100644 --- a/app/src/main/res/layout/activity_read_book.xml +++ b/app/src/main/res/layout/activity_read_book.xml @@ -1,12 +1,12 @@ + android:layout_height="match_parent" + android:orientation="vertical"> + android:layout_width="match_parent" + android:layout_height="match_parent" /> + android:theme="?attr/actionBarStyle" + android:visibility="gone"> + android:textSize="12sp" + android:visibility="gone" /> + android:textSize="12sp" + android:visibility="gone" />