Fix on Android downloader and code indent

This commit is contained in:
valfieri
2019-08-23 12:58:10 +02:00
parent 30622010df
commit 9dfd513ad3
2 changed files with 550 additions and 712 deletions
@@ -4,9 +4,11 @@ import org.jsoup.Jsoup;
import org.jsoup.nodes.Document; import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element; import org.jsoup.nodes.Element;
import org.jsoup.select.Elements; import org.jsoup.select.Elements;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.Enumeration; import java.util.Enumeration;
import net.lingala.zip4j.model.ZipParameters; import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.CompressionMethod; import net.lingala.zip4j.model.enums.CompressionMethod;
@@ -35,7 +37,8 @@ public class ImgDownloader {
break; break;
out.append(buffer, 0, rsz); out.append(buffer, 0, rsz);
} }
} catch (Exception e) {} } catch (Exception e) {
}
return out.toString(); return out.toString();
} }
@@ -97,19 +100,21 @@ public class ImgDownloader {
bos.close(); bos.close();
cardsfilepath = filePath.toString(); cardsfilepath = filePath.toString();
todelete = true; todelete = true;
} catch (Exception ex) {} } catch (Exception ex) {
}
break; break;
} }
} }
} }
} }
} catch (IOException ioe){ } } catch (IOException ioe) {
finally { } finally {
try { try {
if (zipFile != null) { if (zipFile != null) {
zipFile.close(); zipFile.close();
} }
} catch (IOException ioe) {} } catch (IOException ioe) {
}
} }
} else { } else {
File setFolder = new File(path + File.separator + "sets" + File.separator + setName + File.separator); File setFolder = new File(path + File.separator + "sets" + File.separator + setName + File.separator);
@@ -148,9 +153,11 @@ public class ImgDownloader {
return tokendoc; return tokendoc;
} }
} }
} catch (Exception e) {} } catch (Exception e) {
}
}
} catch (Exception e) {
} }
} catch (Exception e){}
System.out.println("Warning: Token " + name + " has not been found between " + set + " tokens, i will search for it between any other set..."); System.out.println("Warning: Token " + name + " has not been found between " + set + " tokens, i will search for it between any other set...");
for (int i = 1; i < availableSets.length; i++) { for (int i = 1; i < availableSets.length; i++) {
String currentSet = availableSets[i].toLowerCase().split(" - ")[0]; String currentSet = availableSets[i].toLowerCase().split(" - ")[0];
@@ -170,9 +177,11 @@ public class ImgDownloader {
return tokendoc; return tokendoc;
} }
} }
} catch (Exception e) {} } catch (Exception e) {
}
}
} catch (Exception e) {
} }
} catch (Exception e) {}
} }
} }
System.err.println("Error: Token " + name + " has not been found between any set of " + imageurl); System.err.println("Error: Token " + name + " has not been found between any set of " + imageurl);
@@ -267,7 +276,7 @@ public class ImgDownloader {
int lastIndex = lines.indexOf(findStr); int lastIndex = lines.indexOf(findStr);
String totals = lines.substring(lastIndex, lines.indexOf("\n", lastIndex)); String totals = lines.substring(lastIndex, lines.indexOf("\n", lastIndex));
totalcards = Integer.parseInt(totals.split("=")[1]); totalcards = Integer.parseInt(totals.split("=")[1]);
for (int i = 0; i < totalcards; i++) { while (lines.contains("[card]")) {
findStr = "[card]"; findStr = "[card]";
lastIndex = lines.indexOf(findStr); lastIndex = lines.indexOf(findStr);
String id = null; String id = null;
@@ -593,7 +602,8 @@ public class ImgDownloader {
try { try {
File oldzip = new File(destinationPath + "/" + set + "/" + set + ".zip"); File oldzip = new File(destinationPath + "/" + set + "/" + set + ".zip");
oldzip.delete(); oldzip.delete();
} catch (Exception e) {} } catch (Exception e) {
}
ZipParameters zipParameters = new ZipParameters(); ZipParameters zipParameters = new ZipParameters();
zipParameters.setCompressionMethod(CompressionMethod.STORE); zipParameters.setCompressionMethod(CompressionMethod.STORE);
File folder = new File(destinationPath + set + "/"); File folder = new File(destinationPath + set + "/");
File diff suppressed because it is too large Load Diff