mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-01-07 10:00:31 +05:30
improve the UI
This commit is contained in:
parent
48951f13c3
commit
7e984dd57f
@ -2,13 +2,16 @@ package com.github.libretube.ui.adapters
|
|||||||
|
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.github.libretube.databinding.PlaylistBookmarkRowBinding
|
import com.github.libretube.databinding.PlaylistBookmarkRowBinding
|
||||||
import com.github.libretube.db.obj.PlaylistBookmark
|
import com.github.libretube.db.obj.PlaylistBookmark
|
||||||
|
import com.github.libretube.ui.sheets.PlaylistOptionsBottomSheet
|
||||||
import com.github.libretube.ui.viewholders.PlaylistBookmarkViewHolder
|
import com.github.libretube.ui.viewholders.PlaylistBookmarkViewHolder
|
||||||
import com.github.libretube.util.ImageHelper
|
import com.github.libretube.util.ImageHelper
|
||||||
|
import com.github.libretube.util.NavigationHelper
|
||||||
|
|
||||||
class PlaylistBookmarksAdapter(
|
class PlaylistBookmarkAdapter(
|
||||||
private val bookmarks: List<PlaylistBookmark>
|
private val bookmarks: List<PlaylistBookmark>
|
||||||
) : RecyclerView.Adapter<PlaylistBookmarkViewHolder>() {
|
) : RecyclerView.Adapter<PlaylistBookmarkViewHolder>() {
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistBookmarkViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): PlaylistBookmarkViewHolder {
|
||||||
@ -26,6 +29,21 @@ class PlaylistBookmarksAdapter(
|
|||||||
ImageHelper.loadImage(bookmark.thumbnailUrl, thumbnail)
|
ImageHelper.loadImage(bookmark.thumbnailUrl, thumbnail)
|
||||||
playlistName.text = bookmark.playlistName
|
playlistName.text = bookmark.playlistName
|
||||||
uploaderName.text = bookmark.uploader
|
uploaderName.text = bookmark.uploader
|
||||||
|
|
||||||
|
root.setOnClickListener {
|
||||||
|
NavigationHelper.navigatePlaylist(root.context, bookmark.playlistId, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
root.setOnLongClickListener {
|
||||||
|
PlaylistOptionsBottomSheet(
|
||||||
|
playlistId = bookmark.playlistId,
|
||||||
|
playlistName = bookmark.playlistName ?: "",
|
||||||
|
isOwner = false
|
||||||
|
).show(
|
||||||
|
(root.context as AppCompatActivity).supportFragmentManager
|
||||||
|
)
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,7 +16,7 @@ import com.github.libretube.databinding.FragmentHomeBinding
|
|||||||
import com.github.libretube.db.DatabaseHolder
|
import com.github.libretube.db.DatabaseHolder
|
||||||
import com.github.libretube.extensions.awaitQuery
|
import com.github.libretube.extensions.awaitQuery
|
||||||
import com.github.libretube.extensions.toastFromMainThread
|
import com.github.libretube.extensions.toastFromMainThread
|
||||||
import com.github.libretube.ui.adapters.PlaylistBookmarksAdapter
|
import com.github.libretube.ui.adapters.PlaylistBookmarkAdapter
|
||||||
import com.github.libretube.ui.adapters.PlaylistsAdapter
|
import com.github.libretube.ui.adapters.PlaylistsAdapter
|
||||||
import com.github.libretube.ui.adapters.VideosAdapter
|
import com.github.libretube.ui.adapters.VideosAdapter
|
||||||
import com.github.libretube.ui.base.BaseFragment
|
import com.github.libretube.ui.base.BaseFragment
|
||||||
@ -121,9 +121,9 @@ class HomeFragment : BaseFragment() {
|
|||||||
}
|
}
|
||||||
if (bookmarkedPlaylists.isEmpty()) return@runOrError
|
if (bookmarkedPlaylists.isEmpty()) return@runOrError
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
makeVisible(binding.bookmarksRV, binding.bookmarksRV)
|
makeVisible(binding.bookmarksTV, binding.bookmarksRV)
|
||||||
binding.playlistsRV.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
binding.bookmarksRV.layoutManager = LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||||
binding.playlistsRV.adapter = PlaylistBookmarksAdapter(bookmarkedPlaylists)
|
binding.bookmarksRV.adapter = PlaylistBookmarkAdapter(bookmarkedPlaylists)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,11 @@ class PlaylistFragment : BaseFragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isOwner) binding.bookmark.visibility = View.GONE
|
||||||
|
|
||||||
binding.bookmark.setOnClickListener {
|
binding.bookmark.setOnClickListener {
|
||||||
|
isBookmarked = !isBookmarked
|
||||||
|
updateBookmarkRes()
|
||||||
query {
|
query {
|
||||||
if (isBookmarked) {
|
if (isBookmarked) {
|
||||||
DatabaseHolder.Database.playlistBookmarkDao().delete(
|
DatabaseHolder.Database.playlistBookmarkDao().delete(
|
||||||
@ -149,8 +153,6 @@ class PlaylistFragment : BaseFragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isBookmarked = !isBookmarked
|
|
||||||
updateBookmarkRes()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playlistAdapter = PlaylistAdapter(
|
playlistAdapter = PlaylistAdapter(
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/bookmarksTV"
|
android:id="@+id/bookmarksTV"
|
||||||
style="@style/HomeCategoryTitle"
|
style="@style/HomeCategoryTitle"
|
||||||
android:text="@string/playlists" />
|
android:text="@string/bookmarks" />
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/bookmarksRV"
|
android:id="@+id/bookmarksRV"
|
||||||
|
@ -2,32 +2,37 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="250dp"
|
android:layout_width="200dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:layout_margin="5dp"
|
||||||
|
android:background="@drawable/rounded_ripple"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="5dp">
|
||||||
|
|
||||||
<com.google.android.material.imageview.ShapeableImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/thumbnail"
|
android:id="@+id/thumbnail"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginHorizontal="10dp"
|
|
||||||
android:layout_marginVertical="10dp"
|
|
||||||
android:adjustViewBounds="true"
|
android:adjustViewBounds="true"
|
||||||
android:scaleType="fitCenter"
|
android:scaleType="fitCenter"
|
||||||
app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.ExtraLarge"
|
app:shapeAppearanceOverlay="@style/ShapeAppearance.Material3.Corner.Medium"
|
||||||
tools:src="@tools:sample/backgrounds/scenic" />
|
tools:src="@tools:sample/backgrounds/scenic" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/playlistName"
|
android:id="@+id/playlistName"
|
||||||
android:textSize="18sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/uploaderName"
|
android:id="@+id/uploaderName"
|
||||||
android:textSize="16sp"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user