diff --git a/app/src/main/java/com/github/libretube/api/obj/ChapterSegment.kt b/app/src/main/java/com/github/libretube/api/obj/ChapterSegment.kt index c0fb3d7eb..d6019c325 100644 --- a/app/src/main/java/com/github/libretube/api/obj/ChapterSegment.kt +++ b/app/src/main/java/com/github/libretube/api/obj/ChapterSegment.kt @@ -4,7 +4,7 @@ import kotlinx.serialization.Serializable @Serializable data class ChapterSegment( - val title: String? = null, - val image: String? = null, - val start: Long? = null + val title: String, + val image: String, + val start: Long ) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt index 3dc32e5a2..f55b9c5c4 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt @@ -29,7 +29,7 @@ class ChaptersAdapter( holder.binding.apply { ImageHelper.loadImage(chapter.image, chapterImage) chapterTitle.text = chapter.title - timeStamp.text = chapter.start?.let { DateUtils.formatElapsedTime(it) } + timeStamp.text = DateUtils.formatElapsedTime(chapter.start) val color = if (selectedPosition == position) { ThemeHelper.getThemeColor(root.context, android.R.attr.colorControlHighlight) @@ -40,7 +40,7 @@ class ChaptersAdapter( root.setOnClickListener { updateSelectedPosition(position) - val chapterStart = chapter.start!! * 1000 // s -> ms + val chapterStart = chapter.start * 1000 // s -> ms exoPlayer.seekTo(chapterStart) } } diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index ef95fed9d..222186d8d 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -1183,13 +1183,13 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { // enable the chapters dialog in the player val titles = chapters.map { chapter -> - "(${chapter.start?.let { DateUtils.formatElapsedTime(it) }}) ${chapter.title}" + "(${DateUtils.formatElapsedTime(chapter.start)}) ${chapter.title}" } playerBinding.chapterLL.setOnClickListener { MaterialAlertDialogBuilder(requireContext()) .setTitle(R.string.chapters) .setItems(titles.toTypedArray()) { _, index -> - exoPlayer.seekTo(chapters[index].start!! * 1000) + exoPlayer.seekTo(chapters[index].start * 1000) } .show() } @@ -1206,7 +1206,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { binding.player.postDelayed(this::setCurrentChapterName, 100) val chapterIndex = getCurrentChapterIndex() ?: return - val chapterName = chapters[chapterIndex].title?.trim() + val chapterName = chapters[chapterIndex].title.trim() // change the chapter name textView text to the chapterName if (chapterName != playerBinding.chapterName.text) { @@ -1222,7 +1222,7 @@ class PlayerFragment : Fragment(), OnlinePlayerOptions { */ private fun getCurrentChapterIndex(): Int? { val currentPosition = exoPlayer.currentPosition / 1000 - return chapters.indexOfLast { currentPosition >= it.start!! }.takeIf { it >= 0 } + return chapters.indexOfLast { currentPosition >= it.start }.takeIf { it >= 0 } } private fun setMediaSource(uri: Uri, mimeType: String) {