mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
feat(VideosAdapter): clearly indicate future videos as upcoming
Replaces the duration of future videos (i.e. Premieres) as 'Upcoming'. This helps to differentiate them from normal videos.
This commit is contained in:
parent
884a8c8527
commit
de975986ce
@ -83,7 +83,7 @@ class PlaylistAdapter(
|
|||||||
videoInfo.text = streamItem.uploaderName
|
videoInfo.text = streamItem.uploaderName
|
||||||
channelImage.isGone = true
|
channelImage.isGone = true
|
||||||
|
|
||||||
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort)
|
thumbnailDuration.setFormattedDuration(streamItem.duration ?: -1, streamItem.isShort, streamItem.uploaded)
|
||||||
|
|
||||||
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
ImageHelper.loadImage(streamItem.thumbnail, thumbnail)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class SearchChannelAdapter : ListAdapter<ContentItem, SearchViewHolder>(SearchCa
|
|||||||
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
|
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
||||||
thumbnailDuration.setFormattedDuration(item.duration, item.isShort)
|
thumbnailDuration.setFormattedDuration(item.duration, item.isShort, item.uploaded)
|
||||||
videoTitle.text = item.title
|
videoTitle.text = item.title
|
||||||
videoInfo.text = TextUtils.formatViewsString(root.context, item.views, item.uploaded)
|
videoInfo.text = TextUtils.formatViewsString(root.context, item.views, item.uploaded)
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ class SearchResultsAdapter(
|
|||||||
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
|
private fun bindVideo(item: ContentItem, binding: VideoRowBinding, position: Int) {
|
||||||
binding.apply {
|
binding.apply {
|
||||||
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
ImageHelper.loadImage(item.thumbnail, thumbnail)
|
||||||
thumbnailDuration.setFormattedDuration(item.duration, item.isShort)
|
thumbnailDuration.setFormattedDuration(item.duration, item.isShort, item.uploaded)
|
||||||
videoTitle.text = item.title
|
videoTitle.text = item.title
|
||||||
videoInfo.text = TextUtils.formatViewsString(root.context, item.views, item.uploaded)
|
videoInfo.text = TextUtils.formatViewsString(root.context, item.views, item.uploaded)
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ class VideosAdapter(
|
|||||||
textViewTitle.text = video.title
|
textViewTitle.text = video.title
|
||||||
textViewChannel.text = TextUtils.formatViewsString(root.context, video.views ?: -1, video.uploaded, video.uploaderName)
|
textViewChannel.text = TextUtils.formatViewsString(root.context, video.views ?: -1, video.uploaded, video.uploaderName)
|
||||||
|
|
||||||
video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort) }
|
video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort, video.uploaded) }
|
||||||
channelImage.setOnClickListener {
|
channelImage.setOnClickListener {
|
||||||
NavigationHelper.navigateChannel(root.context, video.uploaderUrl)
|
NavigationHelper.navigateChannel(root.context, video.uploaderUrl)
|
||||||
}
|
}
|
||||||
@ -141,7 +141,7 @@ class VideosAdapter(
|
|||||||
videoTitle.text = video.title
|
videoTitle.text = video.title
|
||||||
videoInfo.text = TextUtils.formatViewsString(root.context, video.views ?: -1, video.uploaded)
|
videoInfo.text = TextUtils.formatViewsString(root.context, video.views ?: -1, video.uploaded)
|
||||||
|
|
||||||
thumbnailDuration.text = video.duration?.let { DateUtils.formatElapsedTime(it) }
|
video.duration?.let { thumbnailDuration.setFormattedDuration(it, video.isShort, video.uploaded) }
|
||||||
ImageHelper.loadImage(video.thumbnail, thumbnail)
|
ImageHelper.loadImage(video.thumbnail, thumbnail)
|
||||||
|
|
||||||
if (forceMode != LayoutMode.CHANNEL_ROW) {
|
if (forceMode != LayoutMode.CHANNEL_ROW) {
|
||||||
|
@ -59,7 +59,8 @@ class WatchHistoryAdapter(
|
|||||||
ImageHelper.loadImage(video.thumbnailUrl, thumbnail)
|
ImageHelper.loadImage(video.thumbnailUrl, thumbnail)
|
||||||
|
|
||||||
if (video.duration != null) {
|
if (video.duration != null) {
|
||||||
thumbnailDuration.setFormattedDuration(video.duration, null)
|
// we pass in 0 for the uploadDate, as a future video cannot be watched already
|
||||||
|
thumbnailDuration.setFormattedDuration(video.duration, null, 0)
|
||||||
} else {
|
} else {
|
||||||
thumbnailDurationCard.isGone = true
|
thumbnailDurationCard.isGone = true
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,11 @@ 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, isShort: Boolean?) {
|
fun TextView.setFormattedDuration(duration: Long, isShort: Boolean?, uploadDate: Long) {
|
||||||
this.text = when {
|
this.text = when {
|
||||||
isShort == true -> context.getString(R.string.yt_shorts)
|
isShort == true -> context.getString(R.string.yt_shorts)
|
||||||
duration < 0L -> context.getString(R.string.live)
|
duration < 0L -> context.getString(R.string.live)
|
||||||
|
uploadDate > System.currentTimeMillis() -> context.getString(R.string.upcoming)
|
||||||
else -> DateUtils.formatElapsedTime(duration)
|
else -> DateUtils.formatElapsedTime(duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,7 @@
|
|||||||
<string name="appearance_summary">Adjust the app to your liking</string>
|
<string name="appearance_summary">Adjust the app to your liking</string>
|
||||||
<string name="advanced_summary">Downloads, and reset</string>
|
<string name="advanced_summary">Downloads, and reset</string>
|
||||||
<string name="live">Live</string>
|
<string name="live">Live</string>
|
||||||
|
<string name="upcoming">Upcoming</string>
|
||||||
<string name="shareTo">Share URL to</string>
|
<string name="shareTo">Share URL to</string>
|
||||||
<string name="normal_views">%1$s views%2$s</string>
|
<string name="normal_views">%1$s views%2$s</string>
|
||||||
<string name="defaultIcon">Default</string>
|
<string name="defaultIcon">Default</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user