From 7f694ccdad7b916c393489371d41fcdc2d4d196b Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 19 Aug 2019 17:12:40 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/bookinfo/BookInfoActivity.kt | 4 ++++ .../io/legado/app/ui/bookinfo/BookInfoViewModel.kt | 6 ------ .../legado/app/ui/changesource/ChangeSourceDialog.kt | 12 +++++++++++- .../io/legado/app/ui/readbook/ReadBookActivity.kt | 4 ++++ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt index 36ed1d254..c2a8de623 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoActivity.kt @@ -189,6 +189,10 @@ class BookInfoActivity : VMBaseActivity(R.layout.activity_boo } } + override fun oldBook(): Book? { + return viewModel.bookData.value + } + override fun changeTo(book: Book) { viewModel.changeTo(book) } diff --git a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt index 672f36d01..a4f7a1b53 100644 --- a/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/bookinfo/BookInfoViewModel.kt @@ -82,12 +82,6 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) { } fun changeTo(book: Book) { - bookData.value?.let { - book.durChapterIndex = it.durChapterIndex - book.durChapterPos = it.durChapterPos - book.customCoverUrl = it.customCoverUrl - book.customIntro = it.customIntro - } execute { if (inBookshelf) { bookData.value?.let { diff --git a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt index a7d457c1f..c66e7ba9c 100644 --- a/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt @@ -109,7 +109,16 @@ class ChangeSourceDialog : DialogFragment(), } override fun changeTo(searchBook: SearchBook) { - callBack?.changeTo(searchBook.toBook()) + callBack?.let { + val book = searchBook.toBook() + it.oldBook()?.let { oldBook -> + book.durChapterIndex = oldBook.durChapterIndex + book.durChapterPos = oldBook.durChapterPos + book.customCoverUrl = oldBook.customCoverUrl + book.customIntro = oldBook.customIntro + } + it.changeTo(book) + } dismiss() } @@ -122,6 +131,7 @@ class ChangeSourceDialog : DialogFragment(), } interface CallBack { + fun oldBook(): Book? fun changeTo(book: Book) } diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index 724d7b2c7..204c7f9e9 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -267,6 +267,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } } + override fun oldBook(): Book? { + return viewModel.bookData.value + } + override fun changeTo(book: Book) { }