Skip to content

Commit

Permalink
tweakerinos
Browse files Browse the repository at this point in the history
  • Loading branch information
DrZed committed Sep 17, 2017
1 parent 80c6747 commit a35e62a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public void run() {
done = true;
}

public double getProgress() {
if (commandProcessing != -1)
return (getCommandsProgress() + getDownloadProgress() + getCompressionProgress()) / 3.0D;
else return (getDownloadProgress() + getCompressionProgress()) / 2.0D;
}

@SuppressWarnings("ResultOfMethodCallIgnored")
public void deleteLoseArchive() {
File looseFileDirectory = new File(downloadDir, title);
Expand Down Expand Up @@ -266,6 +272,10 @@ public synchronized double getCompressionProgress() {
return 0.0D;
}

public synchronized double getCommandsProgress() {
if (pages != 0) return (double) commandProcessing / (double) pages;
return 0.0D;
}
public synchronized String getTitle() {
return title;
}
Expand All @@ -284,10 +294,12 @@ public File getImage(String url, int id) {
return imageFile;
}

private int commandProcessing = -1;
public void processAndSaveGallery() {
if (Configuration.preCompressCommands.size() > 0) {
File looseFileDirectory = new File(downloadDir, title);
for (String command : Configuration.preCompressCommands) {
commandProcessing = 0;
File[] innerFiles = looseFileDirectory.listFiles();
assert innerFiles != null;

Expand All @@ -305,6 +317,7 @@ public void processAndSaveGallery() {
System.out.println(Arrays.toString(innerFiles));

for (File innerFile : innerFiles) {
commandProcessing++;
String[] clone = c.clone();
clone[index] = "\"" + innerFile.getPath() + "\"";
if (Configuration.debug)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,16 @@ public void clicked() {
}

public void mouseScrollEvent(ScrollEvent scrollEvent) {
if (scrollEvent.getDeltaY() < 0 && MainController.galleryIndex.size() > (MainController.listOffset + (MainGui.extraDownloaders_W + 2))) //scroll down
if (scrollEvent.getDeltaY() < 0 && MainController.galleryIndex.size() > 3 + (MainController.listOffset + ((MainGui.extraDownloaders_W + 1) * (MainGui.extraDownloaders_H + 1)))) {
MainController.listOffset += (MainGui.extraDownloaders_W + 1);
else if (scrollEvent.getDeltaY() > 0 && MainController.listOffset > 0) //scroll up
MainGui.instance.updateAll();
} else if (scrollEvent.getDeltaY() > 0 && MainController.listOffset > 0) {
MainController.listOffset -= (MainGui.extraDownloaders_W + 1);
if (MainController.listOffset < 0) MainController.listOffset = 0;
if (MainController.listOffset < 0)
MainController.listOffset = 0;
MainGui.instance.updateAll();
}

MainGui.instance.updateAll();
}

public void downloadGallery() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ private synchronized void start() {
Thread main = new Thread(() -> {
Thread background = new Thread(() -> {
while (running) {
while (downloader != null && !downloader.isDone() && progressBar != null && progressBar.getProgress() != (downloader.getDownloadProgress() + downloader.getCompressionProgress()) / 2.0D)
progressBar.setProgress((downloader.getDownloadProgress() + downloader.getCompressionProgress()) / 2.0D);
if (downloader != null && !downloader.isDone() && progressBar != null && progressBar.getProgress() != (downloader.getDownloadProgress() + downloader.getCompressionProgress()) / 2.0D)
progressBar.setProgress(downloader.getProgress());

if (galleryIndex.size() <= (MainGui.panes2d.size() + listOffset + Configuration.buffer))
MainController.instance.doSearch();
Expand All @@ -68,7 +68,7 @@ private synchronized void start() {
downloadQueue.setText("" + linkStack.size());
}

if (progressBar != null)
if (progressBar != null && progressBar.getProgress() != 0.0D)
progressBar.setProgress(0.0D);

if (!linkStack.empty())
Expand Down

0 comments on commit a35e62a

Please sign in to comment.