diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index 43918a359..510051a28 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -2,10 +2,11 @@ package com.github.libretube.adapters import android.text.format.DateUtils import android.view.LayoutInflater +import android.view.View import android.view.ViewGroup import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.databinding.VideoChannelRowBinding +import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.obj.StreamItem import com.github.libretube.util.ConnectionHelper @@ -29,20 +30,22 @@ class ChannelAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ChannelViewHolder { val layoutInflater = LayoutInflater.from(parent.context) - val binding = VideoChannelRowBinding.inflate(layoutInflater, parent, false) + val binding = VideoRowBinding.inflate(layoutInflater, parent, false) return ChannelViewHolder(binding) } override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.binding.apply { - channelDescription.text = trending.title - channelViews.text = + channelImage.visibility = View.GONE + channelName.visibility = View.GONE + videoTitle.text = trending.title + videoInfo.text = trending.views.formatShort() + " • " + DateUtils.getRelativeTimeSpanString(trending.uploaded!!) - channelDuration.text = + thumbnailDuration.text = DateUtils.formatElapsedTime(trending.duration!!) - ConnectionHelper.loadImage(trending.thumbnail, channelThumbnail) + ConnectionHelper.loadImage(trending.thumbnail, thumbnail) root.setOnClickListener { NavigationHelper.navigateVideo(root.context, trending.url) } @@ -56,4 +59,4 @@ class ChannelAdapter( } } -class ChannelViewHolder(val binding: VideoChannelRowBinding) : RecyclerView.ViewHolder(binding.root) +class ChannelViewHolder(val binding: VideoRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt index d9164eb05..c2802a865 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -7,9 +7,9 @@ import android.view.ViewGroup import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R -import com.github.libretube.databinding.ChannelSearchRowBinding +import com.github.libretube.databinding.ChannelRowBinding import com.github.libretube.databinding.PlaylistSearchRowBinding -import com.github.libretube.databinding.VideoSearchRowBinding +import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.dialogs.PlaylistOptionsDialog import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.obj.SearchItem @@ -45,10 +45,10 @@ class SearchAdapter( return when (viewType) { 0 -> SearchViewHolder( - VideoSearchRowBinding.inflate(layoutInflater, parent, false) + VideoRowBinding.inflate(layoutInflater, parent, false) ) 1 -> SearchViewHolder( - ChannelSearchRowBinding.inflate(layoutInflater, parent, false) + ChannelRowBinding.inflate(layoutInflater, parent, false) ) 2 -> SearchViewHolder( PlaylistSearchRowBinding.inflate(layoutInflater, parent, false) @@ -78,26 +78,26 @@ class SearchAdapter( } } - private fun bindWatch(item: SearchItem, binding: VideoSearchRowBinding) { + private fun bindWatch(item: SearchItem, binding: VideoRowBinding) { binding.apply { - ConnectionHelper.loadImage(item.thumbnail, searchThumbnail) + ConnectionHelper.loadImage(item.thumbnail, thumbnail) if (item.duration != -1L) { - searchThumbnailDuration.text = DateUtils.formatElapsedTime(item.duration!!) + thumbnailDuration.text = DateUtils.formatElapsedTime(item.duration!!) } else { - searchThumbnailDuration.text = root.context.getString(R.string.live) - searchThumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark) + thumbnailDuration.text = root.context.getString(R.string.live) + thumbnailDuration.setBackgroundColor(R.attr.colorPrimaryDark) } - ConnectionHelper.loadImage(item.uploaderAvatar, searchChannelImage) - searchDescription.text = item.title + ConnectionHelper.loadImage(item.uploaderAvatar, channelImage) + videoTitle.text = item.title val viewsString = if (item.views?.toInt() != -1) item.views.formatShort() else "" val uploadDate = if (item.uploadedDate != null) item.uploadedDate else "" - searchViews.text = + videoInfo.text = if (viewsString != "" && uploadDate != "") { "$viewsString • $uploadDate" } else { viewsString + uploadDate } - searchChannelName.text = item.uploaderName + channelName.text = item.uploaderName root.setOnClickListener { NavigationHelper.navigateVideo(root.context, item.url) } @@ -107,13 +107,13 @@ class SearchAdapter( .show(childFragmentManager, "VideoOptionsDialog") true } - searchChannelImage.setOnClickListener { + channelImage.setOnClickListener { NavigationHelper.navigateChannel(root.context, item.uploaderUrl) } } } - private fun bindChannel(item: SearchItem, binding: ChannelSearchRowBinding) { + private fun bindChannel(item: SearchItem, binding: ChannelRowBinding) { binding.apply { ConnectionHelper.loadImage(item.thumbnail, searchChannelImage) searchChannelName.text = item.name @@ -132,7 +132,7 @@ class SearchAdapter( } } - private fun isSubscribed(channelId: String, token: String, binding: ChannelSearchRowBinding) { + private fun isSubscribed(channelId: String, token: String, binding: ChannelRowBinding) { var isSubscribed = false // check whether the user subscribed to the channel @@ -223,15 +223,15 @@ class SearchAdapter( } class SearchViewHolder : RecyclerView.ViewHolder { - var videoRowBinding: VideoSearchRowBinding? = null - var channelRowBinding: ChannelSearchRowBinding? = null + var videoRowBinding: VideoRowBinding? = null + var channelRowBinding: ChannelRowBinding? = null var playlistRowBinding: PlaylistSearchRowBinding? = null - constructor(binding: VideoSearchRowBinding) : super(binding.root) { + constructor(binding: VideoRowBinding) : super(binding.root) { videoRowBinding = binding } - constructor(binding: ChannelSearchRowBinding) : super(binding.root) { + constructor(binding: ChannelRowBinding) : super(binding.root) { channelRowBinding = binding } diff --git a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt index ec4e3d4a0..afee515ca 100644 --- a/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/WatchHistoryAdapter.kt @@ -5,7 +5,7 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView -import com.github.libretube.databinding.WatchHistoryRowBinding +import com.github.libretube.databinding.VideoRowBinding import com.github.libretube.dialogs.VideoOptionsDialog import com.github.libretube.obj.WatchHistoryItem import com.github.libretube.util.ConnectionHelper @@ -26,7 +26,7 @@ class WatchHistoryAdapter( override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WatchHistoryViewHolder { val layoutInflater = LayoutInflater.from(parent.context) - val binding = WatchHistoryRowBinding.inflate(layoutInflater, parent, false) + val binding = VideoRowBinding.inflate(layoutInflater, parent, false) return WatchHistoryViewHolder(binding) } @@ -35,7 +35,7 @@ class WatchHistoryAdapter( holder.binding.apply { videoTitle.text = video.title channelName.text = video.uploader - uploadDate.text = video.uploadDate + videoInfo.text = video.uploadDate thumbnailDuration.text = DateUtils.formatElapsedTime(video.duration?.toLong()!!) ConnectionHelper.loadImage(video.thumbnailUrl, thumbnail) ConnectionHelper.loadImage(video.uploaderAvatar, channelImage) @@ -60,5 +60,5 @@ class WatchHistoryAdapter( } } -class WatchHistoryViewHolder(val binding: WatchHistoryRowBinding) : +class WatchHistoryViewHolder(val binding: VideoRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/res/layout/channel_search_row.xml b/app/src/main/res/layout/channel_row.xml similarity index 100% rename from app/src/main/res/layout/channel_search_row.xml rename to app/src/main/res/layout/channel_row.xml diff --git a/app/src/main/res/layout/video_channel_row.xml b/app/src/main/res/layout/video_channel_row.xml deleted file mode 100644 index d09f8a5f3..000000000 --- a/app/src/main/res/layout/video_channel_row.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/watch_history_row.xml b/app/src/main/res/layout/video_row.xml similarity index 94% rename from app/src/main/res/layout/watch_history_row.xml rename to app/src/main/res/layout/video_row.xml index 1de9b89eb..afde087e5 100644 --- a/app/src/main/res/layout/watch_history_row.xml +++ b/app/src/main/res/layout/video_row.xml @@ -73,7 +73,7 @@ app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@id/video_info" /> - + app:layout_constraintTop_toBottomOf="@id/video_info" /> \ No newline at end of file diff --git a/app/src/main/res/layout/video_search_row.xml b/app/src/main/res/layout/video_search_row.xml deleted file mode 100644 index 8d504f433..000000000 --- a/app/src/main/res/layout/video_search_row.xml +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file