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