diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt index 153e3fcb8..267890628 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditActivity.kt @@ -54,7 +54,7 @@ class BookSourceEditActivity : viewModel.sourceLiveData.observe(this, Observer { upRecyclerView(it) }) - viewModel.setBookSource(intent.getStringExtra("data")) + viewModel.initData(intent) } override fun onDestroy() { diff --git a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt index 1202f74f2..61cc49858 100644 --- a/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/source/edit/BookSourceEditViewModel.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.book.source.edit import android.app.Application import android.content.ClipboardManager import android.content.Context +import android.content.Intent import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.base.BaseViewModel @@ -14,8 +15,9 @@ class BookSourceEditViewModel(application: Application) : BaseViewModel(applicat val sourceLiveData: MutableLiveData = MutableLiveData() var oldSourceUrl: String? = null - fun setBookSource(key: String?) { + fun initData(intent: Intent) { execute { + val key = intent.getStringExtra("data") var source: BookSource? = null if (key != null) { source = App.db.bookSourceDao().getBookSource(key)