discord-jadx/app/src/main/java/com/discord/app/AppDialog.java

227 lines
7.5 KiB
Java

package com.discord.app;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import androidx.annotation.CallSuper;
import androidx.annotation.LayoutRes;
import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.discord.utilities.accessibility.AccessibilityUtils;
import com.discord.utilities.display.DisplayUtils;
import com.discord.utilities.logging.Logger;
import com.discord.utilities.view.text.TextWatcher;
import com.discord.widgets.notice.WidgetNoticeDialog;
import d0.z.d.m;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import rx.subjects.PublishSubject;
import rx.subjects.Subject;
/* compiled from: AppDialog.kt */
public abstract class AppDialog extends DialogFragment implements AppComponent {
private boolean isRecreated;
private boolean onViewBoundOrOnResumeInvoked;
private final Subject<Void, Void> unsubscribeSignal;
/* compiled from: AppDialog.kt */
public static final class a implements View.OnClickListener {
public final /* synthetic */ AppDialog i;
public final /* synthetic */ View j;
public final /* synthetic */ Function1 k;
public a(AppDialog appDialog, View view, Function1 function1) {
this.i = appDialog;
this.j = view;
this.k = function1;
}
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
Unit unit = (Unit) this.k.invoke(this.j);
this.i.dismiss();
}
}
public AppDialog() {
PublishSubject k0 = PublishSubject.k0();
m.checkNotNullExpressionValue(k0, "PublishSubject.create()");
this.unsubscribeSignal = k0;
}
public AppDialog(@LayoutRes int i) {
super(i);
PublishSubject k0 = PublishSubject.k0();
m.checkNotNullExpressionValue(k0, "PublishSubject.create()");
this.unsubscribeSignal = k0;
}
public static /* synthetic */ void hideKeyboard$default(AppDialog appDialog, View view, int i, Object obj) {
if (obj == null) {
if ((i & 1) != 0) {
view = null;
}
appDialog.hideKeyboard(view);
return;
}
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: hideKeyboard");
}
@Override // androidx.fragment.app.DialogFragment
public void dismiss() {
try {
super.dismiss();
} catch (Exception unused) {
}
}
public final AppActivity getAppActivity() {
return (AppActivity) getActivity();
}
public final Bundle getArgumentsOrDefault() {
Bundle arguments = getArguments();
if (arguments == null) {
arguments = new Bundle();
}
m.checkNotNullExpressionValue(arguments, "arguments ?: Bundle()");
return arguments;
}
@Override // com.discord.app.AppComponent
public Subject<Void, Void> getUnsubscribeSignal() {
return this.unsubscribeSignal;
}
public final void hideKeyboard() {
hideKeyboard$default(this, null, 1, null);
}
public final void hideKeyboard(View view) {
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
appActivity.hideKeyboard(view);
}
}
public final boolean isRecreated() {
return this.isRecreated;
}
@Override // androidx.fragment.app.DialogFragment
public Dialog onCreateDialog(Bundle bundle) {
Window window;
Dialog onCreateDialog = super.onCreateDialog(bundle);
m.checkNotNullExpressionValue(onCreateDialog, "super.onCreateDialog(savedInstanceState)");
onCreateDialog.requestWindowFeature(1);
if (AccessibilityUtils.INSTANCE.isReducedMotionEnabled() && (window = onCreateDialog.getWindow()) != null) {
window.setWindowAnimations(2131951958);
}
return onCreateDialog;
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onDestroyView() {
super.onDestroyView();
TextWatcher.Companion.reset(this);
}
@Override // androidx.fragment.app.Fragment
public void onPause() {
super.onPause();
getUnsubscribeSignal().onNext(null);
}
@Override // androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
if (this.onViewBoundOrOnResumeInvoked) {
this.onViewBoundOrOnResumeInvoked = false;
} else {
onViewBoundOrOnResume();
}
}
@Override // androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onStart() {
Window window;
try {
super.onStart();
} catch (Exception e) {
if (this instanceof WidgetNoticeDialog) {
((WidgetNoticeDialog) this).logOnStartError(e);
} else {
AppLog appLog = AppLog.g;
StringBuilder L = c.d.b.a.a.L("Failed to start AppDialog: ");
L.append(getClass().getName());
Logger.e$default(appLog, L.toString(), e, null, 4, null);
}
}
Dialog dialog = getDialog();
if (dialog != null && (window = dialog.getWindow()) != null) {
window.setBackgroundDrawableResource(2131100379);
}
}
@CallSuper
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
}
@CallSuper
public void onViewBoundOrOnResume() {
}
@Override // androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
this.isRecreated = bundle != null;
DisplayUtils.drawUnderSystemBars(view);
onViewBound(view);
onViewBoundOrOnResume();
this.onViewBoundOrOnResumeInvoked = true;
}
public final void setOnClickAndDismissListener(View view, Function1<? super View, Unit> function1) {
m.checkNotNullParameter(view, "$this$setOnClickAndDismissListener");
m.checkNotNullParameter(function1, "onClickListener");
view.setOnClickListener(new a(this, view, function1));
}
@Override // androidx.fragment.app.DialogFragment
public int show(FragmentTransaction fragmentTransaction, String str) {
m.checkNotNullParameter(fragmentTransaction, "transaction");
try {
return super.show(fragmentTransaction, str);
} catch (Exception unused) {
return -1;
}
}
@Override // androidx.fragment.app.DialogFragment
public void show(FragmentManager fragmentManager, String str) {
m.checkNotNullParameter(fragmentManager, "manager");
if (!isDetached()) {
try {
super.show(fragmentManager, str);
} catch (Exception unused) {
}
} else {
AppLog appLog = AppLog.g;
StringBuilder L = c.d.b.a.a.L("failed to show ");
L.append(fragmentManager.getClass().getName());
Logger.e$default(appLog, "Could not show dialog because of detached FragmentManager", new IllegalStateException(L.toString()), null, 4, null);
}
}
public final void showKeyboard(View view) {
m.checkNotNullParameter(view, "view");
AppActivity appActivity = getAppActivity();
if (appActivity != null) {
appActivity.showKeyboard(view);
}
}
}