forked from Juby210/discord-jadx
537 lines
31 KiB
Java
537 lines
31 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.api.user.UserProfile;
|
|
import com.discord.app.AppComponent;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.databinding.UserProfileHeaderBadgeBinding;
|
|
import com.discord.databinding.UserProfileHeaderViewBinding;
|
|
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.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.channels.UserAkaView;
|
|
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.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 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 MGImages.DistinctChangeDetector bannerChangeDetector;
|
|
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 setBannerBackgroundColorSubscription;
|
|
private Subscription syncAvatarRepresentativeColorSubscription;
|
|
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(R.layout.user_profile_header_badge, 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$default(F, appComponent, null, 2, null), 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(R.layout.user_profile_header_view, (ViewGroup) this, false);
|
|
addView(inflate);
|
|
int i = R.id.avatar_edit;
|
|
CardView cardView = (CardView) inflate.findViewById(R.id.avatar_edit);
|
|
if (cardView != null) {
|
|
i = R.id.banner;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(R.id.banner);
|
|
if (simpleDraweeView != null) {
|
|
i = R.id.banner_edit;
|
|
CardView cardView2 = (CardView) inflate.findViewById(R.id.banner_edit);
|
|
if (cardView2 != null) {
|
|
i = R.id.gif_tag;
|
|
ImageView imageView = (ImageView) inflate.findViewById(R.id.gif_tag);
|
|
if (imageView != null) {
|
|
i = R.id.large_avatar;
|
|
UserAvatarPresenceView userAvatarPresenceView = (UserAvatarPresenceView) inflate.findViewById(R.id.large_avatar);
|
|
if (userAvatarPresenceView != null) {
|
|
i = R.id.large_avatar_barrier;
|
|
Barrier barrier = (Barrier) inflate.findViewById(R.id.large_avatar_barrier);
|
|
if (barrier != null) {
|
|
i = R.id.user_aka;
|
|
UserAkaView userAkaView = (UserAkaView) inflate.findViewById(R.id.user_aka);
|
|
if (userAkaView != null) {
|
|
i = R.id.user_profile_header_badges_recycler;
|
|
RecyclerView recyclerView = (RecyclerView) inflate.findViewById(R.id.user_profile_header_badges_recycler);
|
|
if (recyclerView != null) {
|
|
i = R.id.user_profile_header_custom_status;
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = (SimpleDraweeSpanTextView) inflate.findViewById(R.id.user_profile_header_custom_status);
|
|
if (simpleDraweeSpanTextView != null) {
|
|
i = R.id.user_profile_header_name_wrap;
|
|
LinearLayout linearLayout = (LinearLayout) inflate.findViewById(R.id.user_profile_header_name_wrap);
|
|
if (linearLayout != null) {
|
|
i = R.id.user_profile_header_primary_name;
|
|
UsernameView usernameView = (UsernameView) inflate.findViewById(R.id.user_profile_header_primary_name);
|
|
if (usernameView != null) {
|
|
i = R.id.user_profile_header_secondary_name;
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView2 = (SimpleDraweeSpanTextView) inflate.findViewById(R.id.user_profile_header_secondary_name);
|
|
if (simpleDraweeSpanTextView2 != null) {
|
|
ConstraintLayout constraintLayout = (ConstraintLayout) inflate;
|
|
UserProfileHeaderViewBinding userProfileHeaderViewBinding = new UserProfileHeaderViewBinding(constraintLayout, cardView, simpleDraweeView, cardView2, imageView, userAvatarPresenceView, barrier, userAkaView, recyclerView, simpleDraweeSpanTextView, linearLayout, usernameView, simpleDraweeSpanTextView2, constraintLayout);
|
|
m.checkNotNullExpressionValue(userProfileHeaderViewBinding, "UserProfileHeaderViewBin…rom(context), this, true)");
|
|
this.binding = userProfileHeaderViewBinding;
|
|
this.bannerChangeDetector = new MGImages.DistinctChangeDetector();
|
|
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, (int) R.attr.primary_700));
|
|
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$getSetBannerBackgroundColorSubscription$p(UserProfileHeaderView userProfileHeaderView) {
|
|
return userProfileHeaderView.setBannerBackgroundColorSubscription;
|
|
}
|
|
|
|
public static final /* synthetic */ Subscription access$getSyncAvatarRepresentativeColorSubscription$p(UserProfileHeaderView userProfileHeaderView) {
|
|
return userProfileHeaderView.syncAvatarRepresentativeColorSubscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onTapBanner(UserProfileHeaderView userProfileHeaderView) {
|
|
userProfileHeaderView.onTapBanner();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setSetBannerBackgroundColorSubscription$p(UserProfileHeaderView userProfileHeaderView, Subscription subscription) {
|
|
userProfileHeaderView.setBannerBackgroundColorSubscription = subscription;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setSyncAvatarRepresentativeColorSubscription$p(UserProfileHeaderView userProfileHeaderView, Subscription subscription) {
|
|
userProfileHeaderView.syncAvatarRepresentativeColorSubscription = subscription;
|
|
}
|
|
|
|
private final void configureAka(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
UserAkaView userAkaView = this.binding.g;
|
|
m.checkNotNullExpressionValue(userAkaView, "binding.userAka");
|
|
userAkaView.setVisibility(loaded.getShowAkas() ? 0 : 8);
|
|
this.binding.g.configure(loaded.getGuildMembersForAka());
|
|
}
|
|
|
|
private final void configureBanner(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
String str;
|
|
String str2;
|
|
String str3;
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
if (guildMember == null || (str = guildMember.getBannerHash()) == null) {
|
|
str = loaded.getBanner();
|
|
}
|
|
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);
|
|
int i2 = 0;
|
|
if (str == null || !t.startsWith$default(str, "data:", false, 2, null)) {
|
|
GuildMember guildMember2 = loaded.getGuildMember();
|
|
if (guildMember2 == null || !guildMember2.hasBanner()) {
|
|
str3 = IconUtils.INSTANCE.getForUserBanner(loaded.getUser().getId(), str, Integer.valueOf(max), loaded.getShouldAnimateBanner());
|
|
} else {
|
|
IconUtils iconUtils = IconUtils.INSTANCE;
|
|
GuildMember guildMember3 = loaded.getGuildMember();
|
|
str3 = iconUtils.getForGuildMemberBanner(str, (guildMember3 != null ? Long.valueOf(guildMember3.getGuildId()) : null).longValue(), loaded.getUser().getId(), Integer.valueOf(max), loaded.getShouldAnimateBanner());
|
|
}
|
|
str2 = str3;
|
|
} else {
|
|
str2 = str;
|
|
}
|
|
boolean z2 = !(str2 == null || t.isBlank(str2));
|
|
boolean z3 = (str != null && IconUtils.INSTANCE.isDataUrlForGif(str)) || (str != null && !t.startsWith$default(str, "data:", false, 2, null) && IconUtils.INSTANCE.isImageHashAnimated(str));
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1702c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.banner");
|
|
simpleDraweeView.setAspectRatio(!z2 ? 5.0f : 2.5f);
|
|
Ref$BooleanRef ref$BooleanRef = new Ref$BooleanRef();
|
|
ref$BooleanRef.element = false;
|
|
notifyAvatarColorListenerAsync(loaded);
|
|
if ((!z2 || z3) && loaded.isProfileLoaded()) {
|
|
updateBannerColor(loaded);
|
|
ref$BooleanRef.element = true;
|
|
} else if (!loaded.isProfileLoaded()) {
|
|
this.binding.f1702c.setBackgroundColor(this.userProfileHeaderBackgroundColor);
|
|
}
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1702c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.banner");
|
|
MGImages.setImage$default(simpleDraweeView2, str2, 0, 0, false, new UserProfileHeaderView$configureBanner$1(this, ref$BooleanRef, loaded), this.bannerChangeDetector, 28, null);
|
|
this.binding.f1702c.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(R.dimen.avatar_size_medium);
|
|
this.binding.j.b(getPrimaryNameTextForUser(user, guildMember), loaded.getShowMediumAvatar() ? IconUtils.getForUser(loaded.getUser(), false, Integer.valueOf(dimension)) : null, false, Integer.valueOf(dimension), Integer.valueOf(this.userProfileHeaderBackgroundColor));
|
|
this.binding.j.a(user.isBot(), user.isSystemUser() ? R.string.system_dm_tag_system : R.string.bot_tag, UserUtils.INSTANCE.isVerifiedBot(user));
|
|
}
|
|
|
|
private final void configureSecondaryName(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
User user = loaded.getUser();
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder();
|
|
int i = 0;
|
|
if (loaded.getShowSmallAvatar()) {
|
|
int dimension = (int) getResources().getDimension(R.dimen.avatar_size_profile_small);
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
DraweeSpanStringBuilderExtensionsKt.setAvatar$default(draweeSpanStringBuilder, context, IconUtils.getForUser(loaded.getUser(), false, Integer.valueOf(dimension)), false, Integer.valueOf(dimension), Integer.valueOf(this.userProfileHeaderBackgroundColor), null, 32, null);
|
|
}
|
|
CharSequence secondaryNameTextForUser = getSecondaryNameTextForUser(user, guildMember);
|
|
boolean z2 = true;
|
|
if ((secondaryNameTextForUser == null || t.isBlank(secondaryNameTextForUser)) || loaded.getShowAkas()) {
|
|
z2 = false;
|
|
}
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this.binding.k;
|
|
m.checkNotNullExpressionValue(simpleDraweeSpanTextView, "binding.userProfileHeaderSecondaryName");
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
simpleDraweeSpanTextView.setVisibility(i);
|
|
if (z2) {
|
|
draweeSpanStringBuilder.append(secondaryNameTextForUser);
|
|
this.binding.k.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, R.attr.colorHeaderPrimary, R.attr.font_display_bold, R.integer.uikit_textsize_xxlarge_sp, R.attr.colorHeaderSecondary, R.attr.font_primary_semibold, R.integer.uikit_textsize_xxlarge_sp);
|
|
}
|
|
|
|
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 notifyAvatarColorListenerAsync(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
Subscription subscription = this.syncAvatarRepresentativeColorSubscription;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
ObservableExtensionsKt.appSubscribe$default(observeRepresentativeColor(loaded), UserProfileHeaderView.class, (Context) null, new UserProfileHeaderView$notifyAvatarColorListenerAsync$1(this), (Function1) null, (Function0) null, (Function0) null, new UserProfileHeaderView$notifyAvatarColorListenerAsync$2(this), 58, (Object) null);
|
|
}
|
|
|
|
private final Observable<Integer> observeRepresentativeColor(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
GuildMember guildMember = loaded.getGuildMember();
|
|
Observable<Integer> b02 = ObservableExtensionsKt.ui((guildMember == null || !guildMember.hasAvatar()) ? RepresentativeColorsKt.getUserRepresentativeColors().observeRepresentativeColor(loaded.getAvatarColorId()) : RepresentativeColorsKt.getGuildMemberRepresentativeColors().observeRepresentativeColor(loaded.getGuildMemberColorId())).a0(new ViewDetachedFromWindowObservable(this).observe()).b0(UserProfileHeaderView$observeRepresentativeColor$1.INSTANCE);
|
|
m.checkNotNullExpressionValue(b02, "representativeColorObser….takeUntil { it != null }");
|
|
return b02;
|
|
}
|
|
|
|
private final void onTapBanner() {
|
|
this.onBannerPress.mo1invoke();
|
|
}
|
|
|
|
private final void updateBannerBackgroundColorAsync(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
Subscription subscription = this.setBannerBackgroundColorSubscription;
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
ObservableExtensionsKt.appSubscribe$default(observeRepresentativeColor(loaded), UserProfileHeaderView.class, (Context) null, new UserProfileHeaderView$updateBannerBackgroundColorAsync$1(this), (Function1) null, (Function0) null, (Function0) null, new UserProfileHeaderView$updateBannerBackgroundColorAsync$2(this), 58, (Object) null);
|
|
}
|
|
|
|
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.f1702c.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: Removed duplicated region for block: B:10:0x0034 */
|
|
/* JADX WARNING: Removed duplicated region for block: B:12:? A[RETURN, SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:8:0x0027 */
|
|
public final void updateBannerColor(UserProfileHeaderViewModel.ViewState.Loaded loaded) {
|
|
Integer num;
|
|
m.checkNotNullParameter(loaded, "viewState");
|
|
String bannerColorHex = loaded.getBannerColorHex();
|
|
if (bannerColorHex != null) {
|
|
try {
|
|
num = Integer.valueOf(Color.parseColor(bannerColorHex));
|
|
} catch (IllegalArgumentException e) {
|
|
Logger.e$default(AppLog.g, a.v("failed to parse banner color string: ", bannerColorHex), e, null, 4, null);
|
|
}
|
|
if (num != null) {
|
|
this.binding.f1702c.setBackgroundColor(num.intValue());
|
|
}
|
|
if (num != null) {
|
|
updateBannerBackgroundColorAsync(loaded);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
num = null;
|
|
if (num != null) {
|
|
}
|
|
if (num != 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);
|
|
this.binding.f.a(new UserAvatarPresenceView.a(loaded.getUser(), loaded.getPresence(), loaded.getStreamContext(), loaded.getShowPresence(), loaded.getGuildMember()));
|
|
configurePrimaryName(loaded);
|
|
configureAka(loaded);
|
|
configureSecondaryName(loaded);
|
|
Badge.Companion companion = Badge.Companion;
|
|
User user = loaded.getUser();
|
|
UserProfile 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();
|
|
Activity customStatusActivity = presence != null ? PresenceUtils.INSTANCE.getCustomStatusActivity(presence) : null;
|
|
if (customStatusActivity != null) {
|
|
this.binding.i.setDraweeSpanStringBuilder(getCustomStatusDraweeSpanStringBuilder(customStatusActivity, loaded.getAllowAnimatedEmojis()));
|
|
}
|
|
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this.binding.i;
|
|
m.checkNotNullExpressionValue(simpleDraweeSpanTextView, "binding.userProfileHeaderCustomStatus");
|
|
int i = 0;
|
|
simpleDraweeSpanTextView.setVisibility(customStatusActivity != 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);
|
|
}
|
|
}
|