Skip to content

Commit

Permalink
Updates SaveAllSources.updateProgressBar(...)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanue1 committed Aug 15, 2015
1 parent 60a0d69 commit 2f8110a
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ import org.jd.gui.view.SaveAllSourcesView
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.concurrent.Callable
import java.util.concurrent.ExecutorService

class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSavable.Listener {
API api
SaveAllSourcesView saveAllSourcesView
boolean cancel
int counter
int step
int mask

SaveAllSourcesController(SwingBuilder swing, Configuration configuration, API api) {
this.api = api
Expand All @@ -39,19 +38,20 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava
executor.execute(new Runnable() {
void run() {
int fileCount = savable.fileCount
int quotient = (fileCount / 100)

saveAllSourcesView.updateProgressBar(0)
saveAllSourcesView.setMaxValue(fileCount)

cancel = false
counter = 0
step = 1
mask = 2

while (quotient > step) {
step <<= 1
while (fileCount > 64) {
fileCount >>= 1
mask <<= 1
}
step = (step >> 1) - 1

saveAllSourcesView.updateProgressBar(counter)
saveAllSourcesView.setMaxValue(fileCount)
mask--

def path = Paths.get(file.toURI())
Files.deleteIfExists(path)
Expand Down Expand Up @@ -81,7 +81,7 @@ class SaveAllSourcesController implements SourcesSavable.Controller, SourcesSava

// --- SourcesSavable.Listener --- //
void pathSaved(Path path) {
if (((counter++) & step) == 0) {
if (((counter++) & mask) == 0) {
saveAllSourcesView.updateProgressBar(counter)
}
}
Expand Down

0 comments on commit 2f8110a

Please sign in to comment.