diff --git a/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt index 656ea1ac9..e694e8f5a 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/BottomSheetAdapter.kt @@ -6,6 +6,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.BottomSheetItemBinding import com.github.libretube.obj.BottomSheetItem +import com.github.libretube.ui.viewholders.BottomSheetViewHolder class BottomSheetAdapter( private val items: List, @@ -42,7 +43,3 @@ class BottomSheetAdapter( return items.size } } - -class BottomSheetViewHolder( - val binding: BottomSheetItemBinding -) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt index f8c9b7905..1aedd8049 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/ChannelAdapter.kt @@ -1,5 +1,6 @@ package com.github.libretube.ui.adapters +import android.annotation.SuppressLint import android.text.format.DateUtils import android.view.LayoutInflater import android.view.ViewGroup @@ -10,6 +11,7 @@ import com.github.libretube.extensions.formatShort import com.github.libretube.extensions.setWatchProgressLength import com.github.libretube.extensions.toID import com.github.libretube.sheets.VideoOptionsBottomSheet +import com.github.libretube.ui.viewholders.ChannelViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper @@ -35,6 +37,7 @@ class ChannelAdapter( return ChannelViewHolder(binding) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.binding.apply { @@ -58,5 +61,3 @@ class ChannelAdapter( } } } - -class ChannelViewHolder(val binding: VideoRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt index baf9e555f..b0c65a972 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/ChaptersAdapter.kt @@ -5,6 +5,7 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.ChapterColumnBinding +import com.github.libretube.ui.viewholders.ChaptersViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.ThemeHelper import com.google.android.exoplayer2.ExoPlayer @@ -54,5 +55,3 @@ class ChaptersAdapter( return chapters.size } } - -class ChaptersViewHolder(val binding: ChapterColumnBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 3f9b3bef6..042ad28b1 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -13,6 +13,7 @@ import com.github.libretube.api.obj.CommentsPage import com.github.libretube.databinding.CommentsRowBinding import com.github.libretube.extensions.TAG import com.github.libretube.extensions.formatShort +import com.github.libretube.ui.viewholders.CommentsViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper import kotlinx.coroutines.CoroutineScope @@ -106,5 +107,3 @@ class CommentsAdapter( } } } - -class CommentsViewHolder(val binding: CommentsRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt index e0b0fa10b..1634561ac 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/DownloadsAdapter.kt @@ -10,6 +10,7 @@ import com.github.libretube.constants.IntentData import com.github.libretube.databinding.DownloadedMediaRowBinding import com.github.libretube.obj.DownloadedFile import com.github.libretube.ui.activities.OfflinePlayerActivity +import com.github.libretube.ui.viewholders.DownloadsViewHolder import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.io.File @@ -74,7 +75,3 @@ class DownloadsAdapter( return files.size } } - -class DownloadsViewHolder( - val binding: DownloadedMediaRowBinding -) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/LegacySubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/LegacySubscriptionAdapter.kt index 8b10d9053..b0639128d 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/LegacySubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/LegacySubscriptionAdapter.kt @@ -5,6 +5,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.LegacySubscriptionChannelBinding import com.github.libretube.extensions.toID +import com.github.libretube.ui.viewholders.LegacySubscriptionViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper @@ -42,7 +43,3 @@ class LegacySubscriptionAdapter( return subscriptions.size } } - -class LegacySubscriptionViewHolder( - val binding: LegacySubscriptionChannelBinding -) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt index 0877e420b..41fbad960 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/NavBarOptionsAdapter.kt @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.databinding.NavOptionsItemBinding import com.github.libretube.obj.NavBarItem +import com.github.libretube.ui.viewholders.NavBarOptionsViewHolder class NavBarOptionsAdapter( val items: MutableList @@ -49,7 +50,3 @@ class NavBarOptionsAdapter( return items.filter { it.isEnabled }.size } } - -class NavBarOptionsViewHolder( - val binding: NavOptionsItemBinding -) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt index 514db53dd..06e88f4b6 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistAdapter.kt @@ -14,6 +14,7 @@ import com.github.libretube.extensions.setFormattedDuration import com.github.libretube.extensions.setWatchProgressLength import com.github.libretube.extensions.toID import com.github.libretube.sheets.VideoOptionsBottomSheet +import com.github.libretube.ui.viewholders.PlaylistViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper import com.github.libretube.util.PreferenceHelper @@ -97,5 +98,3 @@ class PlaylistAdapter( } } } - -class PlaylistViewHolder(val binding: PlaylistRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt index a11ce1d87..504bc2c0e 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/PlaylistsAdapter.kt @@ -11,6 +11,7 @@ import com.github.libretube.api.RetrofitInstance import com.github.libretube.databinding.PlaylistsRowBinding import com.github.libretube.extensions.TAG import com.github.libretube.sheets.PlaylistOptionsBottomSheet +import com.github.libretube.ui.viewholders.PlaylistsViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper import com.github.libretube.util.PreferenceHelper @@ -111,5 +112,3 @@ class PlaylistsAdapter( } } } - -class PlaylistsViewHolder(val binding: PlaylistsRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/RepliesAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/RepliesAdapter.kt index 8488cfe38..175fac4ed 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/RepliesAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/RepliesAdapter.kt @@ -1,11 +1,13 @@ package com.github.libretube.ui.adapters +import android.annotation.SuppressLint import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.RepliesRowBinding import com.github.libretube.extensions.formatShort +import com.github.libretube.ui.viewholders.RepliesViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper @@ -31,6 +33,7 @@ class RepliesAdapter( return RepliesViewHolder(binding) } + @SuppressLint("SetTextI18n") override fun onBindViewHolder(holder: RepliesViewHolder, position: Int) { holder.binding.apply { val reply = replies[position] @@ -61,5 +64,3 @@ class RepliesAdapter( return replies.size } } - -class RepliesViewHolder(val binding: RepliesRowBinding) : RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt index 9e7dcc43c..255afe162 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchAdapter.kt @@ -1,5 +1,6 @@ package com.github.libretube.ui.adapters +import android.annotation.SuppressLint import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -7,6 +8,7 @@ import androidx.fragment.app.FragmentManager import androidx.recyclerview.widget.RecyclerView import com.github.libretube.R import com.github.libretube.api.SubscriptionHelper +import com.github.libretube.api.obj.SearchItem import com.github.libretube.databinding.ChannelRowBinding import com.github.libretube.databinding.PlaylistSearchRowBinding import com.github.libretube.databinding.VideoRowBinding @@ -16,6 +18,7 @@ import com.github.libretube.extensions.setWatchProgressLength import com.github.libretube.extensions.toID import com.github.libretube.sheets.PlaylistOptionsBottomSheet import com.github.libretube.sheets.VideoOptionsBottomSheet +import com.github.libretube.ui.viewholders.SearchViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper import kotlinx.coroutines.CoroutineScope @@ -23,12 +26,12 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch class SearchAdapter( - private val searchItems: MutableList, + private val searchItems: MutableList, private val childFragmentManager: FragmentManager ) : RecyclerView.Adapter() { - fun updateItems(newItems: List) { + fun updateItems(newItems: List) { val searchItemsSize = searchItems.size searchItems.addAll(newItems) notifyItemRangeInserted(searchItemsSize, newItems.size) @@ -78,7 +81,7 @@ class SearchAdapter( } } - private fun bindWatch(item: com.github.libretube.api.obj.SearchItem, binding: VideoRowBinding) { + private fun bindWatch(item: SearchItem, binding: VideoRowBinding) { binding.apply { ImageHelper.loadImage(item.thumbnail, thumbnail) thumbnailDuration.setFormattedDuration(item.duration!!) @@ -109,8 +112,9 @@ class SearchAdapter( } } + @SuppressLint("SetTextI18n") private fun bindChannel( - item: com.github.libretube.api.obj.SearchItem, + item: SearchItem, binding: ChannelRowBinding ) { binding.apply { @@ -160,7 +164,7 @@ class SearchAdapter( } private fun bindPlaylist( - item: com.github.libretube.api.obj.SearchItem, + item: SearchItem, binding: PlaylistSearchRowBinding ) { binding.apply { @@ -184,21 +188,3 @@ class SearchAdapter( } } } - -class SearchViewHolder : RecyclerView.ViewHolder { - var videoRowBinding: VideoRowBinding? = null - var channelRowBinding: ChannelRowBinding? = null - var playlistRowBinding: PlaylistSearchRowBinding? = null - - constructor(binding: VideoRowBinding) : super(binding.root) { - videoRowBinding = binding - } - - constructor(binding: ChannelRowBinding) : super(binding.root) { - channelRowBinding = binding - } - - constructor(binding: PlaylistSearchRowBinding) : super(binding.root) { - playlistRowBinding = binding - } -} diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchHistoryAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchHistoryAdapter.kt index d050c624d..e6fff4d31 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchHistoryAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchHistoryAdapter.kt @@ -8,6 +8,7 @@ import com.github.libretube.databinding.SearchhistoryRowBinding import com.github.libretube.db.DatabaseHolder.Companion.Database import com.github.libretube.db.obj.SearchHistoryItem import com.github.libretube.extensions.query +import com.github.libretube.ui.viewholders.SearchHistoryViewHolder class SearchHistoryAdapter( private var historyList: List, @@ -47,6 +48,3 @@ class SearchHistoryAdapter( } } } - -class SearchHistoryViewHolder(val binding: SearchhistoryRowBinding) : - RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SearchSuggestionsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SearchSuggestionsAdapter.kt index c3fdca2ee..1abc3d2b3 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SearchSuggestionsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SearchSuggestionsAdapter.kt @@ -5,6 +5,7 @@ import android.view.ViewGroup import androidx.appcompat.widget.SearchView import androidx.recyclerview.widget.RecyclerView import com.github.libretube.databinding.SearchsuggestionRowBinding +import com.github.libretube.ui.viewholders.SearchSuggestionsViewHolder class SearchSuggestionsAdapter( private var suggestionsList: List, @@ -32,6 +33,3 @@ class SearchSuggestionsAdapter( } } } - -class SearchSuggestionsViewHolder(val binding: SearchsuggestionRowBinding) : - RecyclerView.ViewHolder(binding.root) diff --git a/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt index 2d25c107c..ca792802d 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/SubscriptionChannelAdapter.kt @@ -7,6 +7,7 @@ import com.github.libretube.R import com.github.libretube.api.SubscriptionHelper import com.github.libretube.databinding.ChannelSubscriptionRowBinding import com.github.libretube.extensions.toID +import com.github.libretube.ui.viewholders.SubscriptionChannelViewHolder import com.github.libretube.util.ImageHelper import com.github.libretube.util.NavigationHelper @@ -50,6 +51,3 @@ class SubscriptionChannelAdapter(private val subscriptions: MutableList