Merge pull request #154 from aayush2622/dev

warning menu when deleting episode
This commit is contained in:
aayush262 2024-01-23 01:18:07 +05:30 committed by GitHub
commit f333051073
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 4 deletions

View file

@ -1,6 +1,7 @@
package ani.dantotsu.media.anime package ani.dantotsu.media.anime
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Context import android.content.Context
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
@ -125,10 +126,10 @@ class EpisodeAdapter(
binding.itemEpisodeFiller.visibility = View.GONE binding.itemEpisodeFiller.visibility = View.GONE
binding.itemEpisodeFillerView.visibility = View.GONE binding.itemEpisodeFillerView.visibility = View.GONE
} }
holder.bind(ep.number, ep.downloadProgress)
binding.itemEpisodeDesc.visibility = binding.itemEpisodeDesc.visibility =
if (ep.desc != null && ep.desc?.trim(' ') != "") View.VISIBLE else View.GONE if (ep.desc != null && ep.desc?.trim(' ') != "") View.VISIBLE else View.GONE
binding.itemEpisodeDesc.text = ep.desc ?: "" binding.itemEpisodeDesc.text = ep.desc ?: ""
holder.bind(ep.number, ep.downloadProgress , ep.desc)
if (media.userProgress != null) { if (media.userProgress != null) {
if ((ep.number.toFloatOrNull() ?: 9999f) <= media.userProgress!!.toFloat()) { if ((ep.number.toFloatOrNull() ?: 9999f) <= media.userProgress!!.toFloat()) {
@ -339,7 +340,16 @@ class EpisodeAdapter(
fragment.onAnimeEpisodeStopDownloadClick(episodeNumber) fragment.onAnimeEpisodeStopDownloadClick(episodeNumber)
return@setOnClickListener return@setOnClickListener
} else if (downloadedEpisodes.contains(episodeNumber)) { } else if (downloadedEpisodes.contains(episodeNumber)) {
fragment.onAnimeEpisodeRemoveDownloadClick(episodeNumber) val builder = AlertDialog.Builder(currContext(), R.style.MyPopup)
builder.setTitle("Delete Episode")
builder.setMessage("Are you sure you want to delete Episode ${episodeNumber}?")
builder.setPositiveButton("Yes") { _, _ ->
fragment.onAnimeEpisodeRemoveDownloadClick(episodeNumber)
}
builder.setNegativeButton("No") { _, _ ->
}
val dialog = builder.show()
dialog.window?.setDimAmount(0.8f)
return@setOnClickListener return@setOnClickListener
} else { } else {
fragment.onAnimeEpisodeDownloadClick(episodeNumber) fragment.onAnimeEpisodeDownloadClick(episodeNumber)
@ -354,8 +364,9 @@ class EpisodeAdapter(
} }
} }
fun bind(episodeNumber: String, progress: String?) { fun bind(episodeNumber: String, progress: String?, desc: String?) {
if (progress != null) { if (progress != null) {
binding.itemEpisodeDesc.visibility = View.GONE
binding.itemDownloadStatus.visibility = View.VISIBLE binding.itemDownloadStatus.visibility = View.VISIBLE
binding.itemDownloadStatus.text = progress binding.itemDownloadStatus.text = progress
} else { } else {
@ -366,7 +377,9 @@ class EpisodeAdapter(
// Show spinner // Show spinner
binding.itemDownload.setImageResource(R.drawable.ic_sync) binding.itemDownload.setImageResource(R.drawable.ic_sync)
startOrContinueRotation(episodeNumber) startOrContinueRotation(episodeNumber)
binding.itemEpisodeDesc.visibility = View.GONE
} else if (downloadedEpisodes.contains(episodeNumber)) { } else if (downloadedEpisodes.contains(episodeNumber)) {
binding.itemEpisodeDesc.visibility = View.GONE
binding.itemDownloadStatus.visibility = View.VISIBLE binding.itemDownloadStatus.visibility = View.VISIBLE
// Show checkmark // Show checkmark
binding.itemDownload.setImageResource(R.drawable.ic_circle_check) binding.itemDownload.setImageResource(R.drawable.ic_circle_check)
@ -378,6 +391,7 @@ class EpisodeAdapter(
}, 1000) }, 1000)
} else { } else {
binding.itemDownloadStatus.visibility = View.GONE binding.itemDownloadStatus.visibility = View.GONE
binding.itemEpisodeDesc.visibility = if (desc != null && desc.trim(' ') != "") View.VISIBLE else View.GONE
// Show download icon // Show download icon
binding.itemDownload.setImageResource(R.drawable.ic_circle_add) binding.itemDownload.setImageResource(R.drawable.ic_circle_add)
binding.itemDownload.rotation = 0f binding.itemDownload.rotation = 0f

View file

@ -218,7 +218,16 @@ class MangaChapterAdapter(
fragment.onMangaChapterStopDownloadClick(chapterNumber) fragment.onMangaChapterStopDownloadClick(chapterNumber)
return@setOnClickListener return@setOnClickListener
} else if (downloadedChapters.contains(chapterNumber)) { } else if (downloadedChapters.contains(chapterNumber)) {
fragment.onMangaChapterRemoveDownloadClick(chapterNumber) val builder = AlertDialog.Builder(currContext(), R.style.MyPopup)
builder.setTitle("Delete Chapter")
builder.setMessage("Are you sure you want to delete ${chapterNumber}?")
builder.setPositiveButton("Yes") { _, _ ->
fragment.onMangaChapterRemoveDownloadClick(chapterNumber)
}
builder.setNegativeButton("No") { _, _ ->
}
val dialog = builder.show()
dialog.window?.setDimAmount(0.8f)
return@setOnClickListener return@setOnClickListener
} else { } else {
fragment.onMangaChapterDownloadClick(chapterNumber) fragment.onMangaChapterDownloadClick(chapterNumber)