From a62b75832b552962f1bd1a83a7fe542e0f1609fb Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 3 Oct 2019 15:58:09 +0800 Subject: [PATCH] up --- .../legado/app/ui/book/source/edit/BookSourceEditActivity.kt | 2 +- .../legado/app/ui/book/source/edit/BookSourceEditViewModel.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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)