Skip to content
Snippets Groups Projects
Commit 3895f65a authored by Drahomír Karchňák's avatar Drahomír Karchňák
Browse files

#29 Removed "not enough space' dialog due to various problems...

parent 3b9f0ff6
No related branches found
No related tags found
No related merge requests found
......@@ -74,9 +74,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
private static boolean requestAccepted = false;
private static boolean downloadPaused = false;
private static boolean freeSpaceDialogRequested = false;
private static boolean freeSpaceDialogShown = false;
private Locale locale;
private Map<String, String> buildChecksum;
private Stage stage;
......@@ -115,15 +112,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
showRequestDialog();
}
//Show free space dialog ?
if(freeSpaceDialogRequested && !freeSpaceDialogShown) {
showFreeSpaceDialog();
}
if(freeSpaceDialogRequested) {
return false;
}
return super.update();
}
......@@ -140,17 +128,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
this ).show(stage);
}
private void showFreeSpaceDialog() {
freeSpaceDialogShown = true;
Log.info(ZipAssetLoader.class, "Not enough free space dialog has been shown");
String dialogContent = ApplicationTextManager.getInstance().getText(ApplicationTextManager.ApplicationTextsAssets.ZIPASSETLOADER_NOT_ENOUGH_SPACE);
new LoaderFreeSpaceDialog( Tablexia.ERROR_DIALOG_WIDTH,
Tablexia.ERROR_DIALOG_HEIGHT,
new DialogTextContent(dialogContent)).show(stage);
}
/**
* Accepts the download request and notifies the downloading thread
*/
......@@ -162,10 +139,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
}
}
public void requestFreeSpaceDialog() {
freeSpaceDialogRequested = true;
}
/**
* Event that is emitted when loader starts to check assets files
*/
......@@ -335,17 +308,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
return false;
}
/**
* Checks if there is enough place to save asset file
* @param destinationFolder
* @param fileLength
* @return true if there is enough space
*/
private boolean checkFreeSpace(String destinationFolder, long fileLength) {
return new File(destinationFolder).getUsableSpace() > fileLength;
}
//////////////////////////// DOWNLOAD
private void prepareKeyStore() {
......@@ -379,9 +341,6 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
Log.info(ZipAssetLoader.class, String.format("Checksum or assets package file not found!", zipFileName));
}
if(freeSpaceDialogRequested)
return false;
/*
* If user is using mobile data
* Stop the thread and wait for the user to accept Request Download Dialog
......@@ -402,23 +361,18 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
return false;
}
if(checkFreeSpace(TablexiaAbstractFileManager.getFileStoragePath(TablexiaAbstractFileManager.DownloadStorageType.EXTERNAL), ASSET_FILE_SIZE)) {
// download assets package checksum
Log.info(ZipAssetLoader.class, String.format("Downloading checksum file: %s try %d/%d", checksumFileName, tryCounter + 1, DOWNLOAD_TRY_COUNT));
startTimer();
downloadToOutputStream(fileName + CHECKSUM_FILE_EXTENSION, checksumFileHandle.write(false));
resultTimer("Download delay of " + checksumFileName);
Log.info(ZipAssetLoader.class, String.format("Downloading assets package file: %s try %d/%d", zipFileName, tryCounter + 1, DOWNLOAD_TRY_COUNT));
startTimer();
downloadToOutputStream(fileName + ZIP_FILE_EXTENSION, zipFileHandle.write(false));
resultTimer("Download delay of " + zipFileName);
tryCounter++;
}
else{
zipAssetLoader.requestFreeSpaceDialog();
}
// download assets package checksum
Log.info(ZipAssetLoader.class, String.format("Downloading checksum file: %s try %d/%d", checksumFileName, tryCounter + 1, DOWNLOAD_TRY_COUNT));
startTimer();
downloadToOutputStream(fileName + CHECKSUM_FILE_EXTENSION, checksumFileHandle.write(false));
resultTimer("Download delay of " + checksumFileName);
Log.info(ZipAssetLoader.class, String.format("Downloading assets package file: %s try %d/%d", zipFileName, tryCounter + 1, DOWNLOAD_TRY_COUNT));
startTimer();
downloadToOutputStream(fileName + ZIP_FILE_EXTENSION, zipFileHandle.write(false));
resultTimer("Download delay of " + zipFileName);
tryCounter++;
}
}
......@@ -457,11 +411,11 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
ApplicationBus.getInstance().post(new FileDownloadEvent(FileDownloadEvent.FileDownloadEventType.Finished, fileName, 1)).asynchronously();
downloadResult = true;
} catch (IOException e) {
Log.err(ZipAssetLoader.class, "Cannot download file: " + fileName + " !", e);
downloadResult = false;
} catch (IOException e) {
Log.err(ZipAssetLoader.class, "Cannot download file: " + fileName + " !", e);
downloadResult = false;
}
notifyDownload();
notifyDownload();
}
@Override
......@@ -629,42 +583,4 @@ public class ZipAssetLoader extends TablexiaDataManager<Void> implements IApplic
createButton(button, clickListener);
}
}
/**
* Dialog that shows up when there is not enough free space
*/
private static class LoaderFreeSpaceDialog extends AbstractButtonDialog {
public LoaderFreeSpaceDialog(float width, float height, DialogTextContent dialogTextContent) {
super((Gdx.graphics.getWidth() / 2) - (width / 2),
(Gdx.graphics.getHeight() / 2) - (height / 2),
width,
height,
new NinePatchDrawable(new NinePatch(new Texture(Gdx.files.internal(Tablexia.ERROR_DIALOG_BACKGROUND_INTERNAL)))),
dialogTextContent);
setModal(true);
createButton(Tablexia.ERROR_BUTTON_RED_UNPRESSED_INTERNAL,
Tablexia.ERROR_BUTTON_RED_PRESSED_INTERNAL,
ApplicationTextManager.ApplicationTextsAssets.SYSTEM_EXIT,
new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Gdx.app.exit();
}
});
}
private void createButton(String unpressed, String pressed, String textKey, ClickListener clickListener) {
TablexiaButton button = new TablexiaButton(new NinePatchDrawable(new NinePatch(new Texture(Gdx.files.internal(unpressed)))),
new NinePatchDrawable(new NinePatch(new Texture(Gdx.files.internal(pressed)))),
null,
null,
ApplicationTextManager.getInstance().getText(textKey));
createButton(button, clickListener);
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment