X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d4729a6a77ca98ea7c4b25e88962da2e370f8dc5..abbf2252a3d97f95ef967dfbe7fc01c45af5d6b9:/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..02025226 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(); } @@ -488,14 +476,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 +490,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 +534,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(); + } } }