|
|
|
@ -15,8 +15,13 @@ import io.legado.app.App |
|
|
|
|
import io.legado.app.R |
|
|
|
|
import io.legado.app.base.VMBaseActivity |
|
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
|
import io.legado.app.lib.theme.accentColor |
|
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
|
import kotlinx.android.synthetic.main.activity_import_book.* |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
|
import kotlinx.coroutines.Dispatchers.Main |
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
@ -55,6 +60,7 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
recycler_view.layoutManager = LinearLayoutManager(this) |
|
|
|
|
importBookAdapter = ImportBookAdapter(this, this) |
|
|
|
|
recycler_view.adapter = importBookAdapter |
|
|
|
|
rotate_loading.loadingColor = accentColor |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun initEvent() { |
|
|
|
@ -98,7 +104,9 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
} |
|
|
|
|
tv_path.text = path |
|
|
|
|
importBookAdapter.selectedUris.clear() |
|
|
|
|
|
|
|
|
|
importBookAdapter.clearItems() |
|
|
|
|
rotate_loading.show() |
|
|
|
|
launch(IO) { |
|
|
|
|
val docList = arrayListOf<DocumentFile>() |
|
|
|
|
lastDoc.listFiles().forEach { |
|
|
|
|
if (it.isDirectory && it.name?.startsWith(".") == false) { |
|
|
|
@ -108,9 +116,13 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
docList.sortWith(compareBy({ !it.isDirectory }, { it.name })) |
|
|
|
|
withContext(Main) { |
|
|
|
|
rotate_loading.hide() |
|
|
|
|
importBookAdapter.setItems(docList) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun selectImportFolder() { |
|
|
|
|
try { |
|
|
|
|