From 8782ae8eb82dd4811c3452c47434229797066555 Mon Sep 17 00:00:00 2001 From: xuexiangjys Date: Sat, 6 Jun 2020 04:31:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7XUtil=E5=BA=93=E7=9A=84?= =?UTF-8?q?=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 ++-- .../xuidemo/fragment/SettingFragment.java | 18 +----------------- .../xuexiang/xuidemo/utils/PrivacyUtils.java | 2 +- .../java/com/xuexiang/xuidemo/utils/Utils.java | 17 +---------------- .../xuidemo/utils/sdkinit/XBasicLibInit.java | 1 - 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index d402ea82..435a356a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -108,8 +108,8 @@ dependencies { // implementation 'com.qmuiteam:qmui:1.2.0' //工具类 - implementation 'com.github.xuexiangjys.XUtil:xutil-core:1.1.7' - implementation 'com.github.xuexiangjys.XUtil:xutil-sub:1.1.7' + implementation 'com.github.xuexiangjys.XUtil:xutil-core:1.1.8' + implementation 'com.github.xuexiangjys.XUtil:xutil-sub:1.1.8' //切片 implementation 'com.github.xuexiangjys.XAOP:xaop-runtime:1.0.5x' //页面路由 diff --git a/app/src/main/java/com/xuexiang/xuidemo/fragment/SettingFragment.java b/app/src/main/java/com/xuexiang/xuidemo/fragment/SettingFragment.java index 55a2e563..8b910202 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/fragment/SettingFragment.java +++ b/app/src/main/java/com/xuexiang/xuidemo/fragment/SettingFragment.java @@ -17,9 +17,6 @@ package com.xuexiang.xuidemo.fragment; -import android.app.AlarmManager; -import android.app.PendingIntent; -import android.content.Context; import android.content.Intent; import com.xuexiang.xpage.annotation.Page; @@ -29,9 +26,7 @@ import com.xuexiang.xuidemo.activity.MainActivity; import com.xuexiang.xuidemo.base.BaseFragment; import com.xuexiang.xuidemo.utils.SettingSPUtils; -import com.xuexiang.xutil.XUtil; import com.xuexiang.xutil.app.AppUtils; -import com.xuexiang.xutil.app.IntentUtils; import butterknife.BindView; @@ -77,19 +72,8 @@ protected void initViews() { DialogLoader.getInstance().showTipDialog(getContext(), -1, "切换字体", "切换字体需重启App后生效, 点击“重启”应用将自动重启!", "重启", (dialog, which) -> { SettingSPUtils.getInstance().setIsUseCustomFont(isChecked); //重启app - rebootApp(); + AppUtils.rebootApp(500); }); }); } - - private void rebootApp() { - Intent intent = IntentUtils.getLaunchAppIntent(XUtil.getContext().getPackageName()); - PendingIntent restartIntent = PendingIntent.getActivity(XUtil.getContext(), 0, intent, PendingIntent.FLAG_ONE_SHOT); - AlarmManager mgr = (AlarmManager) XUtil.getContext().getSystemService(Context.ALARM_SERVICE); - if (mgr != null) { - mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, restartIntent); - } - //退出程序 - AppUtils.exitApp(); - } } diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/PrivacyUtils.java b/app/src/main/java/com/xuexiang/xuidemo/utils/PrivacyUtils.java index 72375e4f..0424f95f 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/utils/PrivacyUtils.java +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/PrivacyUtils.java @@ -79,7 +79,7 @@ public static Dialog showPrivacyDialog(Context context, MaterialDialog.SingleBut showPrivacyDialog(context, submitListener); }, ResUtils.getString(R.string.lab_exit_app), (dialog12, which1) -> { dialog12.dismiss(); - XUtil.get().exitApp(); + XUtil.exitApp(); }); }); }).build(); diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java b/app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java index 260ff777..fb247961 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java @@ -76,26 +76,11 @@ public static void initTheme(Activity activity) { * 同步首页状态,未启动就启动 */ public static void syncMainPageStatus() { - if (!Utils.isActivityExist(MainActivity.class)) { + if (!XUtil.getActivityLifecycleHelper().isActivityExist(MainActivity.class)) { ActivityUtils.startActivity(MainActivity.class); } } - /** - * 某一个Activity是否存在 - * - * @return - */ - public static boolean isActivityExist(@NonNull Class clazz) { - Stack stack = XUtil.get().getActivityLifecycleHelper().getActivityStack(); - for (Activity activity : stack) { - if (activity.getClass().equals(clazz)) { - return true; - } - } - return false; - } - /** * 请求浏览器 * diff --git a/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java b/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java index 5f8c7fe3..8e58f6fe 100644 --- a/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java +++ b/app/src/main/java/com/xuexiang/xuidemo/utils/sdkinit/XBasicLibInit.java @@ -63,7 +63,6 @@ public static void init(Application application) { * @param application */ private static void initUtils(Application application) { - XUtil.init(application); XUtil.debug(MyApp.isDebug()); //百度定位 LocationService.get().init(application);