add playhead progress indicator to MediaFragment epsiodes

This commit is contained in:
2022-04-03 14:57:14 +02:00
parent 5b5a74a1de
commit b2196f11da
4 changed files with 30 additions and 11 deletions

View File

@ -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)