Skip to content

Commit 96812c0

Browse files
committed
see 10/30 log
1 parent 3155dcd commit 96812c0

File tree

3 files changed

+33
-16
lines changed

3 files changed

+33
-16
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88

99
dependencies {
1010
classpath depConfig.gradle
11-
classpath 'com.blankj:bus-gradle-plugin:1.0'
11+
classpath 'com.blankj:bus-gradle-plugin:1.3'
1212
// classpath depConfig.kotlin_gradle_plugin
1313
}
1414
}

utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import android.app.AppOpsManager;
77
import android.app.usage.UsageStats;
88
import android.app.usage.UsageStatsManager;
9-
import android.content.ComponentName;
109
import android.content.Context;
1110
import android.content.Intent;
1211
import android.content.pm.ApplicationInfo;
@@ -421,12 +420,22 @@ public static void launchApp(final Activity activity,
421420
* Relaunch the application.
422421
*/
423422
public static void relaunchApp() {
423+
relaunchApp(false);
424+
}
425+
426+
/**
427+
* Relaunch the application.
428+
*
429+
* @param isKillProcess True to kill the process, false otherwise.
430+
*/
431+
public static void relaunchApp(final boolean isKillProcess) {
424432
PackageManager packageManager = Utils.getApp().getPackageManager();
425433
Intent intent = packageManager.getLaunchIntentForPackage(Utils.getApp().getPackageName());
426434
if (intent == null) return;
427-
ComponentName componentName = intent.getComponent();
428-
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
429-
Utils.getApp().startActivity(mainIntent);
435+
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
436+
Utils.getApp().startActivity(intent);
437+
if (!isKillProcess) return;
438+
android.os.Process.killProcess(android.os.Process.myPid());
430439
System.exit(0);
431440
}
432441

utilcode/src/main/java/com/blankj/utilcode/util/ZipUtils.java

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,22 @@ public static List<File> unzipFileByKeyword(final File zipFile,
287287
List<File> files = new ArrayList<>();
288288
ZipFile zip = new ZipFile(zipFile);
289289
Enumeration<?> entries = zip.entries();
290-
if (isSpace(keyword)) {
291-
while (entries.hasMoreElements()) {
292-
ZipEntry entry = ((ZipEntry) entries.nextElement());
293-
if (!unzipChildFile(destDir, files, zip, entry)) return files;
294-
}
295-
} else {
296-
while (entries.hasMoreElements()) {
297-
ZipEntry entry = ((ZipEntry) entries.nextElement());
298-
if (entry.getName().contains(keyword)) {
290+
try {
291+
if (isSpace(keyword)) {
292+
while (entries.hasMoreElements()) {
293+
ZipEntry entry = ((ZipEntry) entries.nextElement());
299294
if (!unzipChildFile(destDir, files, zip, entry)) return files;
300295
}
296+
} else {
297+
while (entries.hasMoreElements()) {
298+
ZipEntry entry = ((ZipEntry) entries.nextElement());
299+
if (entry.getName().contains(keyword)) {
300+
if (!unzipChildFile(destDir, files, zip, entry)) return files;
301+
}
302+
}
301303
}
304+
} finally {
305+
zip.close();
302306
}
303307
return files;
304308
}
@@ -358,10 +362,12 @@ public static List<String> getFilesPath(final File zipFile)
358362
throws IOException {
359363
if (zipFile == null) return null;
360364
List<String> paths = new ArrayList<>();
361-
Enumeration<?> entries = new ZipFile(zipFile).entries();
365+
ZipFile zip = new ZipFile(zipFile);
366+
Enumeration<?> entries = zip.entries();
362367
while (entries.hasMoreElements()) {
363368
paths.add(((ZipEntry) entries.nextElement()).getName());
364369
}
370+
zip.close();
365371
return paths;
366372
}
367373

@@ -388,11 +394,13 @@ public static List<String> getComments(final File zipFile)
388394
throws IOException {
389395
if (zipFile == null) return null;
390396
List<String> comments = new ArrayList<>();
391-
Enumeration<?> entries = new ZipFile(zipFile).entries();
397+
ZipFile zip = new ZipFile(zipFile);
398+
Enumeration<?> entries = zip.entries();
392399
while (entries.hasMoreElements()) {
393400
ZipEntry entry = ((ZipEntry) entries.nextElement());
394401
comments.add(entry.getComment());
395402
}
403+
zip.close();
396404
return comments;
397405
}
398406

0 commit comments

Comments
 (0)