mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30: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()) {
|
if (playlists.isNotEmpty()) {
|
||||||
showPlaylists(playlists)
|
showPlaylists(playlists)
|
||||||
} else {
|
} else {
|
||||||
|
binding.sortTV.isVisible = false
|
||||||
binding.nothingHere.isVisible = true
|
binding.nothingHere.isVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,11 +199,13 @@ class LibraryFragment : DynamicLayoutManagerFragment() {
|
|||||||
RecyclerView.AdapterDataObserver() {
|
RecyclerView.AdapterDataObserver() {
|
||||||
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
override fun onItemRangeRemoved(positionStart: Int, itemCount: Int) {
|
||||||
_binding?.nothingHere?.isVisible = playlistsAdapter.itemCount == 0
|
_binding?.nothingHere?.isVisible = playlistsAdapter.itemCount == 0
|
||||||
|
_binding?.sortTV?.isVisible = playlistsAdapter.itemCount > 0
|
||||||
super.onItemRangeRemoved(positionStart, itemCount)
|
super.onItemRangeRemoved(positionStart, itemCount)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
binding.nothingHere.isGone = true
|
binding.nothingHere.isGone = true
|
||||||
|
binding.sortTV.isVisible = true
|
||||||
binding.playlistRecView.adapter = playlistsAdapter
|
binding.playlistRecView.adapter = playlistsAdapter
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,6 +136,8 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
nextPage = response.nextpage
|
nextPage = response.nextpage
|
||||||
playlistName = response.name
|
playlistName = response.name
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
|
||||||
|
if (!response.thumbnailUrl.isNullOrEmpty())
|
||||||
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
ImageHelper.loadImage(response.thumbnailUrl, binding.thumbnail)
|
||||||
binding.playlistProgress.isGone = true
|
binding.playlistProgress.isGone = true
|
||||||
binding.playlistAppBar.isVisible = true
|
binding.playlistAppBar.isVisible = true
|
||||||
@ -193,6 +195,13 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
sheet.show(fragmentManager)
|
sheet.show(fragmentManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (playlistFeed.isEmpty()) {
|
||||||
|
binding.nothingHere.isVisible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (playlistFeed.isEmpty()) {
|
||||||
|
binding.playAll.isGone = true
|
||||||
|
} else {
|
||||||
binding.playAll.setOnClickListener {
|
binding.playAll.setOnClickListener {
|
||||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
if (playlistFeed.isEmpty()) return@setOnClickListener
|
||||||
NavigationHelper.navigateVideo(
|
NavigationHelper.navigateVideo(
|
||||||
@ -201,6 +210,7 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
playlistId
|
playlistId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (playlistType == PlaylistType.PUBLIC) {
|
if (playlistType == PlaylistType.PUBLIC) {
|
||||||
binding.bookmark.setOnClickListener {
|
binding.bookmark.setOnClickListener {
|
||||||
@ -218,10 +228,12 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// private playlist, means shuffle is possible because all videos are received at once
|
// private playlist, means shuffle is possible because all videos are received at once
|
||||||
|
if (playlistFeed.isEmpty()) {
|
||||||
|
binding.bookmark.isGone = true
|
||||||
|
} else {
|
||||||
binding.bookmark.setIconResource(R.drawable.ic_shuffle)
|
binding.bookmark.setIconResource(R.drawable.ic_shuffle)
|
||||||
binding.bookmark.text = getString(R.string.shuffle)
|
binding.bookmark.text = getString(R.string.shuffle)
|
||||||
binding.bookmark.setOnClickListener {
|
binding.bookmark.setOnClickListener {
|
||||||
if (playlistFeed.isEmpty()) return@setOnClickListener
|
|
||||||
val queue = playlistFeed.shuffled()
|
val queue = playlistFeed.shuffled()
|
||||||
PlayingQueue.resetToDefaults()
|
PlayingQueue.resetToDefaults()
|
||||||
PlayingQueue.add(*queue.toTypedArray())
|
PlayingQueue.add(*queue.toTypedArray())
|
||||||
@ -232,8 +244,12 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
keepQueue = true
|
keepQueue = true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
binding.sortContainer.isGone = false
|
}
|
||||||
binding.sortTV.text = sortOptions[selectedSortOrder]
|
|
||||||
|
if (playlistFeed.isEmpty()) {
|
||||||
|
binding.sortContainer.isGone = true
|
||||||
|
} else {
|
||||||
|
binding.sortContainer.isVisible = true
|
||||||
binding.sortContainer.setOnClickListener {
|
binding.sortContainer.setOnClickListener {
|
||||||
BaseBottomSheet().apply {
|
BaseBottomSheet().apply {
|
||||||
setSimpleItems(sortOptions.toList()) { index ->
|
setSimpleItems(sortOptions.toList()) { index ->
|
||||||
@ -245,6 +261,10 @@ class PlaylistFragment : DynamicLayoutManagerFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binding.sortTV.text = sortOptions[selectedSortOrder]
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
updatePlaylistBookmark(response)
|
updatePlaylistBookmark(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -152,6 +152,29 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</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>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user