From 32d56d33f89ae989b17f2a0d3479ac696dc23369 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 4 Aug 2022 10:20:27 +0200 Subject: [PATCH 1/2] fix player crash --- .../java/com/github/libretube/fragments/PlayerFragment.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 76c1742bd7..e0f96ed7d6 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -115,7 +115,6 @@ class PlayerFragment : Fragment() { */ private var videoId: String? = null private var playlistId: String? = null - private var channelId: String? = null private var isSubscribed: Boolean? = false private var isLive = false private lateinit var streams: Streams @@ -1558,8 +1557,9 @@ class PlayerFragment : Fragment() { private fun isSubscribed() { fun run() { + val channelId = streams.uploaderUrl.toID() lifecycleScope.launchWhenCreated { - isSubscribed = SubscriptionHelper.isSubscribed(channelId!!) + isSubscribed = SubscriptionHelper.isSubscribed(channelId) if (isSubscribed == null) return@launchWhenCreated @@ -1569,10 +1569,10 @@ class PlayerFragment : Fragment() { } binding.playerSubscribe.setOnClickListener { if (isSubscribed == true) { - SubscriptionHelper.unsubscribe(channelId!!) + SubscriptionHelper.unsubscribe(channelId) binding.playerSubscribe.text = getString(R.string.subscribe) } else { - SubscriptionHelper.subscribe(channelId!!) + SubscriptionHelper.subscribe(channelId) binding.playerSubscribe.text = getString(R.string.unsubscribe) } } From 2c22978cce68b9450ba00dac6c69232ee2855f61 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Thu, 4 Aug 2022 10:24:11 +0200 Subject: [PATCH 2/2] fix subs --- .../main/java/com/github/libretube/fragments/PlayerFragment.kt | 2 ++ 1 file changed, 2 insertions(+) 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 e0f96ed7d6..1f37d6ea7c 100644 --- a/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/fragments/PlayerFragment.kt @@ -1571,9 +1571,11 @@ class PlayerFragment : Fragment() { if (isSubscribed == true) { SubscriptionHelper.unsubscribe(channelId) binding.playerSubscribe.text = getString(R.string.subscribe) + isSubscribed = false } else { SubscriptionHelper.subscribe(channelId) binding.playerSubscribe.text = getString(R.string.unsubscribe) + isSubscribed = true } } }