mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-15 14:50:30 +05:30
Merge pull request #4379 from Bnyro/master
chore: simplify RecyclerView.Adapter#getItemCount where possible
This commit is contained in:
commit
18698b4b62
@ -35,7 +35,5 @@ class BottomSheetAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = items.size
|
||||||
return items.size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,5 @@ class CommentsAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = comments.size
|
||||||
return comments.size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,5 @@ class DownloadsAdapter(
|
|||||||
notifyItemInserted(position)
|
notifyItemInserted(position)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = downloads.size
|
||||||
return downloads.size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,7 @@ class IconsSheetAdapter : RecyclerView.Adapter<IconsSheetViewHolder>() {
|
|||||||
return IconsSheetViewHolder(binding)
|
return IconsSheetViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = availableIcons.size
|
||||||
return availableIcons.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: IconsSheetViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: IconsSheetViewHolder, position: Int) {
|
||||||
val appIcon = availableIcons[position]
|
val appIcon = availableIcons[position]
|
||||||
|
@ -47,7 +47,5 @@ class LegacySubscriptionAdapter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = subscriptions.size
|
||||||
return subscriptions.size
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,7 @@ class NavBarOptionsAdapter(
|
|||||||
return NavBarOptionsViewHolder(binding)
|
return NavBarOptionsViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = items.size
|
||||||
return items.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onBindViewHolder(holder: NavBarOptionsViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: NavBarOptionsViewHolder, position: Int) {
|
||||||
val item = items[position]
|
val item = items[position]
|
||||||
|
@ -24,9 +24,7 @@ class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
|
|||||||
return PlayingQueueViewHolder(binding)
|
return PlayingQueueViewHolder(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = PlayingQueue.size()
|
||||||
return PlayingQueue.size()
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) {
|
||||||
|
@ -18,9 +18,7 @@ class PlaylistsAdapter(
|
|||||||
private val playlistType: PlaylistType
|
private val playlistType: PlaylistType
|
||||||
) : RecyclerView.Adapter<PlaylistsViewHolder>() {
|
) : RecyclerView.Adapter<PlaylistsViewHolder>() {
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = playlists.size
|
||||||
return playlists.size
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateItems(newItems: List<Playlists>) {
|
fun updateItems(newItems: List<Playlists>) {
|
||||||
val oldSize = playlists.size
|
val oldSize = playlists.size
|
||||||
|
@ -18,9 +18,7 @@ class SearchHistoryAdapter(
|
|||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<SuggestionsViewHolder>() {
|
RecyclerView.Adapter<SuggestionsViewHolder>() {
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = historyList.size
|
||||||
return historyList.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
|
||||||
val layoutInflater = LayoutInflater.from(parent.context)
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
|
@ -13,9 +13,7 @@ class SearchSuggestionsAdapter(
|
|||||||
) :
|
) :
|
||||||
RecyclerView.Adapter<SuggestionsViewHolder>() {
|
RecyclerView.Adapter<SuggestionsViewHolder>() {
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = suggestionsList.size
|
||||||
return suggestionsList.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
|
||||||
val layoutInflater = LayoutInflater.from(parent.context)
|
val layoutInflater = LayoutInflater.from(parent.context)
|
||||||
|
@ -17,9 +17,7 @@ class SubscriptionChannelAdapter(
|
|||||||
private val subscriptions: MutableList<Subscription>
|
private val subscriptions: MutableList<Subscription>
|
||||||
) : RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
|
) : RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
|
||||||
|
|
||||||
override fun getItemCount(): Int {
|
override fun getItemCount() = subscriptions.size
|
||||||
return subscriptions.size
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreateViewHolder(
|
override fun onCreateViewHolder(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
|
@ -24,7 +24,7 @@ class WatchHistoryAdapter(
|
|||||||
|
|
||||||
private var visibleCount = minOf(10, watchHistory.size)
|
private var visibleCount = minOf(10, watchHistory.size)
|
||||||
|
|
||||||
override fun getItemCount(): Int = visibleCount
|
override fun getItemCount() = visibleCount
|
||||||
|
|
||||||
fun removeFromWatchHistory(position: Int) {
|
fun removeFromWatchHistory(position: Int) {
|
||||||
val history = watchHistory[position]
|
val history = watchHistory[position]
|
||||||
|
Loading…
Reference in New Issue
Block a user