discord-jadx/app/src/main/java/com/discord/widgets/guilds/create/GuildTemplateChannelsView.java
2021-07-13 22:23:20 +02:00

193 lines
8.9 KiB
Java

package com.discord.widgets.guilds.create;
import android.content.Context;
import android.content.res.Resources;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.LayoutRes;
import androidx.recyclerview.widget.RecyclerView;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.databinding.GuildTemplateChannelsItemViewBinding;
import com.discord.databinding.GuildTemplateChannelsViewBinding;
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
import d0.t.o;
import d0.z.d.m;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/* compiled from: GuildTemplateChannelsView.kt */
public final class GuildTemplateChannelsView extends LinearLayout {
private final GuildTemplateChannelsViewBinding binding;
private final ChannelsAdapter channelsAdapter;
/* compiled from: GuildTemplateChannelsView.kt */
public static final class ChannelDataPayload implements MGRecyclerDataPayload {
private final Channel channel;
private final String key = String.valueOf(hashCode());
private final int type;
public ChannelDataPayload(Channel channel) {
m.checkNotNullParameter(channel, "channel");
this.channel = channel;
}
public static /* synthetic */ ChannelDataPayload copy$default(ChannelDataPayload channelDataPayload, Channel channel, int i, Object obj) {
if ((i & 1) != 0) {
channel = channelDataPayload.channel;
}
return channelDataPayload.copy(channel);
}
public final Channel component1() {
return this.channel;
}
public final ChannelDataPayload copy(Channel channel) {
m.checkNotNullParameter(channel, "channel");
return new ChannelDataPayload(channel);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ChannelDataPayload) && m.areEqual(this.channel, ((ChannelDataPayload) obj).channel);
}
return true;
}
public final Channel getChannel() {
return this.channel;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
public String getKey() {
return this.key;
}
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
public int getType() {
return this.type;
}
public int hashCode() {
Channel channel = this.channel;
if (channel != null) {
return channel.hashCode();
}
return 0;
}
public String toString() {
StringBuilder L = a.L("ChannelDataPayload(channel=");
L.append(this.channel);
L.append(")");
return L.toString();
}
}
/* compiled from: GuildTemplateChannelsView.kt */
public static final class ChannelViewHolder extends MGRecyclerViewHolder<ChannelsAdapter, ChannelDataPayload> {
private final GuildTemplateChannelsItemViewBinding binding;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ChannelViewHolder(@LayoutRes int i, ChannelsAdapter channelsAdapter) {
super(i, channelsAdapter);
m.checkNotNullParameter(channelsAdapter, "adapter");
View view = this.itemView;
int i2 = 2131363531;
ImageView imageView = (ImageView) view.findViewById(2131363531);
if (imageView != null) {
i2 = 2131363532;
TextView textView = (TextView) view.findViewById(2131363532);
if (textView != null) {
GuildTemplateChannelsItemViewBinding guildTemplateChannelsItemViewBinding = new GuildTemplateChannelsItemViewBinding((LinearLayout) view, imageView, textView);
m.checkNotNullExpressionValue(guildTemplateChannelsItemViewBinding, "GuildTemplateChannelsIte…iewBinding.bind(itemView)");
this.binding = guildTemplateChannelsItemViewBinding;
return;
}
}
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i2)));
}
public void onConfigure(int i, ChannelDataPayload channelDataPayload) {
m.checkNotNullParameter(channelDataPayload, "data");
super.onConfigure(i, (int) channelDataPayload);
TextView textView = this.binding.f1614c;
m.checkNotNullExpressionValue(textView, "binding.guildTemplateChannelsItemName");
textView.setText(AnimatableValueParser.y0(channelDataPayload.getChannel()));
if (AnimatableValueParser.f1(channelDataPayload.getChannel())) {
this.binding.b.setImageResource(2131231523);
} else if (AnimatableValueParser.B1(channelDataPayload.getChannel())) {
this.binding.b.setImageResource(2131231506);
} else {
this.binding.b.setImageResource(2131231497);
}
if (channelDataPayload.getChannel().r() > 0) {
ImageView imageView = this.binding.b;
m.checkNotNullExpressionValue(imageView, "binding.guildTemplateChannelsItemImage");
ViewGroup.LayoutParams layoutParams = imageView.getLayoutParams();
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
Resources resources = ((ChannelsAdapter) this.adapter).getContext().getResources();
m.checkNotNullExpressionValue(resources, "adapter.context.resources");
((ViewGroup.MarginLayoutParams) layoutParams).leftMargin = (int) TypedValue.applyDimension(1, 24.0f, resources.getDisplayMetrics());
}
}
}
/* compiled from: GuildTemplateChannelsView.kt */
public static final class ChannelsAdapter extends MGRecyclerAdapterSimple<ChannelDataPayload> {
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ChannelsAdapter(RecyclerView recyclerView) {
super(recyclerView, false, 2, null);
m.checkNotNullParameter(recyclerView, "recyclerView");
}
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
public MGRecyclerViewHolder<ChannelsAdapter, ChannelDataPayload> onCreateViewHolder(ViewGroup viewGroup, int i) {
m.checkNotNullParameter(viewGroup, "parent");
return new ChannelViewHolder(2131558519, this);
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public GuildTemplateChannelsView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(attributeSet, "attrs");
View inflate = LayoutInflater.from(context).inflate(2131558520, (ViewGroup) this, false);
addView(inflate);
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(2131363533);
if (recyclerView != null) {
GuildTemplateChannelsViewBinding guildTemplateChannelsViewBinding = new GuildTemplateChannelsViewBinding((LinearLayout) inflate, recyclerView);
m.checkNotNullExpressionValue(guildTemplateChannelsViewBinding, "GuildTemplateChannelsVie…rom(context), this, true)");
this.binding = guildTemplateChannelsViewBinding;
LinearLayout.inflate(context, 2131558520, this);
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
m.checkNotNullExpressionValue(recyclerView, "binding.guildTemplateChannelsRecyclerView");
this.channelsAdapter = (ChannelsAdapter) companion.configure(new ChannelsAdapter(recyclerView));
recyclerView.setHasFixedSize(false);
return;
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(2131363533)));
}
public final void updateView(List<Channel> list) {
m.checkNotNullParameter(list, "channels");
ChannelsAdapter channelsAdapter = this.channelsAdapter;
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(list, 10));
for (Channel channel : list) {
arrayList.add(new ChannelDataPayload(channel));
}
channelsAdapter.setData(arrayList);
}
}