164 lines
6.2 KiB
Java
164 lines
6.2 KiB
Java
package com.discord.widgets.channels.permissions;
|
|
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.l;
|
|
import c.a.d.q;
|
|
import c.a.z.a.a.o;
|
|
import c.a.z.a.a.p;
|
|
import c.a.z.a.a.t;
|
|
import c.d.b.a.a;
|
|
import com.airbnb.lottie.parser.AnimatableValueParser;
|
|
import com.discord.api.channel.Channel;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.user.MeUser;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapter;
|
|
import com.discord.utilities.permissions.PermissionUtils;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.widgets.channels.SimpleRolesAdapter;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import rx.Observable;
|
|
public class WidgetChannelSettingsPermissionsAddRole extends AppFragment {
|
|
private static final String INTENT_EXTRA_CHANNEL_ID = "INTENT_EXTRA_CHANNEL_ID";
|
|
private SimpleRolesAdapter rolesAdapter;
|
|
private RecyclerView rolesRecycler;
|
|
|
|
public static class Model {
|
|
private final boolean canManage;
|
|
private final Channel channel;
|
|
private final List<SimpleRolesAdapter.RoleItem> roleItems;
|
|
|
|
private Model(MeUser meUser, Guild guild, Channel channel, Long l, List<SimpleRolesAdapter.RoleItem> list) {
|
|
this.channel = channel;
|
|
this.roleItems = list;
|
|
boolean mfaEnabled = meUser.getMfaEnabled();
|
|
this.canManage = guild.getOwnerId() == meUser.getId() || PermissionUtils.canAndIsElevated(268435456, l, mfaEnabled, guild.getMfaLevel()) || PermissionUtils.canAndIsElevated(8, l, mfaEnabled, guild.getMfaLevel());
|
|
}
|
|
|
|
public static /* synthetic */ boolean access$000(Model model) {
|
|
return model.canManage;
|
|
}
|
|
|
|
public static /* synthetic */ List access$100(Model model) {
|
|
return model.roleItems;
|
|
}
|
|
|
|
public static /* synthetic */ Channel access$200(Model model) {
|
|
return model.channel;
|
|
}
|
|
|
|
public static Observable<Model> get(long j) {
|
|
return StoreStream.getChannels().observeChannel(j).Y(new p(j)).k(c.a.d.p.i);
|
|
}
|
|
|
|
private static boolean isValid(Guild guild, Channel channel) {
|
|
return (channel == null || guild == null) ? false : true;
|
|
}
|
|
|
|
public static /* synthetic */ Model lambda$null$2(Channel channel, Guild guild, MeUser meUser, Long l, List list) {
|
|
if (isValid(guild, channel)) {
|
|
return new Model(meUser, guild, channel, l, list);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public boolean canEqual(Object obj) {
|
|
return obj instanceof Model;
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (obj == this) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Model)) {
|
|
return false;
|
|
}
|
|
Model model = (Model) obj;
|
|
if (!model.canEqual(this) || this.canManage != model.canManage) {
|
|
return false;
|
|
}
|
|
Channel channel = this.channel;
|
|
Channel channel2 = model.channel;
|
|
if (channel != null ? !channel.equals(channel2) : channel2 != null) {
|
|
return false;
|
|
}
|
|
List<SimpleRolesAdapter.RoleItem> list = this.roleItems;
|
|
List<SimpleRolesAdapter.RoleItem> list2 = model.roleItems;
|
|
return list != null ? list.equals(list2) : list2 == null;
|
|
}
|
|
|
|
public int hashCode() {
|
|
int i = this.canManage ? 79 : 97;
|
|
Channel channel = this.channel;
|
|
int i2 = 43;
|
|
int hashCode = ((i + 59) * 59) + (channel == null ? 43 : channel.hashCode());
|
|
List<SimpleRolesAdapter.RoleItem> list = this.roleItems;
|
|
int i3 = hashCode * 59;
|
|
if (list != null) {
|
|
i2 = list.hashCode();
|
|
}
|
|
return i3 + i2;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder K = a.K("WidgetChannelSettingsPermissionsAddRole.Model(channel=");
|
|
K.append(this.channel);
|
|
K.append(", roleItems=");
|
|
K.append(this.roleItems);
|
|
K.append(", canManage=");
|
|
return a.F(K, this.canManage, ")");
|
|
}
|
|
}
|
|
|
|
public WidgetChannelSettingsPermissionsAddRole() {
|
|
super(2131558896);
|
|
}
|
|
|
|
private void configureToolbar(Channel channel) {
|
|
setActionBarTitle(2131886237);
|
|
setActionBarSubtitle(AnimatableValueParser.z0(channel, requireContext(), true));
|
|
}
|
|
|
|
private void configureUI(Model model) {
|
|
if (model != null && Model.access$000(model) && !Model.access$100(model).isEmpty()) {
|
|
configureToolbar(Model.access$200(model));
|
|
this.rolesAdapter.setData(Model.access$100(model), new t(this, model));
|
|
} else if (getActivity() != null) {
|
|
getActivity().onBackPressed();
|
|
}
|
|
}
|
|
|
|
public static void create(Context context, long j) {
|
|
Intent intent = new Intent();
|
|
intent.putExtra("INTENT_EXTRA_CHANNEL_ID", j);
|
|
l.d(context, WidgetChannelSettingsPermissionsAddRole.class, intent);
|
|
}
|
|
|
|
public static /* synthetic */ void g(WidgetChannelSettingsPermissionsAddRole widgetChannelSettingsPermissionsAddRole, Model model) {
|
|
widgetChannelSettingsPermissionsAddRole.configureUI(model);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(@NonNull View view) {
|
|
super.onViewBound(view);
|
|
setActionBarDisplayHomeAsUpEnabled();
|
|
this.rolesRecycler = (RecyclerView) view.findViewById(2131362368);
|
|
this.rolesAdapter = (SimpleRolesAdapter) MGRecyclerAdapter.configure(new SimpleRolesAdapter(this.rolesRecycler));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
Observable<Model> observable = Model.get(getMostRecentIntent().getLongExtra("INTENT_EXTRA_CHANNEL_ID", -1));
|
|
m.checkNotNullParameter(this, "appComponent");
|
|
m.checkNotNullExpressionValue(observable, "it");
|
|
ObservableExtensionsKt.ui(observable, this, null).k(q.e(new o(this), getClass()));
|
|
}
|
|
}
|