88 lines
4.5 KiB
Java
88 lines
4.5 KiB
Java
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;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.databinding.DirectoryAddServerListItemBinding;
|
|
import com.discord.databinding.DirectoryEntryListItemBinding;
|
|
import com.discord.views.directories.ServerDiscoveryItem;
|
|
import com.discord.widgets.directories.DirectoryChannelItem;
|
|
import d0.t.n;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
/* compiled from: WidgetDirectoryChannelAdapter.kt */
|
|
public final class WidgetDirectoryChannelAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
|
private final DirectoryChannelItemClickInterface clickListener;
|
|
private List<? extends DirectoryChannelItem> directoryChannelItems = n.emptyList();
|
|
|
|
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) {
|
|
return ((DirectoryChannelItem) this.directoryChannelItems.get(i)).getViewType();
|
|
}
|
|
|
|
@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");
|
|
DirectoryChannelItem.Companion companion = DirectoryChannelItem.Companion;
|
|
if (i == companion.getVIEW_TYPE_ITEM()) {
|
|
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.directory_entry_list_item, viewGroup, false);
|
|
Objects.requireNonNull(inflate, "rootView");
|
|
ServerDiscoveryItem serverDiscoveryItem = (ServerDiscoveryItem) inflate;
|
|
DirectoryEntryListItemBinding directoryEntryListItemBinding = new DirectoryEntryListItemBinding(serverDiscoveryItem, serverDiscoveryItem);
|
|
m.checkNotNullExpressionValue(directoryEntryListItemBinding, "DirectoryEntryListItemBi… false\n )");
|
|
return new DirectoryEntryViewHolder(directoryEntryListItemBinding);
|
|
} else if (i == companion.getVIEW_TYPE_ADD_SERVER()) {
|
|
View inflate2 = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.directory_add_server_list_item, viewGroup, false);
|
|
Objects.requireNonNull(inflate2, "rootView");
|
|
TextView textView = (TextView) inflate2;
|
|
DirectoryAddServerListItemBinding directoryAddServerListItemBinding = new DirectoryAddServerListItemBinding(textView, textView);
|
|
m.checkNotNullExpressionValue(directoryAddServerListItemBinding, "DirectoryAddServerListIt… false\n )");
|
|
return new AddServerViewHolder(directoryAddServerListItemBinding);
|
|
} else {
|
|
throw new IllegalStateException(a.j("Missing view type for ", i));
|
|
}
|
|
}
|
|
|
|
public final void setDirectoryChannelItems(List<? extends DirectoryChannelItem> list) {
|
|
m.checkNotNullParameter(list, "value");
|
|
this.directoryChannelItems = list;
|
|
notifyDataSetChanged();
|
|
}
|
|
}
|