X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/423ac7670263e7cfab73961170832e04b8896a7f..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 11e0a399..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; @@ -194,6 +195,7 @@ implements OnRemoteOperationListener, ComponentsGetter { @Override protected void onPause() { + if (mOperationsServiceBinder != null) { mOperationsServiceBinder.removeOperationListener(this); } @@ -204,7 +206,6 @@ implements OnRemoteOperationListener, ComponentsGetter { @Override protected void onDestroy() { - super.onDestroy(); if (mOperationsServiceConnection != null) { unbindService(mOperationsServiceConnection); mOperationsServiceBinder = null; @@ -217,6 +218,7 @@ implements OnRemoteOperationListener, ComponentsGetter { unbindService(mUploadServiceConnection); mUploadServiceConnection = null; } + super.onDestroy(); } @@ -446,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); @@ -456,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( @@ -475,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(); - } + } } @@ -492,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(); - } - + } } @@ -540,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(); + } } }