pull/517/head
gedoor 4 years ago
parent 448c9077d7
commit 924d44f737
  1. 4
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt
  2. 7
      app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt

@ -100,7 +100,9 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
when (item.itemId) {
R.id.menu_add_book_source -> startActivity<BookSourceEditActivity>()
R.id.menu_import_source_qr -> startActivityForResult<QrCodeActivity>(qrRequestCode)
R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection())
R.id.menu_share_source -> viewModel.shareSelection(adapter.getSelection()) {
startActivity(Intent.createChooser(it, getString(R.string.share_selected_source)))
}
R.id.menu_group_manage ->
GroupManageDialog().show(supportFragmentManager, "groupManage")
R.id.menu_import_source_local -> FilePicker

@ -7,7 +7,6 @@ import androidx.core.content.FileProvider
import androidx.documentfile.provider.DocumentFile
import io.legado.app.App
import io.legado.app.BuildConfig
import io.legado.app.R
import io.legado.app.base.BaseViewModel
import io.legado.app.constant.AppPattern
import io.legado.app.data.entities.BookSource
@ -167,7 +166,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
}
}
fun shareSelection(sources: List<BookSource>) {
fun shareSelection(sources: List<BookSource>, success: ((intent: Intent) -> Unit)) {
execute {
val intent = Intent(Intent.ACTION_SEND)
val file = FileUtils.createFileWithReplace("${context.filesDir}/shareBookSource.json")
@ -183,9 +182,7 @@ class BookSourceViewModel(application: Application) : BaseViewModel(application)
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent
}.onSuccess {
context.startActivity(
Intent.createChooser(it, context.getString(R.string.share_selected_source))
)
success.invoke(it)
}
}

Loading…
Cancel
Save