Loading src/main/java/ecorp/easy/installer/controllers/subcontrollers/DownloadSrcController.java +14 −18 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package ecorp.easy.installer.controllers.subcontrollers; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.MainWindowController; import ecorp.easy.installer.helpers.DeviceHelper; import ecorp.easy.installer.models.RomSource; import ecorp.easy.installer.tasks.CommandExecutionTask; import ecorp.easy.installer.tasks.DownloadTask; import ecorp.easy.installer.utils.UiUtils; import java.io.IOException; import java.net.URL; import java.text.ParseException; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; Loading Loading @@ -61,16 +58,17 @@ public class DownloadSrcController extends AbstractSubController { public void initialize(URL location, ResourceBundle resources) { super.initialize(location, resources); UiUtils.hideNode(restartDownloadBtn); currentService = new DownloadService(); } @Override public void setParentController(MainWindowController parentController){ super.setParentController(parentController); //@todo replace with parentController.getPreparationprocess.getSourcesToDownload(); //Also move the try catch when we load preparationprocess sourcesToDownload = parentController.getPhone().getPrepProcess().getSourcesToDownload(); sourceIterator = sourcesToDownload.entrySet().iterator(); /*try{ //sourcesToDownload = DeviceHelper.getSourcesToDownload(parentController.getPhone().getAdbDevice()); Loading @@ -80,24 +78,26 @@ public class DownloadSrcController extends AbstractSubController { return; }*/ sourceIterator = sourcesToDownload.entrySet().iterator(); startNextDownload(); } private boolean startNextDownload(){ /** * Start to download a part of the rom * or display complete Downloading */ private void startNextDownload(){ logger.info("startNextDownload()"); logger.debug("taskIterator has next ? {} "+sourceIterator.hasNext()); if(sourceIterator.hasNext()){ HashMap.Entry<String, RomSource> source = sourceIterator.next(); currentService = new DownloadService(source.getValue()); currentService.setSource(source.getValue()); bindProgressUIToService(currentService); currentService.reset(); currentService.start(); return true; } return false; }else onDownloadsComplete(); //Looks like a side effect... } /** Loading Loading @@ -183,10 +183,6 @@ public class DownloadSrcController extends AbstractSubController { private RomSource source; public DownloadService(final RomSource source){ this.source = source; } /** * Change the source to download to a new one * @param source Loading @@ -206,7 +202,7 @@ public class DownloadSrcController extends AbstractSubController { unbindProgressUI(); if((Boolean) this.getValue() ){ //This read the "value" (boolean) defined at end of run in DownloadTask //So here: it returns true if file is downloaded and checksum verified if(! startNextDownload() ) onDownloadsComplete(); //if no more download to do, then preparation is over startNextDownload(); }else{ //either download or checksum checks failed displayErrorProgressBar(false); } Loading Loading
src/main/java/ecorp/easy/installer/controllers/subcontrollers/DownloadSrcController.java +14 −18 Original line number Diff line number Diff line Loading @@ -19,14 +19,11 @@ package ecorp.easy.installer.controllers.subcontrollers; import ecorp.easy.installer.AppConstants; import ecorp.easy.installer.controllers.MainWindowController; import ecorp.easy.installer.helpers.DeviceHelper; import ecorp.easy.installer.models.RomSource; import ecorp.easy.installer.tasks.CommandExecutionTask; import ecorp.easy.installer.tasks.DownloadTask; import ecorp.easy.installer.utils.UiUtils; import java.io.IOException; import java.net.URL; import java.text.ParseException; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; Loading Loading @@ -61,16 +58,17 @@ public class DownloadSrcController extends AbstractSubController { public void initialize(URL location, ResourceBundle resources) { super.initialize(location, resources); UiUtils.hideNode(restartDownloadBtn); currentService = new DownloadService(); } @Override public void setParentController(MainWindowController parentController){ super.setParentController(parentController); //@todo replace with parentController.getPreparationprocess.getSourcesToDownload(); //Also move the try catch when we load preparationprocess sourcesToDownload = parentController.getPhone().getPrepProcess().getSourcesToDownload(); sourceIterator = sourcesToDownload.entrySet().iterator(); /*try{ //sourcesToDownload = DeviceHelper.getSourcesToDownload(parentController.getPhone().getAdbDevice()); Loading @@ -80,24 +78,26 @@ public class DownloadSrcController extends AbstractSubController { return; }*/ sourceIterator = sourcesToDownload.entrySet().iterator(); startNextDownload(); } private boolean startNextDownload(){ /** * Start to download a part of the rom * or display complete Downloading */ private void startNextDownload(){ logger.info("startNextDownload()"); logger.debug("taskIterator has next ? {} "+sourceIterator.hasNext()); if(sourceIterator.hasNext()){ HashMap.Entry<String, RomSource> source = sourceIterator.next(); currentService = new DownloadService(source.getValue()); currentService.setSource(source.getValue()); bindProgressUIToService(currentService); currentService.reset(); currentService.start(); return true; } return false; }else onDownloadsComplete(); //Looks like a side effect... } /** Loading Loading @@ -183,10 +183,6 @@ public class DownloadSrcController extends AbstractSubController { private RomSource source; public DownloadService(final RomSource source){ this.source = source; } /** * Change the source to download to a new one * @param source Loading @@ -206,7 +202,7 @@ public class DownloadSrcController extends AbstractSubController { unbindProgressUI(); if((Boolean) this.getValue() ){ //This read the "value" (boolean) defined at end of run in DownloadTask //So here: it returns true if file is downloaded and checksum verified if(! startNextDownload() ) onDownloadsComplete(); //if no more download to do, then preparation is over startNextDownload(); }else{ //either download or checksum checks failed displayErrorProgressBar(false); } Loading