From b2196f11dae062ac78b39f9cc8e470d1f4c83c22 Mon Sep 17 00:00:00 2001 From: Jannik Date: Sun, 3 Apr 2022 14:57:14 +0200 Subject: [PATCH] add playhead progress indicator to MediaFragment epsiodes --- .../teapod/util/adapter/EpisodeItemAdapter.kt | 9 +++++++++ app/src/main/res/layout/item_episode.xml | 20 ++++++++++++++----- .../main/res/layout/item_episode_player.xml | 10 +++++----- app/src/main/res/values/colors.xml | 2 +- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/org/mosad/teapod/util/adapter/EpisodeItemAdapter.kt b/app/src/main/java/org/mosad/teapod/util/adapter/EpisodeItemAdapter.kt index e8f64a9..291f540 100644 --- a/app/src/main/java/org/mosad/teapod/util/adapter/EpisodeItemAdapter.kt +++ b/app/src/main/java/org/mosad/teapod/util/adapter/EpisodeItemAdapter.kt @@ -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) diff --git a/app/src/main/res/layout/item_episode.xml b/app/src/main/res/layout/item_episode.xml index 77e1e06..b731a31 100644 --- a/app/src/main/res/layout/item_episode.xml +++ b/app/src/main/res/layout/item_episode.xml @@ -10,21 +10,22 @@ android:paddingBottom="7dp"> + android:layout_width="128dp" + android:layout_height="72dp"> + app:srcCompat="@color/imagePlaceholder" /> + + + android:layout_width="192dp" + android:layout_height="108dp"> + app:srcCompat="@color/imagePlaceholder" /> #99dc45 #317a00 #607d8b - #c2c2c2 + #c2c2c2 #ffffff