From 2ce5c797287b1c583c39c53b1348d32d5e3b100e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 16 Jan 2023 15:09:35 +0100 Subject: [PATCH 1/3] Fix that queue doesn't regenerate --- .../java/com/github/libretube/ui/fragments/PlayerFragment.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 02837a246..40078965f 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 @@ -250,8 +250,11 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { super.onViewCreated(view, savedInstanceState) context?.hideKeyboard(view) + // reset the callbacks of the playing queue + PlayingQueue.resetToDefaults() + // clear the playing queue - if (!keepQueue) PlayingQueue.resetToDefaults() + if (!keepQueue) PlayingQueue.clear() changeOrientationMode() From 7af4f20e53e64c8ca5d769f6dcf6e626361ce96d Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 16 Jan 2023 15:14:22 +0100 Subject: [PATCH 2/3] Fix the visibility of the 'add to queue' btn --- .../github/libretube/ui/fragments/PlayerFragment.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 40078965f..6408708d1 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 @@ -343,15 +343,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { // actions that don't depend on video information private fun initializeOnClickActions() { binding.closeImageView.setOnClickListener { - viewModel.isMiniPlayerVisible.value = false - binding.playerMotionLayout.transitionToEnd() - val mainActivity = activity as MainActivity - mainActivity.supportFragmentManager.beginTransaction() - .remove(this) - .commit() + PlayingQueue.clear() BackgroundHelper.stopBackgroundPlay(requireContext()) + killPlayerFragment() } playerBinding.closeImageButton.setOnClickListener { + PlayingQueue.clear() + BackgroundHelper.stopBackgroundPlay(requireContext()) killPlayerFragment() } playerBinding.autoPlay.visibility = View.VISIBLE @@ -1526,6 +1524,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { mainActivity.supportFragmentManager.beginTransaction() .remove(this) .commit() + + onDestroy() } override fun onConfigurationChanged(newConfig: Configuration) { From 88ecef18dd56b98b8ee8892fc4d7fd4d4ca11f2e Mon Sep 17 00:00:00 2001 From: Bnyro Date: Mon, 16 Jan 2023 15:18:32 +0100 Subject: [PATCH 3/3] Minor cleanup to the `PlayerFragment` --- .../com/github/libretube/ui/fragments/PlayerFragment.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 6408708d1..894f0b111 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 @@ -1209,8 +1209,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { }.flatten() .filter { it > 0 } .sortedDescending() - .toSet() - .toList() + .distinct() return resolutions.map { VideoResolution( @@ -1359,8 +1358,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { override fun onCaptionsClicked() { if (!this@PlayerFragment::streams.isInitialized || - streams.subtitles == null || - streams.subtitles!!.isEmpty() + streams.subtitles.isNullOrEmpty() ) { Toast.makeText(context, R.string.no_subtitles_available, Toast.LENGTH_SHORT).show() return @@ -1375,7 +1373,7 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { BaseBottomSheet() .setSimpleItems(subtitlesNamesList) { index -> - val language = if (index > 0) subtitleCodesList[index] else null + val language = subtitleCodesList.getOrNull(index) updateCaptionsLanguage(language) this.captionLanguage = language }