discord-jadx/app/src/main/java/com/discord/widgets/channels/WidgetChannelPickerBottomSh...

292 lines
12 KiB
Java

package com.discord.widgets.channels;
import android.content.Context;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.app.AppViewModel;
import com.discord.stores.StoreChannels;
import com.discord.stores.StoreStream;
import com.discord.stores.updates.ObservationDeck;
import com.discord.stores.updates.ObservationDeckProvider;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.widgets.channels.ChannelPickerAdapterItem;
import d0.g0.t;
import d0.g0.w;
import d0.z.d.m;
import d0.z.d.o;
import java.util.ArrayList;
import java.util.List;
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: WidgetChannelPickerBottomSheetViewModel.kt */
public final class WidgetChannelPickerBottomSheetViewModel extends AppViewModel<ViewState> {
public static final Companion Companion = new Companion(null);
private StoreState currentStoreState;
private final long guildId;
private String searchQuery;
private final long selectedChannelId;
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
/* renamed from: com.discord.widgets.channels.WidgetChannelPickerBottomSheetViewModel$1 reason: invalid class name */
public static final class AnonymousClass1 extends o implements Function1<StoreState, Unit> {
public final /* synthetic */ WidgetChannelPickerBottomSheetViewModel this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public AnonymousClass1(WidgetChannelPickerBottomSheetViewModel widgetChannelPickerBottomSheetViewModel) {
super(1);
this.this$0 = widgetChannelPickerBottomSheetViewModel;
}
/* 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) {
WidgetChannelPickerBottomSheetViewModel widgetChannelPickerBottomSheetViewModel = this.this$0;
m.checkNotNullExpressionValue(storeState, "storeState");
WidgetChannelPickerBottomSheetViewModel.access$handleStoreState(widgetChannelPickerBottomSheetViewModel, storeState);
}
}
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static final /* synthetic */ Observable access$observeStoreState(Companion companion, long j, ObservationDeck observationDeck, StoreChannels storeChannels) {
return companion.observeStoreState(j, observationDeck, storeChannels);
}
private final Observable<StoreState> observeStoreState(long j, ObservationDeck observationDeck, StoreChannels storeChannels) {
return ObservationDeck.connectRx$default(observationDeck, new ObservationDeck.UpdateSource[]{storeChannels}, false, null, null, new WidgetChannelPickerBottomSheetViewModel$Companion$observeStoreState$1(storeChannels, j), 14, null);
}
}
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static abstract class StoreState {
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static final class Invalid extends StoreState {
public static final Invalid INSTANCE = new Invalid();
private Invalid() {
super(null);
}
}
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static final class Loaded extends StoreState {
private final List<Channel> channels;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(List<Channel> list) {
super(null);
m.checkNotNullParameter(list, "channels");
this.channels = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.channels.WidgetChannelPickerBottomSheetViewModel$StoreState$Loaded */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Loaded copy$default(Loaded loaded, List list, int i, Object obj) {
if ((i & 1) != 0) {
list = loaded.channels;
}
return loaded.copy(list);
}
public final List<Channel> component1() {
return this.channels;
}
public final Loaded copy(List<Channel> list) {
m.checkNotNullParameter(list, "channels");
return new Loaded(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Loaded) && m.areEqual(this.channels, ((Loaded) obj).channels);
}
return true;
}
public final List<Channel> getChannels() {
return this.channels;
}
public int hashCode() {
List<Channel> list = this.channels;
if (list != null) {
return list.hashCode();
}
return 0;
}
public String toString() {
return a.J(a.P("Loaded(channels="), this.channels, ")");
}
}
private StoreState() {
}
public /* synthetic */ StoreState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static abstract class ViewState {
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static final class Loaded extends ViewState {
private final List<ChannelPickerAdapterItem> adapterItems;
/* JADX DEBUG: Multi-variable search result rejected for r2v0, resolved type: java.util.List<? extends com.discord.widgets.channels.ChannelPickerAdapterItem> */
/* JADX WARN: Multi-variable type inference failed */
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public Loaded(List<? extends ChannelPickerAdapterItem> list) {
super(null);
m.checkNotNullParameter(list, "adapterItems");
this.adapterItems = list;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.channels.WidgetChannelPickerBottomSheetViewModel$ViewState$Loaded */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ Loaded copy$default(Loaded loaded, List list, int i, Object obj) {
if ((i & 1) != 0) {
list = loaded.adapterItems;
}
return loaded.copy(list);
}
public final List<ChannelPickerAdapterItem> component1() {
return this.adapterItems;
}
public final Loaded copy(List<? extends ChannelPickerAdapterItem> list) {
m.checkNotNullParameter(list, "adapterItems");
return new Loaded(list);
}
public boolean equals(Object obj) {
if (this != obj) {
return (obj instanceof Loaded) && m.areEqual(this.adapterItems, ((Loaded) obj).adapterItems);
}
return true;
}
public final List<ChannelPickerAdapterItem> getAdapterItems() {
return this.adapterItems;
}
public int hashCode() {
List<ChannelPickerAdapterItem> list = this.adapterItems;
if (list != null) {
return list.hashCode();
}
return 0;
}
public String toString() {
return a.J(a.P("Loaded(adapterItems="), this.adapterItems, ")");
}
}
/* compiled from: WidgetChannelPickerBottomSheetViewModel.kt */
public static final class Loading extends ViewState {
public static final Loading INSTANCE = new Loading();
private Loading() {
super(null);
}
}
private ViewState() {
}
public /* synthetic */ ViewState(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public WidgetChannelPickerBottomSheetViewModel(long j, long j2, ObservationDeck observationDeck, StoreChannels storeChannels, Observable<StoreState> observable) {
super(ViewState.Loading.INSTANCE);
m.checkNotNullParameter(observationDeck, "observationDeck");
m.checkNotNullParameter(storeChannels, "storeChannels");
m.checkNotNullParameter(observable, "storeStateObservable");
this.guildId = j;
this.selectedChannelId = j2;
this.searchQuery = "";
Observable<StoreState> r = observable.r();
m.checkNotNullExpressionValue(r, "storeStateObservable\n … .distinctUntilChanged()");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.computationLatest(r), this, null, 2, null), WidgetChannelPickerBottomSheetViewModel.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 */ WidgetChannelPickerBottomSheetViewModel(long j, long j2, ObservationDeck observationDeck, StoreChannels storeChannels, Observable observable, int i, DefaultConstructorMarker defaultConstructorMarker) {
this(j, j2, r6, r7, (i & 16) != 0 ? Companion.access$observeStoreState(Companion, j, r6, r7) : observable);
ObservationDeck observationDeck2 = (i & 4) != 0 ? ObservationDeckProvider.get() : observationDeck;
StoreChannels channels = (i & 8) != 0 ? StoreStream.Companion.getChannels() : storeChannels;
}
public static final /* synthetic */ void access$handleStoreState(WidgetChannelPickerBottomSheetViewModel widgetChannelPickerBottomSheetViewModel, StoreState storeState) {
widgetChannelPickerBottomSheetViewModel.handleStoreState(storeState);
}
private final List<ChannelPickerAdapterItem> buildChannelItemList(List<Channel> list) {
ArrayList arrayList = new ArrayList();
arrayList.add(ChannelPickerAdapterItem.CreateChannelItem.INSTANCE);
for (Channel channel : list) {
boolean z2 = false;
if (t.isBlank(this.searchQuery) || w.contains$default((CharSequence) AnimatableValueParser.y0(channel), (CharSequence) this.searchQuery, false, 2, (Object) null)) {
if (channel.h() == this.selectedChannelId) {
z2 = true;
}
arrayList.add(new ChannelPickerAdapterItem.ChannelItem(channel, z2));
}
}
return arrayList;
}
private final ViewState generateViewState(StoreState storeState) {
if (storeState instanceof StoreState.Invalid) {
return ViewState.Loading.INSTANCE;
}
if (storeState instanceof StoreState.Loaded) {
return new ViewState.Loaded(buildChannelItemList(((StoreState.Loaded) storeState).getChannels()));
}
throw new NoWhenBranchMatchedException();
}
private final void handleStoreState(StoreState storeState) {
this.currentStoreState = storeState;
updateViewState(generateViewState(storeState));
}
public final void updateSearchQuery(String str) {
m.checkNotNullParameter(str, "query");
if (!m.areEqual(str, this.searchQuery)) {
this.searchQuery = str;
StoreState storeState = this.currentStoreState;
if (storeState != null) {
updateViewState(generateViewState(storeState));
}
}
}
}