|
|
@ -55,6 +55,7 @@ class BookInfoActivity : |
|
|
|
|
|
|
|
|
|
|
|
private val requestCodeChapterList = 568 |
|
|
|
private val requestCodeChapterList = 568 |
|
|
|
private val requestCodeSourceEdit = 562 |
|
|
|
private val requestCodeSourceEdit = 562 |
|
|
|
|
|
|
|
private val requestCodeRead = 432 |
|
|
|
|
|
|
|
|
|
|
|
override val viewModel: BookInfoViewModel |
|
|
|
override val viewModel: BookInfoViewModel |
|
|
|
get() = getViewModel(BookInfoViewModel::class.java) |
|
|
|
get() = getViewModel(BookInfoViewModel::class.java) |
|
|
@ -309,7 +310,8 @@ class BookInfoActivity : |
|
|
|
Pair("bookUrl", book.bookUrl), |
|
|
|
Pair("bookUrl", book.bookUrl), |
|
|
|
Pair("inBookshelf", viewModel.inBookshelf) |
|
|
|
Pair("inBookshelf", viewModel.inBookshelf) |
|
|
|
) |
|
|
|
) |
|
|
|
else -> startActivity<ReadBookActivity>( |
|
|
|
else -> startActivityForResult<ReadBookActivity>( |
|
|
|
|
|
|
|
requestCodeRead, |
|
|
|
Pair("bookUrl", book.bookUrl), |
|
|
|
Pair("bookUrl", book.bookUrl), |
|
|
|
Pair("inBookshelf", viewModel.inBookshelf), |
|
|
|
Pair("inBookshelf", viewModel.inBookshelf), |
|
|
|
Pair("key", IntentDataHelp.putData(book)) |
|
|
|
Pair("key", IntentDataHelp.putData(book)) |
|
|
@ -358,23 +360,29 @@ class BookInfoActivity : |
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { |
|
|
|
super.onActivityResult(requestCode, resultCode, data) |
|
|
|
super.onActivityResult(requestCode, resultCode, data) |
|
|
|
when (requestCode) { |
|
|
|
when (requestCode) { |
|
|
|
requestCodeSourceEdit -> if (resultCode == Activity.RESULT_OK) { |
|
|
|
requestCodeSourceEdit -> |
|
|
|
viewModel.upEditBook() |
|
|
|
if (resultCode == Activity.RESULT_OK) { |
|
|
|
} |
|
|
|
viewModel.upEditBook() |
|
|
|
requestCodeChapterList -> if (resultCode == Activity.RESULT_OK) { |
|
|
|
} |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
requestCodeChapterList -> |
|
|
|
data?.getIntExtra("index", it.durChapterIndex)?.let { index -> |
|
|
|
if (resultCode == Activity.RESULT_OK) { |
|
|
|
if (it.durChapterIndex != index) { |
|
|
|
viewModel.bookData.value?.let { |
|
|
|
it.durChapterIndex = index |
|
|
|
data?.getIntExtra("index", it.durChapterIndex)?.let { index -> |
|
|
|
it.durChapterPos = 0 |
|
|
|
if (it.durChapterIndex != index) { |
|
|
|
|
|
|
|
it.durChapterIndex = index |
|
|
|
|
|
|
|
it.durChapterPos = 0 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
startReadActivity(it) |
|
|
|
} |
|
|
|
} |
|
|
|
startReadActivity(it) |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!viewModel.inBookshelf) { |
|
|
|
|
|
|
|
viewModel.delBook() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
requestCodeRead -> if (resultCode == Activity.RESULT_OK) { |
|
|
|
if (!viewModel.inBookshelf) { |
|
|
|
viewModel.inBookshelf = true |
|
|
|
viewModel.delBook() |
|
|
|
upTvBookshelf() |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|