无痛单词 v1.8.1版本的 MD5 值为:7ae56c6858542fe70230b6be4f1a4b5a
以下内容为反编译后的 BaseDialog.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.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.core.motion.utils.TypedValues;
import androidx.core.view.ViewCompat;
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.R;
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 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;
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
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 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) {
}
}
}
public enum BOOLEAN {
TRUE,
FALSE
}
public BaseDialog() {
this.cancelable = true;
this.enterAnimDuration = -1L;
this.exitAnimDuration = -1L;
this.cancelable = DialogX.cancelable;
this.enterAnimDuration = DialogX.enterAnimDuration;
this.exitAnimDuration = DialogX.exitAnimDuration;
}
private static void addDialogToRunningList(BaseDialog baseDialog) {
if (runningDialogList == null) {
runningDialogList = new CopyOnWriteArrayList();
}
runningDialogList.add(baseDialog);
}
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 cleanContext() {
WeakReference<Activity> weakReference = activityWeakReference;
if (weakReference != null) {
weakReference.clear();
}
activityWeakReference = null;
System.gc();
}
public 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) {
runOnMain(new Runnable() {
@Override
public void run() {
ViewGroup rootFrameLayout;
if (view.getParent() != null && (view.getParent() instanceof ViewGroup)) {
rootFrameLayout = (ViewGroup) view.getParent();
} else if (baseDialog.getRootFrameLayout() == null) {
return;
} else {
rootFrameLayout = baseDialog.getRootFrameLayout();
}
rootFrameLayout.removeView(view);
BaseDialog.requestDialogFocus();
}
}, true);
} else {
WeakReference<DialogXFloatingWindowActivity> weakReference3 = baseDialog.floatingWindowActivity;
if (weakReference3 != null && weakReference3.get() != null) {
FrameLayout frameLayout = (FrameLayout) baseDialog.floatingWindowActivity.get().getWindow().getDecorView();
if (frameLayout != null) {
frameLayout.removeView(view);
}
baseDialog.floatingWindowActivity.get().finish(baseDialog.dialogKey());
requestDialogFocus();
}
}
if (baseDialog.getDialogListBuilder() == null || baseDialog.getDialogListBuilder().isEmpty()) {
return;
}
baseDialog.getDialogListBuilder().showNext();
}
public static void error(Object obj) {
if (DialogX.DEBUGMODE) {
Log.e(">>>", obj.toString());
}
}
public static ActivityRunnable getActivityRunnable(String str) {
if (str == null) {
return null;
}
return waitRunDialogX.get(str);
}
public static Context getApplicationContext() {
return ActivityLifecycleImpl.getApplicationContext();
}
public static Context getContext() {
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;
}
private static Handler getMainHandler() {
WeakReference<Handler> weakReference;
WeakReference<Handler> weakReference2 = mMainHandler;
if (weakReference2 == null || weakReference2.get() == null) {
weakReference = new WeakReference<>(new Handler(Looper.getMainLooper()));
mMainHandler = weakReference;
} else {
weakReference = mMainHandler;
}
return weakReference.get();
}
public static List<BaseDialog> getRunningDialogList() {
return runningDialogList == null ? new ArrayList() : new CopyOnWriteArrayList(runningDialogList);
}
private static FragmentManager getSupportFragmentManager(Activity activity) {
if (activity instanceof AppCompatActivity) {
return ((AppCompatActivity) activity).getSupportFragmentManager();
}
return null;
}
public static Activity getTopActivity() {
WeakReference<Activity> weakReference = activityWeakReference;
if (weakReference == null) {
init(null);
weakReference = activityWeakReference;
if (weakReference == null) {
return ActivityLifecycleImpl.getTopActivity();
}
}
return weakReference.get();
}
public static Thread getUiThread() {
if (uiThread == null) {
uiThread = Looper.getMainLooper().getThread();
}
return uiThread;
}
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 e2) {
e2.printStackTrace();
error("DialogX.init: 初始化异常,找不到Activity的根布局");
}
}
public static boolean isNull(CharSequence charSequence) {
String valueOf = String.valueOf(charSequence);
return charSequence == null || valueOf.trim().isEmpty() || AbstractJsonLexerKt.NULL.equals(valueOf) || "(null)".equals(valueOf);
}
public static boolean isNull(String str) {
return str == null || str.trim().isEmpty() || AbstractJsonLexerKt.NULL.equals(str) || "(null)".equals(str);
}
public static void log(Object obj) {
if (DialogX.DEBUGMODE) {
Log.i(">>>", 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(R.id.box_root);
if ((findViewById instanceof DialogXBaseRelativeLayout) && ((DialogXBaseRelativeLayout) findViewById).isBaseFocusable()) {
findViewById.requestFocus();
return;
}
}
}
}
}
public static WindowInsets publicWindowInsets() {
return windowInsets;
}
public static void publicWindowInsets(WindowInsets windowInsets2) {
if (windowInsets2 != null) {
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(R.id.box_root);
if (findViewById instanceof DialogXBaseRelativeLayout) {
((DialogXBaseRelativeLayout) findViewById).paddingView(windowInsets2);
}
}
}
}
}
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 (i != 3 && runningDialogList != null) {
Iterator it = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it.hasNext()) {
BaseDialog baseDialog = (BaseDialog) it.next();
if (baseDialog.getOwnActivity() == activity) {
baseDialog.cleanActivityContext();
runningDialogList.remove(baseDialog);
}
}
}
} else if (runningDialogList != null) {
Iterator it2 = new CopyOnWriteArrayList(runningDialogList).iterator();
while (it2.hasNext()) {
BaseDialog baseDialog2 = (BaseDialog) it2.next();
if (baseDialog2.getOwnActivity() == activity && (weakReference2 = baseDialog2.ownDialogFragmentImpl) != null && weakReference2.get() != null) {
baseDialog2.ownDialogFragmentImpl.get().dismiss();
}
}
}
} 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();
}
}
private static void removeDialogToRunningList(BaseDialog baseDialog) {
List<BaseDialog> list = runningDialogList;
if (list != null) {
list.remove(baseDialog);
}
}
public static void requestDialogFocus() {
if (getTopActivity() instanceof Activity) {
onActivityResume(getTopActivity());
}
}
public static void runOnMain(Runnable runnable) {
if (!DialogX.autoRunOnUIThread || (getUiThread() != null && Thread.currentThread() == getUiThread())) {
runnable.run();
} else {
runOnMain(runnable, true);
}
}
public static void runOnMain(Runnable runnable, boolean z2) {
getMainHandler().post(runnable);
}
public static void runOnMainDelay(Runnable runnable, long j2) {
if (j2 < 0) {
return;
}
if (!DialogX.autoRunOnUIThread) {
runnable.run();
}
getMainHandler().postDelayed(runnable, j2);
}
public static void show(Activity activity, final View view) {
WindowInsets rootWindowInsets;
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.ownActivity = new WeakReference<>(activity);
baseDialog.dialogView = new WeakReference<>(view);
int i = Build.VERSION.SDK_INT;
if (i >= 23) {
rootWindowInsets = baseDialog.getRootFrameLayout().getRootWindowInsets();
publicWindowInsets(rootWindowInsets);
}
log(baseDialog + ".show");
addDialogToRunningList(baseDialog);
int i2 = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[baseDialog.dialogImplMode.ordinal()];
if (i2 == 1) {
WindowUtil.show(activity, view, !(baseDialog instanceof NoTouchInterface));
return;
}
if (i2 == 2) {
DialogFragmentImpl dialogFragmentImpl = new DialogFragmentImpl(baseDialog, view);
dialogFragmentImpl.show(getSupportFragmentManager(activity), "DialogX");
baseDialog.ownDialogFragmentImpl = new WeakReference<>(dialogFragmentImpl);
return;
}
if (i2 != 3) {
final FrameLayout frameLayout = (FrameLayout) activity.getWindow().getDecorView();
if (frameLayout == null) {
return;
}
runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() != baseDialog.getRootFrameLayout()) {
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
frameLayout.addView(view);
} else {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
}
}
});
return;
}
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);
final FrameLayout frameLayout2 = (FrameLayout) activity2.getWindow().getDecorView();
if (frameLayout2 == null) {
return;
}
BaseDialog.runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() != BaseDialog.this.getRootFrameLayout()) {
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
frameLayout2.addView(view);
} else {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
}
}
});
}
});
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(TypedValues.TransitionType.S_FROM, activity.hashCode());
intent.putExtra("fromActivityUiStatus", activity.getWindow().getDecorView().getSystemUiVisibility());
activity.startActivity(intent);
if (Integer.valueOf(i).intValue() > 5) {
activity.overridePendingTransition(0, 0);
}
}
}
public static void show(final View view) {
final BaseDialog baseDialog;
WindowInsets rootWindowInsets;
if (view == null || (baseDialog = (BaseDialog) view.getTag()) == null) {
return;
}
if (baseDialog.isShow) {
if (baseDialog.getDialogView() != null) {
baseDialog.getDialogView().setVisibility(0);
return;
}
error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
return;
}
baseDialog.ownActivity = new WeakReference<>(getTopActivity());
baseDialog.dialogView = new WeakReference<>(view);
int i = Build.VERSION.SDK_INT;
if (i >= 23) {
rootWindowInsets = baseDialog.getRootFrameLayout().getRootWindowInsets();
publicWindowInsets(rootWindowInsets);
}
log(baseDialog.dialogKey() + ".show");
addDialogToRunningList(baseDialog);
int i2 = AnonymousClass8.$SwitchMap$com$kongzue$dialogx$DialogX$IMPL_MODE[baseDialog.dialogImplMode.ordinal()];
if (i2 == 1) {
WindowUtil.show(getTopActivity(), view, !(baseDialog instanceof NoTouchInterface));
return;
}
if (i2 == 2) {
DialogFragmentImpl dialogFragmentImpl = new DialogFragmentImpl(baseDialog, view);
dialogFragmentImpl.show(getSupportFragmentManager(getTopActivity()), "DialogX");
baseDialog.ownDialogFragmentImpl = new WeakReference<>(dialogFragmentImpl);
return;
}
if (i2 != 3) {
if (baseDialog.getRootFrameLayout() == null) {
return;
}
runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() != baseDialog.getRootFrameLayout()) {
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
baseDialog.getRootFrameLayout().addView(view);
} else {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
}
}
});
return;
}
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);
final FrameLayout frameLayout = (FrameLayout) activity.getWindow().getDecorView();
if (frameLayout == null) {
return;
}
BaseDialog.runOnMain(new Runnable() {
@Override
public void run() {
if (view.getParent() != BaseDialog.this.getRootFrameLayout()) {
if (view.getParent() != null) {
((ViewGroup) view.getParent()).removeView(view);
}
frameLayout.addView(view);
} else {
BaseDialog.error(((BaseDialog) view.getTag()).dialogKey() + "已处于显示状态,请勿重复执行 show() 指令。");
}
}
});
}
});
DialogXFloatingWindowActivity dialogXFloatingWindowActivity = DialogXFloatingWindowActivity.getDialogXFloatingWindowActivity();
if (dialogXFloatingWindowActivity != null && dialogXFloatingWindowActivity.isSameFrom(getTopActivity().hashCode())) {
dialogXFloatingWindowActivity.showDialogX(baseDialog.dialogKey());
return;
}
Intent intent = new Intent(getContext(), (Class<?>) DialogXFloatingWindowActivity.class);
if (getTopActivity() == null) {
intent.addFlags(268435456);
}
intent.putExtra("dialogXKey", baseDialog.dialogKey());
intent.putExtra("fromActivityUiStatus", getTopActivity() == null ? 0 : getTopActivity().getWindow().getDecorView().getSystemUiVisibility());
intent.putExtra(TypedValues.TransitionType.S_FROM, getContext().hashCode());
getContext().startActivity(intent);
if (Integer.valueOf(i).intValue() <= 5 || getTopActivity() == null) {
return;
}
getTopActivity().overridePendingTransition(0, 0);
}
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());
}
textView.setEllipsize(textInfo.isShowEllipsis() ? TextUtils.TruncateAt.END : null);
textView.setMaxLines(textInfo.getMaxLines() != -1 ? textInfo.getMaxLines() : Integer.MAX_VALUE);
textView.getPaint().setFakeBoldText(textInfo.isBold());
}
public void beforeShow() {
this.preShow = true;
this.dismissAnimFlag = false;
if (getTopActivity() == null) {
init(null);
if (getTopActivity() == null) {
error("DialogX 未初始化(E5)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return;
}
}
if (this.dialogImplMode != DialogX.IMPL_MODE.VIEW && (getTopActivity() instanceof LifecycleOwner)) {
((LifecycleOwner) getTopActivity()).getLifecycle().addObserver(new LifecycleEventObserver() {
@Override
public void onStateChanged(@NonNull LifecycleOwner lifecycleOwner, @NonNull Lifecycle.Event event) {
if (event == Lifecycle.Event.ON_DESTROY) {
BaseDialog.recycleDialog(BaseDialog.getTopActivity());
}
}
});
}
View currentFocus = getTopActivity().getCurrentFocus();
if (currentFocus != null) {
((InputMethodManager) getTopActivity().getSystemService("input_method")).hideSoftInputFromWindow(currentFocus.getWindowToken(), 2);
}
}
public void bindFloatingActivity(DialogXFloatingWindowActivity dialogXFloatingWindowActivity) {
this.floatingWindowActivity = new WeakReference<>(dialogXFloatingWindowActivity);
}
public void cleanActivityContext() {
WeakReference<Activity> weakReference = this.ownActivity;
if (weakReference != null) {
weakReference.clear();
}
this.ownActivity = null;
}
public void cleanDialogList() {
this.dialogListBuilder = null;
}
public View createView(int i) {
if (getApplicationContext() != null) {
return LayoutInflater.from(getApplicationContext()).inflate(i, (ViewGroup) null);
}
error("DialogX 未初始化(E3)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
public abstract String dialogKey();
public int dip2px(float f) {
return (int) ((f * getResources().getDisplayMetrics().density) + 0.5f);
}
public int getColor(int i) {
if (getApplicationContext() != null) {
return getResources().getColor(i);
}
error("DialogX 未初始化(E7)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return ViewCompat.MEASURED_STATE_MASK;
}
public DialogX.IMPL_MODE getDialogImplMode() {
return this.dialogImplMode;
}
public DialogListBuilder getDialogListBuilder() {
WeakReference<DialogListBuilder> weakReference = this.dialogListBuilder;
if (weakReference == null) {
return null;
}
return weakReference.get();
}
public View getDialogView() {
WeakReference<View> weakReference = this.dialogView;
if (weakReference == null) {
return null;
}
return weakReference.get();
}
@Override
@NonNull
public Lifecycle getLifecycle() {
return this.lifecycle;
}
public int getMaxHeight() {
int i = this.maxHeight;
return i == 0 ? DialogX.dialogMaxHeight : i;
}
public int getMaxWidth() {
int i = this.maxWidth;
return i == 0 ? DialogX.dialogMaxWidth : i;
}
public int getMinHeight() {
return this.minWidth == 0 ? DialogX.dialogMinHeight : this.minHeight;
}
public int getMinWidth() {
int i = this.minWidth;
return i == 0 ? DialogX.dialogMinWidth : i;
}
public Activity getOwnActivity() {
WeakReference<Activity> weakReference = this.ownActivity;
if (weakReference == null) {
return null;
}
return weakReference.get();
}
public Resources getResources() {
return getApplicationContext() == null ? Resources.getSystem() : getApplicationContext().getResources();
}
public FrameLayout getRootFrameLayout() {
Activity ownActivity = getOwnActivity();
if (ownActivity == null) {
ownActivity = getTopActivity();
}
WeakReference<FrameLayout> weakReference = new WeakReference<>((FrameLayout) ownActivity.getWindow().getDecorView());
this.rootFrameLayout = weakReference;
return weakReference.get();
}
public String getString(int i) {
if (getApplicationContext() != null) {
return getResources().getString(i);
}
error("DialogX 未初始化(E6)。\n请检查是否在启动对话框前进行初始化操作,使用以下代码进行初始化:\nDialogX.init(context);\n\n另外建议您前往查看 DialogX 的文档进行使用:https://github.com/kongzue/DialogX");
return null;
}
public DialogXStyle getStyle() {
return this.style;
}
public DialogX.THEME getTheme() {
return this.theme;
}
public void imeShow(EditText editText, boolean z2) {
if (getTopActivity() == null) {
return;
}
InputMethodManager inputMethodManager = (InputMethodManager) getTopActivity().getSystemService("input_method");
if (z2) {
inputMethodManager.showSoftInput(editText, 0);
} else {
inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(), 0);
}
}
public abstract boolean isCancelable();
public boolean isLightTheme() {
DialogX.THEME theme = this.theme;
return theme == DialogX.THEME.AUTO ? getApplicationContext() == null ? this.theme == DialogX.THEME.LIGHT : (getResources().getConfiguration().uiMode & 48) == 16 : theme == DialogX.THEME.LIGHT;
}
public boolean isPreShow() {
return this.preShow;
}
public boolean isShow() {
return this.isShow;
}
public void onDialogInit() {
}
public void onDialogRefreshUI() {
}
public void onDialogShow() {
}
public abstract void restartDialog();
public void setDialogListBuilder(DialogListBuilder dialogListBuilder) {
this.dialogListBuilder = new WeakReference<>(dialogListBuilder);
}
public abstract <D extends BaseDialog> D show();
public void showText(TextView textView, CharSequence charSequence) {
if (textView == null) {
return;
}
if (isNull(charSequence)) {
textView.setVisibility(8);
charSequence = "";
} else {
textView.setVisibility(0);
}
textView.setText(charSequence);
}
public abstract void shutdown();
public void tintColor(View view, int i) {
if (view == null) {
return;
}
view.setBackgroundTintList(ColorStateList.valueOf(i));
}
}