Skip to content

Commit c577eb6

Browse files
committed
see 01/10 log
1 parent 3ac7bd3 commit c577eb6

File tree

23 files changed

+357
-184
lines changed

23 files changed

+357
-184
lines changed

README-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.11.0-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.11.1-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ If this ptoject helps you a lot, and you would like to support this ptoject's fu
4141

4242
[logo]: https://raw.githubusercontent.com/Blankj/AndroidUtilCode/master/art/logo.png
4343

44-
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.11.0-brightgreen.svg
44+
[aucsvg]: https://img.shields.io/badge/AndroidUtilCode-v1.11.1-brightgreen.svg
4545
[auc]: https://github.com/Blankj/AndroidUtilCode
4646

4747
[apisvg]: https://img.shields.io/badge/API-14+-brightgreen.svg

app/src/main/java/com/blankj/androidutilcode/UtilsApp.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.blankj.androidutilcode;
22

3+
import android.app.AlarmManager;
4+
import android.app.PendingIntent;
5+
import android.content.Context;
6+
import android.content.Intent;
7+
38
import com.blankj.androidutilcode.base.BaseApplication;
9+
import com.blankj.utilcode.util.ActivityUtils;
410
import com.blankj.utilcode.util.CrashUtils;
511
import com.blankj.utilcode.util.LogUtils;
612
import com.blankj.utilcode.util.PermissionUtils;
@@ -65,7 +71,26 @@ public void initLog() {
6571
}
6672

6773
private void initCrash() {
68-
CrashUtils.init();
74+
CrashUtils.init(new CrashUtils.OnCrashListener() {
75+
@Override
76+
public void onCrash(Throwable e) {
77+
e.printStackTrace();
78+
restartApp();
79+
}
80+
});
81+
}
82+
83+
private void restartApp() {
84+
Intent intent = new Intent();
85+
intent.setClassName("com.blankj.androidutilcode", "com.blankj.androidutilcode.MainActivity");
86+
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
87+
PendingIntent restartIntent = PendingIntent.getActivity(this, 0, intent, 0);
88+
AlarmManager manager = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
89+
if (manager == null) return;
90+
manager.set(AlarmManager.RTC, System.currentTimeMillis() + 1, restartIntent);
91+
ActivityUtils.finishAllActivities();
92+
android.os.Process.killProcess(android.os.Process.myPid());
93+
System.exit(1);
6994
}
7095
}
7196

app/src/main/java/com/blankj/androidutilcode/feature/core/CoreUtilActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class CoreUtilActivity extends BaseBackActivity {
3939

4040
public static void start(Context context) {
4141
Intent starter = new Intent(context, CoreUtilActivity.class);
42-
context.startActivity(starter);
42+
context.startActivity(starter.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
4343
}
4444

4545
@Override
@@ -88,8 +88,6 @@ public void cleanClick(View view) {
8888
}
8989

9090
public void crashClick(View view) {
91-
// PermissionUtils.permission(PermissionConstants.WRITE_EXTERNAL_STORAGE)
92-
9391
throw new NullPointerException("crash test");
9492
}
9593

app/src/main/java/com/blankj/androidutilcode/feature/core/keyboard/KeyboardActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import com.blankj.androidutilcode.R;
1414
import com.blankj.androidutilcode.base.BaseBackActivity;
15+
import com.blankj.androidutilcode.helper.DialogHelper;
1516
import com.blankj.utilcode.util.KeyboardUtils;
1617
import com.blankj.utilcode.util.SpanUtils;
1718

@@ -86,7 +87,7 @@ public void onWidgetClick(View view) {
8687
KeyboardUtils.toggleSoftInput();
8788
break;
8889
case R.id.btn_keyboard_in_fragment:
89-
new KeyboardDialog(this).show();
90+
DialogHelper.showKeyboardDialog();
9091
KeyboardUtils.showSoftInput(this);
9192
break;
9293
}

app/src/main/java/com/blankj/androidutilcode/feature/core/keyboard/KeyboardDialog.java

Lines changed: 0 additions & 67 deletions
This file was deleted.

app/src/main/java/com/blankj/androidutilcode/feature/core/network/NetworkActivity.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@ public boolean handleMessage(Message msg) {
3636
text += '\n';
3737
}
3838
if (msg.what == 1) {
39-
tvAboutNetworkAsync.setText(text + "isAvailableByPing: " + msg.obj);
39+
tvAboutNetworkAsync.setText(new SpanUtils()
40+
.append(text + "isAvailableByPing: " + msg.obj)
41+
.create()
42+
);
4043
} else {
41-
tvAboutNetworkAsync.setText(text + "getDomainAddress: " + msg.obj);
44+
tvAboutNetworkAsync.setText(new SpanUtils()
45+
.append(text + "getDomainAddress: " + msg.obj)
46+
.create()
47+
);
4248
}
4349
return true;
4450
}

app/src/main/java/com/blankj/androidutilcode/feature/core/permission/PermissionActivity.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import com.blankj.androidutilcode.R;
1212
import com.blankj.androidutilcode.base.BaseBackActivity;
13-
import com.blankj.androidutilcode.helper.PermissionHelper;
13+
import com.blankj.androidutilcode.helper.DialogHelper;
1414
import com.blankj.utilcode.constant.PermissionConstants;
1515
import com.blankj.utilcode.util.LogUtils;
1616
import com.blankj.utilcode.util.PermissionUtils;
@@ -85,7 +85,7 @@ public void onWidgetClick(View view) {
8585
.rationale(new PermissionUtils.OnRationaleListener() {
8686
@Override
8787
public void rationale(final ShouldRequest shouldRequest) {
88-
PermissionHelper.showRationaleDialog(shouldRequest);
88+
DialogHelper.showRationaleDialog(shouldRequest);
8989
}
9090
})
9191
.callback(new PermissionUtils.FullCallback() {
@@ -98,7 +98,7 @@ public void onGranted(List<String> permissionsGranted) {
9898
public void onDenied(List<String> permissionsDeniedForever,
9999
List<String> permissionsDenied) {
100100
if (!permissionsDeniedForever.isEmpty()) {
101-
PermissionHelper.showOpenAppSettingDialog();
101+
DialogHelper.showOpenAppSettingDialog();
102102
}
103103
LogUtils.d(permissionsDeniedForever, permissionsDenied);
104104
}
@@ -116,7 +116,7 @@ public void onActivityCreate(Activity activity) {
116116
.rationale(new PermissionUtils.OnRationaleListener() {
117117
@Override
118118
public void rationale(final ShouldRequest shouldRequest) {
119-
PermissionHelper.showRationaleDialog(shouldRequest);
119+
DialogHelper.showRationaleDialog(shouldRequest);
120120
}
121121
})
122122
.callback(new PermissionUtils.FullCallback() {
@@ -129,7 +129,7 @@ public void onGranted(List<String> permissionsGranted) {
129129
public void onDenied(List<String> permissionsDeniedForever,
130130
List<String> permissionsDenied) {
131131
if (!permissionsDeniedForever.isEmpty()) {
132-
PermissionHelper.showOpenAppSettingDialog();
132+
DialogHelper.showOpenAppSettingDialog();
133133
}
134134
LogUtils.d(permissionsDeniedForever, permissionsDenied);
135135
}

app/src/main/java/com/blankj/androidutilcode/feature/core/process/ProcessActivity.java

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.blankj.androidutilcode.R;
1010
import com.blankj.androidutilcode.base.BaseBackActivity;
1111
import com.blankj.utilcode.util.ProcessUtils;
12+
import com.blankj.utilcode.util.SpanUtils;
1213

1314
import java.util.Iterator;
1415
import java.util.Set;
@@ -47,9 +48,12 @@ public void initView(Bundle savedInstanceState, View view) {
4748
findViewById(R.id.btn_kill_all_background_processes).setOnClickListener(this);
4849
tvAboutProcess = findViewById(R.id.tv_about_process);
4950
Set<String> set = ProcessUtils.getAllBackgroundProcesses();
50-
tvAboutProcess.setText("getForegroundProcessName: " + ProcessUtils.getForegroundProcessName()
51-
+ "\n\ngetAllBackgroundProcesses: " + getSetItems(set)
52-
+ "\nsize: " + set.size());
51+
tvAboutProcess.setText(new SpanUtils()
52+
.appendLine("getForegroundProcessName: " + ProcessUtils.getForegroundProcessName())
53+
.appendLine("getAllBackgroundProcesses: " + getSetItems(set))
54+
.append("size: " + set.size())
55+
.create()
56+
);
5357
}
5458

5559
@Override
@@ -63,11 +67,14 @@ public void onWidgetClick(View view) {
6367
case R.id.btn_kill_all_background_processes:
6468
Set<String> set = ProcessUtils.getAllBackgroundProcesses();
6569
Set<String> set1 = ProcessUtils.killAllBackgroundProcesses();
66-
tvAboutProcess.setText("getForegroundProcessName: " + ProcessUtils.getForegroundProcessName()
67-
+ "\n\ngetAllBackgroundProcesses: " + getSetItems(set)
68-
+ "\nsize: " + set.size()
69-
+ "\n\nkillAllBackgroundProcesses: " + getSetItems(set1)
70-
+ "\nsize: " + set1.size());
70+
tvAboutProcess.setText(new SpanUtils()
71+
.appendLine("getForegroundProcessName: " + ProcessUtils.getForegroundProcessName())
72+
.appendLine("getAllBackgroundProcesses: " + getSetItems(set))
73+
.appendLine("size: " + set.size())
74+
.appendLine("killAllBackgroundProcesses: " + getSetItems(set1))
75+
.append("size: " + set1.size())
76+
.create()
77+
);
7178
break;
7279
}
7380
}

app/src/main/java/com/blankj/androidutilcode/feature/core/screen/ScreenActivity.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.blankj.androidutilcode.R;
1111
import com.blankj.androidutilcode.base.BaseBackActivity;
1212
import com.blankj.utilcode.util.ScreenUtils;
13+
import com.blankj.utilcode.util.SpanUtils;
1314

1415
/**
1516
* <pre>
@@ -49,14 +50,16 @@ public void initView(Bundle savedInstanceState, View view) {
4950
findViewById(R.id.btn_set_sleep_duration).setOnClickListener(this);
5051
ivScreenshot = findViewById(R.id.iv_screenshot);
5152
TextView tvAboutSdcard = findViewById(R.id.tv_about_screen);
52-
tvAboutSdcard.setText("getScreenWidth: " + ScreenUtils.getScreenWidth()
53-
+ "\ngetScreenHeight: " + ScreenUtils.getScreenHeight()
54-
+ "\nisLandscape: " + ScreenUtils.isLandscape()
55-
+ "\nisPortrait: " + ScreenUtils.isPortrait()
56-
+ "\ngetScreenRotation: " + ScreenUtils.getScreenRotation(this)
57-
+ "\nisScreenLock: " + ScreenUtils.isScreenLock()
58-
+ "\ngetSleepDuration: " + ScreenUtils.getSleepDuration()
59-
+ "\nisTablet: " + ScreenUtils.isTablet()
53+
tvAboutSdcard.setText(new SpanUtils()
54+
.appendLine("getScreenWidth: " + ScreenUtils.getScreenWidth())
55+
.appendLine("getScreenHeight: " + ScreenUtils.getScreenHeight())
56+
.appendLine("isLandscape: " + ScreenUtils.isLandscape())
57+
.appendLine("isPortrait: " + ScreenUtils.isPortrait())
58+
.appendLine("getScreenRotation: " + ScreenUtils.getScreenRotation(this))
59+
.appendLine("isScreenLock: " + ScreenUtils.isScreenLock())
60+
.appendLine("getSleepDuration: " + ScreenUtils.getSleepDuration())
61+
.append("isTablet: " + ScreenUtils.isTablet())
62+
.create()
6063
);
6164

6265

0 commit comments

Comments
 (0)