From e93a677d1bbdf3cb617b10731faa737d0141021c Mon Sep 17 00:00:00 2001 From: Jenly Date: Mon, 26 Apr 2021 14:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=86=E8=8A=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/king/app/dialog/AppDialog.java | 46 ++++++++++--------- .../com/king/appupdater/MainActivity.java | 4 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/app-dialog/src/main/java/com/king/app/dialog/AppDialog.java b/app-dialog/src/main/java/com/king/app/dialog/AppDialog.java index 01396d1..b26937f 100644 --- a/app-dialog/src/main/java/com/king/app/dialog/AppDialog.java +++ b/app-dialog/src/main/java/com/king/app/dialog/AppDialog.java @@ -3,6 +3,7 @@ package com.king.app.dialog; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; +import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.view.Window; @@ -106,38 +107,39 @@ public enum AppDialog { * @param config 弹框配置 {@link AppDialogConfig} */ public void showDialog(AppDialogConfig config){ - showDialog(config.getContext(),config); + showDialog(config,true); } + /** - * 显示弹框 请使用{@link #showDialog(AppDialogConfig)} - * @param context + * 显示弹框 * @param config 弹框配置 {@link AppDialogConfig} + * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public void showDialog(Context context,AppDialogConfig config){ - showDialog(context,config,true); + public void showDialog(AppDialogConfig config,boolean isCancel){ + showDialog(config.getContext(),config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); } /** - * 显示弹框,请使用{@link #showDialog(AppDialogConfig, boolean)} + * 显示弹框 * @param context * @param config 弹框配置 {@link AppDialogConfig} - * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public void showDialog(Context context,AppDialogConfig config,boolean isCancel){ - showDialog(context,config.buildAppDialogView(),isCancel); + public void showDialog(Context context,AppDialogConfig config){ + showDialog(context,config,true); } + /** * 显示弹框 + * @param context * @param config 弹框配置 {@link AppDialogConfig} * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public void showDialog(AppDialogConfig config,boolean isCancel){ - showDialog(config.getContext(),config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); + public void showDialog(Context context,AppDialogConfig config,boolean isCancel){ + showDialog(context,config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); } - /** * 显示弹框 * @param context @@ -225,31 +227,31 @@ public enum AppDialog { } /** - * 创建弹框,请使用{@link #createDialog(AppDialogConfig)} - * @param context + * 创建弹框 * @param config 弹框配置 {@link AppDialogConfig} + * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public Dialog createDialog(Context context,AppDialogConfig config){ - return createDialog(context,config,true); + public Dialog createDialog(AppDialogConfig config,boolean isCancel){ + return createDialog(config.getContext(),config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); } /** - * 创建弹框,请使用{@link #createDialog(AppDialogConfig, boolean)} + * 创建弹框 * @param context * @param config 弹框配置 {@link AppDialogConfig} - * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public Dialog createDialog(Context context,AppDialogConfig config,boolean isCancel){ - return createDialog(context,config.buildAppDialogView(),isCancel); + public Dialog createDialog(Context context,AppDialogConfig config){ + return createDialog(context,config,true); } /** * 创建弹框 + * @param context * @param config 弹框配置 {@link AppDialogConfig} * @param isCancel 是否可取消(默认为true,false则拦截back键) */ - public Dialog createDialog(AppDialogConfig config,boolean isCancel){ - return createDialog(config.getContext(),config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); + public Dialog createDialog(Context context,AppDialogConfig config,boolean isCancel){ + return createDialog(context,config.buildAppDialogView(),config.getStyleId(),DEFAULT_WIDTH_RATIO,isCancel); } /** diff --git a/app/src/main/java/com/king/appupdater/MainActivity.java b/app/src/main/java/com/king/appupdater/MainActivity.java index 08233af..a43f03f 100644 --- a/app/src/main/java/com/king/appupdater/MainActivity.java +++ b/app/src/main/java/com/king/appupdater/MainActivity.java @@ -172,7 +172,7 @@ public class MainActivity extends AppCompatActivity { AppDialog.INSTANCE.dismissDialog(); } }); - AppDialog.INSTANCE.showDialog(getContext(),config); + AppDialog.INSTANCE.showDialog(config); } /** @@ -195,7 +195,7 @@ public class MainActivity extends AppCompatActivity { } }); //强制升级,拦截返回 - AppDialog.INSTANCE.showDialog(getContext(),config,false); + AppDialog.INSTANCE.showDialog(config,false); } /**