pull/69/head
kunfei 5 years ago
parent 454e5395ee
commit 2d74a38d08
  1. 12
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  2. 1
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt

@ -80,7 +80,7 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
R.id.menu_disable_selection -> viewModel.disableSelection(adapter.getSelectionIds())
R.id.menu_del_selection -> viewModel.delSelection(adapter.getSelectionIds())
R.id.menu_export_selection -> viewModel.exportSelection(adapter.getSelectionIds())
R.id.menu_import_source_local -> selectFile()
R.id.menu_import_source_local -> selectFileSys()
R.id.menu_import_source_onLine -> showImportDialog()
R.id.menu_import_source_qr -> startActivityForResult<QrCodeActivity>(qrRequestCode)
R.id.menu_group_manage -> GroupManageDialog()
@ -203,10 +203,14 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
}
private fun selectFileSys() {
try {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.addCategory(Intent.CATEGORY_OPENABLE)
intent.type = "text/*"//设置类型
startActivityForResult(intent, importSource)
} catch (e: Exception) {
selectFile()
}
}
override fun onMenuClick(menu: String) {
@ -229,11 +233,11 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
super.onActivityResult(requestCode, resultCode, data)
when (requestCode) {
importSource -> if (resultCode == Activity.RESULT_OK) {
data?.data?.let {
FileUtils.getPath(this, it)?.let { path ->
data?.data?.let { uri ->
uri.readText(this)?.let {
Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE)
.show()
viewModel.importSourceFromFilePath(path) { msg ->
viewModel.importSource(it) { msg ->
title_bar.snackbar(msg)
}
}

@ -115,7 +115,6 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
}
}
fun importSourceFromFilePath(path: String, finally: (msg: String) -> Unit) {
execute {
val file = File(path)

Loading…
Cancel
Save