fix #11 titres videos et border radius
This commit is contained in:
@@ -37,7 +37,7 @@ class ProjectActivity : AppCompatActivity() {
|
|||||||
private var project: Project? = null
|
private var project: Project? = null
|
||||||
private var imageUrls = emptyList<String>()
|
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) {
|
override fun getItemOffsets(outRect: Rect, view: View, parent: RecyclerView, state: RecyclerView.State) {
|
||||||
val position = parent.getChildAdapterPosition(view) // Position de l'item
|
val position = parent.getChildAdapterPosition(view) // Position de l'item
|
||||||
if (position == RecyclerView.NO_POSITION) return
|
if (position == RecyclerView.NO_POSITION) return
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import androidx.fragment.app.Fragment
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import android.widget.GridLayout
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.dreamteam.timelapse.data.ProjectRepository
|
import com.dreamteam.timelapse.data.ProjectRepository
|
||||||
@@ -70,7 +72,6 @@ class ProjetsFrag : Fragment(), ProjectAdapter.OnEmptyStateListener {
|
|||||||
recyclerView = binding.recyclerView // view.findViewById(R.id.recyclerView)
|
recyclerView = binding.recyclerView // view.findViewById(R.id.recyclerView)
|
||||||
recyclerView.layoutManager = LinearLayoutManager(context)
|
recyclerView.layoutManager = LinearLayoutManager(context)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun fetchProjects() {
|
private fun fetchProjects() {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.annotation.SuppressLint
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
@@ -13,12 +14,16 @@ import androidx.core.content.ContextCompat
|
|||||||
import androidx.core.graphics.drawable.DrawableCompat
|
import androidx.core.graphics.drawable.DrawableCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
|
import com.bumptech.glide.load.resource.bitmap.CenterCrop
|
||||||
import com.dreamteam.timelapse.data.ApiService
|
import com.dreamteam.timelapse.data.ApiService
|
||||||
import com.dreamteam.timelapse.data.ProjectRepository
|
import com.dreamteam.timelapse.data.ProjectRepository
|
||||||
import com.dreamteam.timelapse.data.Video
|
import com.dreamteam.timelapse.data.Video
|
||||||
import com.dreamteam.timelapse.data.VideoRepository
|
import com.dreamteam.timelapse.data.VideoRepository
|
||||||
import retrofit2.Retrofit
|
import retrofit2.Retrofit
|
||||||
import retrofit2.converter.gson.GsonConverterFactory
|
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(
|
class VideoAdapter(
|
||||||
public val withProjectNames : Boolean,
|
public val withProjectNames : Boolean,
|
||||||
@@ -42,7 +47,7 @@ class VideoAdapter(
|
|||||||
|
|
||||||
class VideoViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
class VideoViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||||
val videoTitle: TextView = itemView.findViewById(R.id.videoTitle)
|
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)
|
val playButton: ImageView = itemView.findViewById(R.id.playButton)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,12 +70,21 @@ class VideoAdapter(
|
|||||||
|
|
||||||
// Load video thumbnail
|
// Load video thumbnail
|
||||||
val url = "https://timelapse.kerboul.me/api/videos/file/${video.id}"
|
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)
|
Glide.with(context)
|
||||||
.asBitmap()
|
|
||||||
.load(url) // Load the video URL
|
.load(url) // Load the video URL
|
||||||
.frame(0)
|
.frame(0)
|
||||||
.placeholder(R.drawable.not_found) // Optional placeholder
|
.placeholder(R.drawable.not_found) // Optional placeholder
|
||||||
.into(holder.videoThumbnail)
|
.into(holder.videoThumbnail)
|
||||||
|
|
||||||
// Click listener to open video player
|
// Click listener to open video player
|
||||||
holder.itemView.setOnClickListener {
|
holder.itemView.setOnClickListener {
|
||||||
val intent = Intent(context, VideoPlayerActivity::class.java)
|
val intent = Intent(context, VideoPlayerActivity::class.java)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import androidx.fragment.app.Fragment
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.dreamteam.timelapse.data.VideoRepository
|
import com.dreamteam.timelapse.data.VideoRepository
|
||||||
@@ -69,7 +70,8 @@ class VideoFrag : Fragment(), VideoAdapter.OnEmptyStateListener {
|
|||||||
fetchVideos()
|
fetchVideos()
|
||||||
|
|
||||||
recyclerView = binding.recyclerView // view.findViewById(R.id.recyclerView)
|
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
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,17 +6,17 @@
|
|||||||
android:layout_height="wrap_content">
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
<!-- Video Thumbnail -->
|
<!-- Video Thumbnail -->
|
||||||
<ImageView
|
<com.google.android.material.imageview.ShapeableImageView
|
||||||
android:id="@+id/videoThumbnail"
|
android:id="@+id/videoThumbnail"
|
||||||
android:layout_width="0dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="0dp"
|
||||||
android:scaleType="centerCrop"
|
android:scaleType="centerCrop"
|
||||||
app:layout_constraintDimensionRatio="16:9"
|
app:layout_constraintDimensionRatio="16:9"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintBottom_toTopOf="@id/videoTitle"
|
app:layout_constraintBottom_toTopOf="@id/videoTitle"
|
||||||
/>
|
app:shapeAppearanceOverlay="@style/RoundedImage"/>
|
||||||
|
|
||||||
<!-- Play Button (Centered on Thumbnail) -->
|
<!-- Play Button (Centered on Thumbnail) -->
|
||||||
<ImageView
|
<ImageView
|
||||||
|
|||||||
6
app/src/main/res/values/styles.xml
Normal file
6
app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="RoundedImage">
|
||||||
|
<item name="cornerSize">12dp</item>
|
||||||
|
</style>
|
||||||
|
</resources>
|
||||||
Reference in New Issue
Block a user