discord-jadx/app/src/main/java/com/discord/widgets/notice/NoticePopupChannel.java

393 lines
20 KiB
Java

package com.discord.widgets.notice;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.View;
import androidx.core.content.ContextCompat;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.api.message.attachment.MessageAttachment;
import com.discord.api.message.attachment.MessageAttachmentType;
import com.discord.api.message.embed.MessageEmbed;
import com.discord.api.role.GuildRole;
import com.discord.api.sticker.Sticker;
import com.discord.models.guild.Guild;
import com.discord.models.member.GuildMember;
import com.discord.models.message.Message;
import com.discord.models.user.CoreUser;
import com.discord.models.user.User;
import com.discord.simpleast.core.parser.Parser;
import com.discord.stores.StoreGuilds;
import com.discord.stores.StoreStream;
import com.discord.stores.StoreUser;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.drawable.DrawableCompat;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.message.MessageUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.textprocessing.AstRenderer;
import com.discord.utilities.textprocessing.DiscordParser;
import com.discord.utilities.textprocessing.MessageParseState;
import com.discord.utilities.textprocessing.MessageRenderContext;
import com.facebook.drawee.span.DraweeSpanStringBuilder;
import d0.g0.t;
import d0.o;
import d0.t.n;
import d0.t.u;
import d0.z.d.m;
import j0.l.e.j;
import java.util.List;
import java.util.Map;
import kotlin.Pair;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import rx.Observable;
/* compiled from: NoticePopupChannel.kt */
public final class NoticePopupChannel {
public static final NoticePopupChannel INSTANCE = new NoticePopupChannel();
/* compiled from: NoticePopupChannel.kt */
public static final class Model {
private final DraweeSpanStringBuilder noticeBody;
private Drawable noticeBodyBackgroundDrawable;
private Drawable noticeBodyImageDrawable;
private String noticeBodyImageUrl;
private final Drawable noticeIconTopRight;
private final String noticeIconUrl;
private final List<Sticker> noticeStickers;
private final CharSequence noticeSubtitle;
private final CharSequence noticeTitle;
private final Function1<View, Unit> onClickTopRightIcon;
/* JADX DEBUG: Multi-variable search result rejected for r10v0, resolved type: kotlin.jvm.functions.Function1<? super android.view.View, kotlin.Unit> */
/* JADX WARN: Multi-variable type inference failed */
public Model(CharSequence charSequence, CharSequence charSequence2, DraweeSpanStringBuilder draweeSpanStringBuilder, String str, Drawable drawable, String str2, Drawable drawable2, Drawable drawable3, Function1<? super View, Unit> function1, List<Sticker> list) {
m.checkNotNullParameter(charSequence, "noticeTitle");
m.checkNotNullParameter(draweeSpanStringBuilder, "noticeBody");
m.checkNotNullParameter(function1, "onClickTopRightIcon");
this.noticeTitle = charSequence;
this.noticeSubtitle = charSequence2;
this.noticeBody = draweeSpanStringBuilder;
this.noticeIconUrl = str;
this.noticeBodyBackgroundDrawable = drawable;
this.noticeBodyImageUrl = str2;
this.noticeBodyImageDrawable = drawable2;
this.noticeIconTopRight = drawable3;
this.onClickTopRightIcon = function1;
this.noticeStickers = list;
}
public static /* synthetic */ Model copy$default(Model model, CharSequence charSequence, CharSequence charSequence2, DraweeSpanStringBuilder draweeSpanStringBuilder, String str, Drawable drawable, String str2, Drawable drawable2, Drawable drawable3, Function1 function1, List list, int i, Object obj) {
return model.copy((i & 1) != 0 ? model.noticeTitle : charSequence, (i & 2) != 0 ? model.noticeSubtitle : charSequence2, (i & 4) != 0 ? model.noticeBody : draweeSpanStringBuilder, (i & 8) != 0 ? model.noticeIconUrl : str, (i & 16) != 0 ? model.noticeBodyBackgroundDrawable : drawable, (i & 32) != 0 ? model.noticeBodyImageUrl : str2, (i & 64) != 0 ? model.noticeBodyImageDrawable : drawable2, (i & 128) != 0 ? model.noticeIconTopRight : drawable3, (i & 256) != 0 ? model.onClickTopRightIcon : function1, (i & 512) != 0 ? model.noticeStickers : list);
}
public final CharSequence component1() {
return this.noticeTitle;
}
public final List<Sticker> component10() {
return this.noticeStickers;
}
public final CharSequence component2() {
return this.noticeSubtitle;
}
public final DraweeSpanStringBuilder component3() {
return this.noticeBody;
}
public final String component4() {
return this.noticeIconUrl;
}
public final Drawable component5() {
return this.noticeBodyBackgroundDrawable;
}
public final String component6() {
return this.noticeBodyImageUrl;
}
public final Drawable component7() {
return this.noticeBodyImageDrawable;
}
public final Drawable component8() {
return this.noticeIconTopRight;
}
public final Function1<View, Unit> component9() {
return this.onClickTopRightIcon;
}
public final Model copy(CharSequence charSequence, CharSequence charSequence2, DraweeSpanStringBuilder draweeSpanStringBuilder, String str, Drawable drawable, String str2, Drawable drawable2, Drawable drawable3, Function1<? super View, Unit> function1, List<Sticker> list) {
m.checkNotNullParameter(charSequence, "noticeTitle");
m.checkNotNullParameter(draweeSpanStringBuilder, "noticeBody");
m.checkNotNullParameter(function1, "onClickTopRightIcon");
return new Model(charSequence, charSequence2, draweeSpanStringBuilder, str, drawable, str2, drawable2, drawable3, function1, list);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof Model)) {
return false;
}
Model model = (Model) obj;
return m.areEqual(this.noticeTitle, model.noticeTitle) && m.areEqual(this.noticeSubtitle, model.noticeSubtitle) && m.areEqual(this.noticeBody, model.noticeBody) && m.areEqual(this.noticeIconUrl, model.noticeIconUrl) && m.areEqual(this.noticeBodyBackgroundDrawable, model.noticeBodyBackgroundDrawable) && m.areEqual(this.noticeBodyImageUrl, model.noticeBodyImageUrl) && m.areEqual(this.noticeBodyImageDrawable, model.noticeBodyImageDrawable) && m.areEqual(this.noticeIconTopRight, model.noticeIconTopRight) && m.areEqual(this.onClickTopRightIcon, model.onClickTopRightIcon) && m.areEqual(this.noticeStickers, model.noticeStickers);
}
public final DraweeSpanStringBuilder getNoticeBody() {
return this.noticeBody;
}
public final Drawable getNoticeBodyBackgroundDrawable() {
return this.noticeBodyBackgroundDrawable;
}
public final Drawable getNoticeBodyImageDrawable() {
return this.noticeBodyImageDrawable;
}
public final String getNoticeBodyImageUrl() {
return this.noticeBodyImageUrl;
}
public final Drawable getNoticeIconTopRight() {
return this.noticeIconTopRight;
}
public final String getNoticeIconUrl() {
return this.noticeIconUrl;
}
public final List<Sticker> getNoticeStickers() {
return this.noticeStickers;
}
public final CharSequence getNoticeSubtitle() {
return this.noticeSubtitle;
}
public final CharSequence getNoticeTitle() {
return this.noticeTitle;
}
public final Function1<View, Unit> getOnClickTopRightIcon() {
return this.onClickTopRightIcon;
}
public int hashCode() {
CharSequence charSequence = this.noticeTitle;
int i = 0;
int hashCode = (charSequence != null ? charSequence.hashCode() : 0) * 31;
CharSequence charSequence2 = this.noticeSubtitle;
int hashCode2 = (hashCode + (charSequence2 != null ? charSequence2.hashCode() : 0)) * 31;
DraweeSpanStringBuilder draweeSpanStringBuilder = this.noticeBody;
int hashCode3 = (hashCode2 + (draweeSpanStringBuilder != null ? draweeSpanStringBuilder.hashCode() : 0)) * 31;
String str = this.noticeIconUrl;
int hashCode4 = (hashCode3 + (str != null ? str.hashCode() : 0)) * 31;
Drawable drawable = this.noticeBodyBackgroundDrawable;
int hashCode5 = (hashCode4 + (drawable != null ? drawable.hashCode() : 0)) * 31;
String str2 = this.noticeBodyImageUrl;
int hashCode6 = (hashCode5 + (str2 != null ? str2.hashCode() : 0)) * 31;
Drawable drawable2 = this.noticeBodyImageDrawable;
int hashCode7 = (hashCode6 + (drawable2 != null ? drawable2.hashCode() : 0)) * 31;
Drawable drawable3 = this.noticeIconTopRight;
int hashCode8 = (hashCode7 + (drawable3 != null ? drawable3.hashCode() : 0)) * 31;
Function1<View, Unit> function1 = this.onClickTopRightIcon;
int hashCode9 = (hashCode8 + (function1 != null ? function1.hashCode() : 0)) * 31;
List<Sticker> list = this.noticeStickers;
if (list != null) {
i = list.hashCode();
}
return hashCode9 + i;
}
public final void setNoticeBodyBackgroundDrawable(Drawable drawable) {
this.noticeBodyBackgroundDrawable = drawable;
}
public final void setNoticeBodyImageDrawable(Drawable drawable) {
this.noticeBodyImageDrawable = drawable;
}
public final void setNoticeBodyImageUrl(String str) {
this.noticeBodyImageUrl = str;
}
public String toString() {
StringBuilder K = a.K("Model(noticeTitle=");
K.append(this.noticeTitle);
K.append(", noticeSubtitle=");
K.append(this.noticeSubtitle);
K.append(", noticeBody=");
K.append((Object) this.noticeBody);
K.append(", noticeIconUrl=");
K.append(this.noticeIconUrl);
K.append(", noticeBodyBackgroundDrawable=");
K.append(this.noticeBodyBackgroundDrawable);
K.append(", noticeBodyImageUrl=");
K.append(this.noticeBodyImageUrl);
K.append(", noticeBodyImageDrawable=");
K.append(this.noticeBodyImageDrawable);
K.append(", noticeIconTopRight=");
K.append(this.noticeIconTopRight);
K.append(", onClickTopRightIcon=");
K.append(this.onClickTopRightIcon);
K.append(", noticeStickers=");
return a.D(K, this.noticeStickers, ")");
}
}
private NoticePopupChannel() {
}
public static final /* synthetic */ Model access$createModel(NoticePopupChannel noticePopupChannel, Context context, Message message, Guild guild, Channel channel, Map map, Long l, User user, Map map2, Map map3) {
return noticePopupChannel.createModel(context, message, guild, channel, map, l, user, map2, map3);
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARNING: Code restructure failed: missing block: B:9:0x0076, code lost:
if (r0 != null) goto L_0x0080;
*/
/* JADX WARNING: Unknown variable types count: 1 */
private final Model createModel(Context context, Message message, Guild guild, Channel channel, Map<Long, GuildMember> map, Long l, User user, Map<Long, String> map2, Map<Long, GuildRole> map3) {
int i;
?? r1;
DraweeSpanStringBuilder draweeSpanStringBuilder;
Pair pair;
Channel channel2;
String str;
Context context2;
Drawable drawable;
Drawable drawable2;
String str2;
String str3;
MessageEmbed messageEmbed;
boolean z2;
if (channel != null) {
long h = channel.h();
if (l == null || l.longValue() != h) {
MessageRenderContext messageRenderContext = new MessageRenderContext(context, user.getId(), true, MessageUtils.getNickOrUsernames$default(message, channel, map, null, 8, null), map2, map3, 0, null, NoticePopupChannel$createModel$messageRenderContext$1.INSTANCE, ColorCompat.getThemedColor(context, 2130970183), 0, null, null, null, 15552, null);
String content = message.getContent();
if (content != null) {
z2 = false;
r1 = 0;
i = 0;
draweeSpanStringBuilder = AstRenderer.render(Parser.parse$default(DiscordParser.createParser$default(false, true, false, 4, null), content, MessageParseState.Companion.getInitialState(), null, 4, null), messageRenderContext);
} else {
i = 0;
z2 = false;
}
draweeSpanStringBuilder = new DraweeSpanStringBuilder();
r1 = z2;
String str4 = "";
if (t.isBlank(draweeSpanStringBuilder)) {
List<MessageEmbed> embeds = message.getEmbeds();
String j = (embeds == null || (messageEmbed = (MessageEmbed) u.firstOrNull(embeds)) == null) ? r1 : messageEmbed.j();
if (j == null) {
j = str4;
}
draweeSpanStringBuilder.append((CharSequence) j);
}
long f = channel.f();
if (f == -1 || f == 0) {
pair = o.to(AnimatableValueParser.y0(channel), r1);
} else {
String name = guild != null ? guild.getName() : r1;
if (name != null) {
str4 = name;
}
StringBuilder H = a.H('#');
H.append(AnimatableValueParser.y0(channel));
pair = o.to(str4, H.toString());
}
String str5 = (String) pair.component1();
String str6 = (String) pair.component2();
if (AnimatableValueParser.l1(channel)) {
str = IconUtils.getForGuild$default(guild, "asset://asset/images/default_icon_selected.jpg", false, null, 12, null);
channel2 = channel;
} else {
channel2 = channel;
str = IconUtils.getForChannel$default(channel2, r1, 2, r1);
}
if (!AnimatableValueParser.h1(channel)) {
com.discord.api.user.User author = message.getAuthor();
m.checkNotNull(author);
CoreUser coreUser = new CoreUser(author);
SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(a.s(GuildMember.Companion.getNickOrUsername$default(GuildMember.Companion, coreUser, map.get(Long.valueOf(coreUser.getId())), channel, null, 8, null), ": "));
context2 = context;
Object[] objArr = new Object[2];
objArr[i] = new ForegroundColorSpan(ColorCompat.getThemedColor(context2, 2130969872));
objArr[1] = new StyleSpan(1);
for (Object obj : n.listOf(objArr)) {
spannableStringBuilder.setSpan(obj, i, spannableStringBuilder.length(), 33);
}
draweeSpanStringBuilder.insert(i, (CharSequence) spannableStringBuilder);
} else {
context2 = context;
}
List<MessageAttachment> attachments = message.getAttachments();
MessageAttachment messageAttachment = attachments != null ? (MessageAttachment) u.firstOrNull((List<? extends Object>) attachments) : r1;
if (messageAttachment == null || !messageAttachment.h()) {
if ((messageAttachment != null ? messageAttachment.e() : r1) == MessageAttachmentType.IMAGE) {
str2 = messageAttachment.c();
str3 = r1;
} else if ((messageAttachment != null ? messageAttachment.e() : r1) == MessageAttachmentType.VIDEO) {
Drawable drawable$default = DrawableCompat.getDrawable$default(context, 2131232326, ColorCompat.getThemedColor(context2, 2130968905), false, 4, null);
drawable2 = DrawableCompat.getDrawable$default(context, 2131231876, ColorCompat.getThemedColor(context2, 2130968946), false, 4, null);
str2 = r1;
drawable = drawable$default;
} else {
str2 = r1;
str3 = str2;
}
drawable = str3;
drawable2 = str3;
} else {
drawable2 = ContextCompat.getDrawable(context2, DrawableCompat.getThemedDrawableRes$default(context2, 2130970183, i, 2, (Object) r1));
str2 = r1;
drawable = str2;
}
return new Model(str5, str6, draweeSpanStringBuilder, str, drawable, str2, drawable2, ContextCompat.getDrawable(context2, DrawableCompat.getThemedDrawableRes$default(context2, AnimatableValueParser.t1(channel) ? 2130969395 : 2130969451, i, 2, (Object) r1)), new NoticePopupChannel$createModel$onClickTopRightIcon$1(channel2, context2), message.getStickers());
}
}
return null;
}
public final void enqueue(Context context, String str, Message message, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(str, "noticeName");
m.checkNotNullParameter(message, "message");
m.checkNotNullParameter(function1, "onClick");
j jVar = new j(context);
j jVar2 = new j(message);
StoreStream.Companion companion = StoreStream.Companion;
Observable<Guild> observeFromChannelId = companion.getGuilds().observeFromChannelId(message.getChannelId());
Observable<Channel> observeChannel = companion.getChannels().observeChannel(message.getChannelId());
StoreGuilds guilds = companion.getGuilds();
Long guildId = message.getGuildId();
long j = 0;
Observable<Map<Long, GuildMember>> observeComputed = guilds.observeComputed(guildId != null ? guildId.longValue() : 0);
Observable<Long> observeId = companion.getChannelsSelected().observeId();
Observable observeMe$default = StoreUser.observeMe$default(companion.getUsers(), false, 1, null);
Observable<Map<Long, String>> observeNames = companion.getChannels().observeNames();
StoreGuilds guilds2 = companion.getGuilds();
Long guildId2 = message.getGuildId();
if (guildId2 != null) {
j = guildId2.longValue();
}
Observable c2 = Observable.c(jVar, jVar2, observeFromChannelId, observeChannel, observeComputed, observeId, observeMe$default, observeNames, guilds2.observeRoles(j), new NoticePopupChannel$sam$rx_functions_Func9$0(new NoticePopupChannel$enqueue$1(this)));
m.checkNotNullExpressionValue(c2, "Observable\n .comb…is::createModel\n )");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(ObservableExtensionsKt.computationLatest(ObservableExtensionsKt.takeSingleUntilTimeout$default(c2, 0, false, 3, null))), NoticePopupChannel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new NoticePopupChannel$enqueue$2(str, function1), 62, (Object) null);
}
}