discord-jadx/app/src/main/java/com/discord/widgets/chat/input/gifpicker/GifPickerViewModel.java

242 lines
10 KiB
Java

package com.discord.widgets.chat.input.gifpicker;
import android.content.Context;
import c.d.b.a.a;
import com.discord.app.AppViewModel;
import com.discord.models.gifpicker.domain.ModelGifCategory;
import com.discord.stores.StoreStream;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.chat.input.gifpicker.GifCategoryItem;
import d0.t.n;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.List;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
import rx.functions.Func2;
/* compiled from: GifPickerViewModel.kt */
public final class GifPickerViewModel extends AppViewModel<ViewState> {
/* compiled from: GifPickerViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.gifpicker.GifPickerViewModel$1 reason: invalid class name */
public static final class AnonymousClass1<T1, T2, R> implements Func2<List<? extends ModelGifCategory>, String, StoreState> {
public static final AnonymousClass1 INSTANCE = new AnonymousClass1();
public final StoreState call(List<ModelGifCategory> list, String str) {
m.checkNotNullExpressionValue(list, "gifCategories");
m.checkNotNullExpressionValue(str, "trendingGifCategoryPreviewUrl");
return new StoreState(list, str);
}
/* 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, java.lang.Object] */
@Override // rx.functions.Func2
public /* bridge */ /* synthetic */ StoreState call(List<? extends ModelGifCategory> list, String str) {
return call((List<ModelGifCategory>) list, str);
}
}
/* compiled from: GifPickerViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.gifpicker.GifPickerViewModel$2 reason: invalid class name */
public static final class AnonymousClass2 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ GifPickerViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass2(GifPickerViewModel gifPickerViewModel) {
super(1);
this.this$0 = gifPickerViewModel;
}
/* 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) {
m.checkNotNullParameter(storeState, "storeState");
GifPickerViewModel.access$handleStoreState(this.this$0, storeState);
}
}
/* compiled from: GifPickerViewModel.kt */
public static final class StoreState {
private final List<ModelGifCategory> gifCategories;
private final String trendingGifCategoryPreviewUrl;
public StoreState(List<ModelGifCategory> list, String str) {
m.checkNotNullParameter(list, "gifCategories");
m.checkNotNullParameter(str, "trendingGifCategoryPreviewUrl");
this.gifCategories = list;
this.trendingGifCategoryPreviewUrl = str;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.gifpicker.GifPickerViewModel$StoreState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ StoreState copy$default(StoreState storeState, List list, String str, int i, Object obj) {
if ((i & 1) != 0) {
list = storeState.gifCategories;
}
if ((i & 2) != 0) {
str = storeState.trendingGifCategoryPreviewUrl;
}
return storeState.copy(list, str);
}
public final List<ModelGifCategory> component1() {
return this.gifCategories;
}
public final String component2() {
return this.trendingGifCategoryPreviewUrl;
}
public final StoreState copy(List<ModelGifCategory> list, String str) {
m.checkNotNullParameter(list, "gifCategories");
m.checkNotNullParameter(str, "trendingGifCategoryPreviewUrl");
return new StoreState(list, str);
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof StoreState)) {
return false;
}
StoreState storeState = (StoreState) obj;
return m.areEqual(this.gifCategories, storeState.gifCategories) && m.areEqual(this.trendingGifCategoryPreviewUrl, storeState.trendingGifCategoryPreviewUrl);
}
public final List<ModelGifCategory> getGifCategories() {
return this.gifCategories;
}
public final String getTrendingGifCategoryPreviewUrl() {
return this.trendingGifCategoryPreviewUrl;
}
public int hashCode() {
List<ModelGifCategory> list = this.gifCategories;
int i = 0;
int hashCode = (list != null ? list.hashCode() : 0) * 31;
String str = this.trendingGifCategoryPreviewUrl;
if (str != null) {
i = str.hashCode();
}
return hashCode + i;
}
public String toString() {
StringBuilder L = a.L("StoreState(gifCategories=");
L.append(this.gifCategories);
L.append(", trendingGifCategoryPreviewUrl=");
return a.D(L, this.trendingGifCategoryPreviewUrl, ")");
}
}
/* compiled from: GifPickerViewModel.kt */
public static final class ViewState {
private final List<GifCategoryItem> gifCategoryItems;
private final boolean isLoaded;
/* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: java.util.List<? extends com.discord.widgets.chat.input.gifpicker.GifCategoryItem> */
/* JADX WARN: Multi-variable type inference failed */
public ViewState(List<? extends GifCategoryItem> list) {
m.checkNotNullParameter(list, "gifCategoryItems");
this.gifCategoryItems = list;
this.isLoaded = !list.isEmpty();
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.gifpicker.GifPickerViewModel$ViewState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ ViewState copy$default(ViewState viewState, List list, int i, Object obj) {
if ((i & 1) != 0) {
list = viewState.gifCategoryItems;
}
return viewState.copy(list);
}
public final List<GifCategoryItem> component1() {
return this.gifCategoryItems;
}
public final ViewState copy(List<? extends GifCategoryItem> list) {
m.checkNotNullParameter(list, "gifCategoryItems");
return new ViewState(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ViewState) && m.areEqual(this.gifCategoryItems, ((ViewState) obj).gifCategoryItems);
}
return true;
}
public final List<GifCategoryItem> getGifCategoryItems() {
return this.gifCategoryItems;
}
public int hashCode() {
List<GifCategoryItem> list = this.gifCategoryItems;
if (list != null) {
return list.hashCode();
}
return 0;
}
public final boolean isLoaded() {
return this.isLoaded;
}
public String toString() {
return a.E(a.L("ViewState(gifCategoryItems="), this.gifCategoryItems, ")");
}
}
public GifPickerViewModel() {
this(null, 1, null);
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public GifPickerViewModel(Observable<StoreState> observable) {
super(new ViewState(n.emptyList()));
m.checkNotNullParameter(observable, "storeStateObservable");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(observable), this, null, 2, null), GifPickerViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass2(this), 62, (Object) null);
}
/* JADX WARNING: Illegal instructions before constructor call */
public /* synthetic */ GifPickerViewModel(Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(observable);
if ((i & 1) != 0) {
StoreStream.Companion companion = StoreStream.Companion;
observable = Observable.j(companion.getGifPicker().observeGifCategories(), companion.getGifPicker().observeTrendingGifCategoryPreviewUrl(), AnonymousClass1.INSTANCE);
m.checkNotNullExpressionValue(observable, "Observable.combineLatest…egoryPreviewUrl\n )\n }");
}
}
public static final /* synthetic */ void access$handleStoreState(GifPickerViewModel gifPickerViewModel, StoreState storeState) {
gifPickerViewModel.handleStoreState(storeState);
}
private final void handleStoreState(StoreState storeState) {
ArrayList arrayList = new ArrayList();
if (storeState.getTrendingGifCategoryPreviewUrl().length() > 0) {
arrayList.add(new GifCategoryItem.Trending(storeState.getTrendingGifCategoryPreviewUrl()));
}
List<ModelGifCategory> gifCategories = storeState.getGifCategories();
ArrayList arrayList2 = new ArrayList(d0.t.o.collectionSizeOrDefault(gifCategories, 10));
for (ModelGifCategory modelGifCategory : gifCategories) {
arrayList2.add(new GifCategoryItem.Standard(modelGifCategory));
}
arrayList.addAll(arrayList2);
updateViewState(new ViewState(arrayList));
}
}