diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index 599a26acc..b1998cfb5 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt @@ -24,6 +24,9 @@ import kotlinx.android.synthetic.main.activity_book_info.* import kotlinx.android.synthetic.main.view_title_bar.* import org.jetbrains.anko.sdk27.listeners.onClick import org.jetbrains.anko.startActivity +import androidx.recyclerview.widget.RecyclerView + + class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info), ChapterListAdapter.CallBack, @@ -82,7 +85,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo tv_author.text = getString(R.string.author_show, book.author) tv_origin.text = getString(R.string.origin_show, book.originName) tv_lasted.text = getString(R.string.lasted_show, book.latestChapterTitle) - tv_intro.text = getString(R.string.intro_show, book.getDisplayIntro()) + tv_intro.text = book.getDisplayIntro(); // getString(R.string.intro_show, book.getDisplayIntro()) book.getDisplayCover()?.let { ImageLoader.load(this, it) .placeholder(R.drawable.img_cover_default) @@ -153,10 +156,16 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo adapter = ChapterListAdapter(this, this) ATH.applyEdgeEffectColor(rv_chapter_list) rv_chapter_list.layoutManager = LinearLayoutManager(this) - rv_chapter_list.addItemDecoration(DividerItemDecoration(this, LinearLayout.VERTICAL)) + rv_chapter_list.addItemDecoration(getRecyclerViewDivider()) rv_chapter_list.adapter = adapter } + private fun getRecyclerViewDivider(): RecyclerView.ItemDecoration { + val itemDecoration = DividerItemDecoration(this, DividerItemDecoration.VERTICAL) + itemDecoration.setDrawable(resources.getDrawable(R.drawable.recyclerview_item_divider)) + return itemDecoration + } + private fun initOnClick() { tv_read.onClick { viewModel.bookData.value?.let { @@ -195,12 +204,8 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo } } iv_chapter_top.onClick { - rv_chapter_list.scrollToPosition(0) - } - iv_chapter_bottom.onClick { - viewModel.chapterListData.value?.let { - rv_chapter_list.scrollToPosition(it.size - 1) - } + adapter.reorder = !adapter.reorder; + adapter.notifyDataSetChanged(); } } diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt index 31468c980..3b2edf158 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/ChapterListAdapter.kt @@ -13,16 +13,22 @@ import org.jetbrains.anko.textColorResource class ChapterListAdapter(context: Context, var callBack: CallBack) : SimpleRecyclerAdapter(context, R.layout.item_chapter_list) { + var reorder: Boolean = false; // 是否倒序 + override fun convert(holder: ItemViewHolder, item: BookChapter, payloads: MutableList) { holder.itemView.apply { - tv_chapter_name.text = item.title - if (item.index == callBack.durChapterIndex()) { + var _item: BookChapter = item; + if (reorder) { + _item = getItems().get(getItems().size - item.index - 1); + } + tv_chapter_name.text = _item.title + if (_item.index == callBack.durChapterIndex()) { tv_chapter_name.setTextColor(context.accentColor) } else { - tv_chapter_name.textColorResource = R.color.tv_text_default + tv_chapter_name.textColorResource = R.color.tv_text_secondary } this.onClick { - callBack.openChapter(item) + callBack.openChapter(_item) } } } diff --git a/app/src/main/res/drawable/bg_chapter_item_divider.xml b/app/src/main/res/drawable/bg_chapter_item_divider.xml index a8bce5ae4..38db10eaf 100644 --- a/app/src/main/res/drawable/bg_chapter_item_divider.xml +++ b/app/src/main/res/drawable/bg_chapter_item_divider.xml @@ -2,7 +2,7 @@ diff --git a/app/src/main/res/drawable/ic_divider.xml b/app/src/main/res/drawable/ic_divider.xml index 7515c3960..1ecb2d6d8 100644 --- a/app/src/main/res/drawable/ic_divider.xml +++ b/app/src/main/res/drawable/ic_divider.xml @@ -1,6 +1,6 @@ - + diff --git a/app/src/main/res/drawable/ic_exchange_order.xml b/app/src/main/res/drawable/ic_exchange_order.xml new file mode 100644 index 000000000..36c2bcefc --- /dev/null +++ b/app/src/main/res/drawable/ic_exchange_order.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/recyclerview_item_divider.xml b/app/src/main/res/drawable/recyclerview_item_divider.xml new file mode 100644 index 000000000..cf8d2882a --- /dev/null +++ b/app/src/main/res/drawable/recyclerview_item_divider.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_btn_accent_bg.xml b/app/src/main/res/drawable/selector_btn_accent_bg.xml new file mode 100644 index 000000000..a888e77e0 --- /dev/null +++ b/app/src/main/res/drawable/selector_btn_accent_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/selector_btn_write_bg.xml b/app/src/main/res/drawable/selector_btn_write_bg.xml new file mode 100644 index 000000000..8ba143cb2 --- /dev/null +++ b/app/src/main/res/drawable/selector_btn_write_bg.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 8ddbb5cd7..a54649937 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -13,46 +13,58 @@ app:title="@string/book_info" app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintTop_toBottomOf="@+id/title_bar" + app:cardCornerRadius="5.0dp" + android:layout_margin="12dp" + android:layout_width="wrap_content" + android:layout_height="wrap_content"> + + + + + android:minHeight="115dp" + android:paddingBottom="8dp" + app:layout_constraintTop_toTopOf="@+id/iv_cover_s" + app:layout_constraintLeft_toRightOf="@+id/iv_cover_s" + app:layout_constraintRight_toRightOf="parent"> + android:layout_marginBottom="12dp" + android:textColor="@color/tv_text_default" + android:textSize="18sp" /> @@ -119,113 +133,162 @@ - - - - + android:layout_height="wrap_content"> + + + android:textSize="16sp" + android:textColor="@color/tv_text_default" + android:text="简介" + android:padding="8dp" + android:layout_width="match_parent" + android:layout_height="wrap_content" /> + + + + + + + + + + + + + + + android:orientation="horizontal" + app:layout_constraintTop_toBottomOf="@+id/view_chapter"> + + + + + + + - - - + + + android:orientation="horizontal"> - - - + android:layout_height="1px" /> + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 8bd010541..59b1bea6c 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -40,7 +40,7 @@ #aaaaaaaa - #FFD4D4D4 + #8fe0e0e0 #19000000 #f4f4f4 @@ -50,6 +50,10 @@ #000000 #ffffff + + #ffffffff + #efe0e0e0 +