pull/48/head
kunfei 5 years ago
parent 7e65dceb53
commit 15263ffdb8
  1. 22
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceViewModel.kt

@ -15,6 +15,7 @@ import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.ItemTouchHelper import androidx.recyclerview.widget.ItemTouchHelper
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.google.android.material.snackbar.Snackbar
import io.legado.app.App import io.legado.app.App
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
@ -184,7 +185,10 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
cacheUrls.add(0, it) cacheUrls.add(0, it)
aCache.put("sourceUrl", cacheUrls.joinToString(",")) aCache.put("sourceUrl", cacheUrls.joinToString(","))
} }
viewModel.importSource(it) Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show()
viewModel.importSource(it) { msg ->
title_bar.snackbar(msg)
}
} }
} }
cancelButton() cancelButton()
@ -215,7 +219,10 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
override fun onFilePicked(requestCode: Int, currentPath: String) { override fun onFilePicked(requestCode: Int, currentPath: String) {
if (requestCode == importSource) { if (requestCode == importSource) {
viewModel.importSourceFromFilePath(currentPath) Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE).show()
viewModel.importSourceFromFilePath(currentPath) { msg ->
title_bar.snackbar(msg)
}
} }
} }
@ -225,13 +232,20 @@ class RssSourceActivity : VMBaseActivity<RssSourceViewModel>(R.layout.activity_r
importSource -> if (resultCode == Activity.RESULT_OK) { importSource -> if (resultCode == Activity.RESULT_OK) {
data?.data?.let { data?.data?.let {
FileUtils.getPath(this, it)?.let { path -> FileUtils.getPath(this, it)?.let { path ->
viewModel.importSourceFromFilePath(path) Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE)
.show()
viewModel.importSourceFromFilePath(path) { msg ->
title_bar.snackbar(msg)
}
} }
} }
} }
qrRequestCode -> if (resultCode == RESULT_OK) { qrRequestCode -> if (resultCode == RESULT_OK) {
data?.getStringExtra("result")?.let { data?.getStringExtra("result")?.let {
viewModel.importSource(it) Snackbar.make(title_bar, R.string.importing, Snackbar.LENGTH_INDEFINITE)
viewModel.importSource(it) { msg ->
title_bar.snackbar(msg)
}
} }
} }
} }

@ -97,7 +97,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
fun importSourceFromFilePath(path: String) { fun importSourceFromFilePath(path: String, finally: (msg: String) -> Unit) {
execute { execute {
val file = File(path) val file = File(path)
if (file.exists()) { if (file.exists()) {
@ -108,7 +108,7 @@ class RssSourceViewModel(application: Application) : BaseViewModel(application)
} }
} }
fun importSource(sourceStr: String) { fun importSource(sourceStr: String, finally: (msg: String) -> Unit) {
} }
} }
Loading…
Cancel
Save