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