From f968b3a51102867a64497a8e498e40eacf643010 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 16 Aug 2023 18:28:27 +0200 Subject: [PATCH] feat(playlist): navigate to uploader on click --- .../com/github/libretube/ui/adapters/PlaylistAdapter.kt | 7 ++++++- .../github/libretube/ui/fragments/PlaylistFragment.kt | 9 +++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt index f948f46a4..4f72e62e4 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt @@ -6,6 +6,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.ViewGroup import androidx.core.view.isGone +import androidx.core.view.updatePadding import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.api.PlaylistsHelper @@ -13,6 +14,7 @@ import com.github.libretube.api.obj.StreamItem import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.enums.PlaylistType import com.github.libretube.extensions.TAG +import com.github.libretube.extensions.dpToPx import com.github.libretube.extensions.toID import com.github.libretube.extensions.toastFromMainDispatcher import com.github.libretube.helpers.ImageHelper @@ -89,9 +91,12 @@ class PlaylistAdapter( } if (!streamItem.uploaderUrl.isNullOrBlank()) { - channelContainer.setOnClickListener { + videoInfo.setOnClickListener { NavigationHelper.navigateChannel(root.context, streamItem.uploaderUrl.toID()) } + // add some extra padding to make it easier to click + val extraPadding = (3).dpToPx().toInt() + videoInfo.updatePadding(top = extraPadding, bottom = extraPadding) } watchProgress.setWatchProgressLength(videoId, streamItem.duration) diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index a2b671108..520859d10 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -6,6 +6,7 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.core.os.bundleOf import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.core.view.updatePadding @@ -35,6 +36,7 @@ import com.github.libretube.extensions.toID import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.NavigationHelper import com.github.libretube.helpers.PreferenceHelper +import com.github.libretube.ui.activities.MainActivity import com.github.libretube.ui.adapters.PlaylistAdapter import com.github.libretube.ui.models.PlayerViewModel import com.github.libretube.ui.sheets.BaseBottomSheet @@ -147,6 +149,13 @@ class PlaylistFragment : Fragment() { } binding.playlistInfo.text = getChannelAndVideoString(response, response.videos) + binding.playlistInfo.setOnClickListener { + (context as MainActivity).navController.navigate( + R.id.channelFragment, + bundleOf(IntentData.channelId to response.uploaderUrl?.toID()) + ) + } + binding.playlistDescription.text = response.description // hide playlist description text view if not provided binding.playlistDescription.isGone = response.description.orEmpty().isBlank()