fix #11 titres videos et border radius

This commit is contained in:
Raphael
2025-03-11 15:37:55 +01:00
parent fe51ff6804
commit 491849e8fe
6 changed files with 33 additions and 10 deletions

View File

@@ -37,7 +37,7 @@ class ProjectActivity : AppCompatActivity() {
private var project: Project? = null
private var imageUrls = emptyList<String>()
private class GridSpacingItemDecoration(private val spacing: Int) : RecyclerView.ItemDecoration() {
class GridSpacingItemDecoration(private val spacing: Int) : RecyclerView.ItemDecoration() {
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
val position = parent.getChildAdapterPosition(view) // Position de l'item
if (position == RecyclerView.NO_POSITION) return

View File

@@ -7,6 +7,8 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.GridLayout
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dreamteam.timelapse.data.ProjectRepository
@@ -70,7 +72,6 @@ class ProjetsFrag : Fragment(), ProjectAdapter.OnEmptyStateListener {
recyclerView = binding.recyclerView // view.findViewById(R.id.recyclerView)
recyclerView.layoutManager = LinearLayoutManager(context)
}
private fun fetchProjects() {

View File

@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.util.Log
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -13,12 +14,16 @@ import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.dreamteam.timelapse.data.ApiService
import com.dreamteam.timelapse.data.ProjectRepository
import com.dreamteam.timelapse.data.Video
import com.dreamteam.timelapse.data.VideoRepository
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.request.RequestOptions
import com.google.android.material.imageview.ShapeableImageView
class VideoAdapter(
public val withProjectNames : Boolean,
@@ -42,7 +47,7 @@ class VideoAdapter(
class VideoViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val videoTitle: TextView = itemView.findViewById(R.id.videoTitle)
val videoThumbnail: ImageView = itemView.findViewById(R.id.videoThumbnail)
val videoThumbnail: ShapeableImageView = itemView.findViewById(R.id.videoThumbnail)
val playButton: ImageView = itemView.findViewById(R.id.playButton)
}
@@ -65,12 +70,21 @@ class VideoAdapter(
// Load video thumbnail
val url = "https://timelapse.kerboul.me/api/videos/file/${video.id}"
// val shapeAppearanceModel = holder.videoThumbnail.shapeAppearanceModel
// .toBuilder()
// .setAllCornerSizes(
// TypedValue.applyDimension(
// TypedValue.COMPLEX_UNIT_DIP, 25f, holder.itemView.resources.displayMetrics)) // 16dp fixed
// .build()
//holder.videoThumbnail.shapeAppearanceModel = shapeAppearanceModel
Glide.with(context)
.asBitmap()
.load(url) // Load the video URL
.frame(0)
.placeholder(R.drawable.not_found) // Optional placeholder
.into(holder.videoThumbnail)
// Click listener to open video player
holder.itemView.setOnClickListener {
val intent = Intent(context, VideoPlayerActivity::class.java)

View File

@@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dreamteam.timelapse.data.VideoRepository
@@ -69,7 +70,8 @@ class VideoFrag : Fragment(), VideoAdapter.OnEmptyStateListener {
fetchVideos()
recyclerView = binding.recyclerView // view.findViewById(R.id.recyclerView)
recyclerView.layoutManager = LinearLayoutManager(context)
recyclerView.layoutManager = GridLayoutManager(context, 2, RecyclerView.VERTICAL, false)//LinearLayoutManager(context)
recyclerView.addItemDecoration(ProjectActivity.GridSpacingItemDecoration(50)) // 16px spacing
}

View File

@@ -6,17 +6,17 @@
android:layout_height="wrap_content">
<!-- Video Thumbnail -->
<ImageView
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/videoThumbnail"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintDimensionRatio="16:9"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@id/videoTitle"
/>
app:shapeAppearanceOverlay="@style/RoundedImage"/>
<!-- Play Button (Centered on Thumbnail) -->
<ImageView

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="RoundedImage">
<item name="cornerSize">12dp</item>
</style>
</resources>