pull/63/head
kunfei 5 years ago
parent 1466e9dee8
commit 1de48788fe
  1. 4
      app/src/main/java/io/legado/app/help/BookHelp.kt
  2. 15
      app/src/main/java/io/legado/app/ui/download/DownloadAdapter.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/explore/ExploreAdapter.kt
  4. 6
      app/src/main/res/layout/item_find_book.xml
  5. 1
      app/src/main/res/values/strings.xml

@ -49,6 +49,10 @@ object BookHelp {
file.writeText(content) file.writeText(content)
} }
fun getChapterCount(book: Book): Int {
return FileHelp.getFolder(getBookFolder(book)).list()?.size ?: 0
}
fun hasContent(book: Book, bookChapter: BookChapter): Boolean { fun hasContent(book: Book, bookChapter: BookChapter): Boolean {
val filePath = getChapterPath(book, bookChapter) val filePath = getChapterPath(book, bookChapter)
runCatching { runCatching {

@ -1,10 +1,12 @@
package io.legado.app.ui.download package io.legado.app.ui.download
import android.content.Context import android.content.Context
import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.adapter.ItemViewHolder import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.Book import io.legado.app.data.entities.Book
import io.legado.app.help.BookHelp
import kotlinx.android.synthetic.main.item_download.view.* import kotlinx.android.synthetic.main.item_download.view.*
@ -13,9 +15,22 @@ class DownloadAdapter(context: Context) :
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
if (payloads.isEmpty()) {
tv_name.text = item.name tv_name.text = item.name
tv_author.text = item.author tv_author.text = item.author
upDownloadCount(this, item)
} else {
upDownloadCount(this, item)
} }
} }
}
private fun upDownloadCount(view: View, book: Book) {
view.tv_download.text = context.getString(
R.string.download_count,
BookHelp.getChapterCount(book),
book.totalChapterNum
)
}
} }

@ -9,7 +9,6 @@ import io.legado.app.base.adapter.ItemViewHolder
import io.legado.app.base.adapter.SimpleRecyclerAdapter import io.legado.app.base.adapter.SimpleRecyclerAdapter
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.lib.theme.ATH
import io.legado.app.lib.theme.accentColor import io.legado.app.lib.theme.accentColor
import io.legado.app.utils.ACache import io.legado.app.utils.ACache
import io.legado.app.utils.gone import io.legado.app.utils.gone
@ -29,7 +28,6 @@ class ExploreAdapter(context: Context, private val scope: CoroutineScope, val ca
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) { override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) {
with(holder.itemView) { with(holder.itemView) {
if (payloads.isEmpty()) { if (payloads.isEmpty()) {
ATH.applyBackgroundTint(ll_title)
tv_name.text = item.bookSourceName tv_name.text = item.bookSourceName
ll_title.onClick { ll_title.onClick {
val oldEx = exIndex val oldEx = exIndex

@ -18,11 +18,9 @@
android:paddingTop="6dp" android:paddingTop="6dp"
android:paddingBottom="6dp" android:paddingBottom="6dp"
android:layout_margin="4dp" android:layout_margin="4dp"
android:background="@color/background" android:background="@color/btn_bg_press"
android:elevation="3dp"
android:orientation="horizontal" android:orientation="horizontal"
android:gravity="center_vertical" android:gravity="center_vertical">
tools:ignore="UseCompoundDrawables">
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"

@ -208,6 +208,7 @@
<string name="download_start">开始下载</string> <string name="download_start">开始下载</string>
<string name="download_cancel">取消下载</string> <string name="download_cancel">取消下载</string>
<string name="no_download">暂无任务</string> <string name="no_download">暂无任务</string>
<string name="download_count">已下载 %d/%d</string>
<string name="import_select_book">导入选择书籍</string> <string name="import_select_book">导入选择书籍</string>
<string name="update_search_threads_num">更新和搜索线程数,如感觉卡顿请减小线程数,量力而行</string> <string name="update_search_threads_num">更新和搜索线程数,如感觉卡顿请减小线程数,量力而行</string>
<string name="change_icon">切换图标</string> <string name="change_icon">切换图标</string>

Loading…
Cancel
Save