|
|
|
@ -6,17 +6,13 @@ import io.legado.app.R |
|
|
|
|
import io.legado.app.base.adapter.ItemViewHolder |
|
|
|
|
import io.legado.app.base.adapter.SimpleRecyclerAdapter |
|
|
|
|
import io.legado.app.constant.AppConst |
|
|
|
|
import io.legado.app.utils.StringUtils |
|
|
|
|
import io.legado.app.utils.gone |
|
|
|
|
import io.legado.app.utils.invisible |
|
|
|
|
import io.legado.app.utils.visible |
|
|
|
|
import io.legado.app.utils.* |
|
|
|
|
import kotlinx.android.synthetic.main.item_import_book.view.* |
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
SimpleRecyclerAdapter<DocumentFile>(context, R.layout.item_import_book) { |
|
|
|
|
SimpleRecyclerAdapter<DocItem>(context, R.layout.item_import_book) { |
|
|
|
|
var selectedUris = linkedSetOf<String>() |
|
|
|
|
private var localUri = arrayListOf<String>() |
|
|
|
|
|
|
|
|
@ -26,9 +22,9 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
notifyDataSetChanged() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun convert(holder: ItemViewHolder, item: DocumentFile, payloads: MutableList<Any>) { |
|
|
|
|
override fun convert(holder: ItemViewHolder, item: DocItem, payloads: MutableList<Any>) { |
|
|
|
|
holder.itemView.apply { |
|
|
|
|
if (item.isDirectory) { |
|
|
|
|
if (item.isDir) { |
|
|
|
|
iv_icon.setImageResource(R.drawable.ic_folder) |
|
|
|
|
iv_icon.visible() |
|
|
|
|
cb_select.invisible() |
|
|
|
@ -43,15 +39,15 @@ class ImportBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
cb_select.visible() |
|
|
|
|
} |
|
|
|
|
ll_brief.visible() |
|
|
|
|
tv_tag.text = item.name?.substringAfterLast(".") |
|
|
|
|
tv_size.text = StringUtils.toSize(item.length()) |
|
|
|
|
tv_date.text = AppConst.DATE_FORMAT.format(Date(item.lastModified())) |
|
|
|
|
tv_tag.text = item.name.substringAfterLast(".") |
|
|
|
|
tv_size.text = StringUtils.toSize(item.size) |
|
|
|
|
tv_date.text = AppConst.DATE_FORMAT.format(item.date) |
|
|
|
|
} |
|
|
|
|
tv_name.text = item.name |
|
|
|
|
cb_select.isChecked = selectedUris.contains(item.uri.toString()) |
|
|
|
|
onClick { |
|
|
|
|
if (item.isDirectory) { |
|
|
|
|
callBack.nextDoc(item) |
|
|
|
|
if (item.isDir) { |
|
|
|
|
callBack.nextDoc(DocumentFile.fromTreeUri(context, item.uri)!!) |
|
|
|
|
} else { |
|
|
|
|
cb_select.isChecked = !cb_select.isChecked |
|
|
|
|
if (cb_select.isChecked) { |
|
|
|
|