Skip to content

Commit

Permalink
升级XUtil库的版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Jun 5, 2020
1 parent 71128d2 commit 8782ae8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 37 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
//页面路由
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
17 changes: 1 addition & 16 deletions app/src/main/java/com/xuexiang/xuidemo/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends Activity> clazz) {
Stack<Activity> stack = XUtil.get().getActivityLifecycleHelper().getActivityStack();
for (Activity activity : stack) {
if (activity.getClass().equals(clazz)) {
return true;
}
}
return false;
}

/**
* 请求浏览器
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8782ae8

Please sign in to comment.