fix: crash on softsub download
This commit is contained in:
parent
92c663cd38
commit
69fead70d1
1 changed files with 8 additions and 6 deletions
|
@ -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.Activity
|
||||||
import android.app.AlertDialog
|
import android.app.AlertDialog
|
||||||
import android.content.DialogInterface
|
import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
@ -316,6 +317,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
val subtitles = extractor.subtitles
|
val subtitles = extractor.subtitles
|
||||||
val subtitleNames = subtitles.map { it.language }
|
val subtitleNames = subtitles.map { it.language }
|
||||||
var subtitleToDownload: Subtitle? = null
|
var subtitleToDownload: Subtitle? = null
|
||||||
|
val activity = currActivity()?:requireActivity()
|
||||||
if (subtitles.isNotEmpty()) {
|
if (subtitles.isNotEmpty()) {
|
||||||
val alertDialog = AlertDialog.Builder(context, R.style.MyPopup)
|
val alertDialog = AlertDialog.Builder(context, R.style.MyPopup)
|
||||||
.setTitle("Download Subtitle")
|
.setTitle("Download Subtitle")
|
||||||
|
@ -329,7 +331,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
if (selectedVideo != null) {
|
if (selectedVideo != null) {
|
||||||
Helper.startAnimeDownloadService(
|
Helper.startAnimeDownloadService(
|
||||||
currActivity()!!,
|
activity,
|
||||||
media!!.mainName(),
|
media!!.mainName(),
|
||||||
episode.number,
|
episode.number,
|
||||||
selectedVideo,
|
selectedVideo,
|
||||||
|
@ -337,7 +339,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
media,
|
media,
|
||||||
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
||||||
)
|
)
|
||||||
broadcastDownloadStarted(episode.number)
|
broadcastDownloadStarted(episode.number, activity)
|
||||||
} else {
|
} else {
|
||||||
snackString("No Video Selected")
|
snackString("No Video Selected")
|
||||||
}
|
}
|
||||||
|
@ -354,7 +356,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
media,
|
media,
|
||||||
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
||||||
)
|
)
|
||||||
broadcastDownloadStarted(episode.number)
|
broadcastDownloadStarted(episode.number, activity)
|
||||||
} else {
|
} else {
|
||||||
snackString("No Video Selected")
|
snackString("No Video Selected")
|
||||||
}
|
}
|
||||||
|
@ -378,7 +380,7 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
media,
|
media,
|
||||||
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
episode.thumb?.url ?: media!!.banner ?: media!!.cover
|
||||||
)
|
)
|
||||||
broadcastDownloadStarted(episode.number)
|
broadcastDownloadStarted(episode.number, activity)
|
||||||
} else {
|
} else {
|
||||||
snackString("No Video Selected")
|
snackString("No Video Selected")
|
||||||
}
|
}
|
||||||
|
@ -399,11 +401,11 @@ class SelectorDialogFragment : BottomSheetDialogFragment() {
|
||||||
binding.urlQuality.text = extractor.server.name
|
binding.urlQuality.text = extractor.server.name
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun broadcastDownloadStarted(episodeNumber: String) {
|
private fun broadcastDownloadStarted(episodeNumber: String, activity: Activity) {
|
||||||
val intent = Intent(AnimeWatchFragment.ACTION_DOWNLOAD_STARTED).apply {
|
val intent = Intent(AnimeWatchFragment.ACTION_DOWNLOAD_STARTED).apply {
|
||||||
putExtra(AnimeWatchFragment.EXTRA_EPISODE_NUMBER, episodeNumber)
|
putExtra(AnimeWatchFragment.EXTRA_EPISODE_NUMBER, episodeNumber)
|
||||||
}
|
}
|
||||||
requireActivity().sendBroadcast(intent)
|
activity.sendBroadcast(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int = extractor.videos.size
|
override fun getItemCount(): Int = extractor.videos.size
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue