Skip to content

Commit 9905c2a

Browse files
[Fix]ProgressBar,Reset Buttons
1 parent 42e6aca commit 9905c2a

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

mode/tools/SDKUpdater/src/processing/mode/android/tools/SDKUpdater.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,12 @@ public int compare(String o1, String o2) {
336336

337337
class DownloadTask extends SwingWorker<Object, Object> {
338338
ProgressIndicator progress;
339-
JProgressBar progressBar;
340339
Boolean isPlatform;
341340
JLabel status;
342341

343342
DownloadTask(JProgressBar progressBar, Boolean isPlatform,JLabel status) {
344343
super();
345344
progress = new ConsoleProgressIndicator();
346-
this.progressBar = progressBar;
347345
this.isPlatform = isPlatform;
348346
this.status = status;
349347
}
@@ -388,11 +386,15 @@ protected Object doInBackground() throws Exception {
388386
for (RemotePackage p : remotes) {
389387
Installer installer = SdkInstallerUtil.findBestInstallerFactory(p, mHandler)
390388
.createInstaller(p, mRepoManager, downloader, mHandler.getFileOp());
391-
status.setText("Downloading...");
392-
if (!(installer.prepare(progress) && installer.complete(progress))) {
393-
// there was an error, abort.
394-
throw new SdkManagerCli.CommandFailedException();
395-
}
389+
status.setText("Downloading. . .");
390+
if ((installer.prepare(progress))) {
391+
if(isPlatform) statusPlatform.setText("Unzipping. . .");
392+
else status.setText("Unzipping");
393+
if (!installer.complete(progress)) {
394+
// there was an error, abort.
395+
throw new SdkManagerCli.CommandFailedException();
396+
}
397+
} else throw new SdkManagerCli.CommandFailedException();
396398
}
397399
} else {
398400
progress.logWarning("Unable to compute a complete list of dependencies.");
@@ -405,17 +407,16 @@ protected Object doInBackground() throws Exception {
405407
@Override
406408
protected void done() {
407409
super.done();
408-
409410
try {
410411
get();
411412
actionButton.setEnabled(false);
412413
tabs.setEnabled(true);
413414
status.setText("Refreshing packages...");
414415
statusPlatform.setText("Refreshing packages...");
415416

416-
//reset the progress bar to indeterminate for querying
417-
progressBar.setIndeterminate(false);
418-
progressBarPlatform.setIndeterminate(false);
417+
//reset Buttons
418+
actionButton.setText("Update");
419+
actionButtonPlatform.setText("Install");
419420

420421
//start querying again
421422
queryTask = new QueryTask();
@@ -430,7 +431,6 @@ protected void done() {
430431
e.printStackTrace();
431432
} finally {
432433
downloadTaskRunning = false;
433-
this.progressBar.setIndeterminate(false);
434434
}
435435
}
436436

@@ -501,6 +501,8 @@ public void run() {
501501
} catch (InterruptedException e) { }
502502
bar.setValue((int) (downloadTask.progress.getFraction() * 100));
503503
}
504+
bar.setValue(0);
505+
bar.setIndeterminate(true);
504506
}
505507
};
506508
update.start();

0 commit comments

Comments
 (0)