|
|
|
@ -13,12 +13,14 @@ import io.legado.app.base.VMBaseActivity |
|
|
|
|
import io.legado.app.help.AppConfig |
|
|
|
|
import io.legado.app.utils.getViewModel |
|
|
|
|
import kotlinx.android.synthetic.main.activity_import_book.* |
|
|
|
|
import java.io.File |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity_import_book) { |
|
|
|
|
private val requestCodeSelectFolder = 342 |
|
|
|
|
private var rootDoc: DocumentFile? = null |
|
|
|
|
private val subDirs = arrayListOf<String>() |
|
|
|
|
private lateinit var importBookAdapter: ImportBookAdapter |
|
|
|
|
|
|
|
|
|
override val viewModel: ImportBookViewModel |
|
|
|
|
get() = getViewModel(ImportBookViewModel::class.java) |
|
|
|
@ -42,15 +44,26 @@ class ImportBookActivity : VMBaseActivity<ImportBookViewModel>(R.layout.activity |
|
|
|
|
|
|
|
|
|
private fun initView() { |
|
|
|
|
recycler_view.layoutManager = LinearLayoutManager(this) |
|
|
|
|
importBookAdapter = ImportBookAdapter(this) |
|
|
|
|
recycler_view.adapter = importBookAdapter |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun upPath() { |
|
|
|
|
AppConfig.importBookPath?.let { |
|
|
|
|
val rootUri = Uri.parse(it) |
|
|
|
|
rootDoc = DocumentFile.fromTreeUri(this, rootUri) |
|
|
|
|
subDirs.clear() |
|
|
|
|
tv_path.text = getPath() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun getPath(): String { |
|
|
|
|
rootDoc?.let { |
|
|
|
|
return it.name + File.separator + subDirs.joinToString(File.separator) |
|
|
|
|
} |
|
|
|
|
return "" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun selectImportFolder() { |
|
|
|
|
try { |
|
|
|
|
val intent = Intent(Intent.ACTION_OPEN_DOCUMENT_TREE) |
|
|
|
|