discord-jadx/app/src/main/java/com/discord/widgets/user/presence/ViewHolderUserRichPresence....

777 lines
46 KiB
Java

package com.discord.widgets.user.presence;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.SeekBar;
import android.widget.Space;
import android.widget.TextView;
import androidx.annotation.MainThread;
import androidx.annotation.StringRes;
import androidx.constraintlayout.widget.Barrier;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.view.ViewKt;
import androidx.fragment.app.FragmentManager;
import c.a.i.c5;
import c.a.i.d5;
import c.a.i.l5;
import c.a.i.m5;
import c.a.i.p5;
import c.a.l.b;
import com.discord.api.activity.Activity;
import com.discord.api.activity.ActivityAssets;
import com.discord.api.activity.ActivityParty;
import com.discord.api.activity.ActivityTimestamps;
import com.discord.app.AppComponent;
import com.discord.models.user.User;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.presence.ActivityUtilsKt;
import com.discord.utilities.presence.PresenceUtils;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.streams.StreamContext;
import com.discord.utilities.time.ClockFactory;
import com.discord.utilities.time.TimeUtils;
import com.discord.utilities.view.extensions.ViewExtensions;
import com.discord.views.StreamPreviewView;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.button.MaterialButton;
import d0.g0.t;
import d0.g0.w;
import d0.t.n;
import d0.t.u;
import d0.z.d.m;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function5;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
import rx.Subscription;
/* compiled from: ViewHolderUserRichPresence.kt */
public class ViewHolderUserRichPresence {
public static final int BASE_RICH_PRESENCE_TYPE = 0;
public static final Companion Companion = new Companion(null);
public static final int GAME_RICH_PRESENCE_TYPE = 1;
public static final int MUSIC_RICH_PRESENCE_TYPE = 2;
public static final int PLATFORM_RICH_PRESENCE_TYPE = 3;
public static final int STAGE_CHANNEL_RICH_PRESENCE_TYPE = 5;
public static final int STREAM_RICH_PRESENCE_TYPE = 4;
private Function5<? super Context, ? super Long, ? super String, ? super Long, ? super Integer, Unit> onActivityCustomButtonClicked;
private Subscription perSecondTimerSubscription;
private final TextView richPresenceDetails;
private final TextView richPresenceHeader;
private final SimpleDraweeView richPresenceImageLarge;
private final SimpleDraweeView richPresenceImageSmall;
private final Button richPresencePrimaryButton;
private final Button richPresenceSecondaryButton;
private final TextView richPresenceState;
private final View richPresenceTextContainer;
private final TextView richPresenceTime;
private final TextView richPresenceTitle;
private final int richPresenceType;
private final View root;
/* compiled from: ViewHolderUserRichPresence.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
private final ViewHolderUserRichPresence createRPView(ViewGroup viewGroup, int i) {
String str;
int i2;
ViewHolderUserRichPresence viewHolderUserRichPresence;
int i3;
String str2;
int i4;
String str3;
int i5;
LayoutInflater from = LayoutInflater.from(viewGroup.getContext());
if (i == 1) {
p5 a = p5.a(from, viewGroup, true);
m.checkNotNullExpressionValue(a, "WidgetUserRichPresenceBi…e(inflater, parent, true)");
SimpleDraweeView simpleDraweeView = a.e;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.richPresenceImageLarge");
SimpleDraweeView simpleDraweeView2 = a.f;
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.richPresenceImageSmall");
TextView textView = a.d;
m.checkNotNullExpressionValue(textView, "binding.richPresenceHeader");
TextView textView2 = a.k;
m.checkNotNullExpressionValue(textView2, "binding.richPresenceTitle");
TextView textView3 = a.f145c;
m.checkNotNullExpressionValue(textView3, "binding.richPresenceDetails");
TextView textView4 = a.j;
m.checkNotNullExpressionValue(textView4, "binding.richPresenceTime");
TextView textView5 = a.i;
m.checkNotNullExpressionValue(textView5, "binding.richPresenceState");
LinearLayout linearLayout = a.b;
m.checkNotNullExpressionValue(linearLayout, "binding.richPresenceContainerData");
MaterialButton materialButton = a.g;
m.checkNotNullExpressionValue(materialButton, "binding.richPresencePrimaryButton");
MaterialButton materialButton2 = a.h;
m.checkNotNullExpressionValue(materialButton2, "binding.richPresenceSecondaryButton");
return new ViewHolderGameRichPresence(viewGroup, simpleDraweeView, simpleDraweeView2, textView, textView2, textView3, textView4, textView5, linearLayout, materialButton, materialButton2);
} else if (i != 2) {
if (i == 3) {
View inflate = from.inflate(2131559129, viewGroup, false);
viewGroup.addView(inflate);
Barrier barrier = (Barrier) inflate.findViewById(2131362099);
if (barrier != null) {
Space space = (Space) inflate.findViewById(2131363624);
if (space != null) {
LinearLayout linearLayout2 = (LinearLayout) inflate.findViewById(2131364526);
if (linearLayout2 != null) {
TextView textView6 = (TextView) inflate.findViewById(2131364528);
if (textView6 != null) {
SimpleDraweeView simpleDraweeView3 = (SimpleDraweeView) inflate.findViewById(2131364529);
if (simpleDraweeView3 != null) {
SimpleDraweeView simpleDraweeView4 = (SimpleDraweeView) inflate.findViewById(2131364532);
if (simpleDraweeView4 != null) {
MaterialButton materialButton3 = (MaterialButton) inflate.findViewById(2131364536);
if (materialButton3 != null) {
TextView textView7 = (TextView) inflate.findViewById(2131364540);
if (textView7 != null) {
TextView textView8 = (TextView) inflate.findViewById(2131364541);
if (textView8 != null) {
m.checkNotNullExpressionValue(new d5((LinearLayout) inflate, barrier, space, linearLayout2, textView6, simpleDraweeView3, simpleDraweeView4, materialButton3, textView7, textView8), "WidgetPlatformRichPresen…e(inflater, parent, true)");
m.checkNotNullExpressionValue(simpleDraweeView3, "binding.richPresenceImageLarge");
m.checkNotNullExpressionValue(simpleDraweeView4, "binding.richPresenceImageSmall");
m.checkNotNullExpressionValue(textView6, "binding.richPresenceHeader");
m.checkNotNullExpressionValue(textView8, "binding.richPresenceTitle");
m.checkNotNullExpressionValue(textView7, "binding.richPresenceTime");
m.checkNotNullExpressionValue(linearLayout2, "binding.richPresenceContainerData");
m.checkNotNullExpressionValue(materialButton3, "binding.richPresencePrimaryButton");
viewHolderUserRichPresence = new ViewHolderPlatformRichPresence(viewGroup, simpleDraweeView3, simpleDraweeView4, textView6, textView8, textView7, linearLayout2, materialButton3);
} else {
i3 = 2131364541;
}
} else {
i3 = 2131364540;
}
} else {
i3 = 2131364536;
}
} else {
i3 = 2131364532;
}
} else {
i3 = 2131364529;
}
} else {
i3 = 2131364528;
}
} else {
i3 = 2131364526;
}
} else {
i3 = 2131363624;
}
} else {
i3 = 2131362099;
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i3)));
} else if (i == 4) {
View inflate2 = from.inflate(2131559265, viewGroup, false);
viewGroup.addView(inflate2);
LinearLayout linearLayout3 = (LinearLayout) inflate2.findViewById(2131364526);
if (linearLayout3 != null) {
TextView textView9 = (TextView) inflate2.findViewById(2131364527);
if (textView9 != null) {
TextView textView10 = (TextView) inflate2.findViewById(2131364528);
if (textView10 != null) {
SimpleDraweeView simpleDraweeView5 = (SimpleDraweeView) inflate2.findViewById(2131364529);
if (simpleDraweeView5 != null) {
TextView textView11 = (TextView) inflate2.findViewById(2131364539);
if (textView11 != null) {
TextView textView12 = (TextView) inflate2.findViewById(2131364540);
if (textView12 != null) {
TextView textView13 = (TextView) inflate2.findViewById(2131364541);
str2 = "Missing required view with ID: ";
if (textView13 != null) {
StreamPreviewView streamPreviewView = (StreamPreviewView) inflate2.findViewById(2131365233);
if (streamPreviewView != null) {
m.checkNotNullExpressionValue(new m5((ConstraintLayout) inflate2, linearLayout3, textView9, textView10, simpleDraweeView5, textView11, textView12, textView13, streamPreviewView), "WidgetStreamRichPresence…e(inflater, parent, true)");
m.checkNotNullExpressionValue(simpleDraweeView5, "binding.richPresenceImageLarge");
m.checkNotNullExpressionValue(textView10, "binding.richPresenceHeader");
m.checkNotNullExpressionValue(textView13, "binding.richPresenceTitle");
m.checkNotNullExpressionValue(textView9, "binding.richPresenceDetails");
m.checkNotNullExpressionValue(textView12, "binding.richPresenceTime");
m.checkNotNullExpressionValue(textView11, "binding.richPresenceState");
m.checkNotNullExpressionValue(linearLayout3, "binding.richPresenceContainerData");
m.checkNotNullExpressionValue(streamPreviewView, "binding.streamPreview");
viewHolderUserRichPresence = new ViewHolderStreamRichPresence(viewGroup, simpleDraweeView5, textView10, textView13, textView9, textView12, textView11, linearLayout3, streamPreviewView);
} else {
i4 = 2131365233;
}
} else {
i4 = 2131364541;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364540;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364539;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364529;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364528;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364527;
}
} else {
str2 = "Missing required view with ID: ";
i4 = 2131364526;
}
throw new NullPointerException(str2.concat(inflate2.getResources().getResourceName(i4)));
} else if (i != 5) {
p5 a2 = p5.a(from, viewGroup, true);
m.checkNotNullExpressionValue(a2, "WidgetUserRichPresenceBi…e(inflater, parent, true)");
SimpleDraweeView simpleDraweeView6 = a2.e;
m.checkNotNullExpressionValue(simpleDraweeView6, "binding.richPresenceImageLarge");
SimpleDraweeView simpleDraweeView7 = a2.f;
TextView textView14 = a2.d;
m.checkNotNullExpressionValue(textView14, "binding.richPresenceHeader");
TextView textView15 = a2.k;
m.checkNotNullExpressionValue(textView15, "binding.richPresenceTitle");
TextView textView16 = a2.f145c;
TextView textView17 = a2.j;
m.checkNotNullExpressionValue(textView17, "binding.richPresenceTime");
TextView textView18 = a2.i;
LinearLayout linearLayout4 = a2.b;
m.checkNotNullExpressionValue(linearLayout4, "binding.richPresenceContainerData");
return new ViewHolderUserRichPresence(viewGroup, simpleDraweeView6, simpleDraweeView7, textView14, textView15, textView16, textView17, textView18, linearLayout4, a2.g, a2.h, 0, 2048, null);
} else {
View inflate3 = from.inflate(2131559249, viewGroup, false);
viewGroup.addView(inflate3);
Barrier barrier2 = (Barrier) inflate3.findViewById(2131362099);
if (barrier2 != null) {
Space space2 = (Space) inflate3.findViewById(2131363624);
if (space2 != null) {
LinearLayout linearLayout5 = (LinearLayout) inflate3.findViewById(2131364526);
if (linearLayout5 != null) {
TextView textView19 = (TextView) inflate3.findViewById(2131364527);
if (textView19 != null) {
TextView textView20 = (TextView) inflate3.findViewById(2131364528);
if (textView20 != null) {
SimpleDraweeView simpleDraweeView8 = (SimpleDraweeView) inflate3.findViewById(2131364529);
if (simpleDraweeView8 != null) {
TextView textView21 = (TextView) inflate3.findViewById(2131364530);
if (textView21 != null) {
FrameLayout frameLayout = (FrameLayout) inflate3.findViewById(2131364531);
if (frameLayout != null) {
MaterialButton materialButton4 = (MaterialButton) inflate3.findViewById(2131364536);
if (materialButton4 != null) {
TextView textView22 = (TextView) inflate3.findViewById(2131364540);
str3 = "Missing required view with ID: ";
if (textView22 != null) {
TextView textView23 = (TextView) inflate3.findViewById(2131364541);
if (textView23 != null) {
m.checkNotNullExpressionValue(new l5((LinearLayout) inflate3, barrier2, space2, linearLayout5, textView19, textView20, simpleDraweeView8, textView21, frameLayout, materialButton4, textView22, textView23), "WidgetStageChannelRichPr…e(inflater, parent, true)");
m.checkNotNullExpressionValue(simpleDraweeView8, "binding.richPresenceImageLarge");
m.checkNotNullExpressionValue(textView20, "binding.richPresenceHeader");
m.checkNotNullExpressionValue(textView23, "binding.richPresenceTitle");
m.checkNotNullExpressionValue(textView19, "binding.richPresenceDetails");
m.checkNotNullExpressionValue(textView22, "binding.richPresenceTime");
m.checkNotNullExpressionValue(linearLayout5, "binding.richPresenceContainerData");
m.checkNotNullExpressionValue(materialButton4, "binding.richPresencePrimaryButton");
m.checkNotNullExpressionValue(textView21, "binding.richPresenceImageLargeText");
viewHolderUserRichPresence = new ViewHolderStageChannelRichPresence(viewGroup, simpleDraweeView8, textView20, textView23, textView19, textView22, linearLayout5, materialButton4, textView21);
} else {
i5 = 2131364541;
}
} else {
i5 = 2131364540;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364536;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364531;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364530;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364529;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364528;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364527;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131364526;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131363624;
}
} else {
str3 = "Missing required view with ID: ";
i5 = 2131362099;
}
throw new NullPointerException(str3.concat(inflate3.getResources().getResourceName(i5)));
}
return viewHolderUserRichPresence;
} else {
View inflate4 = from.inflate(2131559111, viewGroup, false);
viewGroup.addView(inflate4);
Barrier barrier3 = (Barrier) inflate4.findViewById(2131362099);
if (barrier3 != null) {
Space space3 = (Space) inflate4.findViewById(2131363624);
if (space3 != null) {
LinearLayout linearLayout6 = (LinearLayout) inflate4.findViewById(2131364526);
if (linearLayout6 != null) {
TextView textView24 = (TextView) inflate4.findViewById(2131364527);
if (textView24 != null) {
TextView textView25 = (TextView) inflate4.findViewById(2131364528);
if (textView25 != null) {
i2 = 2131364529;
SimpleDraweeView simpleDraweeView9 = (SimpleDraweeView) inflate4.findViewById(2131364529);
if (simpleDraweeView9 != null) {
SimpleDraweeView simpleDraweeView10 = (SimpleDraweeView) inflate4.findViewById(2131364532);
if (simpleDraweeView10 != null) {
TextView textView26 = (TextView) inflate4.findViewById(2131364533);
str = "Missing required view with ID: ";
if (textView26 != null) {
TextView textView27 = (TextView) inflate4.findViewById(2131364534);
if (textView27 != null) {
FrameLayout frameLayout2 = (FrameLayout) inflate4.findViewById(2131364535);
if (frameLayout2 != null) {
MaterialButton materialButton5 = (MaterialButton) inflate4.findViewById(2131364536);
if (materialButton5 != null) {
SeekBar seekBar = (SeekBar) inflate4.findViewById(2131364538);
if (seekBar != null) {
TextView textView28 = (TextView) inflate4.findViewById(2131364540);
if (textView28 != null) {
TextView textView29 = (TextView) inflate4.findViewById(2131364541);
if (textView29 != null) {
m.checkNotNullExpressionValue(new c5((LinearLayout) inflate4, barrier3, space3, linearLayout6, textView24, textView25, simpleDraweeView9, simpleDraweeView10, textView26, textView27, frameLayout2, materialButton5, seekBar, textView28, textView29), "WidgetMusicRichPresenceB…e(inflater, parent, true)");
m.checkNotNullExpressionValue(simpleDraweeView9, "binding.richPresenceImageLarge");
m.checkNotNullExpressionValue(simpleDraweeView10, "binding.richPresenceImageSmall");
m.checkNotNullExpressionValue(textView25, "binding.richPresenceHeader");
m.checkNotNullExpressionValue(textView29, "binding.richPresenceTitle");
m.checkNotNullExpressionValue(textView24, "binding.richPresenceDetails");
m.checkNotNullExpressionValue(textView28, "binding.richPresenceTime");
m.checkNotNullExpressionValue(linearLayout6, "binding.richPresenceContainerData");
m.checkNotNullExpressionValue(materialButton5, "binding.richPresencePrimaryButton");
m.checkNotNullExpressionValue(seekBar, "binding.richPresenceSeekbar");
m.checkNotNullExpressionValue(textView26, "binding.richPresenceMusicDuration");
m.checkNotNullExpressionValue(textView27, "binding.richPresenceMusicElapsed");
return new ViewHolderMusicRichPresence(viewGroup, simpleDraweeView9, simpleDraweeView10, textView25, textView29, textView24, textView28, linearLayout6, materialButton5, seekBar, textView26, textView27);
}
i2 = 2131364541;
} else {
i2 = 2131364540;
}
} else {
i2 = 2131364538;
}
} else {
i2 = 2131364536;
}
} else {
i2 = 2131364535;
}
} else {
i2 = 2131364534;
}
} else {
i2 = 2131364533;
}
} else {
str = "Missing required view with ID: ";
i2 = 2131364532;
}
} else {
str = "Missing required view with ID: ";
}
} else {
str = "Missing required view with ID: ";
i2 = 2131364528;
}
} else {
str = "Missing required view with ID: ";
i2 = 2131364527;
}
} else {
str = "Missing required view with ID: ";
i2 = 2131364526;
}
} else {
str = "Missing required view with ID: ";
i2 = 2131363624;
}
} else {
str = "Missing required view with ID: ";
i2 = 2131362099;
}
throw new NullPointerException(str.concat(inflate4.getResources().getResourceName(i2)));
}
}
private final int getRPViewHolderType(Activity activity, StreamContext streamContext) {
if (streamContext != null) {
return 4;
}
if (activity != null && ActivityUtilsKt.isGamePlatform(activity)) {
return 3;
}
if (activity != null && ActivityUtilsKt.isGameActivity(activity)) {
return 1;
}
if (activity == null || !ActivityUtilsKt.isSpotifyActivity(activity)) {
return (activity == null || !ActivityUtilsKt.isStageChannelActivity(activity)) ? 0 : 5;
}
return 2;
}
public final ViewHolderUserRichPresence setRichPresence(ViewGroup viewGroup, Activity activity, StreamContext streamContext, ViewHolderUserRichPresence viewHolderUserRichPresence) {
m.checkNotNullParameter(viewGroup, "parent");
int rPViewHolderType = getRPViewHolderType(activity, streamContext);
if (viewHolderUserRichPresence != null && rPViewHolderType == viewHolderUserRichPresence.getRichPresenceType()) {
return viewHolderUserRichPresence;
}
viewGroup.removeAllViews();
return ViewHolderUserRichPresence.Companion.createRPView(viewGroup, rPViewHolderType);
}
}
public ViewHolderUserRichPresence(View view, SimpleDraweeView simpleDraweeView, SimpleDraweeView simpleDraweeView2, TextView textView, TextView textView2, TextView textView3, TextView textView4, TextView textView5, View view2, Button button, Button button2, int i) {
m.checkNotNullParameter(view, "root");
m.checkNotNullParameter(simpleDraweeView, "richPresenceImageLarge");
m.checkNotNullParameter(textView, "richPresenceHeader");
m.checkNotNullParameter(textView2, "richPresenceTitle");
m.checkNotNullParameter(textView4, "richPresenceTime");
m.checkNotNullParameter(view2, "richPresenceTextContainer");
this.root = view;
this.richPresenceImageLarge = simpleDraweeView;
this.richPresenceImageSmall = simpleDraweeView2;
this.richPresenceHeader = textView;
this.richPresenceTitle = textView2;
this.richPresenceDetails = textView3;
this.richPresenceTime = textView4;
this.richPresenceState = textView5;
this.richPresenceTextContainer = view2;
this.richPresencePrimaryButton = button;
this.richPresenceSecondaryButton = button2;
this.richPresenceType = i;
}
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
public /* synthetic */ ViewHolderUserRichPresence(View view, SimpleDraweeView simpleDraweeView, SimpleDraweeView simpleDraweeView2, TextView textView, TextView textView2, TextView textView3, TextView textView4, TextView textView5, View view2, Button button, Button button2, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
this(view, simpleDraweeView, simpleDraweeView2, textView, textView2, textView3, textView4, textView5, view2, button, button2, (i2 & 2048) != 0 ? 0 : i);
}
public static final /* synthetic */ Subscription access$getPerSecondTimerSubscription$p(ViewHolderUserRichPresence viewHolderUserRichPresence) {
return viewHolderUserRichPresence.perSecondTimerSubscription;
}
public static final /* synthetic */ void access$handleActivityCustomButtonClick(ViewHolderUserRichPresence viewHolderUserRichPresence, Context context, User user, Activity activity, int i) {
viewHolderUserRichPresence.handleActivityCustomButtonClick(context, user, activity, i);
}
public static final /* synthetic */ void access$setPerSecondTimerSubscription$p(ViewHolderUserRichPresence viewHolderUserRichPresence, Subscription subscription) {
viewHolderUserRichPresence.perSecondTimerSubscription = subscription;
}
private final void handleActivityCustomButtonClick(Context context, User user, Activity activity, int i) {
String k;
Long a;
if (user != null) {
long id2 = user.getId();
if (activity != null && (k = activity.k()) != null && (a = activity.a()) != null) {
long longValue = a.longValue();
Function5<? super Context, ? super Long, ? super String, ? super Long, ? super Integer, Unit> function5 = this.onActivityCustomButtonClicked;
if (function5 != null) {
function5.invoke(context, Long.valueOf(id2), k, Long.valueOf(longValue), Integer.valueOf(i));
}
}
}
}
public static /* synthetic */ void setImageAndVisibilityBy$default(ViewHolderUserRichPresence viewHolderUserRichPresence, ImageView imageView, String str, boolean z2, int i, Object obj) {
if (obj == null) {
if ((i & 2) != 0) {
z2 = false;
}
viewHolderUserRichPresence.setImageAndVisibilityBy(imageView, str, z2);
return;
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: setImageAndVisibilityBy");
}
public static final ViewHolderUserRichPresence setRichPresence(ViewGroup viewGroup, Activity activity, StreamContext streamContext, ViewHolderUserRichPresence viewHolderUserRichPresence) {
return Companion.setRichPresence(viewGroup, activity, streamContext, viewHolderUserRichPresence);
}
@MainThread
public void configureAssetUi(Activity activity, StreamContext streamContext) {
String c2;
String str = null;
ActivityAssets b = activity != null ? activity.b() : null;
if (b == null) {
this.richPresenceImageLarge.setVisibility(8);
SimpleDraweeView simpleDraweeView = this.richPresenceImageSmall;
if (simpleDraweeView != null) {
simpleDraweeView.setVisibility(8);
return;
}
return;
}
Long a = activity.a();
String a2 = b.a();
String assetImage$default = a2 != null ? IconUtils.getAssetImage$default(IconUtils.INSTANCE, a, a2, 0, 4, null) : null;
if (!(assetImage$default == null || (c2 = b.c()) == null)) {
str = IconUtils.getAssetImage$default(IconUtils.INSTANCE, a, c2, 0, 4, null);
}
setImageAndVisibilityBy$default(this, this.richPresenceImageLarge, assetImage$default, false, 2, null);
this.richPresenceImageLarge.setContentDescription(b.b());
SimpleDraweeView simpleDraweeView2 = this.richPresenceImageSmall;
if (simpleDraweeView2 != null) {
setImageAndVisibilityBy(simpleDraweeView2, str, true);
}
SimpleDraweeView simpleDraweeView3 = this.richPresenceImageSmall;
if (simpleDraweeView3 != null) {
simpleDraweeView3.setContentDescription(b.d());
}
}
@MainThread
public void configureCustomButtonsUi(User user, Activity activity, Context context) {
m.checkNotNullParameter(context, "applicationContext");
List<String> c2 = activity != null ? activity.c() : null;
int i = 0;
for (Object obj : n.listOf((Object[]) new Button[]{this.richPresencePrimaryButton, this.richPresenceSecondaryButton})) {
int i2 = i + 1;
if (i < 0) {
n.throwIndexOverflow();
}
Button button = (Button) obj;
String str = c2 != null ? (String) u.getOrNull(c2, i) : null;
if (str != null) {
if (button != null) {
button.setText(str);
}
if (button != null) {
ViewKt.setVisible(button, true);
}
if (button != null) {
button.setOnClickListener(new ViewHolderUserRichPresence$configureCustomButtonsUi$$inlined$forEachIndexed$lambda$1(i, this, c2, context, user, activity));
}
} else if (button != null) {
ViewKt.setVisible(button, false);
}
i = i2;
}
}
/* JADX WARNING: Code restructure failed: missing block: B:12:0x0043, code lost:
if (r1 != null) goto L_0x0048;
*/
public void configureTextUi(Activity activity, StreamContext streamContext) {
String str;
CharSequence charSequence;
Context context;
if (activity != null) {
String l = activity.l();
CharSequence charSequence2 = null;
if (l != null) {
ActivityParty i = activity.i();
if (i != null) {
PresenceUtils presenceUtils = PresenceUtils.INSTANCE;
charSequence = (presenceUtils.getMaxSize(i) == 0 || (context = this.root.getContext()) == null) ? null : b.g(context, 2131894412, new Object[]{String.valueOf(presenceUtils.getCurrentSize(i)), String.valueOf(presenceUtils.getMaxSize(i))}, null, 4);
}
charSequence = "";
String str2 = l + ' ' + charSequence;
Objects.requireNonNull(str2, "null cannot be cast to non-null type kotlin.CharSequence");
str = w.trim(str2).toString();
} else {
str = null;
}
TextView textView = this.richPresenceHeader;
Context context2 = textView.getContext();
m.checkNotNullExpressionValue(context2, "richPresenceHeader.context");
textView.setText(PresenceUtils.getActivityHeader(context2, activity));
this.richPresenceTitle.setText(activity.e());
TextView textView2 = this.richPresenceDetails;
if (textView2 != null) {
ViewExtensions.setTextAndVisibilityBy(textView2, str);
}
TextView textView3 = this.richPresenceState;
if (textView3 != null) {
ActivityAssets b = activity.b();
ViewExtensions.setTextAndVisibilityBy(textView3, b != null ? b.b() : null);
}
TextView textView4 = this.richPresenceTime;
ActivityTimestamps o = activity.o();
if (o != null) {
charSequence2 = friendlyTime(o);
}
ViewExtensions.setTextAndVisibilityBy(textView4, charSequence2);
}
}
@MainThread
public void configureUi(FragmentManager fragmentManager, StreamContext streamContext, boolean z2, User user, Context context, ModelRichPresence modelRichPresence, boolean z3) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
m.checkNotNullParameter(context, "applicationContext");
disposeTimer();
Activity primaryActivity = modelRichPresence != null ? modelRichPresence.getPrimaryActivity() : null;
if (streamContext == null && primaryActivity == null) {
this.root.setVisibility(8);
return;
}
this.root.setVisibility(0);
configureTextUi(primaryActivity, streamContext);
this.richPresenceTextContainer.setSelected(true);
configureAssetUi(primaryActivity, streamContext);
configureCustomButtonsUi(user, primaryActivity, context);
}
@MainThread
public void configureUiTimestamp(Activity activity, AppComponent appComponent) {
m.checkNotNullParameter(appComponent, "appComponent");
if (activity != null && this.root.getVisibility() == 0) {
ActivityTimestamps o = activity.o();
if ((o != null ? friendlyTime(o) : null) != null) {
if (this.perSecondTimerSubscription == null) {
Observable<Long> D = Observable.D(0, 1, TimeUnit.SECONDS);
m.checkNotNullExpressionValue(D, "Observable\n .in…0L, 1L, TimeUnit.SECONDS)");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(D, appComponent, null, 2, null), getClass(), (Context) null, new ViewHolderUserRichPresence$configureUiTimestamp$1(this), (Function1) null, (Function0) null, (Function0) null, new ViewHolderUserRichPresence$configureUiTimestamp$2(this, activity), 58, (Object) null);
return;
}
return;
}
}
disposeTimer();
}
public void disposeSubscriptions() {
disposeTimer();
}
@MainThread
public final void disposeTimer() {
Subscription subscription = this.perSecondTimerSubscription;
if (subscription != null) {
subscription.unsubscribe();
}
this.perSecondTimerSubscription = null;
}
public final CharSequence friendlyTime(ActivityTimestamps activityTimestamps) {
m.checkNotNullParameter(activityTimestamps, "$this$friendlyTime");
if (activityTimestamps.b() > 0) {
return TimeUtils.INSTANCE.toFriendlyString(ClockFactory.get().currentTimeMillis(), activityTimestamps.b(), getString(2131894414), "timeDelta");
}
if (activityTimestamps.c() > 0) {
return TimeUtils.INSTANCE.toFriendlyString(activityTimestamps.c(), ClockFactory.get().currentTimeMillis(), getString(2131894416), "timeDelta");
}
return null;
}
public final TextView getRichPresenceDetails() {
return this.richPresenceDetails;
}
public final TextView getRichPresenceHeader() {
return this.richPresenceHeader;
}
public final SimpleDraweeView getRichPresenceImageLarge() {
return this.richPresenceImageLarge;
}
public final SimpleDraweeView getRichPresenceImageSmall() {
return this.richPresenceImageSmall;
}
public final Button getRichPresencePrimaryButton() {
return this.richPresencePrimaryButton;
}
public final Button getRichPresenceSecondaryButton() {
return this.richPresenceSecondaryButton;
}
public final TextView getRichPresenceState() {
return this.richPresenceState;
}
public final View getRichPresenceTextContainer() {
return this.richPresenceTextContainer;
}
public final TextView getRichPresenceTime() {
return this.richPresenceTime;
}
public final TextView getRichPresenceTitle() {
return this.richPresenceTitle;
}
public final int getRichPresenceType() {
return this.richPresenceType;
}
public final View getRoot() {
return this.root;
}
public final String getString(@StringRes int i) {
Context context = this.root.getContext();
if (context != null) {
return context.getString(i);
}
return null;
}
public final void setImageAndVisibilityBy(ImageView imageView, String str, boolean z2) {
m.checkNotNullParameter(imageView, "$this$setImageAndVisibilityBy");
MGImages.setImage$default(imageView, str, 0, 0, z2, null, null, 108, null);
int i = 0;
if (!(!(str == null || t.isBlank(str)))) {
i = 8;
}
imageView.setVisibility(i);
}
public final void setOnActivityCustomButtonClicked(Function5<? super Context, ? super Long, ? super String, ? super Long, ? super Integer, Unit> function5) {
m.checkNotNullParameter(function5, "newOnActivityCustomButtonClicked");
this.onActivityCustomButtonClicked = function5;
}
public void setTimeTextViews(ActivityTimestamps activityTimestamps) {
ViewExtensions.setTextAndVisibilityBy(this.richPresenceTime, activityTimestamps != null ? friendlyTime(activityTimestamps) : null);
}
}