Merge pull request #4379 from Bnyro/master

chore: simplify RecyclerView.Adapter#getItemCount where possible
This commit is contained in:
Bnyro 2023-08-05 18:43:29 +02:00 committed by GitHub
commit 18698b4b62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 12 additions and 34 deletions

View File

@ -35,7 +35,5 @@ class BottomSheetAdapter(
}
}
override fun getItemCount(): Int {
return items.size
}
override fun getItemCount() = items.size
}

View File

@ -134,7 +134,5 @@ class CommentsAdapter(
}
}
override fun getItemCount(): Int {
return comments.size
}
override fun getItemCount() = comments.size
}

View File

@ -141,7 +141,5 @@ class DownloadsAdapter(
notifyItemInserted(position)
}
override fun getItemCount(): Int {
return downloads.size
}
override fun getItemCount() = downloads.size
}

View File

@ -18,9 +18,7 @@ class IconsSheetAdapter : RecyclerView.Adapter<IconsSheetViewHolder>() {
return IconsSheetViewHolder(binding)
}
override fun getItemCount(): Int {
return availableIcons.size
}
override fun getItemCount() = availableIcons.size
override fun onBindViewHolder(holder: IconsSheetViewHolder, position: Int) {
val appIcon = availableIcons[position]

View File

@ -47,7 +47,5 @@ class LegacySubscriptionAdapter(
}
}
override fun getItemCount(): Int {
return subscriptions.size
}
override fun getItemCount() = subscriptions.size
}

View File

@ -22,9 +22,7 @@ class NavBarOptionsAdapter(
return NavBarOptionsViewHolder(binding)
}
override fun getItemCount(): Int {
return items.size
}
override fun getItemCount() = items.size
override fun onBindViewHolder(holder: NavBarOptionsViewHolder, position: Int) {
val item = items[position]

View File

@ -24,9 +24,7 @@ class PlayingQueueAdapter : RecyclerView.Adapter<PlayingQueueViewHolder>() {
return PlayingQueueViewHolder(binding)
}
override fun getItemCount(): Int {
return PlayingQueue.size()
}
override fun getItemCount() = PlayingQueue.size()
@SuppressLint("SetTextI18n")
override fun onBindViewHolder(holder: PlayingQueueViewHolder, position: Int) {

View File

@ -18,9 +18,7 @@ class PlaylistsAdapter(
private val playlistType: PlaylistType
) : RecyclerView.Adapter<PlaylistsViewHolder>() {
override fun getItemCount(): Int {
return playlists.size
}
override fun getItemCount() = playlists.size
fun updateItems(newItems: List<Playlists>) {
val oldSize = playlists.size

View File

@ -18,9 +18,7 @@ class SearchHistoryAdapter(
) :
RecyclerView.Adapter<SuggestionsViewHolder>() {
override fun getItemCount(): Int {
return historyList.size
}
override fun getItemCount() = historyList.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)

View File

@ -13,9 +13,7 @@ class SearchSuggestionsAdapter(
) :
RecyclerView.Adapter<SuggestionsViewHolder>() {
override fun getItemCount(): Int {
return suggestionsList.size
}
override fun getItemCount() = suggestionsList.size
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SuggestionsViewHolder {
val layoutInflater = LayoutInflater.from(parent.context)

View File

@ -17,9 +17,7 @@ class SubscriptionChannelAdapter(
private val subscriptions: MutableList<Subscription>
) : RecyclerView.Adapter<SubscriptionChannelViewHolder>() {
override fun getItemCount(): Int {
return subscriptions.size
}
override fun getItemCount() = subscriptions.size
override fun onCreateViewHolder(
parent: ViewGroup,

View File

@ -24,7 +24,7 @@ class WatchHistoryAdapter(
private var visibleCount = minOf(10, watchHistory.size)
override fun getItemCount(): Int = visibleCount
override fun getItemCount() = visibleCount
fun removeFromWatchHistory(position: Int) {
val history = watchHistory[position]