X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/97b36b23359f29ee77e91c48ee79f11edb91c5c9..a468ae6a2da00fe0a685abbf23d77eaa5fb0a13e:/src/com/owncloud/android/ui/activity/FileActivity.java diff --git a/src/com/owncloud/android/ui/activity/FileActivity.java b/src/com/owncloud/android/ui/activity/FileActivity.java index bebc1437..6b8fa43d 100644 --- a/src/com/owncloud/android/ui/activity/FileActivity.java +++ b/src/com/owncloud/android/ui/activity/FileActivity.java @@ -58,6 +58,7 @@ import com.owncloud.android.operations.UnshareLinkOperation; import com.owncloud.android.services.OperationsService; import com.owncloud.android.services.OperationsService.OperationsServiceBinder; import com.owncloud.android.ui.dialog.LoadingDialog; +import com.owncloud.android.utils.ErrorMessageAdapter; import com.owncloud.android.utils.Log_OC; @@ -180,9 +181,6 @@ implements OnRemoteOperationListener, ComponentsGetter { if (mAccountWasSet) { onAccountSet(mAccountWasRestored); } - if (mOperationsServiceBinder != null) { - mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler); - } } @Override @@ -204,20 +202,9 @@ implements OnRemoteOperationListener, ComponentsGetter { super.onPause(); } - @Override - protected void onStop() { - - if (mOperationsServiceBinder != null) { - mOperationsServiceBinder.removeOperationListener(this); - } - - super.onStop(); - } - @Override protected void onDestroy() { - super.onDestroy(); if (mOperationsServiceConnection != null) { unbindService(mOperationsServiceConnection); mOperationsServiceBinder = null; @@ -230,6 +217,7 @@ implements OnRemoteOperationListener, ComponentsGetter { unbindService(mUploadServiceConnection); mUploadServiceConnection = null; } + super.onDestroy(); } @@ -459,6 +447,13 @@ implements OnRemoteOperationListener, ComponentsGetter { )) { requestCredentialsUpdate(); + + if (result.getCode() == ResultCode.UNAUTHORIZED) { + dismissLoadingDialog(); + Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast.LENGTH_LONG); + t.show(); + } } else if (operation instanceof CreateShareOperation) { onCreateShareOperationFinish((CreateShareOperation) operation, result); @@ -488,14 +483,11 @@ implements OnRemoteOperationListener, ComponentsGetter { Intent sendIntent = operation.getSendIntent(); startActivity(sendIntent); - } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND - Toast t = Toast.makeText(this, getString(R.string.share_link_file_no_exist), Toast.LENGTH_LONG); - t.show(); - } else { // Generic error - // Show a Message, operation finished without success - Toast t = Toast.makeText(this, getString(R.string.share_link_file_error), Toast.LENGTH_LONG); + } else { + Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast.LENGTH_LONG); t.show(); - } + } } @@ -505,15 +497,11 @@ implements OnRemoteOperationListener, ComponentsGetter { if (result.isSuccess()){ updateFileFromDB(); - } else if (result.getCode() == ResultCode.SHARE_NOT_FOUND) { // Error --> SHARE_NOT_FOUND - Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_no_exist), Toast.LENGTH_LONG); - t.show(); - } else { // Generic error - // Show a Message, operation finished without success - Toast t = Toast.makeText(this, getString(R.string.unshare_link_file_error), Toast.LENGTH_LONG); + } else { + Toast t = Toast.makeText(this, ErrorMessageAdapter.getErrorCauseMessage(result, operation, getResources()), + Toast.LENGTH_LONG); t.show(); - } - + } } @@ -553,7 +541,10 @@ implements OnRemoteOperationListener, ComponentsGetter { mOperationsServiceBinder.addOperationListener(FileActivity.this, mHandler); long waitingForOpId = mFileOperationsHelper.getOpIdWaitingFor(); if (waitingForOpId <= Integer.MAX_VALUE) { - mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, this); + boolean wait = mOperationsServiceBinder.dispatchResultIfFinished((int)waitingForOpId, this); + if (!wait ) { + dismissLoadingDialog(); + } } }