feat: 优化代码

pull/172/head
kunfei 5 years ago
parent 18cf6814bc
commit ed96e3addd
  1. 3
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/widget/TitleBar.kt
  3. 26
      app/src/main/res/layout-land/activity_book_info.xml
  4. 7
      app/src/main/res/layout/activity_book_info.xml

@ -57,8 +57,7 @@ class BookInfoActivity :
get() = getViewModel(BookInfoViewModel::class.java) get() = getViewModel(BookInfoViewModel::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
setSupportActionBar(toolbar) title_bar.transparent()
supportActionBar?.setDisplayHomeAsUpEnabled(true)
viewModel.bookData.observe(this, Observer { showBook(it) }) viewModel.bookData.observe(this, Observer { showBook(it) })
viewModel.chapterListData.observe(this, Observer { upLoading(false, it) }) viewModel.chapterListData.observe(this, Observer { upLoading(false, it) })
viewModel.initData(intent) viewModel.initData(intent)

@ -2,6 +2,7 @@ package io.legado.app.ui.widget
import android.content.Context import android.content.Context
import android.content.res.ColorStateList import android.content.res.ColorStateList
import android.graphics.Color
import android.util.AttributeSet import android.util.AttributeSet
import android.view.Menu import android.view.Menu
import android.view.View import android.view.View
@ -186,6 +187,11 @@ class TitleBar(context: Context, attrs: AttributeSet?) : AppBarLayout(context, a
toolbar.setSubtitleTextAppearance(context, resId) toolbar.setSubtitleTextAppearance(context, resId)
} }
fun transparent() {
elevation = 0f
backgroundColor = Color.TRANSPARENT
}
private fun attachToActivity() { private fun attachToActivity() {
if (attachToActivity) { if (attachToActivity) {
activity?.let { activity?.let {

@ -14,13 +14,10 @@
android:contentDescription="@string/bg_image" android:contentDescription="@string/bg_image"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.Toolbar <io.legado.app.ui.widget.TitleBar
android:id="@+id/toolbar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="?attr/actionBarStyle"
android:fitsSystemWindows="true"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:title="@string/book_info" /> app:title="@string/book_info" />
@ -81,7 +78,8 @@
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingTop="8dp" android:paddingTop="8dp"
android:paddingRight="16dp" android:paddingRight="16dp"
android:paddingBottom="3dp"> android:paddingBottom="3dp"
tools:ignore="RtlHardcoded">
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"
@ -147,14 +145,13 @@
android:layout_weight="1.0" android:layout_weight="1.0"
android:orientation="vertical" android:orientation="vertical"
android:layout_marginTop="65dp" android:layout_marginTop="65dp"
android:layout_marginLeft="1px"
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<ScrollView <ScrollView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_weight="1" android:layout_weight="1"
android:background="@color/background" android:background="@color/background"
android:fillViewport="true" android:fillViewport="true"
@ -162,7 +159,8 @@
android:focusable="true" android:focusable="true"
android:padding="0dp" android:padding="0dp"
android:scrollbarStyle="outsideInset" android:scrollbarStyle="outsideInset"
android:scrollbars="vertical"> android:scrollbars="vertical"
tools:ignore="NestedWeights">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -212,7 +210,7 @@
android:text="@string/origin_format" android:text="@string/origin_format"
android:textColor="@color/tv_text_summary" android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights" /> tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
<io.legado.app.ui.widget.text.AccentBgTextView <io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_change_source" android:id="@+id/tv_change_source"
@ -257,7 +255,7 @@
android:text="@string/read_dur_progress" android:text="@string/read_dur_progress"
android:textColor="@color/tv_text_summary" android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights" /> tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
</LinearLayout> </LinearLayout>
@ -290,7 +288,7 @@
android:text="@string/group_s" android:text="@string/group_s"
android:textColor="@color/tv_text_summary" android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights" /> tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
<io.legado.app.ui.widget.text.AccentBgTextView <io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_change_group" android:id="@+id/tv_change_group"
@ -334,7 +332,7 @@
android:text="@string/toc_s" android:text="@string/toc_s"
android:textColor="@color/tv_text_summary" android:textColor="@color/tv_text_summary"
android:textSize="13sp" android:textSize="13sp"
tools:ignore="NestedWeights" /> tools:ignore="NestedWeights,RtlHardcoded,RtlSymmetry" />
<io.legado.app.ui.widget.text.AccentBgTextView <io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_toc_view" android:id="@+id/tv_toc_view"
@ -373,7 +371,7 @@
android:layout_marginBottom="1px" android:layout_marginBottom="1px"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="8dp" android:layout_height="8dp"
android:background="@color/background"></View> android:background="@color/background" />
<LinearLayout <LinearLayout
android:id="@+id/fl_action" android:id="@+id/fl_action"

@ -21,13 +21,10 @@
android:background="#50000000" android:background="#50000000"
android:orientation="vertical"> android:orientation="vertical">
<androidx.appcompat.widget.Toolbar <io.legado.app.ui.widget.TitleBar
android:id="@+id/toolbar" android:id="@+id/title_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:theme="?attr/actionBarStyle"
android:fitsSystemWindows="true"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:title="@string/book_info" /> app:title="@string/book_info" />

Loading…
Cancel
Save