2021-06-27 20:44:35 +00:00
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 ;
2021-12-21 23:37:30 +00:00
import b.d.b.a.a ;
2021-06-27 20:44:35 +00:00
import com.discord.R ;
import com.discord.api.activity.Activity ;
import com.discord.api.activity.ActivityEmoji ;
2021-11-23 19:35:19 +00:00
import com.discord.api.user.UserProfile ;
2021-06-27 20:44:35 +00:00
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 ;
2021-07-27 04:36:47 +00:00
import com.discord.utilities.logging.Logger ;
2021-06-27 20:44:35 +00:00
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 ;
2021-09-14 19:31:33 +00:00
import com.discord.widgets.channels.UserAkaView ;
2021-06-27 20:44:35 +00:00
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 ;
2021-11-08 18:25:28 +00:00
import d0.g0.t ;
import d0.z.d.m ;
import d0.z.d.o ;
2021-06-27 20:44:35 +00:00
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 ;
2021-07-27 04:36:47 +00:00
import kotlin.jvm.internal.Ref $BooleanRef ;
2021-06-27 20:44:35 +00:00
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 ;
2021-09-21 20:20:54 +00:00
private MGImages . DistinctChangeDetector bannerChangeDetector ;
2021-06-27 20:44:35 +00:00
private final UserProfileHeaderViewBinding binding ;
2021-07-13 20:48:29 +00:00
private Function0 < Unit > onAvatarEdit ;
2021-07-27 04:36:47 +00:00
private Function1 < ? super Integer , Unit > onAvatarRepresentativeColorUpdated ;
2021-06-27 20:44:35 +00:00
private Function1 < ? super Badge , Unit > onBadgeClick ;
2021-07-27 04:36:47 +00:00
private Function0 < Unit > onBannerPress ;
2021-08-04 22:02:59 +00:00
private Subscription setBannerBackgroundColorSubscription ;
private Subscription syncAvatarRepresentativeColorSubscription ;
2021-06-27 20:44:35 +00:00
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 " ) ;
2021-08-09 22:50:01 +00:00
View inflate = layoutInflater . inflate ( R . layout . user_profile_header_badge , viewGroup , false ) ;
2021-06-27 20:44:35 +00:00
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 " ) ;
2021-12-21 23:37:30 +00:00
this . binding . f2136b . setImageResource ( badge . getIcon ( ) ) ;
ImageView imageView = this . binding . f2136b ;
2021-06-27 20:44:35 +00:00
m . checkNotNullExpressionValue ( imageView , " binding.userSheetBadgeImage " ) ;
CharSequence text = badge . getText ( ) ;
if ( text = = null ) {
text = badge . getTooltip ( ) ;
}
imageView . setContentDescription ( text ) ;
2021-12-21 23:37:30 +00:00
this . binding . f2136b . setOnClickListener ( new UserProfileHeaderView$BadgeViewHolder$bind$1 ( this , badge ) ) ;
2021-06-27 20:44:35 +00:00
}
}
/* compiled from: UserProfileHeaderView.kt */
public static final class Companion {
private Companion ( ) {
}
public /* synthetic */ Companion ( DefaultConstructorMarker defaultConstructorMarker ) {
this ( ) ;
}
2021-07-13 20:48:29 +00:00
public final void bind ( UserProfileHeaderView userProfileHeaderView , AppComponent appComponent , Observable < UserProfileHeaderViewModel . ViewState > observable ) {
2021-06-27 20:44:35 +00:00
m . checkNotNullParameter ( userProfileHeaderView , " $this$bind " ) ;
m . checkNotNullParameter ( appComponent , " appComponent " ) ;
2021-07-13 20:48:29 +00:00
m . checkNotNullParameter ( observable , " observable " ) ;
2021-10-26 23:51:06 +00:00
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 ) ;
2021-06-27 20:44:35 +00:00
}
}
/* 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 " ) ;
2021-08-09 22:50:01 +00:00
View inflate = LayoutInflater . from ( context ) . inflate ( R . layout . user_profile_header_view , ( ViewGroup ) this , false ) ;
2021-06-27 20:44:35 +00:00
addView ( inflate ) ;
2021-08-09 22:50:01 +00:00
int i = R . id . avatar_edit ;
CardView cardView = ( CardView ) inflate . findViewById ( R . id . avatar_edit ) ;
2021-07-13 20:48:29 +00:00
if ( cardView ! = null ) {
2021-08-09 22:50:01 +00:00
i = R . id . banner ;
SimpleDraweeView simpleDraweeView = ( SimpleDraweeView ) inflate . findViewById ( R . id . banner ) ;
2021-07-13 20:48:29 +00:00
if ( simpleDraweeView ! = null ) {
2021-08-09 22:50:01 +00:00
i = R . id . banner_edit ;
CardView cardView2 = ( CardView ) inflate . findViewById ( R . id . banner_edit ) ;
2021-07-13 20:48:29 +00:00
if ( cardView2 ! = null ) {
2021-08-09 22:50:01 +00:00
i = R . id . gif_tag ;
ImageView imageView = ( ImageView ) inflate . findViewById ( R . id . gif_tag ) ;
2021-07-27 04:36:47 +00:00
if ( imageView ! = null ) {
2021-08-09 22:50:01 +00:00
i = R . id . large_avatar ;
UserAvatarPresenceView userAvatarPresenceView = ( UserAvatarPresenceView ) inflate . findViewById ( R . id . large_avatar ) ;
2021-07-13 20:48:29 +00:00
if ( userAvatarPresenceView ! = null ) {
2021-08-09 22:50:01 +00:00
i = R . id . large_avatar_barrier ;
Barrier barrier = ( Barrier ) inflate . findViewById ( R . id . large_avatar_barrier ) ;
2021-07-13 20:48:29 +00:00
if ( barrier ! = null ) {
2021-09-14 19:31:33 +00:00
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 ;
2021-09-21 20:20:54 +00:00
this . bannerChangeDetector = new MGImages . DistinctChangeDetector ( ) ;
2021-09-14 19:31:33 +00:00
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 ;
}
2021-07-13 20:48:29 +00:00
}
}
2021-06-27 20:44:35 +00:00
}
}
}
}
}
}
}
}
}
throw new NullPointerException ( " Missing required view with ID: " . concat ( inflate . getResources ( ) . getResourceName ( i ) ) ) ;
}
2021-07-13 20:48:29 +00:00
public static final /* synthetic */ void access$editAvatar ( UserProfileHeaderView userProfileHeaderView , UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
userProfileHeaderView . editAvatar ( loaded ) ;
}
2021-06-27 20:44:35 +00:00
public static final /* synthetic */ UserProfileHeaderViewBinding access$getBinding$p ( UserProfileHeaderView userProfileHeaderView ) {
return userProfileHeaderView . binding ;
}
2021-08-04 22:02:59 +00:00
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 ;
2021-06-27 20:44:35 +00:00
}
2021-07-27 04:36:47 +00:00
public static final /* synthetic */ void access$onTapBanner ( UserProfileHeaderView userProfileHeaderView ) {
userProfileHeaderView . onTapBanner ( ) ;
}
2021-08-04 22:02:59 +00:00
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 ;
2021-06-27 20:44:35 +00:00
}
2021-09-14 19:31:33 +00:00
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 ( ) ) ;
}
2021-06-27 20:44:35 +00:00
private final void configureBanner ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
2021-11-15 19:38:30 +00:00
String str ;
String str2 ;
String str3 ;
GuildMember guildMember = loaded . getGuildMember ( ) ;
if ( guildMember = = null | | ( str = guildMember . getBannerHash ( ) ) = = null ) {
str = loaded . getBanner ( ) ;
}
2021-06-27 20:44:35 +00:00
Resources resources = getResources ( ) ;
m . checkNotNullExpressionValue ( resources , " resources " ) ;
int i = resources . getDisplayMetrics ( ) . widthPixels ;
Resources resources2 = getResources ( ) ;
m . checkNotNullExpressionValue ( resources2 , " resources " ) ;
2021-11-15 19:38:30 +00:00
int max = Math . max ( i , resources2 . getDisplayMetrics ( ) . heightPixels ) ;
2021-06-27 20:44:35 +00:00
int i2 = 0 ;
2021-11-15 19:38:30 +00:00
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 ) ) ;
2021-12-21 23:37:30 +00:00
SimpleDraweeView simpleDraweeView = this . binding . c ;
2021-06-27 20:44:35 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView , " binding.banner " ) ;
simpleDraweeView . setAspectRatio ( ! z2 ? 5 . 0f : 2 . 5f ) ;
2021-07-27 04:36:47 +00:00
Ref$BooleanRef ref$BooleanRef = new Ref$BooleanRef ( ) ;
ref$BooleanRef . element = false ;
2021-08-04 22:02:59 +00:00
notifyAvatarColorListenerAsync ( loaded ) ;
if ( ( ! z2 | | z3 ) & & loaded . isProfileLoaded ( ) ) {
2021-07-27 04:36:47 +00:00
updateBannerColor ( loaded ) ;
ref$BooleanRef . element = true ;
} else if ( ! loaded . isProfileLoaded ( ) ) {
2021-12-21 23:37:30 +00:00
this . binding . c . setBackgroundColor ( this . userProfileHeaderBackgroundColor ) ;
2021-06-27 20:44:35 +00:00
}
2021-12-21 23:37:30 +00:00
SimpleDraweeView simpleDraweeView2 = this . binding . c ;
2021-07-27 04:36:47 +00:00
m . checkNotNullExpressionValue ( simpleDraweeView2 , " binding.banner " ) ;
2021-11-15 19:38:30 +00:00
MGImages . setImage$default ( simpleDraweeView2 , str2 , 0 , 0 , false , new UserProfileHeaderView$configureBanner$1 ( this , ref$BooleanRef , loaded ) , this . bannerChangeDetector , 28 , null ) ;
2021-12-21 23:37:30 +00:00
this . binding . c . setOnClickListener ( new UserProfileHeaderView$configureBanner$2 ( this ) ) ;
2021-07-27 04:36:47 +00:00
this . binding . d . setOnClickListener ( new UserProfileHeaderView$configureBanner$3 ( this ) ) ;
ImageView imageView = this . binding . e ;
m . checkNotNullExpressionValue ( imageView , " binding.gifTag " ) ;
if ( ! loaded . getShouldShowGIFTag ( ) ) {
2021-06-27 20:44:35 +00:00
i2 = 8 ;
}
2021-07-27 04:36:47 +00:00
imageView . setVisibility ( i2 ) ;
2021-06-27 20:44:35 +00:00
}
private final void configurePrimaryName ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
User user = loaded . getUser ( ) ;
GuildMember guildMember = loaded . getGuildMember ( ) ;
2021-08-09 22:50:01 +00:00
int dimension = ( int ) getResources ( ) . getDimension ( R . dimen . avatar_size_medium ) ;
2021-09-21 20:20:54 +00:00
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 ) ) ;
2021-09-14 19:31:33 +00:00
this . binding . j . a ( user . isBot ( ) , user . isSystemUser ( ) ? R . string . system_dm_tag_system : R . string . bot_tag , UserUtils . INSTANCE . isVerifiedBot ( user ) ) ;
2021-06-27 20:44:35 +00:00
}
private final void configureSecondaryName ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
User user = loaded . getUser ( ) ;
GuildMember guildMember = loaded . getGuildMember ( ) ;
DraweeSpanStringBuilder draweeSpanStringBuilder = new DraweeSpanStringBuilder ( ) ;
2021-09-21 20:20:54 +00:00
int i = 0 ;
2021-06-27 20:44:35 +00:00
if ( loaded . getShowSmallAvatar ( ) ) {
2021-08-09 22:50:01 +00:00
int dimension = ( int ) getResources ( ) . getDimension ( R . dimen . avatar_size_profile_small ) ;
2021-06-27 20:44:35 +00:00
Context context = getContext ( ) ;
m . checkNotNullExpressionValue ( context , " context " ) ;
2021-12-17 22:03:14 +00:00
DraweeSpanStringBuilderExtensionsKt . setAvatar$default ( draweeSpanStringBuilder , context , IconUtils . getForUser ( loaded . getUser ( ) , false , Integer . valueOf ( dimension ) ) , false , Integer . valueOf ( dimension ) , Integer . valueOf ( this . userProfileHeaderBackgroundColor ) , null , 32 , null ) ;
2021-06-27 20:44:35 +00:00
}
CharSequence secondaryNameTextForUser = getSecondaryNameTextForUser ( user , guildMember ) ;
2021-09-21 20:20:54 +00:00
boolean z2 = true ;
2021-09-14 19:31:33 +00:00
if ( ( secondaryNameTextForUser = = null | | t . isBlank ( secondaryNameTextForUser ) ) | | loaded . getShowAkas ( ) ) {
z2 = false ;
}
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this . binding . k ;
2021-06-27 20:44:35 +00:00
m . checkNotNullExpressionValue ( simpleDraweeSpanTextView , " binding.userProfileHeaderSecondaryName " ) ;
if ( ! z2 ) {
i = 8 ;
}
simpleDraweeSpanTextView . setVisibility ( i ) ;
if ( z2 ) {
draweeSpanStringBuilder . append ( secondaryNameTextForUser ) ;
2021-09-14 19:31:33 +00:00
this . binding . k . setDraweeSpanStringBuilder ( draweeSpanStringBuilder ) ;
2021-07-13 20:48:29 +00:00
}
}
private final void editAvatar ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
if ( loaded . getEditable ( ) ) {
2021-11-08 18:25:28 +00:00
this . onAvatarEdit . mo1invoke ( ) ;
2021-07-13 20:48:29 +00:00
}
}
2021-06-27 20:44:35 +00:00
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 " ) ;
2021-08-09 22:50:01 +00:00
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 ) ;
2021-06-27 20:44:35 +00:00
}
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 ) ;
}
2021-08-04 22:02:59 +00:00
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 ( ) ;
2021-10-26 23:51:06 +00:00
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 ;
2021-08-04 22:02:59 +00:00
}
2021-07-27 04:36:47 +00:00
private final void onTapBanner ( ) {
2021-11-08 18:25:28 +00:00
this . onBannerPress . mo1invoke ( ) ;
2021-07-27 04:36:47 +00:00
}
2021-08-04 22:02:59 +00:00
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 ) ;
}
2021-07-13 20:48:29 +00:00
public final Function0 < Unit > getOnAvatarEdit ( ) {
return this . onAvatarEdit ;
}
2021-07-27 04:36:47 +00:00
/* 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 ;
}
2021-06-27 20:44:35 +00:00
/* 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 ;
}
2021-07-27 04:36:47 +00:00
public final Function0 < Unit > getOnBannerPress ( ) {
return this . onBannerPress ;
2021-07-13 20:48:29 +00:00
}
2021-06-27 20:44:35 +00:00
@Override // android.view.View
public void onFinishInflate ( ) {
super . onFinishInflate ( ) ;
int i = this . userProfileHeaderBackgroundColor ;
if ( i ! = 0 ) {
setBackgroundColor ( i ) ;
2021-07-13 20:48:29 +00:00
this . binding . f . setAvatarBackgroundColor ( this . userProfileHeaderBackgroundColor ) ;
2021-12-21 23:37:30 +00:00
this . binding . c . setBackgroundColor ( this . userProfileHeaderBackgroundColor ) ;
2021-06-27 20:44:35 +00:00
}
}
2021-07-13 20:48:29 +00:00
public final void setOnAvatarEdit ( Function0 < Unit > function0 ) {
m . checkNotNullParameter ( function0 , " <set-?> " ) ;
this . onAvatarEdit = function0 ;
}
2021-07-27 04:36:47 +00:00
public final void setOnAvatarRepresentativeColorUpdated ( Function1 < ? super Integer , Unit > function1 ) {
m . checkNotNullParameter ( function1 , " <set-?> " ) ;
this . onAvatarRepresentativeColorUpdated = function1 ;
}
2021-06-27 20:44:35 +00:00
public final void setOnBadgeClick ( Function1 < ? super Badge , Unit > function1 ) {
m . checkNotNullParameter ( function1 , " <set-?> " ) ;
this . onBadgeClick = function1 ;
}
2021-07-27 04:36:47 +00:00
public final void setOnBannerPress ( Function0 < Unit > function0 ) {
2021-07-13 20:48:29 +00:00
m . checkNotNullParameter ( function0 , " <set-?> " ) ;
2021-07-27 04:36:47 +00:00
this . onBannerPress = function0 ;
}
2021-08-04 22:02:59 +00:00
/* 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 */
2021-07-27 04:36:47 +00:00
public final void updateBannerColor ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
2021-08-04 22:02:59 +00:00
Integer num ;
2021-07-27 04:36:47 +00:00
m . checkNotNullParameter ( loaded , " viewState " ) ;
String bannerColorHex = loaded . getBannerColorHex ( ) ;
if ( bannerColorHex ! = null ) {
try {
2021-08-04 22:02:59 +00:00
num = Integer . valueOf ( Color . parseColor ( bannerColorHex ) ) ;
2021-07-27 04:36:47 +00:00
} catch ( IllegalArgumentException e ) {
2021-11-08 18:25:28 +00:00
Logger . e$default ( AppLog . g , a . v ( " failed to parse banner color string: " , bannerColorHex ) , e , null , 4 , null ) ;
2021-07-27 04:36:47 +00:00
}
2021-08-04 22:02:59 +00:00
if ( num ! = null ) {
2021-12-21 23:37:30 +00:00
this . binding . c . setBackgroundColor ( num . intValue ( ) ) ;
2021-08-04 22:02:59 +00:00
}
if ( num ! = null ) {
updateBannerBackgroundColorAsync ( loaded ) ;
return ;
}
return ;
}
num = null ;
if ( num ! = null ) {
2021-07-27 04:36:47 +00:00
}
if ( num ! = null ) {
}
2021-07-13 20:48:29 +00:00
}
2021-06-27 20:44:35 +00:00
public final void updateViewState ( UserProfileHeaderViewModel . ViewState . Loaded loaded ) {
m . checkNotNullParameter ( loaded , " viewState " ) ;
2021-07-13 20:48:29 +00:00
this . binding . f . setOnAvatarBitmapLoadedListener ( new UserProfileHeaderView$updateViewState$1 ( loaded ) ) ;
this . binding . f . setOnClickListener ( new UserProfileHeaderView$updateViewState$2 ( this , loaded ) ) ;
2021-12-21 23:37:30 +00:00
this . binding . f2137b . setOnClickListener ( new UserProfileHeaderView$updateViewState$3 ( this , loaded ) ) ;
2021-06-27 20:44:35 +00:00
configureBanner ( loaded ) ;
2021-08-24 17:45:16 +00:00
this . binding . f . a ( new UserAvatarPresenceView . a ( loaded . getUser ( ) , loaded . getPresence ( ) , loaded . getStreamContext ( ) , loaded . getShowPresence ( ) , loaded . getGuildMember ( ) ) ) ;
2021-06-27 20:44:35 +00:00
configurePrimaryName ( loaded ) ;
2021-09-14 19:31:33 +00:00
configureAka ( loaded ) ;
2021-06-27 20:44:35 +00:00
configureSecondaryName ( loaded ) ;
Badge . Companion companion = Badge . Companion ;
2021-07-13 20:48:29 +00:00
User user = loaded . getUser ( ) ;
2021-11-23 19:35:19 +00:00
UserProfile userProfile = loaded . getUserProfile ( ) ;
2021-06-27 20:44:35 +00:00
boolean isMeUserPremium = loaded . isMeUserPremium ( ) ;
boolean isMeUserVerified = loaded . isMeUserVerified ( ) ;
Context context = getContext ( ) ;
m . checkNotNullExpressionValue ( context , " context " ) ;
2022-01-19 20:19:48 +00:00
this . badgesAdapter . setData ( companion . getBadgesForUser ( user , userProfile , isMeUserPremium , isMeUserVerified , context ) ) ;
2021-07-13 20:48:29 +00:00
Presence presence = loaded . getPresence ( ) ;
2021-08-24 17:45:16 +00:00
Activity customStatusActivity = presence ! = null ? PresenceUtils . INSTANCE . getCustomStatusActivity ( presence ) : null ;
if ( customStatusActivity ! = null ) {
2021-09-14 19:31:33 +00:00
this . binding . i . setDraweeSpanStringBuilder ( getCustomStatusDraweeSpanStringBuilder ( customStatusActivity , loaded . getAllowAnimatedEmojis ( ) ) ) ;
2021-06-27 20:44:35 +00:00
}
2021-09-14 19:31:33 +00:00
SimpleDraweeSpanTextView simpleDraweeSpanTextView = this . binding . i ;
2021-06-27 20:44:35 +00:00
m . checkNotNullExpressionValue ( simpleDraweeSpanTextView , " binding.userProfileHeaderCustomStatus " ) ;
int i = 0 ;
2021-08-24 17:45:16 +00:00
simpleDraweeSpanTextView . setVisibility ( customStatusActivity ! = null ? 0 : 8 ) ;
2021-12-21 23:37:30 +00:00
CardView cardView = this . binding . f2137b ;
2021-07-13 20:48:29 +00:00
m . checkNotNullExpressionValue ( cardView , " binding.avatarEdit " ) ;
cardView . setVisibility ( loaded . getEditable ( ) ? 0 : 8 ) ;
CardView cardView2 = this . binding . d ;
m . checkNotNullExpressionValue ( cardView2 , " binding.bannerEdit " ) ;
if ( ! loaded . getEditable ( ) ) {
2021-06-27 20:44:35 +00:00
i = 8 ;
}
2021-07-13 20:48:29 +00:00
cardView2 . setVisibility ( i ) ;
2021-06-27 20:44:35 +00:00
}
}