1
0
mirror of https://gitcode.com/gh_mirrors/re/react-native-pushy.git synced 2025-09-17 23:46:15 +08:00
Code Issues Packages Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
Yun
2019-03-22 20:47:01 +08:00
parent 7b7d8a9ec8
commit 88c80390d8
3 changed files with 48 additions and 33 deletions

View File

@@ -22,6 +22,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
@@ -250,17 +251,19 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
}
}
private void copyFromResource(HashMap<String, File> map) throws IOException {
private void copyFromResource(HashMap<String, ArrayList<File> > map) throws IOException {
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(context.getPackageResourcePath())));
ZipEntry ze;
while ((ze = zis.getNextEntry()) != null) {
String fn = ze.getName();
File target = map.get(fn);
if (target != null) {
if (UpdateContext.DEBUG) {
Log.d("RNUpdate", "Copying from resource " + fn + " to " + target);
ArrayList<File> targets = map.get(fn);
if (targets != null) {
for (File target: targets) {
if (UpdateContext.DEBUG) {
Log.d("RNUpdate", "Copying from resource " + fn + " to " + target);
}
unzipToFile(zis, target);
}
unzipToFile(zis, target);
}
}
}
@@ -276,7 +279,7 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
removeDirectory(param.unzipDirectory);
param.unzipDirectory.mkdirs();
HashMap<String, File> copyList = new HashMap<String, File>();
HashMap<String, ArrayList<File>> copyList = new HashMap<String, ArrayList<File>>();
while ((ze = zis.getNextEntry()) != null)
{
@@ -296,7 +299,14 @@ class DownloadTask extends AsyncTask<DownloadTaskParams, Void, Void> {
if (from.isEmpty()) {
from = to;
}
copyList.put(from, new File(param.unzipDirectory, to));
ArrayList<File> target = null;
if (!copyList.containsKey(from)) {
target = new ArrayList<File>();
copyList.put(from, target);
} else {
target = copyList.get((from));
}
target.add(new File(param.unzipDirectory, to));
//copyFromResource(from, new File(param.unzipDirectory, to));
}
continue;