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 781885db9..5649e0b6e 100644 --- a/app/src/main/java/com/github/libretube/activities/MainActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/MainActivity.kt @@ -316,14 +316,23 @@ class MainActivity : BaseActivity() { super.onStart() // check whether an URI got submitted over the intent data and load it when { - intent?.getStringExtra(IntentData.channelId) != null -> loadChannel( - channelId = intent?.getStringExtra(IntentData.channelId) + intent?.getStringExtra(IntentData.channelId) != null -> navController.navigate( + R.id.channelFragment, + bundleOf( + IntentData.channelName to intent?.getStringExtra(IntentData.channelId)!! + ) ) - intent?.getStringExtra(IntentData.userId) != null -> loadChannel( - channelName = intent?.getStringExtra(IntentData.userId) + intent?.getStringExtra(IntentData.channelName) != null -> navController.navigate( + R.id.channelFragment, + bundleOf( + IntentData.channelId to intent?.getStringExtra(IntentData.channelName) + ) ) - intent?.getStringExtra(IntentData.playlistId) != null -> loadPlaylist( - intent?.getStringExtra(IntentData.playlistId)!! + intent?.getStringExtra(IntentData.playlistId) != null -> navController.navigate( + R.id.playlistFragment, + bundleOf( + IntentData.playlistId to intent?.getStringExtra(IntentData.playlistId)!! + ) ) intent?.getStringExtra(IntentData.videoId) != null -> loadVideo( videoId = intent?.getStringExtra(IntentData.videoId)!!, @@ -335,8 +344,8 @@ class MainActivity : BaseActivity() { private fun loadVideo(videoId: String, timeStamp: Long?) { val bundle = Bundle() - bundle.putString("videoId", videoId) - if (timeStamp != null) bundle.putLong("timeStamp", timeStamp) + bundle.putString(IntentData.videoId, videoId) + if (timeStamp != null) bundle.putLong(IntentData.timeStamp, timeStamp) val frag = PlayerFragment() frag.arguments = bundle @@ -354,23 +363,6 @@ class MainActivity : BaseActivity() { }, 100) } - private fun loadChannel( - channelId: String? = null, - channelName: String? = null - ) { - val bundle = if (channelId != null) { - bundleOf("channel_id" to channelId) - } else { - bundleOf("channel_name" to channelName) - } - navController.navigate(R.id.channelFragment, bundle) - } - - private fun loadPlaylist(playlistId: String) { - val bundle = bundleOf("playlist_id" to playlistId) - navController.navigate(R.id.playlistFragment, bundle) - } - private fun minimizePlayer() { binding.mainMotionLayout.transitionToEnd() findViewById(R.id.main_container).isClickable = false diff --git a/app/src/main/java/com/github/libretube/activities/RouterActivity.kt b/app/src/main/java/com/github/libretube/activities/RouterActivity.kt index 159841b26..5cc20ffe2 100644 --- a/app/src/main/java/com/github/libretube/activities/RouterActivity.kt +++ b/app/src/main/java/com/github/libretube/activities/RouterActivity.kt @@ -52,7 +52,7 @@ class RouterActivity : BaseActivity() { .replace("/c/", "") .replace("/user/", "") - intent.putExtra(IntentData.userId, channelName) + intent.putExtra(IntentData.channelName, channelName) } uri.path!!.contains("/playlist") -> { var playlistId = uri.query!! diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index ac781fbb3..dcefa6541 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -49,7 +49,7 @@ class ChannelAdapter( root.setOnClickListener { NavigationHelper.navigateVideo(root.context, trending.url) } - val videoId = trending.url.toID() + val videoId = trending.url!!.toID() root.setOnLongClickListener { VideoOptionsDialog(videoId) .show(childFragmentManager, VideoOptionsDialog::class.java.name) diff --git a/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt index 677c8f742..253e6fb75 100644 --- a/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/LegacySubscriptionAdapter.kt @@ -33,7 +33,7 @@ class LegacySubscriptionAdapter( root.setOnClickListener { NavigationHelper.navigateChannel( root.context, - subscription.url.toID() + subscription.url!!.toID() ) } } diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt index 5abacf141..b36d3fd39 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -97,7 +97,7 @@ class SearchAdapter( root.setOnClickListener { NavigationHelper.navigateVideo(root.context, item.url) } - val videoId = item.url.toID() + val videoId = item.url!!.toID() root.setOnLongClickListener { VideoOptionsDialog(videoId) .show(childFragmentManager, VideoOptionsDialog::class.java.name) @@ -121,7 +121,7 @@ class SearchAdapter( root.setOnClickListener { NavigationHelper.navigateChannel(root.context, item.url) } - val channelId = item.url.toID() + val channelId = item.url!!.toID() isSubscribed(channelId, binding) } diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt index ad1145412..23d5489a9 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionChannelAdapter.kt @@ -36,7 +36,7 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList - -