471 lines
27 KiB
Java
471 lines
27 KiB
Java
package com.discord.widgets.user.profile;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.Resources;
|
|
import android.content.res.TypedArray;
|
|
import android.graphics.Color;
|
|
import android.text.SpannableStringBuilder;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
import androidx.cardview.widget.CardView;
|
|
import androidx.constraintlayout.widget.Barrier;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.d.b.a.a;
|
|
import com.discord.R;
|
|
import com.discord.api.activity.Activity;
|
|
import com.discord.api.activity.ActivityEmoji;
|
|
import com.discord.app.AppComponent;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.databinding.UserProfileHeaderBadgeBinding;
|
|
import com.discord.databinding.UserProfileHeaderViewBinding;
|
|
import com.discord.models.domain.ModelUserProfile;
|
|
import com.discord.models.member.GuildMember;
|
|
import com.discord.models.presence.Presence;
|
|
import com.discord.models.user.User;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.colors.RepresentativeColorsKt;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.utilities.logging.Logger;
|
|
import com.discord.utilities.premium.GuildMemberAvatarsFeatureFlag;
|
|
import com.discord.utilities.presence.PresenceUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.textprocessing.node.EmojiNode;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import com.discord.utilities.view.text.SimpleDraweeSpanTextView;
|
|
import com.discord.utilities.viewcontroller.ViewDetachedFromWindowObservable;
|
|
import com.discord.utilities.views.SimpleRecyclerAdapter;
|
|
import com.discord.views.UsernameView;
|
|
import com.discord.views.user.UserAvatarPresenceView;
|
|
import com.discord.widgets.user.Badge;
|
|
import com.discord.widgets.user.UserNameFormatterKt;
|
|
import com.discord.widgets.user.profile.UserProfileHeaderViewModel;
|
|
import com.facebook.drawee.span.DraweeSpanStringBuilder;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.g0.t;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Objects;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.jvm.internal.Ref$BooleanRef;
|
|
import kotlin.jvm.internal.Ref$ObjectRef;
|
|
import rx.Observable;
|
|
import rx.Subscription;
|
|
/* compiled from: UserProfileHeaderView.kt */
|
|
public final class UserProfileHeaderView extends ConstraintLayout {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final SimpleRecyclerAdapter<Badge, BadgeViewHolder> badgesAdapter;
|
|
private final UserProfileHeaderViewBinding binding;
|
|
private Function0<Unit> onAvatarEdit;
|
|
private Function1<? super Integer, Unit> onAvatarRepresentativeColorUpdated;
|
|
private Function1<? super Badge, Unit> onBadgeClick;
|
|
private Function0<Unit> onBannerPress;
|
|
private Subscription representativeColorSubscription;
|
|
private int userProfileHeaderBackgroundColor;
|
|
|
|
/* compiled from: UserProfileHeaderView.kt */
|
|
/* renamed from: com.discord.widgets.user.profile.UserProfileHeaderView$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function2<LayoutInflater, ViewGroup, BadgeViewHolder> {
|
|
public final /* synthetic */ UserProfileHeaderView this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(UserProfileHeaderView userProfileHeaderView) {
|
|
super(2);
|
|
this.this$0 = userProfileHeaderView;
|
|
}
|
|
|
|
public final BadgeViewHolder invoke(LayoutInflater layoutInflater, ViewGroup viewGroup) {
|
|
m.checkNotNullParameter(layoutInflater, "inflater");
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
View inflate = layoutInflater.inflate(2131558717, viewGroup, false);
|
|
Objects.requireNonNull(inflate, "rootView");
|
|
ImageView imageView = (ImageView) inflate;
|
|
UserProfileHeaderBadgeBinding userProfileHeaderBadgeBinding = new UserProfileHeaderBadgeBinding(imageView, imageView);
|
|
m.checkNotNullExpressionValue(userProfileHeaderBadgeBinding, "UserProfileHeaderBadgeBi…(inflater, parent, false)");
|
|
return new BadgeViewHolder(this.this$0, userProfileHeaderBadgeBinding);
|
|
}
|
|
}
|
|
|
|
/* compiled from: UserProfileHeaderView.kt */
|
|
public final class BadgeViewHolder extends SimpleRecyclerAdapter.ViewHolder<Badge> {
|
|
private final UserProfileHeaderBadgeBinding binding;
|
|
public final /* synthetic */ UserProfileHeaderView this$0;
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public BadgeViewHolder(UserProfileHeaderView userProfileHeaderView, UserProfileHeaderBadgeBinding userProfileHeaderBadgeBinding) {
|
|
super(r2);
|
|
m.checkNotNullParameter(userProfileHeaderBadgeBinding, "binding");
|
|
this.this$0 = userProfileHeaderView;
|
|
ImageView imageView = userProfileHeaderBadgeBinding.a;
|
|
m.checkNotNullExpressionValue(imageView, "binding.root");
|
|
this.binding = userProfileHeaderBadgeBinding;
|
|
}
|
|
|
|
public void bind(Badge badge) {
|
|
m.checkNotNullParameter(badge, "data");
|
|
this.binding.b.setImageResource(badge.getIcon());
|
|
ImageView imageView = this.binding.b;
|
|
m.checkNotNullExpressionValue(imageView, "binding.userSheetBadgeImage");
|
|
CharSequence text = badge.getText();
|
|
if (text == null) {
|
|
text = badge.getTooltip();
|
|
}
|
|
imageView.setContentDescription(text);
|
|
this.binding.b.setOnClickListener(new UserProfileHeaderView$BadgeViewHolder$bind$1(this, badge));
|
|
}
|
|
}
|
|
|
|
/* compiled from: UserProfileHeaderView.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void bind(UserProfileHeaderView userProfileHeaderView, AppComponent appComponent, Observable<UserProfileHeaderViewModel.ViewState> observable) {
|
|
m.checkNotNullParameter(userProfileHeaderView, "$this$bind");
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
m.checkNotNullParameter(observable, "observable");
|
|
Observable<R> F = observable.x(UserProfileHeaderView$Companion$bind$$inlined$filterIs$1.INSTANCE).F(UserProfileHeaderView$Companion$bind$$inlined$filterIs$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "filter { it is T }.map { it as T }");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(F, appComponent), appComponent.getClass(), (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new UserProfileHeaderView$Companion$bind$1(userProfileHeaderView), 62, (Object) null);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public UserProfileHeaderView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(attributeSet, "attrs");
|
|
View inflate = LayoutInflater.from(context).inflate(2131558718, (ViewGroup) this, false);
|
|
addView(inflate);
|
|
int i = 2131362084;
|
|
CardView cardView = (CardView) inflate.findViewById(2131362084);
|
|
if (cardView != null) {
|
|
i = 2131362101;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(2131362101);
|
|
if (simpleDraweeView != null) {
|
|
i = 2131362109;
|
|
CardView cardView2 = (CardView) inflate.findViewById(2131362109);
|
|
if (cardView2 != null) {
|
|
i = 2131363348;
|
|
ImageView imageView = (ImageView) inflate.findViewById(2131363348);
|
|
if (imageView != null) {
|
|
i = 2131363831;
|
|
UserAvatarPresenceView userAvatarPresenceView = (UserAvatarPresenceView) inflate.findViewById(2131363831);
|
|
if (userAvatarPresenceView != null) {
|
|
i = 2131363832;
|
|
Barrier barrier = (Barrier) inflate.findViewById(2131363832);
|
|
if (barrier != null) {
|
|
i = 2131365557;
|
|
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(2131365557);
|
|
if (recyclerView != null) {
|
|
i = 2131365558;
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = (SimpleDraweeSpanTextView) inflate.findViewById(2131365558);
|
|
if (simpleDraweeSpanTextView != null) {
|
|
i = 2131365559;
|
|
LinearLayout linearLayout = (LinearLayout) inflate.findViewById(2131365559);
|
|
if (linearLayout != null) {
|
|
i = 2131365560;
|
|
UsernameView usernameView = (UsernameView) inflate.findViewById(2131365560);
|
|
if (usernameView != null) {
|
|
i = 2131365561;
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView2 = (SimpleDraweeSpanTextView) inflate.findViewById(2131365561);
|
|
if (simpleDraweeSpanTextView2 != null) {
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) inflate;
|
|
UserProfileHeaderViewBinding userProfileHeaderViewBinding = new UserProfileHeaderViewBinding(constraintLayout, cardView, simpleDraweeView, cardView2, imageView, userAvatarPresenceView, barrier, recyclerView, simpleDraweeSpanTextView, linearLayout, usernameView, simpleDraweeSpanTextView2, constraintLayout);
|
|
m.checkNotNullExpressionValue(userProfileHeaderViewBinding, "UserProfileHeaderViewBin…rom(context), this, true)");
|
|
this.binding = userProfileHeaderViewBinding;
|
|
this.onBadgeClick = UserProfileHeaderView$onBadgeClick$1.INSTANCE;
|
|
this.onAvatarEdit = UserProfileHeaderView$onAvatarEdit$1.INSTANCE;
|
|
this.onBannerPress = UserProfileHeaderView$onBannerPress$1.INSTANCE;
|
|
this.onAvatarRepresentativeColorUpdated = UserProfileHeaderView$onAvatarRepresentativeColorUpdated$1.INSTANCE;
|
|
RightToLeftGridLayoutManager rightToLeftGridLayoutManager = new RightToLeftGridLayoutManager(context, 3, 1, true);
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.userProfileHeaderBadgesRecycler");
|
|
recyclerView.setLayoutManager(rightToLeftGridLayoutManager);
|
|
SimpleRecyclerAdapter<Badge, BadgeViewHolder> simpleRecyclerAdapter = new SimpleRecyclerAdapter<>(null, new AnonymousClass1(this), 1, null);
|
|
this.badgesAdapter = simpleRecyclerAdapter;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.userProfileHeaderBadgesRecycler");
|
|
recyclerView.setAdapter(simpleRecyclerAdapter);
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, R.a.UserProfileHeaderView);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "context.obtainStyledAttr…le.UserProfileHeaderView)");
|
|
this.userProfileHeaderBackgroundColor = obtainStyledAttributes.getColor(0, ColorCompat.getThemedColor(this, 2130969899));
|
|
obtainStyledAttributes.recycle();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i)));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$editAvatar(UserProfileHeaderView userProfileHeaderView, UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
userProfileHeaderView.editAvatar(loaded);
|
|
}
|
|
|
|
public static final /* synthetic */ UserProfileHeaderViewBinding access$getBinding$p(UserProfileHeaderView userProfileHeaderView) {
|
|
return userProfileHeaderView.binding;
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getRepresentativeColorSubscription$p(UserProfileHeaderView userProfileHeaderView) {
|
|
return userProfileHeaderView.representativeColorSubscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onTapBanner(UserProfileHeaderView userProfileHeaderView) {
|
|
userProfileHeaderView.onTapBanner();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setRepresentativeColorSubscription$p(UserProfileHeaderView userProfileHeaderView, Subscription subscription) {
|
|
userProfileHeaderView.representativeColorSubscription = subscription;
|
|
}
|
|
|
|
private final void configureBanner(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
Resources resources = getResources();
|
|
m.checkNotNullExpressionValue(resources, "resources");
|
|
int i = resources.getDisplayMetrics().widthPixels;
|
|
Resources resources2 = getResources();
|
|
m.checkNotNullExpressionValue(resources2, "resources");
|
|
int max = Math.max(i, resources2.getDisplayMetrics().heightPixels);
|
|
String bannerHash = loaded.getBannerHash();
|
|
int i2 = 0;
|
|
String forUserBanner = (bannerHash == null || !t.startsWith$default(bannerHash, "data:", false, 2, null)) ? IconUtils.INSTANCE.getForUserBanner(loaded.getUser().getId(), loaded.getBannerHash(), Integer.valueOf(max), loaded.getShouldAnimateBanner()) : loaded.getBannerHash();
|
|
boolean z2 = !(forUserBanner == null || t.isBlank(forUserBanner));
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1643c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.banner");
|
|
simpleDraweeView.setAspectRatio(!z2 ? 5.0f : 2.5f);
|
|
Subscription subscription = this.representativeColorSubscription;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
Ref$BooleanRef ref$BooleanRef = new Ref$BooleanRef();
|
|
ref$BooleanRef.element = false;
|
|
if (!z2 && loaded.isProfileLoaded()) {
|
|
updateBannerColor(loaded);
|
|
ref$BooleanRef.element = true;
|
|
} else if (!loaded.isProfileLoaded()) {
|
|
this.binding.f1643c.setBackgroundColor(this.userProfileHeaderBackgroundColor);
|
|
}
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1643c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.banner");
|
|
MGImages.setImage$default(simpleDraweeView2, forUserBanner, 0, 0, false, new UserProfileHeaderView$configureBanner$1(this, ref$BooleanRef, loaded), null, 92, null);
|
|
this.binding.f1643c.setOnClickListener(new UserProfileHeaderView$configureBanner$2(this));
|
|
this.binding.d.setOnClickListener(new UserProfileHeaderView$configureBanner$3(this));
|
|
ImageView imageView = this.binding.e;
|
|
m.checkNotNullExpressionValue(imageView, "binding.gifTag");
|
|
if (!loaded.getShouldShowGIFTag()) {
|
|
i2 = 8;
|
|
}
|
|
imageView.setVisibility(i2);
|
|
}
|
|
|
|
private final void configurePrimaryName(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
User user = loaded.getUser();
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
int dimension = (int) getResources().getDimension(2131165290);
|
|
this.binding.i.b(getPrimaryNameTextForUser(user, guildMember), loaded.getShowMediumAvatar() ? IconUtils.getForUser(loaded.getUser(), true, Integer.valueOf(dimension)) : null, true, Integer.valueOf(dimension), Integer.valueOf(this.userProfileHeaderBackgroundColor));
|
|
this.binding.i.a(user.isBot(), user.isSystemUser() ? 2131893944 : 2131887052, UserUtils.INSTANCE.isVerifiedBot(user));
|
|
}
|
|
|
|
private final void configureSecondaryName(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
User user = loaded.getUser();
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder();
|
|
if (loaded.getShowSmallAvatar()) {
|
|
int dimension = (int) getResources().getDimension(2131165291);
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
DraweeSpanStringBuilderExtensionsKt.setAvatar(draweeSpanStringBuilder, context, IconUtils.getForUser(loaded.getUser(), true, Integer.valueOf(dimension)), true, Integer.valueOf(dimension), Integer.valueOf(this.userProfileHeaderBackgroundColor), 8194);
|
|
}
|
|
CharSequence secondaryNameTextForUser = getSecondaryNameTextForUser(user, guildMember);
|
|
int i = 0;
|
|
boolean z2 = !(secondaryNameTextForUser == null || t.isBlank(secondaryNameTextForUser));
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this.binding.j;
|
|
m.checkNotNullExpressionValue(simpleDraweeSpanTextView, "binding.userProfileHeaderSecondaryName");
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
simpleDraweeSpanTextView.setVisibility(i);
|
|
if (z2) {
|
|
draweeSpanStringBuilder.append(secondaryNameTextForUser);
|
|
this.binding.j.setDraweeSpanStringBuilder(draweeSpanStringBuilder);
|
|
}
|
|
}
|
|
|
|
private final void editAvatar(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
if (loaded.getEditable()) {
|
|
this.onAvatarEdit.mo1invoke();
|
|
}
|
|
}
|
|
|
|
private final DraweeSpanStringBuilder getCustomStatusDraweeSpanStringBuilder(Activity activity, boolean z2) {
|
|
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder();
|
|
ActivityEmoji f = activity.f();
|
|
EmojiNode emojiNode = null;
|
|
if (f != null) {
|
|
EmojiNode.Companion companion = EmojiNode.Companion;
|
|
emojiNode = EmojiNode.Companion.from$default(companion, 0, companion.generateEmojiIdAndType(f), 1, (Object) null);
|
|
}
|
|
if (emojiNode != null) {
|
|
emojiNode.render((SpannableStringBuilder) draweeSpanStringBuilder, (DraweeSpanStringBuilder) new UserProfileHeaderView$getCustomStatusDraweeSpanStringBuilder$1(this, z2));
|
|
}
|
|
String l = activity.l();
|
|
if (l != null) {
|
|
if (emojiNode != null) {
|
|
draweeSpanStringBuilder.append((char) 8194);
|
|
}
|
|
draweeSpanStringBuilder.append((CharSequence) l);
|
|
}
|
|
return draweeSpanStringBuilder;
|
|
}
|
|
|
|
private final SpannableStringBuilder getPrimaryNameTextForUser(User user, GuildMember guildMember) {
|
|
String nick = guildMember != null ? guildMember.getNick() : null;
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
return UserNameFormatterKt.getSpannableForUserNameWithDiscrim(user, nick, context, 2130968932, 2130969320, 2131427364, 2130968933, 2130969326, 2131427364);
|
|
}
|
|
|
|
private final CharSequence getSecondaryNameTextForUser(User user, GuildMember guildMember) {
|
|
if (guildMember == null || guildMember.getNick() == null) {
|
|
return null;
|
|
}
|
|
return UserUtils.getUserNameWithDiscriminator$default(UserUtils.INSTANCE, user, null, null, 3, null);
|
|
}
|
|
|
|
private final void onTapBanner() {
|
|
this.onBannerPress.mo1invoke();
|
|
}
|
|
|
|
public final Function0<Unit> getOnAvatarEdit() {
|
|
return this.onAvatarEdit;
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super java.lang.Integer, kotlin.Unit>, kotlin.jvm.functions.Function1<java.lang.Integer, kotlin.Unit> */
|
|
public final Function1<Integer, Unit> getOnAvatarRepresentativeColorUpdated() {
|
|
return this.onAvatarRepresentativeColorUpdated;
|
|
}
|
|
|
|
/* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: kotlin.jvm.functions.Function1<? super com.discord.widgets.user.Badge, kotlin.Unit>, kotlin.jvm.functions.Function1<com.discord.widgets.user.Badge, kotlin.Unit> */
|
|
public final Function1<Badge, Unit> getOnBadgeClick() {
|
|
return this.onBadgeClick;
|
|
}
|
|
|
|
public final Function0<Unit> getOnBannerPress() {
|
|
return this.onBannerPress;
|
|
}
|
|
|
|
@Override // android.view.View
|
|
public void onFinishInflate() {
|
|
super.onFinishInflate();
|
|
int i = this.userProfileHeaderBackgroundColor;
|
|
if (i != 0) {
|
|
setBackgroundColor(i);
|
|
this.binding.f.setAvatarBackgroundColor(this.userProfileHeaderBackgroundColor);
|
|
this.binding.f1643c.setBackgroundColor(this.userProfileHeaderBackgroundColor);
|
|
}
|
|
}
|
|
|
|
public final void setOnAvatarEdit(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "<set-?>");
|
|
this.onAvatarEdit = function0;
|
|
}
|
|
|
|
public final void setOnAvatarRepresentativeColorUpdated(Function1<? super Integer, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "<set-?>");
|
|
this.onAvatarRepresentativeColorUpdated = function1;
|
|
}
|
|
|
|
public final void setOnBadgeClick(Function1<? super Badge, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "<set-?>");
|
|
this.onBadgeClick = function1;
|
|
}
|
|
|
|
public final void setOnBannerPress(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "<set-?>");
|
|
this.onBannerPress = function0;
|
|
}
|
|
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public final void updateBannerColor(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
m.checkNotNullParameter(loaded, "viewState");
|
|
String bannerColorHex = loaded.getBannerColorHex();
|
|
Ref$ObjectRef ref$ObjectRef = new Ref$ObjectRef();
|
|
ref$ObjectRef.element = null;
|
|
if (bannerColorHex != null) {
|
|
try {
|
|
ref$ObjectRef.element = Integer.valueOf(Color.parseColor(bannerColorHex));
|
|
} catch (IllegalArgumentException e) {
|
|
Logger.e$default(AppLog.g, a.s("failed to parse banner color string: ", bannerColorHex), e, null, 4, null);
|
|
}
|
|
}
|
|
Integer num = ref$ObjectRef.element;
|
|
if (num != null) {
|
|
this.binding.f1643c.setBackgroundColor(num.intValue());
|
|
}
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
Observable<Integer> b02 = ((guildMember == null || !guildMember.hasAvatar()) ? RepresentativeColorsKt.getUserRepresentativeColors().observeRepresentativeColor(Long.valueOf(loaded.getUser().getId())) : RepresentativeColorsKt.getGuildMemberRepresentativeColors().observeRepresentativeColor(new Pair<>(Long.valueOf(guildMember.getGuildId()), Long.valueOf(guildMember.getUserId())))).a0(new ViewDetachedFromWindowObservable(this).observe()).b0(UserProfileHeaderView$updateBannerColor$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(b02, "representativeColorObser….takeUntil { it != null }");
|
|
ObservableExtensionsKt.appSubscribe$default(b02, UserProfileHeaderView.class, (Context) null, new UserProfileHeaderView$updateBannerColor$2(this), (Function1) null, (Function0) null, (Function0) null, new UserProfileHeaderView$updateBannerColor$3(this, ref$ObjectRef), 58, (Object) null);
|
|
}
|
|
|
|
public final void updateViewState(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
m.checkNotNullParameter(loaded, "viewState");
|
|
this.binding.f.setOnAvatarBitmapLoadedListener(new UserProfileHeaderView$updateViewState$1(loaded));
|
|
this.binding.f.setOnClickListener(new UserProfileHeaderView$updateViewState$2(this, loaded));
|
|
this.binding.b.setOnClickListener(new UserProfileHeaderView$updateViewState$3(this, loaded));
|
|
configureBanner(loaded);
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
Activity activity = null;
|
|
this.binding.f.a(new UserAvatarPresenceView.a(loaded.getUser(), loaded.getPresence(), loaded.getStreamContext(), loaded.getShowPresence(), (guildMember == null || !GuildMemberAvatarsFeatureFlag.Companion.getINSTANCE().isEnabled()) ? null : guildMember));
|
|
configurePrimaryName(loaded);
|
|
configureSecondaryName(loaded);
|
|
Badge.Companion companion = Badge.Companion;
|
|
User user = loaded.getUser();
|
|
ModelUserProfile userProfile = loaded.getUserProfile();
|
|
int snowsGivingHypeSquadEventWinner = loaded.getSnowsGivingHypeSquadEventWinner();
|
|
boolean isMeUserPremium = loaded.isMeUserPremium();
|
|
boolean isMeUserVerified = loaded.isMeUserVerified();
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
this.badgesAdapter.setData(companion.getBadgesForUser(user, userProfile, snowsGivingHypeSquadEventWinner, isMeUserPremium, isMeUserVerified, context));
|
|
Presence presence = loaded.getPresence();
|
|
if (presence != null) {
|
|
activity = PresenceUtils.INSTANCE.getCustomStatusActivity(presence);
|
|
}
|
|
if (activity != null) {
|
|
this.binding.h.setDraweeSpanStringBuilder(getCustomStatusDraweeSpanStringBuilder(activity, loaded.getAllowAnimatedEmojis()));
|
|
}
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this.binding.h;
|
|
m.checkNotNullExpressionValue(simpleDraweeSpanTextView, "binding.userProfileHeaderCustomStatus");
|
|
int i = 0;
|
|
simpleDraweeSpanTextView.setVisibility(activity != null ? 0 : 8);
|
|
CardView cardView = this.binding.b;
|
|
m.checkNotNullExpressionValue(cardView, "binding.avatarEdit");
|
|
cardView.setVisibility(loaded.getEditable() ? 0 : 8);
|
|
CardView cardView2 = this.binding.d;
|
|
m.checkNotNullExpressionValue(cardView2, "binding.bannerEdit");
|
|
if (!loaded.getEditable()) {
|
|
i = 8;
|
|
}
|
|
cardView2.setVisibility(i);
|
|
}
|
|
}
|