|
|
|
@ -47,7 +47,9 @@ import org.koitharu.kotatsu.search.ui.global.GlobalSearchActivity
|
|
|
|
import org.koitharu.kotatsu.utils.ShareHelper
|
|
|
|
import org.koitharu.kotatsu.utils.ShareHelper
|
|
|
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
|
|
|
import org.koitharu.kotatsu.utils.ext.getDisplayMessage
|
|
|
|
|
|
|
|
|
|
|
|
class DetailsActivity : BaseActivity<ActivityDetailsBinding>(), TabLayoutMediator.TabConfigurationStrategy,
|
|
|
|
class DetailsActivity :
|
|
|
|
|
|
|
|
BaseActivity<ActivityDetailsBinding>(),
|
|
|
|
|
|
|
|
TabLayoutMediator.TabConfigurationStrategy,
|
|
|
|
AdapterView.OnItemSelectedListener {
|
|
|
|
AdapterView.OnItemSelectedListener {
|
|
|
|
|
|
|
|
|
|
|
|
private val viewModel by viewModel<DetailsViewModel> {
|
|
|
|
private val viewModel by viewModel<DetailsViewModel> {
|
|
|
|
@ -79,6 +81,7 @@ class DetailsActivity : BaseActivity<ActivityDetailsBinding>(), TabLayoutMediato
|
|
|
|
viewModel.manga.observe(this, ::onMangaUpdated)
|
|
|
|
viewModel.manga.observe(this, ::onMangaUpdated)
|
|
|
|
viewModel.newChaptersCount.observe(this, ::onNewChaptersChanged)
|
|
|
|
viewModel.newChaptersCount.observe(this, ::onNewChaptersChanged)
|
|
|
|
viewModel.onMangaRemoved.observe(this, ::onMangaRemoved)
|
|
|
|
viewModel.onMangaRemoved.observe(this, ::onMangaRemoved)
|
|
|
|
|
|
|
|
viewModel.onChaptersRemoved.observe(this, ::onChaptersRemoved)
|
|
|
|
viewModel.onError.observe(this, ::onError)
|
|
|
|
viewModel.onError.observe(this, ::onError)
|
|
|
|
|
|
|
|
|
|
|
|
registerReceiver(downloadReceiver, IntentFilter(DownloadService.ACTION_DOWNLOAD_COMPLETE))
|
|
|
|
registerReceiver(downloadReceiver, IntentFilter(DownloadService.ACTION_DOWNLOAD_COMPLETE))
|
|
|
|
@ -102,6 +105,10 @@ class DetailsActivity : BaseActivity<ActivityDetailsBinding>(), TabLayoutMediato
|
|
|
|
finishAfterTransition()
|
|
|
|
finishAfterTransition()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun onChaptersRemoved(count: Int) {
|
|
|
|
|
|
|
|
binding.snackbar.show(getString(R.string.removal_completed))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun onError(e: Throwable) {
|
|
|
|
private fun onError(e: Throwable) {
|
|
|
|
when {
|
|
|
|
when {
|
|
|
|
ExceptionResolver.canResolve(e) -> {
|
|
|
|
ExceptionResolver.canResolve(e) -> {
|
|
|
|
@ -262,7 +269,7 @@ class DetailsActivity : BaseActivity<ActivityDetailsBinding>(), TabLayoutMediato
|
|
|
|
fun showChapterMissingDialog(chapterId: Long) {
|
|
|
|
fun showChapterMissingDialog(chapterId: Long) {
|
|
|
|
val remoteManga = viewModel.getRemoteManga()
|
|
|
|
val remoteManga = viewModel.getRemoteManga()
|
|
|
|
if (remoteManga == null) {
|
|
|
|
if (remoteManga == null) {
|
|
|
|
binding.snackbar.show(getString( R.string.chapter_is_missing))
|
|
|
|
binding.snackbar.show(getString(R.string.chapter_is_missing))
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MaterialAlertDialogBuilder(this).apply {
|
|
|
|
MaterialAlertDialogBuilder(this).apply {
|
|
|
|
@ -340,4 +347,4 @@ class DetailsActivity : BaseActivity<ActivityDetailsBinding>(), TabLayoutMediato
|
|
|
|
.putExtra(MangaIntent.KEY_ID, mangaId)
|
|
|
|
.putExtra(MangaIntent.KEY_ID, mangaId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|