diff --git a/app/src/main/java/com/github/libretube/activities/MainActivity.kt b/app/src/main/java/com/github/libretube/activities/MainActivity.kt index 45f032df3..c616a47b5 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -153,12 +153,6 @@ class MainActivity : AppCompatActivity() { false } - /** - * don't remove this line - * this prevents reselected items at the bottomNav to be duplicated in the backstack - */ - binding.bottomNav.setOnItemReselectedListener {} - binding.toolbar.title = ThemeHelper.getStyledAppName(this) binding.toolbar.setNavigationOnClickListener { diff --git a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt index be06f4139..33c15ba8e 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -1033,22 +1033,29 @@ class PlayerFragment : Fragment() { // call the function again in 100ms exoPlayerView.postDelayed(this::setCurrentChapterName, 100) - val currentPosition = exoPlayer.currentPosition - var chapterName: String? = null - val reversedChapters = chapters.toMutableList() + var chapterName = getCurrentChapterName() - // reverse the chapters to start at the end - reversedChapters.reverse() - reversedChapters.forEach { - // check whether the chapter start is greater than the current player position - if (it.start!! * 1000 >= currentPosition) chapterName = it.title - } // change the chapter name textView text to the chapterName if (chapterName != null && chapterName != playerBinding.chapterName.text) { playerBinding.chapterName.text = chapterName } } + // get the name of the currently played chapter + private fun getCurrentChapterName(): String? { + val currentPosition = exoPlayer.currentPosition + var chapterName: String? = null + + chapters.forEach { + // check whether the chapter start is greater than the current player position + if (currentPosition >= it.start!! * 1000) { + // save chapter title if found + chapterName = it.title + } + } + return chapterName + } + private fun setMediaSource( subtitle: MutableList, videoUri: Uri,