|
|
@ -7,6 +7,7 @@ import io.legado.app.base.adapter.SimpleRecyclerAdapter |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.Book |
|
|
|
import kotlinx.android.synthetic.main.item_download.view.* |
|
|
|
import kotlinx.android.synthetic.main.item_download.view.* |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
|
|
|
import org.jetbrains.anko.toast |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DownloadAdapter(context: Context, private val callBack: CallBack) : |
|
|
|
class DownloadAdapter(context: Context, private val callBack: CallBack) : |
|
|
@ -36,9 +37,16 @@ class DownloadAdapter(context: Context, private val callBack: CallBack) : |
|
|
|
|
|
|
|
|
|
|
|
override fun registerListener(holder: ItemViewHolder) { |
|
|
|
override fun registerListener(holder: ItemViewHolder) { |
|
|
|
holder.itemView.tv_export.onClick { |
|
|
|
holder.itemView.tv_export.onClick { |
|
|
|
|
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
|
|
|
|
val cacheSize = cacheChapters[it.bookUrl]?.size ?: 0 |
|
|
|
|
|
|
|
if (cacheSize < it.totalChapterNum) { |
|
|
|
|
|
|
|
context.toast("未下载完成") |
|
|
|
|
|
|
|
} else { |
|
|
|
callBack.export(holder.layoutPosition) |
|
|
|
callBack.export(holder.layoutPosition) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|
fun export(position: Int) |
|
|
|
fun export(position: Int) |
|
|
|