正在查看: 公务员之家 v1.0.1 应用的 BaseDialog.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 公务员之家 v1.0.1 应用的 BaseDialog.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.kongzue.dialogx.interfaces;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowInsets;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleEventObserver;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.LifecycleRegistry;
import com.kongzue.dialogx.DialogX;
import com.kongzue.dialogx.impl.ActivityLifecycleImpl;
import com.kongzue.dialogx.impl.DialogFragmentImpl;
import com.kongzue.dialogx.util.ActivityRunnable;
import com.kongzue.dialogx.util.DialogListBuilder;
import com.kongzue.dialogx.util.DialogXFloatingWindowActivity;
import com.kongzue.dialogx.util.TextInfo;
import com.kongzue.dialogx.util.WindowUtil;
import com.kongzue.dialogx.util.views.DialogXBaseRelativeLayout;
import com.yalantis.ucrop.view.CropImageView;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
public abstract class BaseDialog implements LifecycleOwner {
private static WeakReference<Activity> activityWeakReference;
static WeakReference<Handler> mMainHandler;
private static List<BaseDialog> runningDialogList;
private static Thread uiThread;
private static Map<String, ActivityRunnable> waitRunDialogX;
protected static WindowInsets windowInsets;
protected boolean cancelable;
private WeakReference<DialogListBuilder> dialogListBuilder;
private WeakReference<View> dialogView;
protected boolean dismissAnimFlag;
protected long enterAnimDuration;
protected long exitAnimDuration;
protected WeakReference<DialogXFloatingWindowActivity> floatingWindowActivity;
protected boolean isShow;
protected int maxHeight;
protected int maxWidth;
protected int minHeight;
protected int minWidth;
protected WeakReference<Activity> ownActivity;
protected WeakReference<DialogFragmentImpl> ownDialogFragmentImpl;
protected boolean preShow;
private WeakReference<FrameLayout> rootFrameLayout;
protected DialogX.IMPL_MODE dialogImplMode = DialogX.implIMPLMode;
protected LifecycleRegistry lifecycle = new LifecycleRegistry(this);
protected int backgroundColor = -1;
protected int[] screenPaddings = new int[4];
protected DialogXStyle style = DialogX.globalStyle;
protected DialogX.THEME theme = DialogX.globalTheme;
protected boolean autoShowInputKeyboard = DialogX.autoShowInputKeyboard;
public enum BOOLEAN {
TRUE,
FALSE
}
public enum BUTTON_SELECT_RESULT {
NONE,
BUTTON_OK,
BUTTON_CANCEL,
BUTTON_OTHER
}
public abstract String dialogKey();
public abstract boolean isCancelable();
protected void onDialogInit() {
}
protected void onDialogRefreshUI() {
}
protected void onDialogShow() {
}
public abstract void restartDialog();
public abstract <D extends BaseDialog> D show();
protected abstract void shutdown();
public static void init(Context context) {
if (context == null) {
context = ActivityLifecycleImpl.getTopActivity();
}
if (context instanceof Activity) {
initActivityContext((Activity) context);
}
ActivityLifecycleImpl.init(context, new ActivityLifecycleImpl.onActivityResumeCallBack() {
@Override
public void getActivity(Activity activity) {
BaseDialog.initActivityContext(activity);
}
});
}
public static void initActivityContext(Activity activity) {
if (ActivityLifecycleImpl.isExemptActivities(activity)) {
return;
}
try {
uiThread = Looper.getMainLooper().getThread();
activityWeakReference = new WeakReference<>(activity);
} catch (Exception e) {
e.printStackTrace();
error("DialogX.init: 初始化异常,找不到Activity的根布局");
}
}
protected static void log(Object obj) {
if (DialogX.DEBUGMODE) {
Log.i(">>>", obj.toString());
}
}
protected static void error(Object obj) {
if (DialogX.DEBUGMODE) {
Log.e(">>>", obj.toString());
}
}
public static void onActivityResume(Activity activity) {
if (runningDialogList != null) {
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(runningDialogList);
for (int size = copyOnWriteArrayList.size() - 1; size >= 0; size--) {
BaseDialog baseDialog = (BaseDialog) copyOnWriteArrayList.get(size);
if (baseDialog.getOwnActivity() == activity && baseDialog.isShow && baseDialog.getDialogView() != null) {
View findViewById = baseDialog.getDialogView().findViewById(com.kongzue.dialogx.R.id.box_root);
if (findViewById instanceof DialogXBaseRelativeLayout) {
DialogXBaseRelativeLayout dialogXBaseRelativeLayout = (DialogXBaseRelativeLayout) findViewById;
if (dialogXBaseRelativeLayout.isBaseFocusable()) {
dialogXBaseRelativeLayout.requestFocusOnResume();
return;
}
} else {
continue;
}
}
}
}
}
public static void requestDialogFocus() {
if (runningDialogList != null) {
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(runningDialogList);
for (int size = copyOnWriteArrayList.size() - 1; size >= 0; size--) {
BaseDialog baseDialog = (BaseDialog) copyOnWriteArrayList.get(size);
if (baseDialog.getOwnActivity() == getTopActivity() && baseDialog.isShow && baseDialog.getDialogView() != null) {
View findViewById = baseDialog.getDialogView().findViewById(com.kongzue.dialogx.R.id.box_root);
if ((findViewById instanceof DialogXBaseRelativeLayout) && ((DialogXBaseRelativeLayout) findViewById).isBaseFocusable()) {
findViewById.requestFocus();
return;
}
}
}
}
}
protected static void show(final View view) {
final BaseDialog baseDialog;
if (view == null || (baseDialog = (BaseDialog) view.getTag()) == null) {
return;
}
if (baseDialog.isShow) {
if (baseDialog.getDialogView() != null) {
baseDialog.getDialogView().setVisibility(0);
return;
} else {
error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
}
baseDialog.dialogView = new WeakReference<>(view);
publicWindowInsets(baseDialog.getRootFrameLayout().getRootWindowInsets());
log(baseDialog.dialogKey() + ".show");
addDialogToRunningList(baseDialog);
int i = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[baseDialog.dialogImplMode.ordinal()];
if (i == 1) {
WindowUtil.show(baseDialog.getOwnActivity(), view, !(baseDialog instanceof NoTouchInterface));
return;
}
if (i == 2) {
DialogFragmentImpl dialogFragmentImpl = new DialogFragmentImpl(baseDialog, view);
dialogFragmentImpl.show(getSupportFragmentManager(baseDialog.getOwnActivity()), "DialogX");
baseDialog.ownDialogFragmentImpl = new WeakReference<>(dialogFragmentImpl);
return;
}
if (i == 3) {
if (waitRunDialogX == null) {
waitRunDialogX = new HashMap();
}
waitRunDialogX.put(baseDialog.dialogKey(), new ActivityRunnable() {
@Override
public void run(Activity activity) {
BaseDialog.this.floatingWindowActivity = new WeakReference<>((DialogXFloatingWindowActivity) activity);
BaseDialog.this.floatingWindowActivity.get().setFromActivity(BaseDialog.this.getOwnActivity());
final FrameLayout decorView = BaseDialog.getDecorView(activity);
if (decorView == null) {
return;
}
BaseDialog.runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() == BaseDialog.this.getRootFrameLayout()) {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
decorView.addView(view);
}
});
}
});
DialogXFloatingWindowActivity dialogXFloatingWindowActivity = DialogXFloatingWindowActivity.getDialogXFloatingWindowActivity();
if (dialogXFloatingWindowActivity != null && dialogXFloatingWindowActivity.isSameFrom(baseDialog.getOwnActivity().hashCode())) {
dialogXFloatingWindowActivity.showDialogX(baseDialog.dialogKey());
return;
}
Intent intent = new Intent(getPrivateContext(), (Class<?>) DialogXFloatingWindowActivity.class);
if (baseDialog.getOwnActivity() == null) {
intent.addFlags(268435456);
}
intent.putExtra("dialogXKey", baseDialog.dialogKey());
intent.putExtra("fromActivityUiStatus", (baseDialog.getOwnActivity() == null || getDecorView(baseDialog.getOwnActivity()) == null) ? 0 : getDecorView(baseDialog.getOwnActivity()).getSystemUiVisibility());
intent.putExtra("from", getPrivateContext().hashCode());
getPrivateContext().startActivity(intent);
if (Integer.valueOf(Build.VERSION.SDK_INT).intValue() <= 5 || baseDialog.getOwnActivity() == null) {
return;
}
baseDialog.getOwnActivity().overridePendingTransition(0, 0);
return;
}
if (baseDialog.getRootFrameLayout() == null) {
return;
}
runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() == baseDialog.getRootFrameLayout()) {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
baseDialog.getRootFrameLayout().addView(view);
}
});
}
static class AnonymousClass8 {
static final int[] $SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE;
static {
int[] iArr = new int[DialogX.IMPL_MODE.values().length];
$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE = iArr;
try {
iArr[DialogX.IMPL_MODE.WINDOW.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
try {
$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[DialogX.IMPL_MODE.DIALOG_FRAGMENT.ordinal()] = 2;
} catch (NoSuchFieldError unused2) {
}
try {
$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[DialogX.IMPL_MODE.FLOATING_ACTIVITY.ordinal()] = 3;
} catch (NoSuchFieldError unused3) {
}
}
}
private static FragmentManager getSupportFragmentManager(Activity activity) {
if (activity instanceof AppCompatActivity) {
return ((AppCompatActivity) activity).getSupportFragmentManager();
}
return null;
}
public static ActivityRunnable getActivityRunnable(String str) {
if (str == null) {
return null;
}
return waitRunDialogX.get(str);
}
protected static void show(Activity activity, final View view) {
if (activity == null || view == null) {
return;
}
WeakReference<Activity> weakReference = activityWeakReference;
if (weakReference == null || weakReference.get() == null || ActivityLifecycleImpl.getApplicationContext() == null) {
init(activity.getApplicationContext());
}
final BaseDialog baseDialog = (BaseDialog) view.getTag();
if (baseDialog != null) {
if (baseDialog.getDialogView() != null) {
baseDialog.getDialogView().setVisibility(0);
}
if (baseDialog.isShow) {
error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
if (activity.isDestroyed()) {
error(((BaseDialog) view.getTag()).dialogKey() + ".show ERROR: activity is Destroyed.");
return;
}
baseDialog.dialogView = new WeakReference<>(view);
publicWindowInsets(baseDialog.getRootFrameLayout().getRootWindowInsets());
log(baseDialog + ".show");
addDialogToRunningList(baseDialog);
int i = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[baseDialog.dialogImplMode.ordinal()];
if (i == 1) {
WindowUtil.show(activity, view, !(baseDialog instanceof NoTouchInterface));
return;
}
if (i == 2) {
DialogFragmentImpl dialogFragmentImpl = new DialogFragmentImpl(baseDialog, view);
dialogFragmentImpl.show(getSupportFragmentManager(activity), "DialogX");
baseDialog.ownDialogFragmentImpl = new WeakReference<>(dialogFragmentImpl);
return;
}
if (i == 3) {
if (waitRunDialogX == null) {
waitRunDialogX = new HashMap();
}
waitRunDialogX.put(baseDialog.dialogKey(), new ActivityRunnable() {
@Override
public void run(Activity activity2) {
BaseDialog.this.floatingWindowActivity = new WeakReference<>((DialogXFloatingWindowActivity) activity2);
BaseDialog.this.floatingWindowActivity.get().setFromActivity(BaseDialog.this.getOwnActivity());
final FrameLayout decorView = BaseDialog.getDecorView(activity2);
if (decorView == null) {
return;
}
BaseDialog.runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() == BaseDialog.this.getRootFrameLayout()) {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
decorView.addView(view);
}
});
}
});
DialogXFloatingWindowActivity dialogXFloatingWindowActivity = DialogXFloatingWindowActivity.getDialogXFloatingWindowActivity();
if (dialogXFloatingWindowActivity != null && dialogXFloatingWindowActivity.isSameFrom(activity.hashCode())) {
dialogXFloatingWindowActivity.showDialogX(baseDialog.dialogKey());
return;
}
Intent intent = new Intent(activity, (Class<?>) DialogXFloatingWindowActivity.class);
intent.putExtra("dialogXKey", baseDialog.dialogKey());
intent.putExtra("from", activity.hashCode());
intent.putExtra("fromActivityUiStatus", getDecorView(activity) == null ? 0 : getDecorView(activity).getSystemUiVisibility());
activity.startActivity(intent);
if (Integer.valueOf(Build.VERSION.SDK_INT).intValue() > 5) {
activity.overridePendingTransition(0, 0);
return;
}
return;
}
final FrameLayout decorView = getDecorView(activity);
if (decorView == null) {
return;
}
runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() == baseDialog.getRootFrameLayout()) {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
decorView.addView(view);
}
});
}
}
private void setOwnActivity(Activity activity) {
this.ownActivity = new WeakReference<>(activity);
}
protected static void dismiss(final View view) {
if (view == null) {
return;
}
final BaseDialog baseDialog = (BaseDialog) view.getTag();
log(baseDialog.dialogKey() + ".dismiss");
removeDialogToRunningList(baseDialog);
WeakReference<View> weakReference = baseDialog.dialogView;
if (weakReference != null) {
weakReference.clear();
}
int i = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[baseDialog.dialogImplMode.ordinal()];
if (i == 1) {
WindowUtil.dismiss(view);
} else if (i == 2) {
WeakReference<DialogFragmentImpl> weakReference2 = baseDialog.ownDialogFragmentImpl;
if (weakReference2 != null && weakReference2.get() != null) {
baseDialog.ownDialogFragmentImpl.get().dismiss();
}
} else if (i == 3) {
WeakReference<DialogXFloatingWindowActivity> weakReference3 = baseDialog.floatingWindowActivity;
if (weakReference3 != null && weakReference3.get() != null) {
FrameLayout decorView = getDecorView((Activity) baseDialog.floatingWindowActivity.get());
if (decorView != null) {
decorView.removeView(view);
}
baseDialog.floatingWindowActivity.get().finish(baseDialog.dialogKey());
requestDialogFocus();
}
} else {
runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() == null || !(view.getParent() instanceof ViewGroup)) {
if (baseDialog.getRootFrameLayout() == null) {
return;
} else {
baseDialog.getRootFrameLayout().removeView(view);
}
} else {
((ViewGroup) view.getParent()).removeView(view);
}
BaseDialog.requestDialogFocus();
}
}, true);
}
if (baseDialog.getDialogListBuilder() == null || baseDialog.getDialogListBuilder().isEmpty()) {
return;
}
baseDialog.getDialogListBuilder().showNext();
}
private static void addDialogToRunningList(BaseDialog baseDialog) {
if (runningDialogList == null) {
runningDialogList = new CopyOnWriteArrayList();
}
runningDialogList.add(baseDialog);
}
private static void removeDialogToRunningList(BaseDialog baseDialog) {
List<BaseDialog> list = runningDialogList;
if (list != null) {
list.remove(baseDialog);
}
}
public static Activity getTopActivity() {
WeakReference<Activity> weakReference = activityWeakReference;
if (weakReference == null || weakReference.get() == null) {
init(null);
WeakReference<Activity> weakReference2 = activityWeakReference;
if (weakReference2 == null || weakReference2.get() == null) {
Activity topActivity = ActivityLifecycleImpl.getTopActivity();
init(topActivity);
return topActivity;
}
return activityWeakReference.get();
}
return activityWeakReference.get();
}
@Deprecated
public static Context getContext() {
return getPrivateContext();
}
private static Context getPrivateContext() {
Activity topActivity = getTopActivity();
if (topActivity != null) {
return topActivity;
}
Context applicationContext = getApplicationContext();
if (applicationContext != null) {
return applicationContext;
}
error("DialogX 未初始化(E2)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
public static Context getApplicationContext() {
return ActivityLifecycleImpl.getApplicationContext();
}
public static void cleanContext() {
WeakReference<Activity> weakReference = activityWeakReference;
if (weakReference != null) {
weakReference.clear();
}
activityWeakReference = null;
System.gc();
}
public BaseDialog() {
this.cancelable = true;
this.enterAnimDuration = -1L;
this.exitAnimDuration = -1L;
this.cancelable = DialogX.cancelable;
this.enterAnimDuration = DialogX.enterAnimDuration;
this.exitAnimDuration = DialogX.exitAnimDuration;
}
public View createView(int i) {
if (getApplicationContext() == null) {
error("DialogX 未初始化(E3)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
return LayoutInflater.from(getApplicationContext()).inflate(i, (ViewGroup) null);
}
public boolean isShow() {
return this.isShow;
}
public DialogXStyle getStyle() {
return this.style;
}
public DialogX.THEME getTheme() {
return this.theme;
}
public static void useTextInfo(TextView textView, TextInfo textInfo) {
if (textInfo == null || textView == null) {
return;
}
if (textInfo.getFontSize() > 0) {
textView.setTextSize(textInfo.getFontSizeComplexUnit(), textInfo.getFontSize());
}
if (textInfo.getFontColor() != 1) {
textView.setTextColor(textInfo.getFontColor());
}
if (textInfo.getGravity() != -1) {
textView.setGravity(textInfo.getGravity());
}
if (textInfo.isShowEllipsis()) {
textView.setEllipsize(TextUtils.TruncateAt.END);
} else {
textView.setEllipsize(null);
}
if (textInfo.getMaxLines() != -1) {
textView.setMaxLines(textInfo.getMaxLines());
} else {
textView.setMaxLines(Integer.MAX_VALUE);
}
textView.getPaint().setFakeBoldText(textInfo.isBold());
}
protected void showText(TextView textView, CharSequence charSequence) {
if (textView == null) {
return;
}
if (isNull(charSequence)) {
textView.setVisibility(8);
textView.setText("");
} else {
textView.setVisibility(0);
textView.setText(charSequence);
}
}
public static boolean isNull(String str) {
return str == null || str.trim().isEmpty() || "null".equals(str) || "(null)".equals(str);
}
public static boolean isNull(CharSequence charSequence) {
String valueOf = String.valueOf(charSequence);
return charSequence == null || valueOf.trim().isEmpty() || "null".equals(valueOf) || "(null)".equals(valueOf);
}
public Resources getResources() {
if (getApplicationContext() == null) {
return Resources.getSystem();
}
return getApplicationContext().getResources();
}
public int dip2px(float f) {
return (int) ((f * getResources().getDisplayMetrics().density) + 0.5f);
}
public boolean isLightTheme() {
return this.theme == DialogX.THEME.AUTO ? getApplicationContext() == null ? this.theme == DialogX.THEME.LIGHT : (getResources().getConfiguration().uiMode & 48) == 16 : this.theme == DialogX.THEME.LIGHT;
}
public FrameLayout getRootFrameLayout() {
Activity ownActivity = getOwnActivity();
if (ownActivity == null) {
ownActivity = getTopActivity();
if (ownActivity == null) {
error("DialogX 错误:在 getRootFrameLayout() 时无法获取绑定的 activity,请确认是否正确初始化:\nDialogX.init(context);\n\n或者使用 .show(activity) 启动对话框\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
setOwnActivity(ownActivity);
}
FrameLayout decorView = getDecorView(ownActivity);
if (decorView == null) {
error("DialogX 错误:在 getRootFrameLayout() 时无法获 activity(" + ownActivity + ") 的 decorView,请检查该 activity 是否正常显示且可以使 DialogX 基于其显示。\n若该 activity 不可用,可通过以下代码配置豁免 DialogX 对话框绑定至该 activity,例如:\nDialogX.unsupportedActivitiesPackageNames = new String[]{\n \"com.bytedance.sdk.openadsdk.stub.activity\",\n \"com.mobile.auth.gatewayauth\",\n \"com.google.android.gms.ads\"\n};\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
WeakReference<FrameLayout> weakReference = new WeakReference<>(decorView);
this.rootFrameLayout = weakReference;
return weakReference.get();
}
public void tintColor(View view, int i) {
if (view == null) {
return;
}
view.setBackgroundTintList(ColorStateList.valueOf(i));
}
protected void beforeShow() {
View currentFocus;
this.preShow = true;
this.dismissAnimFlag = false;
setOwnActivity(getTopActivity());
if (getOwnActivity() == null) {
init(null);
if (getOwnActivity() == null) {
error("DialogX 未初始化(E5)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return;
}
}
if (this.dialogImplMode != DialogX.IMPL_MODE.VIEW && (getOwnActivity() instanceof LifecycleOwner)) {
getOwnActivity().getLifecycle().addObserver(new LifecycleEventObserver() {
public void onStateChanged(LifecycleOwner lifecycleOwner, Lifecycle.Event event) {
if (event == Lifecycle.Event.ON_DESTROY) {
BaseDialog.recycleDialog(BaseDialog.this.getOwnActivity());
}
}
});
}
if ((this instanceof NoTouchInterface) || (currentFocus = getOwnActivity().getCurrentFocus()) == null) {
return;
}
((InputMethodManager) getOwnActivity().getSystemService("input_method")).hideSoftInputFromWindow(currentFocus.getWindowToken(), 2);
}
protected String getString(int i) {
if (getApplicationContext() == null) {
error("DialogX 未初始化(E6)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
return getResources().getString(i);
}
protected int getColor(int i) {
if (getApplicationContext() == null) {
error("DialogX 未初始化(E7)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return -16777216;
}
return getResources().getColor(i);
}
protected Integer getColorNullable(Integer num) {
if (num == null) {
return null;
}
return Integer.valueOf(getColor(num.intValue()));
}
protected Integer getColorNullable(Integer num, Integer num2) {
return Integer.valueOf(getColor(num == null ? num2.intValue() : num.intValue()));
}
protected static void runOnMain(Runnable runnable) {
if (!DialogX.autoRunOnUIThread || (getUiThread() != null && Thread.currentThread() == getUiThread())) {
runnable.run();
} else {
runOnMain(runnable, true);
}
}
protected static Thread getUiThread() {
if (uiThread == null) {
uiThread = Looper.getMainLooper().getThread();
}
return uiThread;
}
protected static void runOnMain(Runnable runnable, boolean z) {
getMainHandler().post(runnable);
}
protected static void runOnMainDelay(Runnable runnable, long j) {
if (j < 0) {
return;
}
if (!DialogX.autoRunOnUIThread) {
runnable.run();
}
getMainHandler().postDelayed(runnable, j);
}
public View getDialogView() {
WeakReference<View> weakReference = this.dialogView;
if (weakReference == null) {
return null;
}
return weakReference.get();
}
public Activity getOwnActivity() {
WeakReference<Activity> weakReference = this.ownActivity;
if (weakReference == null || weakReference.get() == null) {
setOwnActivity(getTopActivity());
}
return this.ownActivity.get();
}
protected void cleanActivityContext() {
WeakReference<Activity> weakReference = this.ownActivity;
if (weakReference != null) {
weakReference.clear();
}
this.ownActivity = null;
}
public static void cleanAll() {
if (runningDialogList != null) {
Iterator it = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it.hasNext()) {
BaseDialog baseDialog = (BaseDialog) it.next();
if (baseDialog.isShow()) {
baseDialog.shutdown();
}
baseDialog.cleanActivityContext();
runningDialogList.remove(baseDialog);
}
}
}
public static void recycleDialog(Activity activity) {
WeakReference<View> weakReference;
WeakReference<DialogFragmentImpl> weakReference2;
int i = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[DialogX.implIMPLMode.ordinal()];
if (i != 1) {
if (i == 2) {
if (runningDialogList != null) {
Iterator it = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it.hasNext()) {
BaseDialog baseDialog = (BaseDialog) it.next();
if (baseDialog.getOwnActivity() == activity && (weakReference2 = baseDialog.ownDialogFragmentImpl) != null && weakReference2.get() != null) {
baseDialog.ownDialogFragmentImpl.get().dismiss();
}
}
}
} else if (i != 3 && runningDialogList != null) {
Iterator it2 = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it2.hasNext()) {
BaseDialog baseDialog2 = (BaseDialog) it2.next();
if (baseDialog2.getOwnActivity() == activity) {
baseDialog2.cleanActivityContext();
runningDialogList.remove(baseDialog2);
}
}
}
} else if (runningDialogList != null) {
Iterator it3 = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it3.hasNext()) {
BaseDialog baseDialog3 = (BaseDialog) it3.next();
if (baseDialog3.getOwnActivity() == activity && (weakReference = baseDialog3.dialogView) != null) {
WindowUtil.dismiss(weakReference.get());
}
}
}
if (activity == getTopActivity()) {
cleanContext();
}
}
public static List<BaseDialog> getRunningDialogList() {
if (runningDialogList == null) {
return new ArrayList();
}
return new CopyOnWriteArrayList(runningDialogList);
}
protected void imeShow(EditText editText, boolean z) {
if (getOwnActivity() == null) {
return;
}
InputMethodManager inputMethodManager = (InputMethodManager) getOwnActivity().getSystemService("input_method");
if (z) {
inputMethodManager.showSoftInput(editText, 0);
} else {
inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
}
public DialogX.IMPL_MODE getDialogImplMode() {
return this.dialogImplMode;
}
public static WindowInsets publicWindowInsets() {
return windowInsets;
}
public static void publicWindowInsets(WindowInsets windowInsets2) {
if (windowInsets2 == null) {
return;
}
windowInsets = windowInsets2;
if (runningDialogList != null) {
CopyOnWriteArrayList copyOnWriteArrayList = new CopyOnWriteArrayList(runningDialogList);
for (int size = copyOnWriteArrayList.size() - 1; size >= 0; size--) {
BaseDialog baseDialog = (BaseDialog) copyOnWriteArrayList.get(size);
if (baseDialog.isShow && baseDialog.getDialogView() != null) {
View findViewById = baseDialog.getDialogView().findViewById(com.kongzue.dialogx.R.id.box_root);
if (findViewById instanceof DialogXBaseRelativeLayout) {
((DialogXBaseRelativeLayout) findViewById).paddingView(windowInsets2);
}
}
}
}
}
protected void bindFloatingActivity(DialogXFloatingWindowActivity dialogXFloatingWindowActivity) {
this.floatingWindowActivity = new WeakReference<>(dialogXFloatingWindowActivity);
}
private static Handler getMainHandler() {
WeakReference<Handler> weakReference = mMainHandler;
if (weakReference != null && weakReference.get() != null) {
return mMainHandler.get();
}
WeakReference<Handler> weakReference2 = new WeakReference<>(new Handler(Looper.getMainLooper()));
mMainHandler = weakReference2;
return weakReference2.get();
}
public DialogListBuilder getDialogListBuilder() {
WeakReference<DialogListBuilder> weakReference = this.dialogListBuilder;
if (weakReference == null) {
return null;
}
return weakReference.get();
}
public void setDialogListBuilder(DialogListBuilder dialogListBuilder) {
this.dialogListBuilder = new WeakReference<>(dialogListBuilder);
}
public void cleanDialogList() {
this.dialogListBuilder = null;
}
public boolean isPreShow() {
return this.preShow;
}
public Lifecycle getLifecycle() {
return this.lifecycle;
}
public int getMaxWidth() {
int i = this.maxWidth;
return i == 0 ? DialogX.dialogMaxWidth : i;
}
public int getMaxHeight() {
int i = this.maxHeight;
return i == 0 ? DialogX.dialogMaxHeight : i;
}
public int getMinWidth() {
int i = this.minWidth;
return i == 0 ? DialogX.dialogMinWidth : i;
}
public int getMinHeight() {
int i = this.minHeight;
return i == 0 ? DialogX.dialogMinHeight : i;
}
protected void setLifecycleState(Lifecycle.State state) {
LifecycleRegistry lifecycleRegistry = this.lifecycle;
if (lifecycleRegistry == null || state == null) {
return;
}
try {
lifecycleRegistry.setCurrentState(state);
} catch (Exception unused) {
}
}
protected static FrameLayout getDecorView(Activity activity) {
if (activity == null || activity.getWindow() == null || !(activity.getWindow().getDecorView() instanceof FrameLayout)) {
return null;
}
return (FrameLayout) activity.getWindow().getDecorView();
}
protected List<View> findAllBlurView(View view) {
ArrayList arrayList = new ArrayList();
if (view instanceof BlurViewType) {
arrayList.add(view);
}
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++) {
List<View> findAllBlurView = findAllBlurView(viewGroup.getChildAt(i));
if (findAllBlurView != null) {
arrayList.addAll(findAllBlurView);
}
}
}
if (arrayList.isEmpty()) {
return null;
}
return arrayList;
}
protected Integer getIntStyleAttr(Integer num) {
if (num.intValue() <= 0) {
return null;
}
return num;
}
protected Integer getIntStyleAttr(Integer num, Integer num2) {
return num.intValue() <= 0 ? num2 : num;
}
protected Float getFloatStyleAttr(Float f) {
if (f.floatValue() <= CropImageView.DEFAULT_ASPECT_RATIO) {
return null;
}
return f;
}
protected Float getFloatStyleAttr(Float f, Float f2) {
if (f.floatValue() <= CropImageView.DEFAULT_ASPECT_RATIO) {
log("styleValue=" + f + "<=0 ");
log("return defaultValue=" + f2);
return f2;
}
log("return styleValue=" + f);
return f;
}
}