2021-08-03 07:33:18 +00:00
package com.discord.widgets.directories ;
import android.view.LayoutInflater ;
import android.view.View ;
import android.view.ViewGroup ;
import android.widget.TextView ;
import androidx.recyclerview.widget.RecyclerView ;
2021-10-15 06:18:26 +00:00
import c0.t.n ;
import c0.z.d.m ;
2021-08-09 22:51:56 +00:00
import com.discord.R ;
2021-08-03 07:33:18 +00:00
import com.discord.databinding.DirectoryAddServerListItemBinding ;
import com.discord.databinding.DirectoryEntryListItemBinding ;
2021-10-29 07:19:59 +00:00
import com.discord.databinding.DirectorySectionHeaderListItemBinding ;
2021-08-03 07:33:18 +00:00
import com.discord.views.directories.ServerDiscoveryItem ;
import com.discord.widgets.directories.DirectoryChannelItem ;
import java.util.List ;
import java.util.Objects ;
2021-10-29 07:19:59 +00:00
import kotlin.NoWhenBranchMatchedException ;
2021-08-03 07:33:18 +00:00
/* compiled from: WidgetDirectoryChannelAdapter.kt */
public final class WidgetDirectoryChannelAdapter extends RecyclerView . Adapter < RecyclerView . ViewHolder > {
private final DirectoryChannelItemClickInterface clickListener ;
private List < ? extends DirectoryChannelItem > directoryChannelItems = n . emptyList ( ) ;
2021-10-29 07:19:59 +00:00
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int [ ] $EnumSwitchMapping$0 ;
static {
DirectoryChannelItem . ViewType . values ( ) ;
int [ ] iArr = new int [ 3 ] ;
$EnumSwitchMapping$0 = iArr ;
iArr [ DirectoryChannelItem . ViewType . Item . ordinal ( ) ] = 1 ;
iArr [ DirectoryChannelItem . ViewType . AddServer . ordinal ( ) ] = 2 ;
iArr [ DirectoryChannelItem . ViewType . SectionHeader . ordinal ( ) ] = 3 ;
}
}
2021-08-03 07:33:18 +00:00
public WidgetDirectoryChannelAdapter ( DirectoryChannelItemClickInterface directoryChannelItemClickInterface ) {
m . checkNotNullParameter ( directoryChannelItemClickInterface , " clickListener " ) ;
this . clickListener = directoryChannelItemClickInterface ;
}
public final DirectoryChannelItemClickInterface getClickListener ( ) {
return this . clickListener ;
}
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.List<? extends com.discord.widgets.directories.DirectoryChannelItem>, java.util.List<com.discord.widgets.directories.DirectoryChannelItem> */
public final List < DirectoryChannelItem > getDirectoryChannelItems ( ) {
return this . directoryChannelItems ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemCount ( ) {
return this . directoryChannelItems . size ( ) ;
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public int getItemViewType ( int i ) {
2021-10-29 07:19:59 +00:00
return ( ( DirectoryChannelItem ) this . directoryChannelItems . get ( i ) ) . getViewType ( ) . ordinal ( ) ;
2021-08-03 07:33:18 +00:00
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public void onBindViewHolder ( RecyclerView . ViewHolder viewHolder , int i ) {
m . checkNotNullParameter ( viewHolder , " holder " ) ;
if ( ! ( viewHolder instanceof DirectoryChannelViewHolder ) ) {
viewHolder = null ;
}
DirectoryChannelViewHolder directoryChannelViewHolder = ( DirectoryChannelViewHolder ) viewHolder ;
if ( directoryChannelViewHolder ! = null ) {
directoryChannelViewHolder . bind ( ( DirectoryChannelItem ) this . directoryChannelItems . get ( i ) , this . clickListener ) ;
}
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public RecyclerView . ViewHolder onCreateViewHolder ( ViewGroup viewGroup , int i ) {
m . checkNotNullParameter ( viewGroup , " parent " ) ;
2021-10-29 07:19:59 +00:00
int ordinal = DirectoryChannelItem . ViewType . Companion . findType ( i ) . ordinal ( ) ;
if ( ordinal = = 0 ) {
2021-08-09 22:51:56 +00:00
View inflate = LayoutInflater . from ( viewGroup . getContext ( ) ) . inflate ( R . layout . directory_entry_list_item , viewGroup , false ) ;
2021-08-03 07:33:18 +00:00
Objects . requireNonNull ( inflate , " rootView " ) ;
ServerDiscoveryItem serverDiscoveryItem = ( ServerDiscoveryItem ) inflate ;
DirectoryEntryListItemBinding directoryEntryListItemBinding = new DirectoryEntryListItemBinding ( serverDiscoveryItem , serverDiscoveryItem ) ;
m . checkNotNullExpressionValue ( directoryEntryListItemBinding , " DirectoryEntryListItemBi… false \ n ) " ) ;
return new DirectoryEntryViewHolder ( directoryEntryListItemBinding ) ;
2021-10-29 07:19:59 +00:00
} else if ( ordinal = = 1 ) {
2021-08-09 22:51:56 +00:00
View inflate2 = LayoutInflater . from ( viewGroup . getContext ( ) ) . inflate ( R . layout . directory_add_server_list_item , viewGroup , false ) ;
2021-08-03 07:33:18 +00:00
Objects . requireNonNull ( inflate2 , " rootView " ) ;
TextView textView = ( TextView ) inflate2 ;
DirectoryAddServerListItemBinding directoryAddServerListItemBinding = new DirectoryAddServerListItemBinding ( textView , textView ) ;
m . checkNotNullExpressionValue ( directoryAddServerListItemBinding , " DirectoryAddServerListIt… false \ n ) " ) ;
return new AddServerViewHolder ( directoryAddServerListItemBinding ) ;
2021-10-29 07:19:59 +00:00
} else if ( ordinal = = 2 ) {
View inflate3 = LayoutInflater . from ( viewGroup . getContext ( ) ) . inflate ( R . layout . directory_section_header_list_item , viewGroup , false ) ;
Objects . requireNonNull ( inflate3 , " rootView " ) ;
TextView textView2 = ( TextView ) inflate3 ;
DirectorySectionHeaderListItemBinding directorySectionHeaderListItemBinding = new DirectorySectionHeaderListItemBinding ( textView2 , textView2 ) ;
m . checkNotNullExpressionValue ( directorySectionHeaderListItemBinding , " DirectorySectionHeaderLi… false \ n ) " ) ;
return new SectionHeaderViewHolder ( directorySectionHeaderListItemBinding ) ;
2021-08-03 07:33:18 +00:00
} else {
2021-10-29 07:19:59 +00:00
throw new NoWhenBranchMatchedException ( ) ;
2021-08-03 07:33:18 +00:00
}
}
public final void setDirectoryChannelItems ( List < ? extends DirectoryChannelItem > list ) {
m . checkNotNullParameter ( list , " value " ) ;
this . directoryChannelItems = list ;
notifyDataSetChanged ( ) ;
}
}