feat(playlist): navigate to uploader on click

This commit is contained in:
Bnyro 2023-08-16 18:28:27 +02:00
parent b9a929e39c
commit f968b3a511
2 changed files with 15 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.updatePadding
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.github.libretube.R import com.github.libretube.R
import com.github.libretube.api.PlaylistsHelper 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.databinding.VideoRowBinding
import com.github.libretube.enums.PlaylistType import com.github.libretube.enums.PlaylistType
import com.github.libretube.extensions.TAG import com.github.libretube.extensions.TAG
import com.github.libretube.extensions.dpToPx
import com.github.libretube.extensions.toID import com.github.libretube.extensions.toID
import com.github.libretube.extensions.toastFromMainDispatcher import com.github.libretube.extensions.toastFromMainDispatcher
import com.github.libretube.helpers.ImageHelper import com.github.libretube.helpers.ImageHelper
@ -89,9 +91,12 @@ class PlaylistAdapter(
} }
if (!streamItem.uploaderUrl.isNullOrBlank()) { if (!streamItem.uploaderUrl.isNullOrBlank()) {
channelContainer.setOnClickListener { videoInfo.setOnClickListener {
NavigationHelper.navigateChannel(root.context, streamItem.uploaderUrl.toID()) 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) watchProgress.setWatchProgressLength(videoId, streamItem.duration)

View File

@ -6,6 +6,7 @@ import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.core.os.bundleOf
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.view.updatePadding 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.ImageHelper
import com.github.libretube.helpers.NavigationHelper import com.github.libretube.helpers.NavigationHelper
import com.github.libretube.helpers.PreferenceHelper 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.adapters.PlaylistAdapter
import com.github.libretube.ui.models.PlayerViewModel import com.github.libretube.ui.models.PlayerViewModel
import com.github.libretube.ui.sheets.BaseBottomSheet import com.github.libretube.ui.sheets.BaseBottomSheet
@ -147,6 +149,13 @@ class PlaylistFragment : Fragment() {
} }
binding.playlistInfo.text = getChannelAndVideoString(response, response.videos) 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 binding.playlistDescription.text = response.description
// hide playlist description text view if not provided // hide playlist description text view if not provided
binding.playlistDescription.isGone = response.description.orEmpty().isBlank() binding.playlistDescription.isGone = response.description.orEmpty().isBlank()