package com.discord.widgets.home; import android.content.Context; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.TextView; import androidx.annotation.DrawableRes; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.core.view.ViewKt; import c.a.i.z4; import c.d.b.a.a; import com.airbnb.lottie.parser.AnimatableValueParser; import com.discord.api.channel.Channel; import com.discord.app.AppFragment; import com.discord.databinding.WidgetHomeBinding; import com.discord.models.presence.Presence; import com.discord.stores.StoreChannelsSelected; import com.discord.utilities.channel.GuildChannelIconUtilsKt; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.toolbar.ToolbarUtilsKt; import com.discord.utilities.view.extensions.ViewExtensions; import com.discord.views.StatusView; import com.discord.views.ToolbarTitleLayout; import d0.z.d.m; import kotlin.jvm.internal.DefaultConstructorMarker; import rx.functions.Action1; /* compiled from: WidgetHomeHeaderManager.kt */ public final class WidgetHomeHeaderManager { private static final String ANALYTICS_SOURCE = "Toolbar"; public static final WidgetHomeHeaderManager INSTANCE = new WidgetHomeHeaderManager(); /* compiled from: WidgetHomeHeaderManager.kt */ public static final class HeaderData { private final Integer drawableRes; private final boolean leftButtonIsBack; private final CharSequence subtitle; private final CharSequence title; public HeaderData(CharSequence charSequence, CharSequence charSequence2, @DrawableRes Integer num, boolean z2) { this.title = charSequence; this.subtitle = charSequence2; this.drawableRes = num; this.leftButtonIsBack = z2; } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ HeaderData(CharSequence charSequence, CharSequence charSequence2, Integer num, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) { this(charSequence, (i & 2) != 0 ? null : charSequence2, (i & 4) != 0 ? null : num, (i & 8) != 0 ? false : z2); } public static /* synthetic */ HeaderData copy$default(HeaderData headerData, CharSequence charSequence, CharSequence charSequence2, Integer num, boolean z2, int i, Object obj) { if ((i & 1) != 0) { charSequence = headerData.title; } if ((i & 2) != 0) { charSequence2 = headerData.subtitle; } if ((i & 4) != 0) { num = headerData.drawableRes; } if ((i & 8) != 0) { z2 = headerData.leftButtonIsBack; } return headerData.copy(charSequence, charSequence2, num, z2); } public final CharSequence component1() { return this.title; } public final CharSequence component2() { return this.subtitle; } public final Integer component3() { return this.drawableRes; } public final boolean component4() { return this.leftButtonIsBack; } public final HeaderData copy(CharSequence charSequence, CharSequence charSequence2, @DrawableRes Integer num, boolean z2) { return new HeaderData(charSequence, charSequence2, num, z2); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof HeaderData)) { return false; } HeaderData headerData = (HeaderData) obj; return m.areEqual(this.title, headerData.title) && m.areEqual(this.subtitle, headerData.subtitle) && m.areEqual(this.drawableRes, headerData.drawableRes) && this.leftButtonIsBack == headerData.leftButtonIsBack; } public final Integer getDrawableRes() { return this.drawableRes; } public final boolean getLeftButtonIsBack() { return this.leftButtonIsBack; } public final CharSequence getSubtitle() { return this.subtitle; } public final CharSequence getTitle() { return this.title; } public int hashCode() { CharSequence charSequence = this.title; int i = 0; int hashCode = (charSequence != null ? charSequence.hashCode() : 0) * 31; CharSequence charSequence2 = this.subtitle; int hashCode2 = (hashCode + (charSequence2 != null ? charSequence2.hashCode() : 0)) * 31; Integer num = this.drawableRes; if (num != null) { i = num.hashCode(); } int i2 = (hashCode2 + i) * 31; boolean z2 = this.leftButtonIsBack; if (z2) { z2 = true; } int i3 = z2 ? 1 : 0; int i4 = z2 ? 1 : 0; int i5 = z2 ? 1 : 0; return i2 + i3; } public String toString() { StringBuilder K = a.K("HeaderData(title="); K.append(this.title); K.append(", subtitle="); K.append(this.subtitle); K.append(", drawableRes="); K.append(this.drawableRes); K.append(", leftButtonIsBack="); return a.F(K, this.leftButtonIsBack, ")"); } } private WidgetHomeHeaderManager() { } private final void configureThreadBrowserIconBehavior(Toolbar toolbar, WidgetHomeModel widgetHomeModel, Channel channel, Context context) { View actionView; View actionView2; Menu menu; if (channel != null) { int threadCount = widgetHomeModel.getThreadCount(); View view = null; MenuItem findItem = (toolbar == null || (menu = toolbar.getMenu()) == null) ? null : menu.findItem(2131363972); TextView textView = (findItem == null || (actionView2 = findItem.getActionView()) == null) ? null : (TextView) actionView2.findViewById(2131365358); if (textView != null) { textView.setText(String.valueOf(Math.min(99, threadCount))); } if (textView != null) { ViewKt.setVisible(textView, threadCount != 0); } if (!(findItem == null || (actionView = findItem.getActionView()) == null)) { view = actionView.findViewById(2131365368); } if (view != null) { view.setOnClickListener(new WidgetHomeHeaderManager$configureThreadBrowserIconBehavior$1(context, channel)); } } } private final HeaderData getHeaderData(WidgetHomeModel widgetHomeModel, Context context) { HeaderData headerData; StoreChannelsSelected.ResolvedSelectedChannel selectedChannel = widgetHomeModel.getSelectedChannel(); boolean z2 = true; String str = null; if (selectedChannel instanceof StoreChannelsSelected.ResolvedSelectedChannel.Channel) { Channel channel = widgetHomeModel.getChannel(); Integer valueOf = channel != null ? Integer.valueOf(channel.A()) : null; if (valueOf == null) { return new HeaderData(context.getString(2131887360), null, null, false, 10, null); } if (valueOf.intValue() == 3) { headerData = new HeaderData(AnimatableValueParser.z0(widgetHomeModel.getChannel(), context, false), null, 2131231680, false, 10, null); } else if (valueOf.intValue() == 1) { headerData = new HeaderData(AnimatableValueParser.z0(widgetHomeModel.getChannel(), context, false), null, 2131231576, false, 10, null); } else if (valueOf.intValue() == 14) { headerData = new HeaderData(AnimatableValueParser.z0(widgetHomeModel.getChannel(), context, false), null, 2131231724, false, 10, null); } else if (widgetHomeModel.getChannel().h() <= 0) { return new HeaderData(null, null, null, false, 10, null); } else { String z0 = AnimatableValueParser.z0(widgetHomeModel.getChannel(), context, false); Channel parentChannel = widgetHomeModel.getParentChannel(); if (parentChannel != null) { str = AnimatableValueParser.z0(parentChannel, context, false); } Integer valueOf2 = Integer.valueOf(GuildChannelIconUtilsKt.guildChannelIcon(widgetHomeModel.getChannel())); if (((StoreChannelsSelected.ResolvedSelectedChannel.Channel) widgetHomeModel.getSelectedChannel()).getPeekParent() == null) { z2 = false; } headerData = new HeaderData(z0, str, valueOf2, z2); } } else if (!(selectedChannel instanceof StoreChannelsSelected.ResolvedSelectedChannel.ThreadDraft)) { return new HeaderData(null, null, null, false, 14, null); } else { headerData = new HeaderData(context.getString(2131887968), AnimatableValueParser.z0(((StoreChannelsSelected.ResolvedSelectedChannel.ThreadDraft) widgetHomeModel.getSelectedChannel()).getParentChannel(), context, false), null, true); } return headerData; } private final Action1