mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Fix issue with contructor not available on Android
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<packaging.type>jar</packaging.type>
|
<packaging.type>jar</packaging.type>
|
||||||
<build.min.memory>-Xms128m</build.min.memory>
|
<build.min.memory>-Xms128m</build.min.memory>
|
||||||
<build.max.memory>-Xmx1024m</build.max.memory>
|
<build.max.memory>-Xmx1024m</build.max.memory>
|
||||||
<alpha-version>1.5.34.003</alpha-version>
|
<alpha-version>1.5.34.004</alpha-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import forge.util.FileUtil;
|
|||||||
import forge.util.Utils;
|
import forge.util.Utils;
|
||||||
|
|
||||||
public class Forge implements ApplicationListener {
|
public class Forge implements ApplicationListener {
|
||||||
public static final String CURRENT_VERSION = "1.5.34.003";
|
public static final String CURRENT_VERSION = "1.5.34.004";
|
||||||
|
|
||||||
private static final ApplicationListener app = new Forge();
|
private static final ApplicationListener app = new Forge();
|
||||||
private static Clipboard clipboard;
|
private static Clipboard clipboard;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.io.InputStream;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -25,7 +24,7 @@ import forge.util.FileUtil;
|
|||||||
|
|
||||||
public class GuiDownloadZipService extends GuiDownloadService {
|
public class GuiDownloadZipService extends GuiDownloadService {
|
||||||
private final String name, desc, sourceUrl, destFolder, deleteFolder;
|
private final String name, desc, sourceUrl, destFolder, deleteFolder;
|
||||||
private int filesDownloaded;
|
private int filesExtracted;
|
||||||
|
|
||||||
public GuiDownloadZipService(String name0, String desc0, String sourceUrl0, String destFolder0, String deleteFolder0, IProgressBar progressBar0) {
|
public GuiDownloadZipService(String name0, String desc0, String sourceUrl0, String destFolder0, String deleteFolder0, IProgressBar progressBar0) {
|
||||||
name = name0;
|
name = name0;
|
||||||
@@ -60,7 +59,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
|||||||
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
FThreads.invokeInEdtNowOrLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
progressBar.setDescription(filesDownloaded + " " + desc + " downloaded");
|
progressBar.setDescription(filesExtracted + " " + desc + " extracted");
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -68,7 +67,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void downloadAndUnzip() {
|
public void downloadAndUnzip() {
|
||||||
filesDownloaded = 0;
|
filesExtracted = 0;
|
||||||
String zipFilename = download("temp.zip");
|
String zipFilename = download("temp.zip");
|
||||||
if (zipFilename == null) { return; }
|
if (zipFilename == null) { return; }
|
||||||
|
|
||||||
@@ -89,7 +88,7 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipFile zipFile = new ZipFile(zipFilename, Charset.forName("CP866")); //ensure unzip doesn't fail due to non UTF-8 chars
|
ZipFile zipFile = new ZipFile(zipFilename);
|
||||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||||
|
|
||||||
progressBar.reset();
|
progressBar.reset();
|
||||||
@@ -100,20 +99,31 @@ public class GuiDownloadZipService extends GuiDownloadService {
|
|||||||
FileUtil.ensureDirectoryExists(destFolder);
|
FileUtil.ensureDirectoryExists(destFolder);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int failedCount = 0;
|
||||||
while (entries.hasMoreElements()) {
|
while (entries.hasMoreElements()) {
|
||||||
if (cancel) { break; }
|
if (cancel) { break; }
|
||||||
|
|
||||||
ZipEntry entry = (ZipEntry)entries.nextElement();
|
try {
|
||||||
|
ZipEntry entry = (ZipEntry)entries.nextElement();
|
||||||
|
|
||||||
String path = destFolder + entry.getName();
|
String path = destFolder + entry.getName();
|
||||||
if (entry.isDirectory()) {
|
if (entry.isDirectory()) {
|
||||||
new File(path).mkdir();
|
new File(path).mkdir();
|
||||||
|
progressBar.setValue(++count);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
copyInputStream(zipFile.getInputStream(entry), path);
|
||||||
progressBar.setValue(++count);
|
progressBar.setValue(++count);
|
||||||
continue;
|
filesExtracted++;
|
||||||
}
|
}
|
||||||
copyInputStream(zipFile.getInputStream(entry), path);
|
catch (Exception e) { //don't quit out completely if an entry is not UTF-8
|
||||||
progressBar.setValue(++count);
|
progressBar.setValue(++count);
|
||||||
filesDownloaded++;
|
failedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failedCount > 0) {
|
||||||
|
Log.error("Downloading " + desc, failedCount + " " + desc + " could not be extracted");
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFile.close();
|
zipFile.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user