X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/d4729a6a77ca98ea7c4b25e88962da2e370f8dc5..b154fba6ee7e2dfb77ff10e20c20c080758d2a1d:/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..fced61b4 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 @@ -197,27 +195,17 @@ implements OnRemoteOperationListener, ComponentsGetter { @Override protected void onPause() { - if (mOperationsServiceBinder != null) { - mOperationsServiceBinder.removeOperationListener(this); - } - super.onPause(); - } - - @Override - protected void onStop() { - if (mOperationsServiceBinder != null) { mOperationsServiceBinder.removeOperationListener(this); } - super.onStop(); + super.onPause(); } @Override protected void onDestroy() { - super.onDestroy(); if (mOperationsServiceConnection != null) { unbindService(mOperationsServiceConnection); mOperationsServiceBinder = null; @@ -230,6 +218,7 @@ implements OnRemoteOperationListener, ComponentsGetter { unbindService(mUploadServiceConnection); mUploadServiceConnection = null; } + super.onDestroy(); } @@ -459,6 +448,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); @@ -469,7 +465,7 @@ implements OnRemoteOperationListener, ComponentsGetter { } } - private void requestCredentialsUpdate() { + protected void requestCredentialsUpdate() { Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class); updateAccountCredentials.putExtra(AuthenticatorActivity.EXTRA_ACCOUNT, getAccount()); updateAccountCredentials.putExtra( @@ -488,14 +484,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 +498,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 +542,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(); + } } }