diff --git a/app/build.gradle b/app/build.gradle index cae1dac53..f5886b609 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -117,7 +117,7 @@ dependencies { implementation 'com.google.android:flexbox:1.1.0' //lifecycle - def lifecycle_version = '2.1.0' + def lifecycle_version = '2.2.0' implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" diff --git a/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt b/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt index 42ffb491f..4dcd75776 100644 --- a/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/importbook/ImportBookActivity.kt @@ -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(R.layout.activity_import_book) { private val requestCodeSelectFolder = 342 private var rootDoc: DocumentFile? = null private val subDirs = arrayListOf() + private lateinit var importBookAdapter: ImportBookAdapter override val viewModel: ImportBookViewModel get() = getViewModel(ImportBookViewModel::class.java) @@ -42,15 +44,26 @@ class ImportBookActivity : VMBaseActivity(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) diff --git a/app/src/main/res/layout/activity_import_book.xml b/app/src/main/res/layout/activity_import_book.xml index abccf0f01..e3fd0cef3 100644 --- a/app/src/main/res/layout/activity_import_book.xml +++ b/app/src/main/res/layout/activity_import_book.xml @@ -21,7 +21,7 @@ android:orientation="horizontal">