mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
Use isShort
to display the shorts label
This commit is contained in:
parent
089e72b0c7
commit
cf5ef1292f
@ -66,7 +66,7 @@ class PlaylistAdapter(
|
|||||||
videoInfo.text = streamItem.uploaderName
|
videoInfo.text = streamItem.uploaderName
|
||||||
channelImage.visibility = View.GONE
|
channelImage.visibility = View.GONE
|
||||||
|
|
||||||
thumbnailDuration.setFormattedDuration(streamItem.duration!!)
|
thumbnailDuration.setFormattedDuration(streamItem.duration!!, streamItem.isShort)
|
||||||
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
||||||
root.setOnClickListener {
|
root.setOnClickListener {
|
||||||
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
NavigationHelper.navigateVideo(root.context, streamItem.url, playlistId)
|
||||||
|
@ -83,7 +83,7 @@ class SearchAdapter(
|
|||||||
private fun bindWatch(item: ContentItem, binding: VideoRowBinding) {
|
private fun bindWatch(item: ContentItem, binding: VideoRowBinding) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
||||||
thumbnailDuration.setFormattedDuration(item.duration!!)
|
thumbnailDuration.setFormattedDuration(item.duration!!, item.isShort)
|
||||||
ImageHelper.loadImage(item.uploaderAvatar, channelImage)
|
ImageHelper.loadImage(item.uploaderAvatar, channelImage)
|
||||||
videoTitle.text = item.title
|
videoTitle.text = item.title
|
||||||
val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else ""
|
val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else ""
|
||||||
|
@ -133,7 +133,7 @@ class VideosAdapter(
|
|||||||
TextUtils.SEPARATOR + video.uploaded?.let {
|
TextUtils.SEPARATOR + video.uploaded?.let {
|
||||||
DateUtils.getRelativeTimeSpanString(it)
|
DateUtils.getRelativeTimeSpanString(it)
|
||||||
}
|
}
|
||||||
video.duration?.let { thumbnailDuration.setFormattedDuration(it) }
|
video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort) }
|
||||||
channelImage.setOnClickListener {
|
channelImage.setOnClickListener {
|
||||||
NavigationHelper.navigateChannel(root.context, video.uploaderUrl)
|
NavigationHelper.navigateChannel(root.context, video.uploaderUrl)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ class WatchHistoryAdapter(
|
|||||||
videoTitle.text = video.title
|
videoTitle.text = video.title
|
||||||
channelName.text = video.uploader
|
channelName.text = video.uploader
|
||||||
videoInfo.text = video.uploadDate
|
videoInfo.text = video.uploadDate
|
||||||
thumbnailDuration.setFormattedDuration(video.duration!!)
|
thumbnailDuration.setFormattedDuration(video.duration!!, null)
|
||||||
ImageHelper.loadImage(video.thumbnailUrl, thumbnail)
|
ImageHelper.loadImage(video.thumbnailUrl, thumbnail)
|
||||||
ImageHelper.loadImage(video.uploaderAvatar, channelImage)
|
ImageHelper.loadImage(video.uploaderAvatar, channelImage)
|
||||||
|
|
||||||
|
@ -4,13 +4,10 @@ import android.text.format.DateUtils
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import com.github.libretube.R
|
import com.github.libretube.R
|
||||||
|
|
||||||
fun TextView.setFormattedDuration(duration: Long) {
|
fun TextView.setFormattedDuration(duration: Long, isShort: Boolean?) {
|
||||||
val text = if (duration < 0L) {
|
this.text = when {
|
||||||
this.context.getString(R.string.live)
|
isShort == true -> context.getString(R.string.yt_shorts)
|
||||||
} else if (duration in 0L..60L) {
|
duration < 0L -> context.getString(R.string.live)
|
||||||
this.context.getString(R.string.yt_shorts)
|
else -> DateUtils.formatElapsedTime(duration)
|
||||||
} else {
|
|
||||||
DateUtils.formatElapsedTime(duration)
|
|
||||||
}
|
}
|
||||||
this.text = text
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user