pull all URLDecoder.decode calls into one method and suppress the warning since changing it appears to have broken things before.

This commit is contained in:
Ryan1729
2019-10-06 02:00:12 -06:00
parent ea25ad2c3b
commit d53eb3a3fe

View File

@@ -264,12 +264,8 @@ public abstract class GuiDownloadService implements Runnable {
count++; count++;
cardSkipped = true; //assume skipped unless saved successfully cardSkipped = true; //assume skipped unless saved successfully
String url = kv.getValue(); String url = kv.getValue();
/*
* decode URL Key, Reverted to old version, String decodedKey = decodeURL(kv.getKey());
* on Android 6.0 it throws an error
* when you download the card price
*/
String decodedKey = URLDecoder.decode(kv.getKey());
final File fileDest = new File(decodedKey); final File fileDest = new File(decodedKey);
final String filePath = fileDest.getPath(); final String filePath = fileDest.getPath();
final String subLastIndex = filePath.contains("pics") ? "\\pics\\" : "\\db\\"; final String subLastIndex = filePath.contains("pics") ? "\\pics\\" : "\\db\\";
@@ -365,6 +361,16 @@ public abstract class GuiDownloadService implements Runnable {
GuiBase.getInterface().preventSystemSleep(false); GuiBase.getInterface().preventSystemSleep(false);
} }
@SuppressWarnings("deprecation")
private static String decodeURL(String key) {
/*
* decode URL Key, Reverted to old version,
* on Android 6.0 it throws an error
* when you download the card price
*/
return URLDecoder.decode(key);
}
protected Proxy getProxy() { protected Proxy getProxy() {
if (type == 0) { if (type == 0) {
return Proxy.NO_PROXY; return Proxy.NO_PROXY;
@@ -385,7 +391,7 @@ public abstract class GuiDownloadService implements Runnable {
protected static void addMissingItems(Map<String, String> list, String nameUrlFile, String dir) { protected static void addMissingItems(Map<String, String> list, String nameUrlFile, String dir) {
for (Pair<String, String> nameUrlPair : FileUtil.readNameUrlFile(nameUrlFile)) { for (Pair<String, String> nameUrlPair : FileUtil.readNameUrlFile(nameUrlFile)) {
File f = new File(dir, URLDecoder.decode(nameUrlPair.getLeft())); File f = new File(dir, decodeURL(nameUrlPair.getLeft()));
//System.out.println(f.getAbsolutePath()); //System.out.println(f.getAbsolutePath());
if (!f.exists()) { if (!f.exists()) {
list.put(f.getAbsolutePath(), nameUrlPair.getRight()); list.put(f.getAbsolutePath(), nameUrlPair.getRight());