优化代码

pull/743/head
gedoor 4 years ago
parent 9e63f6aa70
commit 57fb85036d
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/ReadBookBaseActivity.kt
  2. 1
      app/src/main/java/io/legado/app/ui/book/toc/BookmarkAdapter.kt
  3. 3
      app/src/main/java/io/legado/app/ui/book/toc/ChapterListFragment.kt
  4. 8
      app/src/main/res/layout/item_bookmark.xml

@ -206,7 +206,7 @@ abstract class ReadBookBaseActivity :
val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply { val alertBinding = DialogEditTextBinding.inflate(layoutInflater).apply {
editView.setHint(R.string.note_content) editView.setHint(R.string.note_content)
} }
message = book.name + "" + textChapter.title message = bookmark.bookText
customView = alertBinding.root customView = alertBinding.root
yesButton { yesButton {
alertBinding.editView.text?.toString()?.let { editContent -> alertBinding.editView.text?.toString()?.let { editContent ->

@ -44,6 +44,7 @@ class BookmarkAdapter(val callback: Callback) : PagedListAdapter<Bookmark, Bookm
fun bind(bookmark: Bookmark, callback: Callback?) = with(binding) { fun bind(bookmark: Bookmark, callback: Callback?) = with(binding) {
tvChapterName.text = bookmark.chapterName tvChapterName.text = bookmark.chapterName
tvBookText.text = bookmark.bookText
tvContent.text = bookmark.content tvContent.text = bookmark.content
itemView.onClick { itemView.onClick {
callback?.onClick(bookmark) callback?.onClick(bookmark)

@ -27,6 +27,7 @@ import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext import kotlinx.coroutines.withContext
import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.sdk27.listeners.onClick
import kotlin.math.min
class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list), class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragment_chapter_list),
ChapterListAdapter.Callback, ChapterListAdapter.Callback,
@ -134,7 +135,7 @@ class ChapterListFragment : VMBaseFragment<ChapterListViewModel>(R.layout.fragme
get() = viewModel.book?.isLocalBook() == true get() = viewModel.book?.isLocalBook() == true
override fun durChapterIndex(): Int { override fun durChapterIndex(): Int {
return durChapterIndex return min(durChapterIndex, adapter.itemCount)
} }
override fun openChapter(bookChapter: BookChapter) { override fun openChapter(bookChapter: BookChapter) {

@ -13,6 +13,14 @@
android:padding="4dp" android:padding="4dp"
android:singleLine="true" /> android:singleLine="true" />
<TextView
android:id="@+id/tv_book_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="4dp"
android:textSize="12sp"
android:singleLine="true" />
<TextView <TextView
android:id="@+id/tv_content" android:id="@+id/tv_content"
android:layout_width="match_parent" android:layout_width="match_parent"

Loading…
Cancel
Save