pull/49/head
kunfei 5 years ago
parent 53e1e028a0
commit e065ea45eb
  1. 41
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 330
      app/src/main/res/layout-land/activity_book_info.xml
  3. 91
      app/src/main/res/layout/activity_book_info.xml

@ -6,8 +6,6 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.BookType
@ -15,13 +13,11 @@ import io.legado.app.data.entities.Book
import io.legado.app.data.entities.BookChapter
import io.legado.app.help.ImageLoader
import io.legado.app.help.IntentDataHelp
import io.legado.app.lib.theme.ATH
import io.legado.app.ui.audio.AudioPlayActivity
import io.legado.app.ui.book.info.edit.BookInfoEditActivity
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.changesource.ChangeSourceDialog
import io.legado.app.utils.getCompatDrawable
import io.legado.app.utils.getViewModel
import io.legado.app.utils.gone
import io.legado.app.utils.visible
@ -38,11 +34,8 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
override val viewModel: BookInfoViewModel
get() = getViewModel(BookInfoViewModel::class.java)
private lateinit var adapter: ChapterListAdapter
override fun onActivityCreated(savedInstanceState: Bundle?) {
setSupportActionBar(toolbar)
initRecyclerView()
viewModel.bookData.observe(this, Observer { showBook(it) })
viewModel.isLoadingData.observe(this, Observer { upLoading(it) })
viewModel.chapterListData.observe(this, Observer { showChapter(it) })
@ -124,14 +117,11 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
private fun showChapter(chapterList: List<BookChapter>) {
viewModel.bookData.value?.let {
if (it.durChapterIndex < chapterList.size) {
tv_current_chapter_info.text = chapterList[it.durChapterIndex].title
tv_chapter.text = chapterList[it.durChapterIndex].title
} else {
tv_current_chapter_info.text = chapterList.last().title
tv_chapter.text = chapterList.last().title
}
}
adapter.clearItems()
adapter.addItems(chapterList)
rv_chapter_list.scrollToPosition(viewModel.durChapterIndex)
upLoading(false)
}
@ -148,20 +138,6 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
}
}
private fun initRecyclerView() {
adapter = ChapterListAdapter(this, this)
ATH.applyEdgeEffectColor(rv_chapter_list)
rv_chapter_list.layoutManager = LinearLayoutManager(this)
getCompatDrawable(R.drawable.recyclerview_item_divider)?.let { drawable ->
rv_chapter_list.addItemDecoration(
DividerItemDecoration(this, DividerItemDecoration.VERTICAL).apply {
setDrawable(drawable)
}
)
}
rv_chapter_list.adapter = adapter
}
private fun initOnClick() {
tv_read.onClick {
viewModel.bookData.value?.let {
@ -194,16 +170,11 @@ class BookInfoActivity : VMBaseActivity<BookInfoViewModel>(R.layout.activity_boo
ChangeSourceDialog.show(supportFragmentManager, it.name, it.author)
}
}
tv_current_chapter_info.onClick {
viewModel.bookData.value?.let {
rv_chapter_list.scrollToPosition(it.durChapterIndex)
}
}
iv_chapter_top.onClick {
rv_chapter_list.scrollToPosition(0)
tv_chapter.onClick {
}
iv_chapter_bottom.onClick {
rv_chapter_list.scrollToPosition(adapter.itemCount - 1)
tv_group.onClick {
}
}

@ -1,330 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<io.legado.app.ui.widget.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="@string/book_info"
app:layout_constraintTop_toTopOf="parent" />
<View
android:id="@+id/fg"
android:layout_width="1dp"
android:layout_height="0dp"
android:background="@color/btn_bg_press"
app:layout_constraintTop_toBottomOf="@+id/title_bar"
app:layout_constraintBottom_toTopOf="@id/fl_action"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<io.legado.app.ui.widget.image.CoverImageView
android:id="@+id/iv_cover"
android:layout_width="86dp"
android:layout_height="120dp"
android:layout_margin="10dp"
android:src="@drawable/image_cover_default"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title_bar" />
<LinearLayout
android:id="@+id/ll_book_info"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="@+id/iv_cover"
app:layout_constraintLeft_toRightOf="@+id/iv_cover"
app:layout_constraintRight_toLeftOf="@+id/fg"
app:layout_constraintBottom_toBottomOf="@+id/iv_cover">
<TextView
android:id="@+id/tv_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:singleLine="true"
android:textColor="@color/tv_text_default"
android:textSize="18sp" />
<TextView
android:id="@+id/tv_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:singleLine="true"
android:textSize="14sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_origin"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:singleLine="true"
android:textSize="14sp"
tools:ignore="NestedWeights" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
android:id="@+id/tv_change_source"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:text="@string/change_origin"
app:abt_radius="2dp" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_kind"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:orientation="horizontal"
android:visibility="gone">
<io.legado.app.lib.theme.view.ATEAccentBgTextView
android:id="@+id/tv_kind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
android:id="@+id/tv_kind_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
android:id="@+id/tv_kind_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:singleLine="true"
android:text="@string/app_name"
android:textSize="12sp"
app:abt_radius="2dp" />
</LinearLayout>
<TextView
android:id="@+id/tv_lasted"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:singleLine="true"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="@+id/iv_cover"
app:layout_constraintLeft_toLeftOf="@+id/tv_name"
app:layout_constraintRight_toRightOf="@id/tv_name" />
</LinearLayout>
<LinearLayout
android:id="@+id/view_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/iv_cover"
app:layout_constraintBottom_toTopOf="@+id/fl_action"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/fg">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/bg_divider_line" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
android:text="@string/book_intro"
android:textColor="@color/tv_text_default"
android:textSize="16sp" />
<TextView
android:id="@+id/tv_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:maxHeight="160dp"
android:minHeight="100dp"
android:scrollbars="vertical"
android:textIsSelectable="true"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:id="@+id/view_chapter"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/title_bar"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/fg">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:text="@string/chapter_list"
android:textColor="@color/tv_text_default"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/ll_chapter_base_info"
android:layout_width="match_parent"
android:layout_height="36dp"
android:elevation="5dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_constraintTop_toBottomOf="@+id/view_chapter">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/dur_pos" />
<TextView
android:id="@+id/tv_current_chapter_info"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:ellipsize="middle"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:textColor="@color/tv_text_default"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_chapter_top"
android:layout_width="36dp"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/go_to_top"
android:src="@drawable/ic_arrow_drop_up"
android:tooltipText="@string/go_to_top"
app:tint="@color/tv_text_default"
tools:ignore="UnusedAttribute" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_chapter_bottom"
android:layout_width="36dp"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/go_to_bottom"
android:src="@drawable/ic_arrow_drop_down"
android:tooltipText="@string/go_to_bottom"
app:tint="@color/tv_text_default"
tools:ignore="UnusedAttribute" />
</LinearLayout>
</LinearLayout>
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/rv_chapter_list"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/view_chapter"
app:layout_constraintBottom_toTopOf="@id/fl_action"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/fg" />
<FrameLayout
android:id="@+id/fl_action"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/background"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_shelf"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/remove_from_bookshelf"
android:textColor="@color/tv_text_default"
android:textSize="15sp" />
<io.legado.app.lib.theme.view.ATEAccentBgTextView
android:id="@+id/tv_read"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/selector_btn_accent_bg"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:includeFontPadding="false"
android:text="@string/reading"
android:textColor="@color/tv_text_button_nor"
android:textSize="15sp" />
</LinearLayout>
<TextView
android:id="@+id/tv_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/tv_text_button_nor"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:text="@string/data_loading"
android:textColor="#767676"
android:textSize="16sp" />
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/bg_divider_line" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

@ -140,10 +140,11 @@
<LinearLayout
android:id="@+id/view_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="10dp"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/iv_cover">
app:layout_constraintTop_toBottomOf="@+id/iv_cover"
app:layout_constraintBottom_toTopOf="@+id/view_other">
<View
android:layout_width="match_parent"
@ -161,7 +162,8 @@
<TextView
android:id="@+id/tv_intro"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:maxHeight="160dp"
@ -170,92 +172,41 @@
android:textIsSelectable="true"
android:textSize="12sp" />
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/bg_divider_line" />
</LinearLayout>
<LinearLayout
android:id="@+id/view_chapter"
android:id="@+id/view_other"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintTop_toBottomOf="@+id/view_info">
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@color/bg_divider_line" />
app:layout_constraintTop_toBottomOf="@+id/view_info"
app:layout_constraintBottom_toTopOf="@+id/fl_action">
<TextView
android:id="@+id/tv_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="8dp"
android:text="@string/chapter_list"
android:padding="12dp"
android:text="@string/group"
android:textColor="@color/tv_text_default"
android:textSize="16sp" />
<LinearLayout
android:id="@+id/ll_chapter_base_info"
android:layout_width="match_parent"
android:layout_height="36dp"
android:elevation="5dp"
android:gravity="center_vertical"
android:orientation="horizontal"
android:paddingLeft="10dp"
android:paddingRight="10dp"
app:layout_constraintTop_toBottomOf="@+id/view_chapter">
<TextView
android:layout_width="wrap_content"
android:id="@+id/tv_chapter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/dur_pos" />
<TextView
android:id="@+id/tv_current_chapter_info"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="?android:attr/selectableItemBackground"
android:ellipsize="middle"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:singleLine="true"
android:padding="12dp"
android:text="@string/chapter_list"
android:textColor="@color/tv_text_default"
android:textSize="14sp" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_chapter_top"
android:layout_width="36dp"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/go_to_top"
android:src="@drawable/ic_arrow_drop_up"
android:tooltipText="@string/go_to_top"
app:tint="@color/tv_text_default"
tools:ignore="UnusedAttribute" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_chapter_bottom"
android:layout_width="36dp"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/go_to_bottom"
android:src="@drawable/ic_arrow_drop_down"
android:tooltipText="@string/go_to_bottom"
app:tint="@color/tv_text_default"
tools:ignore="UnusedAttribute" />
</LinearLayout>
android:textSize="16sp" />
</LinearLayout>
<io.legado.app.ui.widget.recycler.scroller.FastScrollRecyclerView
android:id="@+id/rv_chapter_list"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@id/fl_action"
app:layout_constraintTop_toBottomOf="@+id/view_chapter" />
<FrameLayout
android:id="@+id/fl_action"
android:layout_width="match_parent"

Loading…
Cancel
Save