Skip to content

Commit 4478c72

Browse files
authored
Merge pull request libre-tube#7157 from Bnyro/master
refactor: use paging adapter for channel content items
2 parents 2c73287 + 4cde385 commit 4478c72

4 files changed

Lines changed: 91 additions & 280 deletions

File tree

app/src/main/java/com/github/libretube/ui/adapters/SearchChannelAdapter.kt

Lines changed: 0 additions & 176 deletions
This file was deleted.

app/src/main/java/com/github/libretube/ui/adapters/SearchResultsAdapter.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.libretube.ui.adapters
33
import android.view.LayoutInflater
44
import android.view.ViewGroup
55
import androidx.core.os.bundleOf
6+
import androidx.core.view.isGone
67
import androidx.core.view.isVisible
78
import androidx.paging.PagingDataAdapter
89
import com.github.libretube.R
@@ -91,10 +92,12 @@ class SearchResultsAdapter(
9192
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
9293
binding.apply {
9394
ImageHelper.loadImage(item.thumbnail, thumbnail)
95+
9496
thumbnailDuration.setFormattedDuration(item.duration, item.isShort, item.uploaded)
9597
videoTitle.text = item.title
9698
videoInfo.text = TextUtils.formatViewsString(root.context, item.views, item.uploaded)
9799

100+
channelContainer.isGone = item.uploaderAvatar.isNullOrEmpty()
98101
channelName.text = item.uploaderName
99102
ImageHelper.loadImage(item.uploaderAvatar, channelImage, true)
100103

@@ -184,12 +187,10 @@ class SearchResultsAdapter(
184187
}
185188

186189
root.setOnLongClickListener {
187-
val playlistId = item.url.toID()
188-
val playlistName = item.name!!
189190
val sheet = PlaylistOptionsBottomSheet()
190191
sheet.arguments = bundleOf(
191-
IntentData.playlistId to playlistId,
192-
IntentData.playlistName to playlistName,
192+
IntentData.playlistId to item.url.toID(),
193+
IntentData.playlistName to item.name.orEmpty(),
193194
IntentData.playlistType to PlaylistType.PUBLIC
194195
)
195196
sheet.show(

0 commit comments

Comments
 (0)