203 lines
12 KiB
Java
203 lines
12 KiB
Java
package com.discord.widgets.servers.settings.invites;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.os.CountDownTimer;
|
|
import android.view.View;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.cardview.widget.CardView;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.api.user.User;
|
|
import com.discord.databinding.WidgetServerSettingsInstantInviteListItemBinding;
|
|
import com.discord.models.domain.ModelInvite;
|
|
import com.discord.models.user.CoreUser;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.widgets.servers.settings.invites.WidgetServerSettingsInstantInvites;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.z.d.m;
|
|
import java.util.Arrays;
|
|
/* compiled from: WidgetServerSettingsInstantInvitesListItem.kt */
|
|
public final class WidgetServerSettingsInstantInvitesListItem extends MGRecyclerViewHolder<WidgetServerSettingsInstantInvites.Adapter, WidgetServerSettingsInstantInvites.Model.InviteItem> {
|
|
private final WidgetServerSettingsInstantInviteListItemBinding binding;
|
|
private CountDownTimer countdownTimer;
|
|
private String currentInviteCode;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetServerSettingsInstantInvitesListItem(WidgetServerSettingsInstantInvites.Adapter adapter) {
|
|
super(2131559191, adapter);
|
|
m.checkNotNullParameter(adapter, "adapter");
|
|
View view = this.itemView;
|
|
int i = 2131363705;
|
|
TextView textView = (TextView) view.findViewById(2131363705);
|
|
if (textView != null) {
|
|
i = 2131363706;
|
|
TextView textView2 = (TextView) view.findViewById(2131363706);
|
|
if (textView2 != null) {
|
|
i = 2131363707;
|
|
LinearLayout linearLayout = (LinearLayout) view.findViewById(2131363707);
|
|
if (linearLayout != null) {
|
|
i = 2131363708;
|
|
View findViewById = view.findViewById(2131363708);
|
|
if (findViewById != null) {
|
|
i = 2131363709;
|
|
LinearLayout linearLayout2 = (LinearLayout) view.findViewById(2131363709);
|
|
if (linearLayout2 != null) {
|
|
i = 2131363710;
|
|
TextView textView3 = (TextView) view.findViewById(2131363710);
|
|
if (textView3 != null) {
|
|
i = 2131363712;
|
|
TextView textView4 = (TextView) view.findViewById(2131363712);
|
|
if (textView4 != null) {
|
|
i = 2131363713;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view.findViewById(2131363713);
|
|
if (simpleDraweeView != null) {
|
|
i = 2131363720;
|
|
LinearLayout linearLayout3 = (LinearLayout) view.findViewById(2131363720);
|
|
if (linearLayout3 != null) {
|
|
i = 2131363724;
|
|
ImageView imageView = (ImageView) view.findViewById(2131363724);
|
|
if (imageView != null) {
|
|
i = 2131363727;
|
|
TextView textView5 = (TextView) view.findViewById(2131363727);
|
|
if (textView5 != null) {
|
|
i = 2131363728;
|
|
TextView textView6 = (TextView) view.findViewById(2131363728);
|
|
if (textView6 != null) {
|
|
i = 2131363729;
|
|
TextView textView7 = (TextView) view.findViewById(2131363729);
|
|
if (textView7 != null) {
|
|
WidgetServerSettingsInstantInviteListItemBinding widgetServerSettingsInstantInviteListItemBinding = new WidgetServerSettingsInstantInviteListItemBinding((CardView) view, textView, textView2, linearLayout, findViewById, linearLayout2, textView3, textView4, simpleDraweeView, linearLayout3, imageView, textView5, textView6, textView7);
|
|
m.checkNotNullExpressionValue(widgetServerSettingsInstantInviteListItemBinding, "WidgetServerSettingsInst…temBinding.bind(itemView)");
|
|
this.binding = widgetServerSettingsInstantInviteListItemBinding;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetServerSettingsInstantInvites.Adapter access$getAdapter$p(WidgetServerSettingsInstantInvitesListItem widgetServerSettingsInstantInvitesListItem) {
|
|
return (WidgetServerSettingsInstantInvites.Adapter) widgetServerSettingsInstantInvitesListItem.adapter;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setCountdownText(WidgetServerSettingsInstantInvitesListItem widgetServerSettingsInstantInvitesListItem, long j) {
|
|
widgetServerSettingsInstantInvitesListItem.setCountdownText(j);
|
|
}
|
|
|
|
private final void cancelTimer() {
|
|
CountDownTimer countDownTimer = this.countdownTimer;
|
|
if (countDownTimer != null) {
|
|
countDownTimer.cancel();
|
|
}
|
|
this.countdownTimer = null;
|
|
this.currentInviteCode = null;
|
|
}
|
|
|
|
private final String getUsesText(ModelInvite modelInvite) {
|
|
int uses = modelInvite.getUses();
|
|
int maxUses = modelInvite.getMaxUses();
|
|
String valueOf = String.valueOf(uses);
|
|
if (maxUses <= 0) {
|
|
return valueOf;
|
|
}
|
|
return valueOf + " / " + maxUses;
|
|
}
|
|
|
|
@SuppressLint({"SetTextI18n"})
|
|
private final void setCountdownText(long j) {
|
|
long j2 = (long) 60;
|
|
int i = (int) ((j / 1000) % j2);
|
|
int i2 = (int) ((j / 60000) % j2);
|
|
long j3 = (long) 24;
|
|
int i3 = (int) ((j / 86400000) % j3);
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteExpirationTime");
|
|
String format = String.format("%02d:%02d:%02d:%02d", Arrays.copyOf(new Object[]{Integer.valueOf(i3), Integer.valueOf((int) ((j / 3600000) % j3)), Integer.valueOf(i2), Integer.valueOf(i)}, 4));
|
|
m.checkNotNullExpressionValue(format, "java.lang.String.format(this, *args)");
|
|
textView.setText(format);
|
|
TextView textView2 = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteExpirationTime");
|
|
textView2.setTextColor(ColorCompat.getColor(textView2, 2131100246));
|
|
}
|
|
|
|
private final void setupExpirationTime(ModelInvite modelInvite) {
|
|
if (modelInvite.getMaxAge() == 0) {
|
|
this.binding.e.setText(2131891154);
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteExpirationTime");
|
|
textView.setTextColor(ColorCompat.getColor(textView, 2131099906));
|
|
cancelTimer();
|
|
} else if (modelInvite.getTimeToExpirationMillis() <= 0) {
|
|
setCountdownText(0);
|
|
cancelTimer();
|
|
} else if ((!m.areEqual(modelInvite.getCode(), this.currentInviteCode)) || this.currentInviteCode == null) {
|
|
setCountdownText(modelInvite.getTimeToExpirationMillis());
|
|
cancelTimer();
|
|
this.currentInviteCode = modelInvite.getCode();
|
|
WidgetServerSettingsInstantInvitesListItem$setupExpirationTime$1 widgetServerSettingsInstantInvitesListItem$setupExpirationTime$1 = new WidgetServerSettingsInstantInvitesListItem$setupExpirationTime$1(this, modelInvite, modelInvite.getTimeToExpirationMillis(), 1000);
|
|
this.countdownTimer = widgetServerSettingsInstantInvitesListItem$setupExpirationTime$1;
|
|
if (widgetServerSettingsInstantInvitesListItem$setupExpirationTime$1 != null) {
|
|
widgetServerSettingsInstantInvitesListItem$setupExpirationTime$1.start();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void onConfigure(int i, WidgetServerSettingsInstantInvites.Model.InviteItem inviteItem) {
|
|
String str;
|
|
m.checkNotNullParameter(inviteItem, "data");
|
|
super.onConfigure(i, (int) inviteItem);
|
|
User inviter = inviteItem.getInvite().getInviter();
|
|
this.binding.d.setOnClickListener(new WidgetServerSettingsInstantInvitesListItem$onConfigure$1(this, inviteItem));
|
|
TextView textView = this.binding.f1905c;
|
|
m.checkNotNullExpressionValue(textView, "binding.inviteCode");
|
|
textView.setText(inviteItem.getInvite().getCode());
|
|
TextView textView2 = this.binding.h;
|
|
m.checkNotNullExpressionValue(textView2, "binding.inviteUses");
|
|
textView2.setText(getUsesText(inviteItem.getInvite()));
|
|
TextView textView3 = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView3, "binding.inviteChannel");
|
|
Channel channel = inviteItem.getInvite().getChannel();
|
|
m.checkNotNullExpressionValue(channel, "data.invite.channel");
|
|
TextView textView4 = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView4, "binding.inviteChannel");
|
|
Context context = textView4.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.inviteChannel.context");
|
|
textView3.setText(AnimatableValueParser.z0(channel, context, true));
|
|
TextView textView5 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView5, "binding.inviteUserName");
|
|
if (inviter == null || (str = inviter.r()) == null) {
|
|
CardView cardView = this.binding.a;
|
|
m.checkNotNullExpressionValue(cardView, "binding.root");
|
|
str = cardView.getContext().getString(2131890513);
|
|
}
|
|
textView5.setText(str);
|
|
if (inviter != null) {
|
|
SimpleDraweeView simpleDraweeView = this.binding.f;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.inviteListItemAvatar");
|
|
IconUtils.setIcon$default(simpleDraweeView, new CoreUser(inviter), 2131165295, null, null, null, 56, null);
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.inviteListItemAvatar");
|
|
simpleDraweeView2.setVisibility(0);
|
|
} else {
|
|
SimpleDraweeView simpleDraweeView3 = this.binding.f;
|
|
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.inviteListItemAvatar");
|
|
simpleDraweeView3.setVisibility(8);
|
|
}
|
|
setupExpirationTime(inviteItem.getInvite());
|
|
}
|
|
}
|