mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-28 07:50:31 +05:30
Merge pull request #5759 from nik-conder/fix-playlist
fix: hide thumbnail space, buttons and filters when playlist empty
This commit is contained in:
commit
2fbc1361b2
@ -179,6 +179,7 @@ class LibraryFragment : DynamicLayoutManagerFragment() {
|
||||
if (playlists.isNotEmpty()) {
|
||||
showPlaylists(playlists)
|
||||
} else {
|
||||
binding.sortTV.isVisible = false
|
||||
binding.nothingHere.isVisible = true
|
||||
}
|
||||
}
|
||||
@ -198,11 +199,13 @@ class LibraryFragment : DynamicLayoutManagerFragment() {
|
||||
RecyclerView.AdapterDataObserver() {
|
||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||
_binding?.nothingHere?.isVisible = playlistsAdapter.itemCount == 0
|
||||
_binding?.sortTV?.isVisible = playlistsAdapter.itemCount > 0
|
||||
super.onItemRangeRemoved(positionStart, itemCount)
|
||||
}
|
||||
})
|
||||
|
||||
binding.nothingHere.isGone = true
|
||||
binding.sortTV.isVisible = true
|
||||
binding.playlistRecView.adapter = playlistsAdapter
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,9 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
||||
nextPage = response.nextpage
|
||||
playlistName = response.name
|
||||
isLoading = false
|
||||
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
||||
|
||||
if (!response.thumbnailUrl.isNullOrEmpty())
|
||||
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
||||
binding.playlistProgress.isGone = true
|
||||
binding.playlistAppBar.isVisible = true
|
||||
binding.playlistRecView.isVisible = true
|
||||
@ -193,13 +195,21 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
||||
sheet.show(fragmentManager)
|
||||
}
|
||||
|
||||
binding.playAll.setOnClickListener {
|
||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
response.relatedStreams.first().url,
|
||||
playlistId
|
||||
)
|
||||
if (playlistFeed.isEmpty()) {
|
||||
binding.nothingHere.isVisible = true
|
||||
}
|
||||
|
||||
if (playlistFeed.isEmpty()) {
|
||||
binding.playAll.isGone = true
|
||||
} else {
|
||||
binding.playAll.setOnClickListener {
|
||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
response.relatedStreams.first().url,
|
||||
playlistId
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (playlistType == PlaylistType.PUBLIC) {
|
||||
@ -218,31 +228,41 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
||||
}
|
||||
} else {
|
||||
// private playlist, means shuffle is possible because all videos are received at once
|
||||
binding.bookmark.setIconResource(R.drawable.ic_shuffle)
|
||||
binding.bookmark.text = getString(R.string.shuffle)
|
||||
binding.bookmark.setOnClickListener {
|
||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
||||
val queue = playlistFeed.shuffled()
|
||||
PlayingQueue.resetToDefaults()
|
||||
PlayingQueue.add(*queue.toTypedArray())
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
queue.first().url,
|
||||
playlistId = playlistId,
|
||||
keepQueue = true
|
||||
)
|
||||
if (playlistFeed.isEmpty()) {
|
||||
binding.bookmark.isGone = true
|
||||
} else {
|
||||
binding.bookmark.setIconResource(R.drawable.ic_shuffle)
|
||||
binding.bookmark.text = getString(R.string.shuffle)
|
||||
binding.bookmark.setOnClickListener {
|
||||
val queue = playlistFeed.shuffled()
|
||||
PlayingQueue.resetToDefaults()
|
||||
PlayingQueue.add(*queue.toTypedArray())
|
||||
NavigationHelper.navigateVideo(
|
||||
requireContext(),
|
||||
queue.first().url,
|
||||
playlistId = playlistId,
|
||||
keepQueue = true
|
||||
)
|
||||
}
|
||||
}
|
||||
binding.sortContainer.isGone = false
|
||||
|
||||
if (playlistFeed.isEmpty()) {
|
||||
binding.sortContainer.isGone = true
|
||||
} else {
|
||||
binding.sortContainer.isVisible = true
|
||||
binding.sortContainer.setOnClickListener {
|
||||
BaseBottomSheet().apply {
|
||||
setSimpleItems(sortOptions.toList()) { index ->
|
||||
selectedSortOrder = index
|
||||
binding.sortTV.text = sortOptions[index]
|
||||
showPlaylistVideos(response)
|
||||
}
|
||||
}.show(childFragmentManager)
|
||||
}
|
||||
}
|
||||
|
||||
binding.sortTV.text = sortOptions[selectedSortOrder]
|
||||
binding.sortContainer.setOnClickListener {
|
||||
BaseBottomSheet().apply {
|
||||
setSimpleItems(sortOptions.toList()) { index ->
|
||||
selectedSortOrder = index
|
||||
binding.sortTV.text = sortOptions[index]
|
||||
showPlaylistVideos(response)
|
||||
}
|
||||
}.show(childFragmentManager)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
updatePlaylistBookmark(response)
|
||||
|
@ -152,6 +152,29 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/nothing_here"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginBottom="35dp"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="100dp"
|
||||
android:layout_gravity="center"
|
||||
android:src="@drawable/ic_list" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/emptyList"
|
||||
android:textSize="20sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user