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

247 lines
11 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.dto.ModelGif;
import com.discord.stores.StoreAnalytics;
import com.discord.stores.StoreGifPicker;
import com.discord.stores.StoreStream;
import com.discord.utilities.analytics.SearchType;
import com.discord.utilities.analytics.Traits;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.chat.MessageManager;
import com.discord.widgets.chat.input.gifpicker.GifAdapterItem;
import com.discord.widgets.chat.input.gifpicker.GifCategoryItem;
import d0.g;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.List;
import kotlin.Lazy;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import rx.Observable;
/* compiled from: GifCategoryViewModel.kt */
public final class GifCategoryViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private final GifCategoryItem gifCategoryItem;
private final MessageManager messageManager;
private final StoreAnalytics storeAnalytics;
private final StoreGifPicker storeGifPicker;
/* compiled from: GifCategoryViewModel.kt */
/* renamed from: com.discord.widgets.chat.input.gifpicker.GifCategoryViewModel$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ GifCategoryViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(GifCategoryViewModel gifCategoryViewModel) {
super(1);
this.this$0 = gifCategoryViewModel;
}
/* 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");
GifCategoryViewModel.access$handleStoreState(this.this$0, storeState);
}
}
/* compiled from: GifCategoryViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, GifCategoryItem gifCategoryItem, StoreGifPicker storeGifPicker) {
return companion.observeStoreState(gifCategoryItem, storeGifPicker);
}
private final Observable<StoreState> observeStoreState(GifCategoryItem gifCategoryItem, StoreGifPicker storeGifPicker) {
Observable<List<ModelGif>> observable;
if (gifCategoryItem instanceof GifCategoryItem.Standard) {
observable = storeGifPicker.observeGifsForSearchQuery(((GifCategoryItem.Standard) gifCategoryItem).getGifCategory().getCategoryName());
} else if (gifCategoryItem instanceof GifCategoryItem.Trending) {
observable = storeGifPicker.observeTrendingCategoryGifs();
} else {
throw new NoWhenBranchMatchedException();
}
Observable<R> F = observable.F(GifCategoryViewModel$Companion$observeStoreState$1.INSTANCE);
m.checkNotNullExpressionValue(F, "gifsObservable.map { gifs -> StoreState(gifs) }");
return F;
}
}
/* compiled from: GifCategoryViewModel.kt */
public static final class StoreState {
private final List<ModelGif> gifs;
public StoreState(List<ModelGif> list) {
m.checkNotNullParameter(list, "gifs");
this.gifs = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.gifpicker.GifCategoryViewModel$StoreState */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ StoreState copy$default(StoreState storeState, List list, int i, Object obj) {
if ((i & 1) != 0) {
list = storeState.gifs;
}
return storeState.copy(list);
}
public final List<ModelGif> component1() {
return this.gifs;
}
public final StoreState copy(List<ModelGif> list) {
m.checkNotNullParameter(list, "gifs");
return new StoreState(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof StoreState) && m.areEqual(this.gifs, ((StoreState) obj).gifs);
}
return true;
}
public final List<ModelGif> getGifs() {
return this.gifs;
}
public int hashCode() {
List<ModelGif> list = this.gifs;
if (list != null) {
return list.hashCode();
}
return 0;
}
public String toString() {
return a.E(a.L("StoreState(gifs="), this.gifs, ")");
}
}
/* compiled from: GifCategoryViewModel.kt */
public static final class ViewState {
private final Lazy gifCount$delegate = g.lazy(new GifCategoryViewModel$ViewState$gifCount$2(this));
private final List<GifAdapterItem.GifItem> gifItems;
public ViewState(List<GifAdapterItem.GifItem> list) {
m.checkNotNullParameter(list, "gifItems");
this.gifItems = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.gifpicker.GifCategoryViewModel$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.gifItems;
}
return viewState.copy(list);
}
public static /* synthetic */ void getGifCount$annotations() {
}
public final List<GifAdapterItem.GifItem> component1() {
return this.gifItems;
}
public final ViewState copy(List<GifAdapterItem.GifItem> list) {
m.checkNotNullParameter(list, "gifItems");
return new ViewState(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof ViewState) && m.areEqual(this.gifItems, ((ViewState) obj).gifItems);
}
return true;
}
public final int getGifCount() {
return ((Number) this.gifCount$delegate.getValue()).intValue();
}
public final List<GifAdapterItem.GifItem> getGifItems() {
return this.gifItems;
}
public int hashCode() {
List<GifAdapterItem.GifItem> list = this.gifItems;
if (list != null) {
return list.hashCode();
}
return 0;
}
public String toString() {
return a.E(a.L("ViewState(gifItems="), this.gifItems, ")");
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public GifCategoryViewModel(Context context, GifCategoryItem gifCategoryItem, MessageManager messageManager, StoreGifPicker storeGifPicker, StoreAnalytics storeAnalytics, Observable<StoreState> observable) {
super(null);
m.checkNotNullParameter(context, "context");
m.checkNotNullParameter(gifCategoryItem, "gifCategoryItem");
m.checkNotNullParameter(messageManager, "messageManager");
m.checkNotNullParameter(storeGifPicker, "storeGifPicker");
m.checkNotNullParameter(storeAnalytics, "storeAnalytics");
m.checkNotNullParameter(observable, "storeStateObservable");
this.gifCategoryItem = gifCategoryItem;
this.messageManager = messageManager;
this.storeGifPicker = storeGifPicker;
this.storeAnalytics = storeAnalytics;
StoreAnalytics.trackSearchStarted$default(storeAnalytics, SearchType.GIF, null, false, 6, null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.restSubscribeOn$default(observable, false, 1, null), this, null, 2, null), GifCategoryViewModel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new AnonymousClass1(this), 62, (Object) null);
}
/* JADX WARNING: Illegal instructions before constructor call */
public /* synthetic */ GifCategoryViewModel(Context context, GifCategoryItem gifCategoryItem, MessageManager messageManager, StoreGifPicker storeGifPicker, StoreAnalytics storeAnalytics, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(context, gifCategoryItem, r16, r0, (i & 16) != 0 ? StoreStream.Companion.getAnalytics() : storeAnalytics, (i & 32) != 0 ? Companion.access$observeStoreState(Companion, gifCategoryItem, r0) : observable);
MessageManager messageManager2 = (i & 4) != 0 ? new MessageManager(context, null, null, null, null, null, null, null, null, 510, null) : messageManager;
StoreGifPicker gifPicker = (i & 8) != 0 ? StoreStream.Companion.getGifPicker() : storeGifPicker;
}
public static final /* synthetic */ void access$handleStoreState(GifCategoryViewModel gifCategoryViewModel, StoreState storeState) {
gifCategoryViewModel.handleStoreState(storeState);
}
private final void handleStoreState(StoreState storeState) {
List<ModelGif> gifs = storeState.getGifs();
ArrayList arrayList = new ArrayList(d0.t.o.collectionSizeOrDefault(gifs, 10));
for (ModelGif modelGif : gifs) {
arrayList.add(new GifAdapterItem.GifItem(modelGif, null, 2, null));
}
ViewState viewState = new ViewState(arrayList);
StoreAnalytics.trackSearchResultViewed$default(this.storeAnalytics, SearchType.GIF, viewState.getGifCount(), null, null, false, 28, null);
updateViewState(viewState);
}
public final void selectGif(GifAdapterItem.GifItem gifItem) {
m.checkNotNullParameter(gifItem, "gifItem");
ViewState viewState = getViewState();
if (viewState != null) {
StoreAnalytics.trackSearchResultSelected$default(this.storeAnalytics, SearchType.GIF, viewState.getGifCount(), null, new Traits.Source(null, null, "GIF Picker", null, null, 27, null), 4, null);
}
MessageManager.sendMessage$default(this.messageManager, gifItem.getGif().getTenorGifUrl(), null, null, null, null, false, null, null, null, 510, null);
}
}