This commit is contained in:
huanghongxun
2015-12-17 18:06:19 +08:00
parent 81443b8252
commit 2b17095c88
15 changed files with 521 additions and 14 deletions

View File

@@ -183,7 +183,11 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
}
public static void download(String url, String file, DownloadListener dl) throws Throwable {
((Task) new FileDownloadTask(url, new File(file)).setProgressProviderListener(dl)).executeTask();
download(url, new File(file), dl);
}
public static void download(String url, File file, DownloadListener dl) throws Throwable {
((Task) new FileDownloadTask(url, file).setProgressProviderListener(dl)).executeTask();
}
@Override

View File

@@ -1,7 +1,7 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
@@ -27,7 +27,7 @@ import java.io.UnsupportedEncodingException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URI;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLDecoder;
@@ -41,6 +41,16 @@ import org.jackhuang.hellominecraft.HMCLog;
*/
public final class Utils {
@SuppressWarnings("ResultOfObjectAllocationIgnored")
public static boolean isURL(String s) {
try {
new URL(s);
return true;
} catch (MalformedURLException ex) {
return false;
}
}
public static String[] getURL() {
URL[] urls = ((URLClassLoader) Utils.class.getClassLoader()).getURLs();
String[] urlStrings = new String[urls.length];
@@ -133,7 +143,8 @@ public final class Utils {
}
}
if (background == null) return init;
if (background == null)
return init;
return background;
}

View File

@@ -30,7 +30,7 @@ public class Selector extends javax.swing.JDialog {
* The index of the chosen in select list.
*/
public int sel;
public static int failedToSel = -1;
public static final int FAILED_TO_SELECT = -1;
/**
* @param parent null
@@ -44,7 +44,7 @@ public class Selector extends javax.swing.JDialog {
setLocationRelativeTo(null);
this.selList = selList;
this.sel = failedToSel;
this.sel = FAILED_TO_SELECT;
this.msg = msg;
jLabel1.setText(msg);
for (String s : selList)
@@ -127,7 +127,7 @@ public class Selector extends javax.swing.JDialog {
}// </editor-fold>//GEN-END:initComponents
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
sel = failedToSel;
sel = FAILED_TO_SELECT;
this.dispose();
}//GEN-LAST:event_btnCancelActionPerformed