+
+ @Override
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+ super.onRemoteOperationFinish(operation, result);
+
+
+ if (operation instanceof CreateFolderOperation) {
+ onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+ }
+
+ }
+
+ /**
+ * Updates the view associated to the activity after the finish of an operation
+ * trying create a new folder
+ *
+ * @param operation Creation operation performed.
+ * @param result Result of the creation.
+ */
+ private void onCreateFolderOperationFinish(CreateFolderOperation operation,
+ RemoteOperationResult result) {
+ if (result.isSuccess()) {
+ dismissLoadingDialog();
+ populateDirectoryList();
+ } else {
+ dismissLoadingDialog();
+ try {
+ Toast msg = Toast.makeText(this,
+ ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()),
+ Toast.LENGTH_LONG);
+ msg.show();
+
+ } catch (NotFoundException e) {
+ Log_OC.e(TAG, "Error while trying to show fail message " , e);
+ }
+ }
+ }
+
+
+ /**
+ * Loads the target folder initialize shown to the user.
+ *
+ * The target account has to be chosen before this method is called.
+ */
+ private void initTargetFolder() {
+ if (getStorageManager() == null) {
+ throw new IllegalStateException("Do not call this method before " +
+ "initializing mStorageManager");
+ }
+
+ SharedPreferences appPreferences = PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext());
+
+ String last_path = appPreferences.getString("last_upload_path", "");
+ // "/" equals root-directory
+ if(last_path.equals("/")) {
+ mParents.add("");
+ } else{
+ String[] dir_names = last_path.split("/");
+ mParents.clear();
+ for (String dir : dir_names)
+ mParents.add(dir);
+ }
+ //Make sure that path still exists, if it doesn't pop the stack and try the previous path
+ while(!getStorageManager().fileExists(generatePath(mParents)) && mParents.size() > 1){
+ mParents.pop();
+ }
+ }