2021-06-27 20:44:35 +00:00
|
|
|
package com.discord.widgets.servers;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.view.View;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import c.a.d.l;
|
|
|
|
import c.d.b.a.a;
|
|
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.app.AppActivity;
|
|
|
|
import com.discord.app.AppFragment;
|
|
|
|
import com.discord.databinding.WidgetServerSettingsChannelsBinding;
|
|
|
|
import com.discord.models.guild.Guild;
|
|
|
|
import com.discord.restapi.RestAPIParams;
|
|
|
|
import com.discord.stores.StoreChannels;
|
|
|
|
import com.discord.stores.StoreStream;
|
|
|
|
import com.discord.stores.StoreUser;
|
|
|
|
import com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter;
|
|
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
|
|
|
import com.discord.utilities.rest.RestAPI;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
|
|
import com.discord.widgets.servers.SettingsChannelListAdapter;
|
|
|
|
import d0.f0.q;
|
|
|
|
import d0.t.u;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.LinkedHashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
|
|
import kotlin.reflect.KProperty;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.subjects.BehaviorSubject;
|
|
|
|
/* compiled from: WidgetServerSettingsChannels.kt */
|
|
|
|
public final class WidgetServerSettingsChannels extends AppFragment {
|
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetServerSettingsChannels.class, "binding", "getBinding()Lcom/discord/databinding/WidgetServerSettingsChannelsBinding;", 0)};
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
public static final String INTENT_EXTRA_GUILD_ID = "INTENT_EXTRA_GUILD_ID";
|
|
|
|
private SettingsChannelListAdapter adapter;
|
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetServerSettingsChannels$binding$2.INSTANCE, null, 2, null);
|
2021-07-03 23:36:06 +00:00
|
|
|
private final BehaviorSubject<Integer> channelSortTypeSubject = BehaviorSubject.l0(-1);
|
2021-06-27 20:44:35 +00:00
|
|
|
|
|
|
|
/* compiled from: WidgetServerSettingsChannels.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void show(Context context, long j) {
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
StoreStream.Companion.getAnalytics().onGuildSettingsPaneViewed("CHANNELS", j);
|
|
|
|
Intent putExtra = new Intent().putExtra("INTENT_EXTRA_GUILD_ID", j);
|
|
|
|
m.checkNotNullExpressionValue(putExtra, "Intent()\n .putE…_EXTRA_GUILD_ID, guildId)");
|
|
|
|
l.d(context, WidgetServerSettingsChannels.class, putExtra);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: WidgetServerSettingsChannels.kt */
|
|
|
|
public static final class Model {
|
|
|
|
public static final Companion Companion = new Companion(null);
|
|
|
|
private final Map<Long, Long> channelPermissions;
|
|
|
|
private final Map<Long, Channel> channels;
|
|
|
|
private final Guild guild;
|
|
|
|
private final boolean isSorting;
|
|
|
|
private final List<CategoricalDragAndDropAdapter.Payload> items;
|
|
|
|
|
|
|
|
/* compiled from: WidgetServerSettingsChannels.kt */
|
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Observable<Model> get(long j, Observable<Integer> observable) {
|
|
|
|
m.checkNotNullParameter(observable, "channelTypeObservable");
|
|
|
|
StoreStream.Companion companion = StoreStream.Companion;
|
|
|
|
Observable e = Observable.e(StoreUser.observeMe$default(companion.getUsers(), false, 1, null), companion.getPermissions().observePermissionsForGuild(j), companion.getGuilds().observeGuild(j), StoreChannels.observeChannelsForGuild$default(companion.getChannels(), j, null, 2, null), companion.getChannels().observeChannelCategories(j), companion.getPermissions().observeChannelPermissionsForGuild(j), observable, WidgetServerSettingsChannels$Model$Companion$get$1.INSTANCE);
|
|
|
|
m.checkNotNullExpressionValue(e, "Observable\n .…ermissions)\n }");
|
2021-07-03 23:36:06 +00:00
|
|
|
Observable<Model> r = ObservableExtensionsKt.computationLatest(e).r();
|
|
|
|
m.checkNotNullExpressionValue(r, "Observable\n .… .distinctUntilChanged()");
|
|
|
|
return r;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v1, resolved type: java.util.LinkedHashMap<java.lang.Long, com.discord.api.channel.Channel> */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public final LinkedHashMap<Long, Channel> getSortedGuildChannels(Map<Long, Channel> map, int i) {
|
|
|
|
m.checkNotNullParameter(map, "guildChannels");
|
|
|
|
LinkedHashMap<Long, Channel> linkedHashMap = new LinkedHashMap<>();
|
|
|
|
for (Object obj : q.sortedWith(q.filter(u.asSequence(map.values()), new WidgetServerSettingsChannels$Model$Companion$getSortedGuildChannels$$inlined$also$lambda$1(map, i)), AnimatableValueParser.K0(Channel.Companion))) {
|
2021-07-03 23:36:06 +00:00
|
|
|
linkedHashMap.put(Long.valueOf(((Channel) obj).h()), obj);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return linkedHashMap;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: java.util.List<? extends com.discord.utilities.mg_recycler.CategoricalDragAndDropAdapter$Payload> */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public Model(Guild guild, List<? extends CategoricalDragAndDropAdapter.Payload> list, boolean z2, Map<Long, Channel> map, Map<Long, Long> map2) {
|
|
|
|
m.checkNotNullParameter(guild, "guild");
|
|
|
|
m.checkNotNullParameter(list, "items");
|
|
|
|
m.checkNotNullParameter(map, "channels");
|
|
|
|
m.checkNotNullParameter(map2, "channelPermissions");
|
|
|
|
this.guild = guild;
|
|
|
|
this.items = list;
|
|
|
|
this.isSorting = z2;
|
|
|
|
this.channels = map;
|
|
|
|
this.channelPermissions = map2;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: com.discord.widgets.servers.WidgetServerSettingsChannels$Model */
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public static /* synthetic */ Model copy$default(Model model, Guild guild, List list, boolean z2, Map map, Map map2, int i, Object obj) {
|
|
|
|
if ((i & 1) != 0) {
|
|
|
|
guild = model.guild;
|
|
|
|
}
|
|
|
|
if ((i & 2) != 0) {
|
|
|
|
list = model.items;
|
|
|
|
}
|
|
|
|
if ((i & 4) != 0) {
|
|
|
|
z2 = model.isSorting;
|
|
|
|
}
|
|
|
|
if ((i & 8) != 0) {
|
|
|
|
map = model.channels;
|
|
|
|
}
|
|
|
|
if ((i & 16) != 0) {
|
|
|
|
map2 = model.channelPermissions;
|
|
|
|
}
|
|
|
|
return model.copy(guild, list, z2, map, map2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Guild component1() {
|
|
|
|
return this.guild;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<CategoricalDragAndDropAdapter.Payload> component2() {
|
|
|
|
return this.items;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean component3() {
|
|
|
|
return this.isSorting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Channel> component4() {
|
|
|
|
return this.channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Long> component5() {
|
|
|
|
return this.channelPermissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Model copy(Guild guild, List<? extends CategoricalDragAndDropAdapter.Payload> list, boolean z2, Map<Long, Channel> map, Map<Long, Long> map2) {
|
|
|
|
m.checkNotNullParameter(guild, "guild");
|
|
|
|
m.checkNotNullParameter(list, "items");
|
|
|
|
m.checkNotNullParameter(map, "channels");
|
|
|
|
m.checkNotNullParameter(map2, "channelPermissions");
|
|
|
|
return new Model(guild, list, z2, map, map2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean equals(Object obj) {
|
|
|
|
if (this == obj) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (!(obj instanceof Model)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Model model = (Model) obj;
|
|
|
|
return m.areEqual(this.guild, model.guild) && m.areEqual(this.items, model.items) && this.isSorting == model.isSorting && m.areEqual(this.channels, model.channels) && m.areEqual(this.channelPermissions, model.channelPermissions);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Long> getChannelPermissions() {
|
|
|
|
return this.channelPermissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Map<Long, Channel> getChannels() {
|
|
|
|
return this.channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final Guild getGuild() {
|
|
|
|
return this.guild;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final List<CategoricalDragAndDropAdapter.Payload> getItems() {
|
|
|
|
return this.items;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int hashCode() {
|
|
|
|
Guild guild = this.guild;
|
|
|
|
int i = 0;
|
|
|
|
int hashCode = (guild != null ? guild.hashCode() : 0) * 31;
|
|
|
|
List<CategoricalDragAndDropAdapter.Payload> list = this.items;
|
|
|
|
int hashCode2 = (hashCode + (list != null ? list.hashCode() : 0)) * 31;
|
|
|
|
boolean z2 = this.isSorting;
|
|
|
|
if (z2) {
|
|
|
|
z2 = true;
|
|
|
|
}
|
|
|
|
int i2 = z2 ? 1 : 0;
|
|
|
|
int i3 = z2 ? 1 : 0;
|
|
|
|
int i4 = z2 ? 1 : 0;
|
|
|
|
int i5 = (hashCode2 + i2) * 31;
|
|
|
|
Map<Long, Channel> map = this.channels;
|
|
|
|
int hashCode3 = (i5 + (map != null ? map.hashCode() : 0)) * 31;
|
|
|
|
Map<Long, Long> map2 = this.channelPermissions;
|
|
|
|
if (map2 != null) {
|
|
|
|
i = map2.hashCode();
|
|
|
|
}
|
|
|
|
return hashCode3 + i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final boolean isSorting() {
|
|
|
|
return this.isSorting;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
StringBuilder L = a.L("Model(guild=");
|
|
|
|
L.append(this.guild);
|
|
|
|
L.append(", items=");
|
|
|
|
L.append(this.items);
|
|
|
|
L.append(", isSorting=");
|
|
|
|
L.append(this.isSorting);
|
|
|
|
L.append(", channels=");
|
|
|
|
L.append(this.channels);
|
|
|
|
L.append(", channelPermissions=");
|
|
|
|
return a.F(L, this.channelPermissions, ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetServerSettingsChannels() {
|
2021-07-13 20:23:20 +00:00
|
|
|
super(2131559166);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetServerSettingsChannels widgetServerSettingsChannels, Model model) {
|
|
|
|
widgetServerSettingsChannels.configureUI(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ WidgetServerSettingsChannelsBinding access$getBinding$p(WidgetServerSettingsChannels widgetServerSettingsChannels) {
|
|
|
|
return widgetServerSettingsChannels.getBinding();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ BehaviorSubject access$getChannelSortTypeSubject$p(WidgetServerSettingsChannels widgetServerSettingsChannels) {
|
|
|
|
return widgetServerSettingsChannels.channelSortTypeSubject;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$reorderChannels(WidgetServerSettingsChannels widgetServerSettingsChannels, Model model, Map map) {
|
|
|
|
widgetServerSettingsChannels.reorderChannels(model, map);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureFabVisibility(Model model) {
|
|
|
|
WidgetServerSettingsChannels$configureFabVisibility$setFabVisibility$1 widgetServerSettingsChannels$configureFabVisibility$setFabVisibility$1 = new WidgetServerSettingsChannels$configureFabVisibility$setFabVisibility$1(this, model);
|
|
|
|
widgetServerSettingsChannels$configureFabVisibility$setFabVisibility$1.mo1invoke();
|
2021-07-13 20:23:20 +00:00
|
|
|
getBinding().f1886c.setOnClickListener(new WidgetServerSettingsChannels$configureFabVisibility$1(this, model, widgetServerSettingsChannels$configureFabVisibility$setFabVisibility$1));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUI(Model model) {
|
|
|
|
if (model == null) {
|
|
|
|
AppActivity appActivity = getAppActivity();
|
|
|
|
if (appActivity != null) {
|
|
|
|
appActivity.onBackPressed();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setActionBarDisplayHomeAsUpEnabled(!model.isSorting());
|
2021-07-13 20:23:20 +00:00
|
|
|
setActionBarTitle(!model.isSorting() ? 2131887355 : 2131893429);
|
2021-06-27 20:44:35 +00:00
|
|
|
setActionBarSubtitle(model.getGuild().getName());
|
|
|
|
setActionBarOptionsMenu(2131623942, new WidgetServerSettingsChannels$configureUI$1(this), new WidgetServerSettingsChannels$configureUI$2(model));
|
|
|
|
configureFabVisibility(model);
|
|
|
|
SettingsChannelListAdapter settingsChannelListAdapter = this.adapter;
|
|
|
|
if (settingsChannelListAdapter != null) {
|
|
|
|
settingsChannelListAdapter.setData(model.getItems());
|
|
|
|
}
|
|
|
|
SettingsChannelListAdapter settingsChannelListAdapter2 = this.adapter;
|
|
|
|
if (settingsChannelListAdapter2 != null) {
|
|
|
|
settingsChannelListAdapter2.setPositionUpdateListener(new WidgetServerSettingsChannels$configureUI$3(this, model));
|
|
|
|
}
|
|
|
|
SettingsChannelListAdapter settingsChannelListAdapter3 = this.adapter;
|
|
|
|
if (settingsChannelListAdapter3 != null) {
|
|
|
|
setOnClickListener(settingsChannelListAdapter3, model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetServerSettingsChannelsBinding getBinding() {
|
|
|
|
return (WidgetServerSettingsChannelsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void reorderChannels(Model model, Map<Long, SettingsChannelListAdapter.UpdatedPosition> map) {
|
|
|
|
ArrayList arrayList = new ArrayList(map.size());
|
|
|
|
for (Map.Entry<Long, SettingsChannelListAdapter.UpdatedPosition> entry : map.entrySet()) {
|
|
|
|
long longValue = entry.getKey().longValue();
|
|
|
|
SettingsChannelListAdapter.UpdatedPosition value = entry.getValue();
|
|
|
|
arrayList.add(new RestAPIParams.ChannelPosition(longValue, value.getPosition(), value.getParentId()));
|
|
|
|
}
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(ObservableExtensionsKt.withDimmer$default(ObservableExtensionsKt.restSubscribeOn$default(RestAPI.Companion.getApiSerializeNulls().reorderChannels(model.getGuild().getId(), arrayList), false, 1, null), getBinding().b, 0, 2, null), this, null, 2, null), WidgetServerSettingsChannels.class, getContext(), (Function1) null, new WidgetServerSettingsChannels$reorderChannels$2(this, model), (Function0) null, (Function0) null, new WidgetServerSettingsChannels$reorderChannels$1(this), 52, (Object) null);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void setOnClickListener(SettingsChannelListAdapter settingsChannelListAdapter, Model model) {
|
|
|
|
settingsChannelListAdapter.setOnClickListener(model.isSorting() ? WidgetServerSettingsChannels$setOnClickListener$1.INSTANCE : new WidgetServerSettingsChannels$setOnClickListener$2(this, model));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
|
|
|
MGRecyclerAdapter.Companion companion = MGRecyclerAdapter.Companion;
|
|
|
|
RecyclerView recyclerView = getBinding().d;
|
|
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.serverSettingsChannelsTextRecycler");
|
|
|
|
this.adapter = (SettingsChannelListAdapter) companion.configure(new SettingsChannelListAdapter(recyclerView, true));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBoundOrOnResume() {
|
|
|
|
super.onViewBoundOrOnResume();
|
|
|
|
long longExtra = getMostRecentIntent().getLongExtra("INTENT_EXTRA_GUILD_ID", -1);
|
|
|
|
Model.Companion companion = Model.Companion;
|
|
|
|
BehaviorSubject<Integer> behaviorSubject = this.channelSortTypeSubject;
|
|
|
|
m.checkNotNullExpressionValue(behaviorSubject, "channelSortTypeSubject");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(companion.get(longExtra, behaviorSubject), this, null, 2, null), WidgetServerSettingsChannels.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetServerSettingsChannels$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
|
|
}
|
|
|
|
}
|