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
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<StreamItem>): RecyclerVi
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
val trending = videoFeed[position]
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)
Picasso.get().load(trending.thumbnail).into(thumbnailImage)
holder.v.setOnClickListener{

View File

@ -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<StreamItem>): RecyclerV
val streamItem = videoFeed[position]
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_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!)
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
Picasso.get().load(streamItem.thumbnail).into(thumbnailImage)
holder.v.setOnClickListener{

View File

@ -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<StreamItem>): RecyclerView
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
val trending = videoFeed[position]
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)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
channelImage.setOnClickListener{
val activity = holder.v.context as MainActivity

View File

@ -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<StreamItem>): RecyclerView.Ada
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
val trending = videoFeed[position]
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)
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
channelImage.setOnClickListener{
val activity = holder.v.context as MainActivity

View File

@ -27,6 +27,15 @@
android:layout_width="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>

View File

@ -34,6 +34,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
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>
<TextView

View File

@ -3,6 +3,9 @@
<color name="black">#000000</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="md_theme_light_primary">#B81B3B</color>
<color name="md_theme_light_onPrimary">#FFFFFF</color>