add playhead progress indicator to MediaFragment epsiodes
This commit is contained in:
@ -4,6 +4,7 @@ import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
@ -60,6 +61,14 @@ class EpisodeItemAdapter(
|
||||
.into(holder.binding.imageEpisode)
|
||||
}
|
||||
|
||||
// add watched progress
|
||||
val playheadProgress = playheads[ep.id]?.let { playhead ->
|
||||
((playhead.playhead.toFloat() / (ep.durationMs / 1000)) * 100).toInt()
|
||||
} ?: 0
|
||||
holder.binding.progressPlayhead.setProgressCompat(playheadProgress, false)
|
||||
holder.binding.progressPlayhead.visibility = if (playheadProgress <= 0)
|
||||
View.GONE else View.VISIBLE
|
||||
|
||||
// add watched icon to episode, if the episode id is present in playheads and fullyWatched
|
||||
val watchedImage: Drawable? = if (playheads[ep.id]?.fullyWatched == true) {
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_baseline_check_circle_24)
|
||||
|
Reference in New Issue
Block a user