package com.discord.widgets.servers; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.MainThread; import androidx.annotation.StringRes; import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.Guideline; import androidx.recyclerview.widget.DiffUtil; import androidx.recyclerview.widget.RecyclerView; import c.a.l.b; import c.d.b.a.a; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.databinding.ViewCategoryOverrideItemBinding; import com.discord.databinding.ViewChannelOverrideItemBinding; import com.discord.models.domain.ModelNotificationSettings; import com.discord.utilities.view.extensions.ViewExtensions; import d0.j; import d0.t.n; import d0.z.d.m; import java.util.List; import kotlin.Unit; import kotlin.jvm.functions.Function2; import kotlin.jvm.internal.DefaultConstructorMarker; /* compiled from: NotificationsOverridesAdapter.kt */ public final class NotificationsOverridesAdapter extends RecyclerView.Adapter { private List data = n.emptyList(); private final Function2 onClick; /* compiled from: NotificationsOverridesAdapter.kt */ public static final class DiffCallback extends DiffUtil.Callback { private final List newItems; private final List oldItems; public DiffCallback(List list, List list2) { m.checkNotNullParameter(list, "newItems"); m.checkNotNullParameter(list2, "oldItems"); this.newItems = list; this.oldItems = list2; } @Override // androidx.recyclerview.widget.DiffUtil.Callback public boolean areContentsTheSame(int i, int i2) { return m.areEqual(this.newItems.get(i2), this.oldItems.get(i)); } @Override // androidx.recyclerview.widget.DiffUtil.Callback public boolean areItemsTheSame(int i, int i2) { return this.newItems.get(i2).getChannel().h() == this.oldItems.get(i).getChannel().h(); } @Override // androidx.recyclerview.widget.DiffUtil.Callback public int getNewListSize() { return this.newItems.size(); } @Override // androidx.recyclerview.widget.DiffUtil.Callback public int getOldListSize() { return this.oldItems.size(); } } /* compiled from: NotificationsOverridesAdapter.kt */ public static final class Item { private final Channel channel; private final ModelNotificationSettings.ChannelOverride overrideSettings; private final Channel parent; public Item(Channel channel, Channel channel2, ModelNotificationSettings.ChannelOverride channelOverride) { m.checkNotNullParameter(channel, "channel"); m.checkNotNullParameter(channelOverride, "overrideSettings"); this.channel = channel; this.parent = channel2; this.overrideSettings = channelOverride; } public final Channel getChannel() { return this.channel; } public final ModelNotificationSettings.ChannelOverride getOverrideSettings() { return this.overrideSettings; } public final Channel getParent() { return this.parent; } } /* compiled from: NotificationsOverridesAdapter.kt */ public static abstract class ViewHolder extends RecyclerView.ViewHolder { private final Function2 onClick; /* compiled from: NotificationsOverridesAdapter.kt */ public static final class CategoryOverridesViewHolder extends ViewHolder { private final ViewCategoryOverrideItemBinding binding; /* JADX WARNING: Illegal instructions before constructor call */ public CategoryOverridesViewHolder(ViewCategoryOverrideItemBinding viewCategoryOverrideItemBinding, Function2 function2) { super(r0, function2, null); m.checkNotNullParameter(viewCategoryOverrideItemBinding, "binding"); m.checkNotNullParameter(function2, "onClick"); ConstraintLayout constraintLayout = viewCategoryOverrideItemBinding.a; m.checkNotNullExpressionValue(constraintLayout, "binding.root"); this.binding = viewCategoryOverrideItemBinding; } @Override // com.discord.widgets.servers.NotificationsOverridesAdapter.ViewHolder public void onBind(Item item) { m.checkNotNullParameter(item, "data"); super.onBind(item); TextView textView = this.binding.b; m.checkNotNullExpressionValue(textView, "binding.categoryOverrideName"); textView.setText(AnimatableValueParser.y0(item.getChannel())); int messageNotificationToString = item.getOverrideSettings().isMuted() ? 2131888702 : messageNotificationToString(item.getOverrideSettings().getMessageNotifications()); TextView textView2 = this.binding.f1646c; m.checkNotNullExpressionValue(textView2, "binding.categoryOverrideStatus"); b.m(textView2, messageNotificationToString, new Object[0], null, 4); } } /* compiled from: NotificationsOverridesAdapter.kt */ public static final class ChannelOverridesViewHolder extends ViewHolder { private final ViewChannelOverrideItemBinding binding; /* JADX WARNING: Illegal instructions before constructor call */ public ChannelOverridesViewHolder(ViewChannelOverrideItemBinding viewChannelOverrideItemBinding, Function2 function2) { super(r0, function2, null); m.checkNotNullParameter(viewChannelOverrideItemBinding, "binding"); m.checkNotNullParameter(function2, "onClick"); ConstraintLayout constraintLayout = viewChannelOverrideItemBinding.a; m.checkNotNullExpressionValue(constraintLayout, "binding.root"); this.binding = viewChannelOverrideItemBinding; } @Override // com.discord.widgets.servers.NotificationsOverridesAdapter.ViewHolder public void onBind(Item item) { m.checkNotNullParameter(item, "data"); super.onBind(item); TextView textView = this.binding.f1647c; m.checkNotNullExpressionValue(textView, "binding.channelOverrideName"); textView.setText(AnimatableValueParser.y0(item.getChannel())); TextView textView2 = this.binding.b; m.checkNotNullExpressionValue(textView2, "binding.channelOverrideCategoryName"); Channel parent = item.getParent(); ViewExtensions.setTextAndVisibilityBy(textView2, parent != null ? AnimatableValueParser.y0(parent) : null); int messageNotificationToString = item.getOverrideSettings().isMuted() ? 2131888702 : messageNotificationToString(item.getOverrideSettings().getMessageNotifications()); TextView textView3 = this.binding.d; m.checkNotNullExpressionValue(textView3, "binding.channelOverrideStatus"); b.m(textView3, messageNotificationToString, new Object[0], null, 4); } } /* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: kotlin.jvm.functions.Function2 */ /* JADX WARN: Multi-variable type inference failed */ private ViewHolder(View view, Function2 function2) { super(view); this.onClick = function2; } public /* synthetic */ ViewHolder(View view, Function2 function2, DefaultConstructorMarker defaultConstructorMarker) { this(view, function2); } public final Function2 getOnClick() { return this.onClick; } @StringRes public final int messageNotificationToString(int i) { if (i == ModelNotificationSettings.FREQUENCY_ALL) { return 2131888610; } if (i == ModelNotificationSettings.FREQUENCY_MENTIONS) { return 2131888710; } return i == ModelNotificationSettings.FREQUENCY_NOTHING ? 2131888705 : 0; } public void onBind(Item item) { m.checkNotNullParameter(item, "data"); this.itemView.setOnClickListener(new NotificationsOverridesAdapter$ViewHolder$onBind$1(this, item)); } } /* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: kotlin.jvm.functions.Function2 */ /* JADX WARN: Multi-variable type inference failed */ public NotificationsOverridesAdapter(Function2 function2) { m.checkNotNullParameter(function2, "onClick"); this.onClick = function2; } public final List getData() { return this.data; } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public int getItemCount() { return this.data.size(); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public int getItemViewType(int i) { return this.data.get(i).getChannel().A(); } public final Function2 getOnClick() { return this.onClick; } public void onBindViewHolder(ViewHolder viewHolder, int i) { m.checkNotNullParameter(viewHolder, "holder"); viewHolder.onBind(this.data.get(i)); } @Override // androidx.recyclerview.widget.RecyclerView.Adapter public ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) { m.checkNotNullParameter(viewGroup, "parent"); int i2 = 2131364087; if (i != 0) { if (i == 4) { View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(2131558729, viewGroup, false); TextView textView = (TextView) inflate.findViewById(2131362236); if (textView != null) { TextView textView2 = (TextView) inflate.findViewById(2131362237); if (textView2 != null) { Guideline guideline = (Guideline) inflate.findViewById(2131363395); if (guideline != null) { ImageView imageView = (ImageView) inflate.findViewById(2131364087); if (imageView != null) { ViewCategoryOverrideItemBinding viewCategoryOverrideItemBinding = new ViewCategoryOverrideItemBinding((ConstraintLayout) inflate, textView, textView2, guideline, imageView); m.checkNotNullExpressionValue(viewCategoryOverrideItemBinding, "ViewCategoryOverrideItem….context), parent, false)"); return new ViewHolder.CategoryOverridesViewHolder(viewCategoryOverrideItemBinding, this.onClick); } } else { i2 = 2131363395; } } else { i2 = 2131362237; } } else { i2 = 2131362236; } throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2))); } else if (i != 5) { throw new j(a.t("An operation is not implemented: ", a.l("Type[", i, "] not implemented"))); } } View inflate2 = LayoutInflater.from(viewGroup.getContext()).inflate(2131558730, viewGroup, false); TextView textView3 = (TextView) inflate2.findViewById(2131362297); if (textView3 != null) { TextView textView4 = (TextView) inflate2.findViewById(2131362298); if (textView4 != null) { TextView textView5 = (TextView) inflate2.findViewById(2131362299); if (textView5 != null) { Guideline guideline2 = (Guideline) inflate2.findViewById(2131363395); if (guideline2 != null) { ImageView imageView2 = (ImageView) inflate2.findViewById(2131364087); if (imageView2 != null) { ViewChannelOverrideItemBinding viewChannelOverrideItemBinding = new ViewChannelOverrideItemBinding((ConstraintLayout) inflate2, textView3, textView4, textView5, guideline2, imageView2); m.checkNotNullExpressionValue(viewChannelOverrideItemBinding, "ViewChannelOverrideItemB….context), parent, false)"); return new ViewHolder.ChannelOverridesViewHolder(viewChannelOverrideItemBinding, this.onClick); } } else { i2 = 2131363395; } } else { i2 = 2131362299; } } else { i2 = 2131362298; } } else { i2 = 2131362297; } throw new NullPointerException("Missing required view with ID: ".concat(inflate2.getResources().getResourceName(i2))); } @MainThread public final void setData(List list) { m.checkNotNullParameter(list, "value"); DiffUtil.DiffResult calculateDiff = DiffUtil.calculateDiff(new DiffCallback(list, this.data), true); m.checkNotNullExpressionValue(calculateDiff, "DiffUtil.calculateDiff(D…back(value, field), true)"); this.data = list; calculateDiff.dispatchUpdatesTo(this); } }