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)
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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"
 | 
			
		||||
 | 
			
		||||
@ -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>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user