diff --git a/app/src/main/java/io/legado/app/data/entities/Book.kt b/app/src/main/java/io/legado/app/data/entities/Book.kt index 02c751114..2274a973c 100644 --- a/app/src/main/java/io/legado/app/data/entities/Book.kt +++ b/app/src/main/java/io/legado/app/data/entities/Book.kt @@ -9,6 +9,7 @@ import androidx.room.PrimaryKey import io.legado.app.constant.BookType import io.legado.app.utils.GSON import io.legado.app.utils.fromJsonObject +import io.legado.app.utils.splitNotBlank import kotlinx.android.parcel.IgnoredOnParcel import kotlinx.android.parcel.Parcelize import kotlin.math.max @@ -76,4 +77,16 @@ data class Book( variableMap?.put(key, value) variable = GSON.toJson(variableMap) } + + fun getKindList(): List { + val kindList = arrayListOf() + wordCount?.let { + if (it.isNotBlank()) kindList.add(it) + } + kind?.let { + val kinds = it.splitNotBlank(",", "\n") + kindList.addAll(kinds) + } + return kindList + } } \ No newline at end of file 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 6b27b6562..104a52dda 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 @@ -7,6 +7,8 @@ import io.legado.app.base.VMBaseActivity import io.legado.app.data.entities.Book import io.legado.app.help.ImageLoader import io.legado.app.utils.getViewModel +import io.legado.app.utils.gone +import io.legado.app.utils.visible import kotlinx.android.synthetic.main.activity_book_info.* class BookInfoActivity : VMBaseActivity(R.layout.activity_book_info) { @@ -31,6 +33,36 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo .centerCrop() .setAsDrawable(iv_cover) } + val kinds = book.getKindList() + if (kinds.isEmpty()) { + ll_kind.gone() + } else { + ll_kind.visible() + for (index in 0..2) { + 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() + } + } + } + } } diff --git a/app/src/main/res/layout/activity_book_info.xml b/app/src/main/res/layout/activity_book_info.xml index 760019f21..02ceb64a8 100644 --- a/app/src/main/res/layout/activity_book_info.xml +++ b/app/src/main/res/layout/activity_book_info.xml @@ -21,45 +21,90 @@ app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toBottomOf="@+id/title_bar" /> - + app:layout_constraintRight_toRightOf="parent" + app:layout_constraintBottom_toBottomOf="@+id/iv_cover"> - + - + - + + + + + + + + + + + + + + +