Browse Source

add playhead progress indicator to MediaFragment epsiodes

develop
Jannik 3 months ago
parent
commit
b2196f11da
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 9
      app/src/main/java/org/mosad/teapod/util/adapter/EpisodeItemAdapter.kt
  2. 20
      app/src/main/res/layout/item_episode.xml
  3. 10
      app/src/main/res/layout/item_episode_player.xml
  4. 2
      app/src/main/res/values/colors.xml

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

20
app/src/main/res/layout/item_episode.xml

@ -10,21 +10,22 @@
android:paddingBottom="7dp">
<LinearLayout
android:id="@+id/linear_episode"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="128dp"
android:layout_height="72dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image_episode"
android:layout_width="128dp"
android:layout_height="72dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/component_poster_desc"
app:shapeAppearance="@style/ShapeAppearance.Teapod.RoundedPoster"
app:srcCompat="@color/imagePlacholder" />
app:srcCompat="@color/imagePlaceholder" />
<ImageView
android:id="@+id/image_episode_play"
@ -35,6 +36,15 @@
android:contentDescription="@string/button_play"
app:srcCompat="@drawable/ic_baseline_play_arrow_24"
app:tint="#FFFFFF" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/progress_playhead"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:max="100"
app:trackColor="#00FFFFFF"
app:trackThickness="2dp" />
</FrameLayout>
<TextView

10
app/src/main/res/layout/item_episode_player.xml

@ -7,16 +7,16 @@
android:padding="7dp">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_width="192dp"
android:layout_height="108dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="@+id/image_episode"
android:layout_width="192dp"
android:layout_height="108dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/component_poster_desc"
app:shapeAppearance="@style/ShapeAppearance.Teapod.RoundedPoster"
app:srcCompat="@color/imagePlacholder" />
app:srcCompat="@color/imagePlaceholder" />
<ImageView
android:id="@+id/image_episode_play"

2
app/src/main/res/values/colors.xml

@ -5,7 +5,7 @@
<color name="colorPrimaryLight">#99dc45</color>
<color name="colorPrimaryDark">#317a00</color>
<color name="colorAccent">#607d8b</color>
<color name="imagePlacholder">#c2c2c2</color>
<color name="imagePlaceholder">#c2c2c2</color>
<!-- light theme colors -->
<color name="themePrimaryLight">#ffffff</color>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close