Show duration on ImageView.

This commit is contained in:
FireMasterK 2022-02-14 20:47:50 +00:00
parent 70dab9fd4e
commit a7f4472a5a
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
7 changed files with 32 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -35,7 +36,8 @@ class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerVi
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
val trending = videoFeed[position] val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.channel_description).text = trending.title holder.v.findViewById<TextView>(R.id.channel_description).text = trending.title
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.videoViews()+""+trending.uploadedDate holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.videoViews()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail) val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
Picasso.get().load(trending.thumbnail).into(thumbnailImage) Picasso.get().load(trending.thumbnail).into(thumbnailImage)
holder.v.setOnClickListener{ holder.v.setOnClickListener{

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -36,6 +37,7 @@ class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerV
val streamItem = videoFeed[position] val streamItem = videoFeed[position]
holder.v.findViewById<TextView>(R.id.channel_description).text = streamItem.title holder.v.findViewById<TextView>(R.id.channel_description).text = streamItem.title
holder.v.findViewById<TextView>(R.id.channel_views).text = streamItem.uploaderName holder.v.findViewById<TextView>(R.id.channel_views).text = streamItem.uploaderName
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail) val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
Picasso.get().load(streamItem.thumbnail).into(thumbnailImage) Picasso.get().load(streamItem.thumbnail).into(thumbnailImage)
holder.v.setOnClickListener{ holder.v.setOnClickListener{

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -42,8 +43,9 @@ class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) { override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
val trending = videoFeed[position] val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+trending.uploadedDate holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail) val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image) val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
channelImage.setOnClickListener{ channelImage.setOnClickListener{
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity

View File

@ -1,6 +1,7 @@
package com.github.libretube.adapters package com.github.libretube.adapters
import android.os.Bundle import android.os.Bundle
import android.text.format.DateUtils
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -31,8 +32,9 @@ class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Ada
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
val trending = videoFeed[position] val trending = videoFeed[position]
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+trending.uploadedDate holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +""+ trending.views.videoViews()+""+DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail) val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image) val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
channelImage.setOnClickListener{ channelImage.setOnClickListener{
val activity = holder.v.context as MainActivity val activity = holder.v.context as MainActivity

View File

@ -27,6 +27,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
/> />
<TextView
android:id="@+id/thumbnail_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="5dp"
android:textColor="@color/duration_text_color"
android:background="@color/duration_background_color"
android:padding="0.5dp"/>
</androidx.cardview.widget.CardView> </androidx.cardview.widget.CardView>

View File

@ -34,6 +34,15 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:srcCompat="@tools:sample/backgrounds/scenic" /> tools:srcCompat="@tools:sample/backgrounds/scenic" />
<TextView
android:id="@+id/channel_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="5dp"
android:textColor="@color/duration_text_color"
android:background="@color/duration_background_color"
android:padding="0.5dp"/>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>
<TextView <TextView

View File

@ -3,6 +3,9 @@
<color name="black">#000000</color> <color name="black">#000000</color>
<color name="white">#ffffff</color> <color name="white">#ffffff</color>
<color name="duration_background_color">#AA000000</color>
<color name="duration_text_color">#EEFFFFFF</color>
<color name="colorPrimary">#B81B3B</color> <color name="colorPrimary">#B81B3B</color>
<color name="md_theme_light_primary">#B81B3B</color> <color name="md_theme_light_primary">#B81B3B</color>
<color name="md_theme_light_onPrimary">#FFFFFF</color> <color name="md_theme_light_onPrimary">#FFFFFF</color>