fix: crash when trying to vote while there are no sb segments yet

This commit is contained in:
Bnyro 2023-11-17 14:57:35 +01:00
parent 563af5ecca
commit a5d41b7802
2 changed files with 8 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import android.os.Bundle
import android.text.format.DateUtils
import android.util.Log
import android.widget.ArrayAdapter
import android.widget.Toast
import androidx.fragment.app.DialogFragment
import androidx.lifecycle.lifecycleScope
import com.github.libretube.R
@ -92,6 +93,12 @@ class VoteForSegmentDialog : DialogFragment() {
withContext(Dispatchers.Main) {
val binding = _binding ?: return@withContext
if (segments.isEmpty()) {
dismiss()
Toast.makeText(context, R.string.no_segments_found, Toast.LENGTH_SHORT).show()
return@withContext
}
val segmentTexts = segments.map {
"${it.category} (${
DateUtils.formatElapsedTime(it.segmentStartAndEnd.first.toLong())

View File

@ -494,6 +494,7 @@
<string name="remember_playback_speed">Remember playback speed</string>
<string name="successfully_removed_from_playlist">Successfully removed \"%1$s\" from the playlist.</string>
<string name="watched">Watched</string>
<string name="no_segments_found">There are no segments for this video yet.</string>
<!-- Notification channel strings -->
<string name="download_channel_name">Download Service</string>