feat: 优化代码

pull/103/head
kunfei 5 years ago
parent ab8f9fe3ca
commit 8c4e590ad0
  1. 25
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt
  2. 25
      app/src/main/java/io/legado/app/ui/explore/ExploreShowAdapter.kt
  3. 42
      app/src/main/res/layout/item_search.xml

@ -83,30 +83,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
ll_kind.gone() ll_kind.gone()
} else { } else {
ll_kind.visible() ll_kind.visible()
for (index in 0..2) { ll_kind.setLabels(kinds)
if (kinds.size > index) {
when (index) {
0 -> {
tv_kind.text = kinds[index]
tv_kind.visible()
}
1 -> {
tv_kind_1.text = kinds[index]
tv_kind_1.visible()
}
2 -> {
tv_kind_2.text = kinds[index]
tv_kind_2.visible()
}
}
} else {
when (index) {
0 -> tv_kind.gone()
1 -> tv_kind_1.gone()
2 -> tv_kind_2.gone()
}
}
}
} }
} }

@ -32,30 +32,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
ll_kind.gone() ll_kind.gone()
} else { } else {
ll_kind.visible() ll_kind.visible()
for (index in 0..2) { ll_kind.setLabels(kinds)
if (kinds.size > index) {
when (index) {
0 -> {
tv_kind.text = kinds[index]
tv_kind.visible()
}
1 -> {
tv_kind_1.text = kinds[index]
tv_kind_1.visible()
}
2 -> {
tv_kind_2.text = kinds[index]
tv_kind_2.visible()
}
}
} else {
when (index) {
0 -> tv_kind.gone()
1 -> tv_kind_1.gone()
2 -> tv_kind_2.gone()
}
}
}
} }
iv_cover.load(item.coverUrl, item.name, item.author) iv_cover.load(item.coverUrl, item.name, item.author)
onClick { onClick {

@ -58,49 +58,11 @@
android:textColor="@color/tv_text_default" android:textColor="@color/tv_text_default"
android:textSize="12sp" /> android:textSize="12sp" />
<LinearLayout <io.legado.app.ui.widget.LabelsBar
android:id="@+id/ll_kind" android:id="@+id/ll_kind"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal" />
<io.legado.app.ui.widget.text.AccentBgTextView
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:radius="2dp" />
<io.legado.app.ui.widget.text.AccentBgTextView
android:id="@+id/tv_kind_1"
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:radius="2dp" />
<io.legado.app.ui.widget.text.AccentBgTextView
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:radius="2dp" />
</LinearLayout>
<TextView <TextView
android:id="@+id/tv_lasted" android:id="@+id/tv_lasted"

Loading…
Cancel
Save