From a7f4472a5ae42bf29f1e5a06cf6267fba012f968 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Mon, 14 Feb 2022 20:47:50 +0000 Subject: [PATCH] Show duration on ImageView. --- .../java/com/github/libretube/adapters/ChannelAdapter.kt | 4 +++- .../com/github/libretube/adapters/PlaylistAdapter.kt | 2 ++ .../com/github/libretube/adapters/SubscriptionAdapter.kt | 4 +++- .../com/github/libretube/adapters/TrendingAdapter.kt | 4 +++- app/src/main/res/layout/trending_row.xml | 9 +++++++++ app/src/main/res/layout/video_channel_row.xml | 9 +++++++++ app/src/main/res/values/colors.xml | 3 +++ 7 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index dd6a35b2a..ab4339994 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -35,7 +36,8 @@ class ChannelAdapter(private val videoFeed: MutableList): RecyclerVi override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = trending.title - holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(trending.thumbnail).into(thumbnailImage) holder.v.setOnClickListener{ diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index 0c74af0d2..1577c101d 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -36,6 +37,7 @@ class PlaylistAdapter(private val videoFeed: MutableList): RecyclerV val streamItem = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = streamItem.title holder.v.findViewById(R.id.channel_views).text = streamItem.uploaderName + holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(streamItem.thumbnail).into(thumbnailImage) holder.v.setOnClickListener{ diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt index c3a712f23..4ce20afc5 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -42,8 +43,9 @@ class SubscriptionAdapter(private val videoFeed: List): RecyclerView override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) + holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) channelImage.setOnClickListener{ val activity = holder.v.context as MainActivity diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt index 409112613..89da2c561 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -1,6 +1,7 @@ package com.github.libretube.adapters import android.os.Bundle +import android.text.format.DateUtils import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -31,8 +32,9 @@ class TrendingAdapter(private val videoFeed: List): RecyclerView.Ada override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) + holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) channelImage.setOnClickListener{ val activity = holder.v.context as MainActivity diff --git a/app/src/main/res/layout/trending_row.xml b/app/src/main/res/layout/trending_row.xml index 943f33ac6..96b42d93d 100644 --- a/app/src/main/res/layout/trending_row.xml +++ b/app/src/main/res/layout/trending_row.xml @@ -27,6 +27,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" /> + diff --git a/app/src/main/res/layout/video_channel_row.xml b/app/src/main/res/layout/video_channel_row.xml index 667c11440..ef136672c 100644 --- a/app/src/main/res/layout/video_channel_row.xml +++ b/app/src/main/res/layout/video_channel_row.xml @@ -34,6 +34,15 @@ android:layout_width="match_parent" android:layout_height="match_parent" tools:srcCompat="@tools:sample/backgrounds/scenic" /> + #000000 #ffffff + #AA000000 + #EEFFFFFF + #B81B3B #B81B3B #FFFFFF