mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-29 16:30:31 +05:30
refactor: save possible stream types to constant values
This commit is contained in:
parent
f48f3f2fd3
commit
b6cfa62d5d
@ -34,4 +34,10 @@ data class StreamItem(
|
||||
duration = duration
|
||||
)
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val TYPE_STREAM = "stream"
|
||||
const val TYPE_CHANNEL = "channel"
|
||||
const val TYPE_PLAYLIST = "playlist"
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ data class WatchHistoryItem(
|
||||
) {
|
||||
fun toStreamItem() = StreamItem(
|
||||
url = videoId,
|
||||
type = "stream",
|
||||
type = StreamItem.TYPE_STREAM,
|
||||
title = title,
|
||||
thumbnail = thumbnailUrl,
|
||||
uploaderName = uploader,
|
||||
|
@ -6,6 +6,7 @@ import androidx.recyclerview.widget.DiffUtil
|
||||
import androidx.recyclerview.widget.ListAdapter
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.api.obj.ContentItem
|
||||
import com.github.libretube.api.obj.StreamItem
|
||||
import com.github.libretube.databinding.ChannelRowBinding
|
||||
import com.github.libretube.databinding.PlaylistsRowBinding
|
||||
import com.github.libretube.databinding.VideoRowBinding
|
||||
@ -65,9 +66,9 @@ class SearchAdapter(
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return when (currentList[position].type) {
|
||||
"stream" -> 0
|
||||
"channel" -> 1
|
||||
"playlist" -> 2
|
||||
StreamItem.TYPE_STREAM -> 0
|
||||
StreamItem.TYPE_CHANNEL -> 1
|
||||
StreamItem.TYPE_PLAYLIST -> 2
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class VideosAdapter(
|
||||
}
|
||||
|
||||
override fun getItemViewType(position: Int): Int {
|
||||
return if (streamItems[position].type == "caught") CAUGHT_UP_TYPE else NORMAL_TYPE
|
||||
return if (streamItems[position].type == CAUGHT_UP_STREAM_TYPE) CAUGHT_UP_TYPE else NORMAL_TYPE
|
||||
}
|
||||
|
||||
fun updateItems() {
|
||||
@ -231,5 +231,7 @@ class VideosAdapter(
|
||||
|
||||
private const val NORMAL_TYPE = 0
|
||||
private const val CAUGHT_UP_TYPE = 1
|
||||
|
||||
const val CAUGHT_UP_STREAM_TYPE = "caught"
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ class SubscriptionsFragment : Fragment() {
|
||||
(it.uploaded ?: 0L) / 1000 < lastCheckedFeedTime
|
||||
}
|
||||
if (caughtUpIndex > 0) {
|
||||
sortedFeed.add(caughtUpIndex, StreamItem(type = "caught"))
|
||||
sortedFeed.add(caughtUpIndex, StreamItem(type = VideosAdapter.CAUGHT_UP_STREAM_TYPE))
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user