139 lines
7.3 KiB
Java
139 lines
7.3 KiB
Java
package com.discord.widgets.channels.permissions;
|
|
|
|
import android.content.Context;
|
|
import android.os.Bundle;
|
|
import android.widget.TextView;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import c.a.d.h0;
|
|
import c.a.d.j0;
|
|
import c.a.l.b;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppDialog;
|
|
import com.discord.databinding.ConfirmRemovePermissionDialogBinding;
|
|
import com.discord.utilities.KotlinExtensionsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.channels.permissions.ConfirmRemovePermissionDialogViewModel;
|
|
import com.discord.widgets.channels.permissions.PermissionOwner;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import java.io.Serializable;
|
|
import java.util.Objects;
|
|
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 kotlin.reflect.KProperty;
|
|
/* compiled from: ConfirmRemovePermissionDialog.kt */
|
|
public final class ConfirmRemovePermissionDialog extends AppDialog {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(ConfirmRemovePermissionDialog.class, "binding", "getBinding()Lcom/discord/databinding/ConfirmRemovePermissionDialogBinding;", 0)};
|
|
private static final String ARG_PERMISSION_OWNER = "ARG_PERMISSION_OWNER";
|
|
public static final Companion Companion = new Companion(null);
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, ConfirmRemovePermissionDialog$binding$2.INSTANCE, null, 2, null);
|
|
private final Lazy viewModel$delegate;
|
|
|
|
/* compiled from: ConfirmRemovePermissionDialog.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final void show(PermissionOwner permissionOwner, long j, FragmentManager fragmentManager) {
|
|
m.checkNotNullParameter(permissionOwner, "permissionOwner");
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
ConfirmRemovePermissionDialog confirmRemovePermissionDialog = new ConfirmRemovePermissionDialog();
|
|
Bundle bundle = new Bundle();
|
|
bundle.putSerializable("ARG_PERMISSION_OWNER", permissionOwner);
|
|
bundle.putLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", j);
|
|
confirmRemovePermissionDialog.setArguments(bundle);
|
|
confirmRemovePermissionDialog.show(fragmentManager, ConfirmRemovePermissionDialog.class.getSimpleName());
|
|
}
|
|
}
|
|
|
|
public ConfirmRemovePermissionDialog() {
|
|
super(2131558446);
|
|
ConfirmRemovePermissionDialog$viewModel$2 confirmRemovePermissionDialog$viewModel$2 = new ConfirmRemovePermissionDialog$viewModel$2(this);
|
|
h0 h0Var = new h0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(ConfirmRemovePermissionDialogViewModel.class), new ConfirmRemovePermissionDialog$appViewModels$$inlined$viewModels$1(h0Var), new j0(confirmRemovePermissionDialog$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(ConfirmRemovePermissionDialog confirmRemovePermissionDialog, ConfirmRemovePermissionDialogViewModel.ViewState viewState) {
|
|
confirmRemovePermissionDialog.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ long access$getChannelIdFromArgs(ConfirmRemovePermissionDialog confirmRemovePermissionDialog) {
|
|
return confirmRemovePermissionDialog.getChannelIdFromArgs();
|
|
}
|
|
|
|
public static final /* synthetic */ PermissionOwner access$getPermissionOwnerFromArgs(ConfirmRemovePermissionDialog confirmRemovePermissionDialog) {
|
|
return confirmRemovePermissionDialog.getPermissionOwnerFromArgs();
|
|
}
|
|
|
|
public static final /* synthetic */ ConfirmRemovePermissionDialogViewModel access$getViewModel$p(ConfirmRemovePermissionDialog confirmRemovePermissionDialog) {
|
|
return confirmRemovePermissionDialog.getViewModel();
|
|
}
|
|
|
|
private final void configureUI(ConfirmRemovePermissionDialogViewModel.ViewState viewState) {
|
|
Unit unit;
|
|
if (viewState instanceof ConfirmRemovePermissionDialogViewModel.ViewState.Default) {
|
|
getBinding().d.setIsLoading(((ConfirmRemovePermissionDialogViewModel.ViewState.Default) viewState).isSubmitting());
|
|
unit = Unit.a;
|
|
} else if (m.areEqual(viewState, ConfirmRemovePermissionDialogViewModel.ViewState.Complete.INSTANCE)) {
|
|
dismiss();
|
|
unit = Unit.a;
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
KotlinExtensionsKt.getExhaustive(unit);
|
|
}
|
|
|
|
private final ConfirmRemovePermissionDialogBinding getBinding() {
|
|
return (ConfirmRemovePermissionDialogBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final long getChannelIdFromArgs() {
|
|
return requireArguments().getLong("com.discord.intent.extra.EXTRA_CHANNEL_ID");
|
|
}
|
|
|
|
private final PermissionOwner getPermissionOwnerFromArgs() {
|
|
Serializable serializable = requireArguments().getSerializable("ARG_PERMISSION_OWNER");
|
|
Objects.requireNonNull(serializable, "null cannot be cast to non-null type com.discord.widgets.channels.permissions.PermissionOwner");
|
|
return (PermissionOwner) serializable;
|
|
}
|
|
|
|
private final ConfirmRemovePermissionDialogViewModel getViewModel() {
|
|
return (ConfirmRemovePermissionDialogViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
@Override // com.discord.app.AppDialog, androidx.fragment.app.Fragment
|
|
public void onResume() {
|
|
String str;
|
|
super.onResume();
|
|
requireDialog().setCanceledOnTouchOutside(true);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), ConfirmRemovePermissionDialog.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new ConfirmRemovePermissionDialog$onResume$1(this), 62, (Object) null);
|
|
PermissionOwner permissionOwnerFromArgs = getPermissionOwnerFromArgs();
|
|
if (permissionOwnerFromArgs instanceof PermissionOwner.Role) {
|
|
str = ((PermissionOwner.Role) permissionOwnerFromArgs).getRole().f();
|
|
} else if (permissionOwnerFromArgs instanceof PermissionOwner.Member) {
|
|
PermissionOwner.Member member = (PermissionOwner.Member) permissionOwnerFromArgs;
|
|
String nickname = member.getNickname();
|
|
str = nickname != null ? nickname : member.getUser().getUsername();
|
|
} else {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
TextView textView = getBinding().b;
|
|
m.checkNotNullExpressionValue(textView, "binding.body");
|
|
b.m(textView, 2131893305, new Object[]{str}, null, 4);
|
|
getBinding().d.setOnClickListener(new ConfirmRemovePermissionDialog$onResume$2(this));
|
|
getBinding().f1598c.setOnClickListener(new ConfirmRemovePermissionDialog$onResume$3(this));
|
|
}
|
|
}
|