From 8bb4f19b9d408425eb5241bd45503f9cfa44434d Mon Sep 17 00:00:00 2001 From: yangyxd Date: Tue, 10 Sep 2019 17:52:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B9=A6=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/bookinfo/BookInfoActivity.kt | 22 +- .../app/ui/bookinfo/ChapterListAdapter.kt | 2 +- .../res/drawable/bg_chapter_item_divider.xml | 2 +- app/src/main/res/drawable/ic_divider.xml | 2 +- .../main/res/drawable/ic_exchange_order.xml | 11 + .../drawable/recyclerview_item_divider.xml | 12 + .../res/drawable/selector_btn_accent_bg.xml | 5 + .../res/drawable/selector_btn_write_bg.xml | 5 + .../main/res/layout/activity_book_info.xml | 264 +++++++++++------- app/src/main/res/values/colors.xml | 6 +- 10 files changed, 214 insertions(+), 117 deletions(-) create mode 100644 app/src/main/res/drawable/ic_exchange_order.xml create mode 100644 app/src/main/res/drawable/recyclerview_item_divider.xml create mode 100644 app/src/main/res/drawable/selector_btn_accent_bg.xml create mode 100644 app/src/main/res/drawable/selector_btn_write_bg.xml 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..1ca198a1e 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, @@ -33,6 +36,7 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo private var changeSourceDialog: ChangeSourceDialog? = null private lateinit var adapter: ChapterListAdapter + private var reorder: Boolean = false; // 是否倒序 override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) @@ -82,7 +86,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 +157,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 +205,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) - } + reorder = !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..d6851e193 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 @@ -19,7 +19,7 @@ class ChapterListAdapter(context: Context, var callBack: CallBack) : 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) 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 +