|
|
@ -72,7 +72,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV |
|
|
|
|
|
|
|
|
|
|
|
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { |
|
|
|
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { |
|
|
|
when (item.itemId) { |
|
|
|
when (item.itemId) { |
|
|
|
R.id.menu_select_folder -> selectFolder.launch(null) |
|
|
|
R.id.menu_select_folder -> selectFolder.launch {} |
|
|
|
R.id.menu_scan_folder -> scanFolder() |
|
|
|
R.id.menu_scan_folder -> scanFolder() |
|
|
|
R.id.menu_import_file_name -> alertImportFileName() |
|
|
|
R.id.menu_import_file_name -> alertImportFileName() |
|
|
|
} |
|
|
|
} |
|
|
@ -133,7 +133,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV |
|
|
|
when { |
|
|
|
when { |
|
|
|
lastPath.isNullOrEmpty() -> { |
|
|
|
lastPath.isNullOrEmpty() -> { |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
selectFolder.launch(null) |
|
|
|
selectFolder.launch {} |
|
|
|
} |
|
|
|
} |
|
|
|
lastPath.isContentScheme() -> { |
|
|
|
lastPath.isContentScheme() -> { |
|
|
|
val rootUri = Uri.parse(lastPath) |
|
|
|
val rootUri = Uri.parse(lastPath) |
|
|
@ -141,7 +141,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV |
|
|
|
val doc = DocumentFile.fromTreeUri(this, rootUri) |
|
|
|
val doc = DocumentFile.fromTreeUri(this, rootUri) |
|
|
|
if (doc == null || doc.name.isNullOrEmpty()) { |
|
|
|
if (doc == null || doc.name.isNullOrEmpty()) { |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
selectFolder.launch(null) |
|
|
|
selectFolder.launch {} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
subDocs.clear() |
|
|
|
subDocs.clear() |
|
|
|
rootDoc = FileDoc.fromDocumentFile(doc) |
|
|
|
rootDoc = FileDoc.fromDocumentFile(doc) |
|
|
@ -149,12 +149,12 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV |
|
|
|
} |
|
|
|
} |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
selectFolder.launch(null) |
|
|
|
selectFolder.launch {} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> { |
|
|
|
Build.VERSION.SDK_INT > Build.VERSION_CODES.Q -> { |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
selectFolder.launch(null) |
|
|
|
selectFolder.launch {} |
|
|
|
} |
|
|
|
} |
|
|
|
else -> initRootPath(lastPath) |
|
|
|
else -> initRootPath(lastPath) |
|
|
|
} |
|
|
|
} |
|
|
@ -172,7 +172,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV |
|
|
|
upPath() |
|
|
|
upPath() |
|
|
|
}.onFailure { |
|
|
|
}.onFailure { |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
binding.tvEmptyMsg.visible() |
|
|
|
selectFolder.launch(null) |
|
|
|
selectFolder.launch {} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
.request() |
|
|
|
.request() |
|
|
|