From 924d44f737c3ab669969fb0e68455aa2a17a3fbf Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 4 Dec 2020 21:14:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/source/manage/BookSourceActivity.kt | 4 +++- .../app/ui/book/source/manage/BookSourceViewModel.kt | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt index 60b595ca2..ff4067850 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceActivity.kt @@ -100,7 +100,9 @@ class BookSourceActivity : VMBaseActivity startActivity() R.id.menu_import_source_qr -> startActivityForResult(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 diff --git a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt index 126d47dac..0a42eb737 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/manage/BookSourceViewModel.kt @@ -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) { + fun shareSelection(sources: List, 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) } }