private void restoreState(Bundle state) { /* * need reference to the app so you can access curDirFiles * as well as processing status */ app = (AndroidCloudApplication) this.getApplication(); if (state != null && state.containsKey("displayDialog") && state.getBoolean("displayDialog")) { showDialog(); } else { hideDialog(); } if (state != null && state.containsKey("container")) { objects = (ContainerObjects) state.getSerializable("container"); } loadObjectData(); if (cdnEnabled.equals("true")) { this.previewButton = (Button) findViewById(R.id.preview_button); previewButton.setOnClickListener(new MyOnClickListener()); } else { this.previewButton = (Button) findViewById(R.id.preview_button); previewButton.setVisibility(View.GONE); } if (state != null && state.containsKey("isDownloaded")) { isDownloaded = state.getBoolean("isDownloaded"); } else { isDownloaded = fileIsDownloaded(); } this.downloadButton = (Button) findViewById(R.id.download_button); if (isDownloaded) { downloadButton.setText("Open File"); } else { downloadButton.setText("Download File"); } downloadButton.setOnClickListener(new MyOnClickListener()); if (app.isDeletingObject()) { deleteObjTask = new DeleteObjectListenerTask(); deleteObjTask.execute(); } if (app.isDownloadingObject()) { downloadObjTask = new DownloadObjectListenerTask(); downloadObjTask.execute(); } }
@Override protected void onStop() { super.onStop(); if (displayDialog) { hideDialog(); displayDialog = true; } /* * Need to stop running listener task * if we exit */ if (deleteObjTask != null) { deleteObjTask.cancel(true); } if (downloadObjTask != null) { downloadObjTask.cancel(true); } }