296 lines
12 KiB
Java
296 lines
12 KiB
Java
package com.discord.widgets.settings.profile;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.MainThread;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppViewModel;
|
|
import com.discord.models.domain.ModelUserProfile;
|
|
import com.discord.models.user.User;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.stores.StoreUser;
|
|
import com.discord.stores.StoreUserProfile;
|
|
import com.discord.stores.updates.ObservationDeck;
|
|
import com.discord.stores.updates.ObservationDeckProvider;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.user.UserUtils;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Observable;
|
|
/* compiled from: EditProfileBannerSheetViewModel.kt */
|
|
public final class EditProfileBannerSheetViewModel extends AppViewModel<ViewState> {
|
|
public static final Companion Companion = new Companion(null);
|
|
private final String defaultBannerColorHex;
|
|
private final String initialColorPreviewHex;
|
|
|
|
/* compiled from: EditProfileBannerSheetViewModel.kt */
|
|
/* renamed from: com.discord.widgets.settings.profile.EditProfileBannerSheetViewModel$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
|
|
public final /* synthetic */ EditProfileBannerSheetViewModel this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public AnonymousClass1(EditProfileBannerSheetViewModel editProfileBannerSheetViewModel) {
|
|
super(1);
|
|
this.this$0 = editProfileBannerSheetViewModel;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(StoreState storeState) {
|
|
invoke(storeState);
|
|
return Unit.a;
|
|
}
|
|
|
|
public final void invoke(StoreState storeState) {
|
|
EditProfileBannerSheetViewModel editProfileBannerSheetViewModel = this.this$0;
|
|
m.checkNotNullExpressionValue(storeState, "storeState");
|
|
EditProfileBannerSheetViewModel.access$handleStoreState(editProfileBannerSheetViewModel, storeState);
|
|
}
|
|
}
|
|
|
|
/* compiled from: EditProfileBannerSheetViewModel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
private final Observable<StoreState> observeStoreState(StoreUser storeUser, StoreUserProfile storeUserProfile) {
|
|
return ObservationDeck.connectRx$default(ObservationDeckProvider.get(), new ObservationDeck.UpdateSource[]{StoreUser.Companion.getMeUpdate(), storeUserProfile}, false, null, null, new EditProfileBannerSheetViewModel$Companion$observeStoreState$1(storeUser, storeUserProfile), 14, null);
|
|
}
|
|
|
|
public static /* synthetic */ Observable observeStoreState$default(Companion companion, StoreUser storeUser, StoreUserProfile storeUserProfile, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
storeUser = StoreStream.Companion.getUsers();
|
|
}
|
|
if ((i & 2) != 0) {
|
|
storeUserProfile = StoreStream.Companion.getUserProfile();
|
|
}
|
|
return companion.observeStoreState(storeUser, storeUserProfile);
|
|
}
|
|
}
|
|
|
|
/* compiled from: EditProfileBannerSheetViewModel.kt */
|
|
public static final class StoreState {
|
|
private final User user;
|
|
private final ModelUserProfile userProfile;
|
|
|
|
public StoreState(User user, ModelUserProfile modelUserProfile) {
|
|
m.checkNotNullParameter(user, "user");
|
|
m.checkNotNullParameter(modelUserProfile, "userProfile");
|
|
this.user = user;
|
|
this.userProfile = modelUserProfile;
|
|
}
|
|
|
|
public static /* synthetic */ StoreState copy$default(StoreState storeState, User user, ModelUserProfile modelUserProfile, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
user = storeState.user;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
modelUserProfile = storeState.userProfile;
|
|
}
|
|
return storeState.copy(user, modelUserProfile);
|
|
}
|
|
|
|
public final User component1() {
|
|
return this.user;
|
|
}
|
|
|
|
public final ModelUserProfile component2() {
|
|
return this.userProfile;
|
|
}
|
|
|
|
public final StoreState copy(User user, ModelUserProfile modelUserProfile) {
|
|
m.checkNotNullParameter(user, "user");
|
|
m.checkNotNullParameter(modelUserProfile, "userProfile");
|
|
return new StoreState(user, modelUserProfile);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof StoreState)) {
|
|
return false;
|
|
}
|
|
StoreState storeState = (StoreState) obj;
|
|
return m.areEqual(this.user, storeState.user) && m.areEqual(this.userProfile, storeState.userProfile);
|
|
}
|
|
|
|
public final User getUser() {
|
|
return this.user;
|
|
}
|
|
|
|
public final ModelUserProfile getUserProfile() {
|
|
return this.userProfile;
|
|
}
|
|
|
|
public int hashCode() {
|
|
User user = this.user;
|
|
int i = 0;
|
|
int hashCode = (user != null ? user.hashCode() : 0) * 31;
|
|
ModelUserProfile modelUserProfile = this.userProfile;
|
|
if (modelUserProfile != null) {
|
|
i = modelUserProfile.hashCode();
|
|
}
|
|
return hashCode + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("StoreState(user=");
|
|
K.append(this.user);
|
|
K.append(", userProfile=");
|
|
K.append(this.userProfile);
|
|
K.append(")");
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: EditProfileBannerSheetViewModel.kt */
|
|
public static final class ViewState {
|
|
private final String bannerColorHex;
|
|
private final boolean hasBannerImage;
|
|
private final boolean showPremiumUpsell;
|
|
|
|
public ViewState(String str, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(str, "bannerColorHex");
|
|
this.bannerColorHex = str;
|
|
this.hasBannerImage = z2;
|
|
this.showPremiumUpsell = z3;
|
|
}
|
|
|
|
public static /* synthetic */ ViewState copy$default(ViewState viewState, String str, boolean z2, boolean z3, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = viewState.bannerColorHex;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z2 = viewState.hasBannerImage;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
z3 = viewState.showPremiumUpsell;
|
|
}
|
|
return viewState.copy(str, z2, z3);
|
|
}
|
|
|
|
public final String component1() {
|
|
return this.bannerColorHex;
|
|
}
|
|
|
|
public final boolean component2() {
|
|
return this.hasBannerImage;
|
|
}
|
|
|
|
public final boolean component3() {
|
|
return this.showPremiumUpsell;
|
|
}
|
|
|
|
public final ViewState copy(String str, boolean z2, boolean z3) {
|
|
m.checkNotNullParameter(str, "bannerColorHex");
|
|
return new ViewState(str, z2, z3);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof ViewState)) {
|
|
return false;
|
|
}
|
|
ViewState viewState = (ViewState) obj;
|
|
return m.areEqual(this.bannerColorHex, viewState.bannerColorHex) && this.hasBannerImage == viewState.hasBannerImage && this.showPremiumUpsell == viewState.showPremiumUpsell;
|
|
}
|
|
|
|
public final String getBannerColorHex() {
|
|
return this.bannerColorHex;
|
|
}
|
|
|
|
public final boolean getHasBannerImage() {
|
|
return this.hasBannerImage;
|
|
}
|
|
|
|
public final boolean getShowPremiumUpsell() {
|
|
return this.showPremiumUpsell;
|
|
}
|
|
|
|
public int hashCode() {
|
|
String str = this.bannerColorHex;
|
|
int hashCode = (str != null ? str.hashCode() : 0) * 31;
|
|
boolean z2 = this.hasBannerImage;
|
|
int i = 1;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i2 = z2 ? 1 : 0;
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = (hashCode + i2) * 31;
|
|
boolean z3 = this.showPremiumUpsell;
|
|
if (!z3) {
|
|
i = z3 ? 1 : 0;
|
|
}
|
|
return i5 + i;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("ViewState(bannerColorHex=");
|
|
K.append(this.bannerColorHex);
|
|
K.append(", hasBannerImage=");
|
|
K.append(this.hasBannerImage);
|
|
K.append(", showPremiumUpsell=");
|
|
return a.F(K, this.showPremiumUpsell, ")");
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public EditProfileBannerSheetViewModel(String str, String str2, Observable<StoreState> observable) {
|
|
super(null);
|
|
m.checkNotNullParameter(str, "defaultBannerColorHex");
|
|
m.checkNotNullParameter(observable, "storeStateObservable");
|
|
this.defaultBannerColorHex = str;
|
|
this.initialColorPreviewHex = str2;
|
|
Observable<StoreState> r = observable.r();
|
|
m.checkNotNullExpressionValue(r, "storeStateObservable\n … .distinctUntilChanged()");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(r), this, null, 2, null), EditProfileBannerSheetViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ EditProfileBannerSheetViewModel(String str, String str2, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(str, str2, (i & 4) != 0 ? Companion.observeStoreState$default(Companion, null, null, 3, null) : observable);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleStoreState(EditProfileBannerSheetViewModel editProfileBannerSheetViewModel, StoreState storeState) {
|
|
editProfileBannerSheetViewModel.handleStoreState(storeState);
|
|
}
|
|
|
|
@MainThread
|
|
private final void handleStoreState(StoreState storeState) {
|
|
ViewState viewState = getViewState();
|
|
String bannerColorHex = viewState != null ? viewState.getBannerColorHex() : null;
|
|
User user = storeState.getUser();
|
|
if (bannerColorHex == null) {
|
|
bannerColorHex = this.initialColorPreviewHex;
|
|
}
|
|
if (bannerColorHex == null) {
|
|
bannerColorHex = this.defaultBannerColorHex;
|
|
}
|
|
updateViewState(new ViewState(bannerColorHex, user.getBanner() != null, !UserUtils.INSTANCE.isPremiumTier2(user)));
|
|
}
|
|
|
|
@MainThread
|
|
public final void updateColorPreview(String str) {
|
|
ViewState viewState = getViewState();
|
|
if (viewState != null) {
|
|
if (str == null) {
|
|
str = this.defaultBannerColorHex;
|
|
}
|
|
updateViewState(ViewState.copy$default(viewState, str, false, false, 6, null));
|
|
}
|
|
}
|
|
}
|