This commit is contained in:
Horis
2024-09-04 21:27:55 +08:00
parent 6534947b7e
commit 93a08627ec
@@ -227,24 +227,26 @@ class AudioPlayActivity :
} }
override fun finish() { override fun finish() {
AudioPlay.book?.let { val book = AudioPlay.book ?: return super.finish()
if (!AudioPlay.inBookshelf) {
if (!AppConfig.showAddToShelfAlert) { if (AudioPlay.inBookshelf) {
viewModel.removeFromBookshelf { super.finish() } return super.finish()
} else { }
alert(title = getString(R.string.add_to_bookshelf)) {
setMessage(getString(R.string.check_add_bookshelf, it.name)) if (!AppConfig.showAddToShelfAlert) {
okButton { viewModel.removeFromBookshelf { super.finish() }
AudioPlay.inBookshelf = true } else {
setResult(Activity.RESULT_OK) alert(title = getString(R.string.add_to_bookshelf)) {
} setMessage(getString(R.string.check_add_bookshelf, book.name))
noButton { viewModel.removeFromBookshelf { super.finish() } } okButton {
} AudioPlay.book?.removeType(BookType.notShelf)
AudioPlay.book?.save()
AudioPlay.inBookshelf = true
setResult(Activity.RESULT_OK)
} }
} else { noButton { viewModel.removeFromBookshelf { super.finish() } }
super.finish()
} }
} ?: super.finish() }
} }
override fun onDestroy() { override fun onDestroy() {