修复简介多了几个空格的问题,是因为格式话做了缩进

pull/1090/head
gedoor 3 years ago
parent 029be1d6a8
commit 4e4b700c41
  1. 11
      app/src/main/java/io/legado/app/data/entities/SearchBook.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/explore/ExploreShowAdapter.kt
  3. 18
      app/src/main/java/io/legado/app/ui/book/search/SearchAdapter.kt

@ -1,7 +1,9 @@
package io.legado.app.data.entities package io.legado.app.data.entities
import android.content.Context
import android.os.Parcelable import android.os.Parcelable
import androidx.room.* import androidx.room.*
import io.legado.app.R
import io.legado.app.utils.GSON import io.legado.app.utils.GSON
import io.legado.app.utils.fromJsonObject import io.legado.app.utils.fromJsonObject
import kotlinx.parcelize.IgnoredOnParcel import kotlinx.parcelize.IgnoredOnParcel
@ -84,6 +86,15 @@ data class SearchBook(
return "无最新章节" return "无最新章节"
} }
fun trimIntro(context: Context): String {
val trimIntro = intro?.trim()
return if (trimIntro.isNullOrEmpty()) {
context.getString(R.string.intro_show_null)
} else {
context.getString(R.string.intro_show, trimIntro)
}
}
fun toBook() = Book( fun toBook() = Book(
name = name, name = name,
author = author, author = author,

@ -34,11 +34,7 @@ class ExploreShowAdapter(context: Context, val callBack: CallBack) :
tvLasted.text = context.getString(R.string.lasted_show, item.latestChapterTitle) tvLasted.text = context.getString(R.string.lasted_show, item.latestChapterTitle)
tvLasted.visible() tvLasted.visible()
} }
if (item.intro.isNullOrEmpty()) { tvIntroduce.text = item.trimIntro(context)
tvIntroduce.text = context.getString(R.string.intro_show_null)
} else {
tvIntroduce.text = context.getString(R.string.intro_show, item.intro)
}
val kinds = item.getKindList() val kinds = item.getKindList()
if (kinds.isEmpty()) { if (kinds.isEmpty()) {
llKind.gone() llKind.gone()

@ -79,13 +79,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
tvAuthor.text = context.getString(R.string.author_show, searchBook.author) tvAuthor.text = context.getString(R.string.author_show, searchBook.author)
bvOriginCount.setBadgeCount(searchBook.origins.size) bvOriginCount.setBadgeCount(searchBook.origins.size)
upLasted(binding, searchBook.latestChapterTitle) upLasted(binding, searchBook.latestChapterTitle)
if (searchBook.intro.isNullOrEmpty()) { tvIntroduce.text = searchBook.trimIntro(context)
tvIntroduce.text =
context.getString(R.string.intro_show_null)
} else {
tvIntroduce.text =
context.getString(R.string.intro_show, searchBook.intro)
}
upKind(binding, searchBook.getKindList()) upKind(binding, searchBook.getKindList())
ivCover.load(searchBook.coverUrl, searchBook.name, searchBook.author) ivCover.load(searchBook.coverUrl, searchBook.name, searchBook.author)
@ -98,15 +92,7 @@ class SearchAdapter(context: Context, val callBack: CallBack) :
when (it) { when (it) {
"origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size) "origins" -> bvOriginCount.setBadgeCount(searchBook.origins.size)
"last" -> upLasted(binding, searchBook.latestChapterTitle) "last" -> upLasted(binding, searchBook.latestChapterTitle)
"intro" -> { "intro" -> tvIntroduce.text = searchBook.trimIntro(context)
if (searchBook.intro.isNullOrEmpty()) {
tvIntroduce.text =
context.getString(R.string.intro_show_null)
} else {
tvIntroduce.text =
context.getString(R.string.intro_show, searchBook.intro)
}
}
"kind" -> upKind(binding, searchBook.getKindList()) "kind" -> upKind(binding, searchBook.getKindList())
"cover" -> ivCover.load( "cover" -> ivCover.load(
searchBook.coverUrl, searchBook.coverUrl,

Loading…
Cancel
Save