Skip to content

Commit

Permalink
see 10/30 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Blankj committed Oct 30, 2018
1 parent 3155dcd commit 96812c0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {

dependencies {
classpath depConfig.gradle
classpath 'com.blankj:bus-gradle-plugin:1.0'
classpath 'com.blankj:bus-gradle-plugin:1.3'
// classpath depConfig.kotlin_gradle_plugin
}
}
Expand Down
17 changes: 13 additions & 4 deletions utilcode/src/main/java/com/blankj/utilcode/util/AppUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import android.app.AppOpsManager;
import android.app.usage.UsageStats;
import android.app.usage.UsageStatsManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
Expand Down Expand Up @@ -421,12 +420,22 @@ public static void launchApp(final Activity activity,
* Relaunch the application.
*/
public static void relaunchApp() {
relaunchApp(false);
}

/**
* Relaunch the application.
*
* @param isKillProcess True to kill the process, false otherwise.
*/
public static void relaunchApp(final boolean isKillProcess) {
PackageManager packageManager = Utils.getApp().getPackageManager();
Intent intent = packageManager.getLaunchIntentForPackage(Utils.getApp().getPackageName());
if (intent == null) return;
ComponentName componentName = intent.getComponent();
Intent mainIntent = Intent.makeRestartActivityTask(componentName);
Utils.getApp().startActivity(mainIntent);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
Utils.getApp().startActivity(intent);
if (!isKillProcess) return;
android.os.Process.killProcess(android.os.Process.myPid());
System.exit(0);
}

Expand Down
30 changes: 19 additions & 11 deletions utilcode/src/main/java/com/blankj/utilcode/util/ZipUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -287,18 +287,22 @@ public static List<File> unzipFileByKeyword(final File zipFile,
List<File> files = new ArrayList<>();
ZipFile zip = new ZipFile(zipFile);
Enumeration<?> entries = zip.entries();
if (isSpace(keyword)) {
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
if (!unzipChildFile(destDir, files, zip, entry)) return files;
}
} else {
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
if (entry.getName().contains(keyword)) {
try {
if (isSpace(keyword)) {
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
if (!unzipChildFile(destDir, files, zip, entry)) return files;
}
} else {
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
if (entry.getName().contains(keyword)) {
if (!unzipChildFile(destDir, files, zip, entry)) return files;
}
}
}
} finally {
zip.close();
}
return files;
}
Expand Down Expand Up @@ -358,10 +362,12 @@ public static List<String> getFilesPath(final File zipFile)
throws IOException {
if (zipFile == null) return null;
List<String> paths = new ArrayList<>();
Enumeration<?> entries = new ZipFile(zipFile).entries();
ZipFile zip = new ZipFile(zipFile);
Enumeration<?> entries = zip.entries();
while (entries.hasMoreElements()) {
paths.add(((ZipEntry) entries.nextElement()).getName());
}
zip.close();
return paths;
}

Expand All @@ -388,11 +394,13 @@ public static List<String> getComments(final File zipFile)
throws IOException {
if (zipFile == null) return null;
List<String> comments = new ArrayList<>();
Enumeration<?> entries = new ZipFile(zipFile).entries();
ZipFile zip = new ZipFile(zipFile);
Enumeration<?> entries = zip.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
comments.add(entry.getComment());
}
zip.close();
return comments;
}

Expand Down

0 comments on commit 96812c0

Please sign in to comment.