- /**
- * {@inheritDoc}
- */
- @Override
- public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
- if (operation.equals(mLastRemoteOperation)) {
- if (operation instanceof RemoveFileOperation) {
- onRemoveFileOperationFinish((RemoveFileOperation)operation, result);
-
- } else if (operation instanceof RenameFileOperation) {
- onRenameFileOperationFinish((RenameFileOperation)operation, result);
-
- } else if (operation instanceof SynchronizeFileOperation) {
- onSynchronizeFileOperationFinish((SynchronizeFileOperation)operation, result);
- }
- }
- }
-
-
- private void onRemoveFileOperationFinish(RemoveFileOperation operation, RemoteOperationResult result) {
- ((FileActivity) getActivity()).dismissLoadingDialog();
- if (result.isSuccess()) {
- Toast msg = Toast.makeText(getActivity().getApplicationContext(), R.string.remove_success_msg, Toast.LENGTH_LONG);
- msg.show();
- ((FileDisplayActivity)getActivity()).cleanSecondFragment();
-
- } else {
- Toast msg = Toast.makeText(getActivity(), R.string.remove_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- if (result.isSslRecoverableException()) {
- // TODO show the SSL warning dialog
- }
- }
- }
-
- private void onRenameFileOperationFinish(RenameFileOperation operation, RemoteOperationResult result) {
- ((FileActivity) getActivity()).dismissLoadingDialog();
-
- if (result.isSuccess()) {
- updateFileDetails(((RenameFileOperation)operation).getFile(), mAccount);
- /* TODO WIP COMMENT
- mContainerActivity.onFileStateChanged();
- */
-
- } else {
- if (result.getCode().equals(ResultCode.INVALID_LOCAL_FILE_NAME)) {
- Toast msg = Toast.makeText(getActivity(), R.string.rename_local_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- // TODO throw again the new rename dialog
- } if (result.getCode().equals(ResultCode.INVALID_CHARACTER_IN_NAME)) {
- Toast msg = Toast.makeText(getActivity(), R.string.filename_forbidden_characters, Toast.LENGTH_LONG);
- msg.show();
- } else {
- Toast msg = Toast.makeText(getActivity(), R.string.rename_server_fail_msg, Toast.LENGTH_LONG);
- msg.show();
- if (result.isSslRecoverableException()) {
- // TODO show the SSL warning dialog
- }
- }
- }
- }
-
- private void onSynchronizeFileOperationFinish(SynchronizeFileOperation operation, RemoteOperationResult result) {
- ((FileActivity) getActivity()).dismissLoadingDialog();
- OCFile file = getFile();
- if (!result.isSuccess()) {
- if (result.getCode() == ResultCode.SYNC_CONFLICT) {
- Intent i = new Intent(getActivity(), ConflictsResolveActivity.class);
- i.putExtra(ConflictsResolveActivity.EXTRA_FILE, file);
- i.putExtra(ConflictsResolveActivity.EXTRA_ACCOUNT, mAccount);
- startActivity(i);
-
- }
-
- if (file.isDown()) {
- setButtonsForDown();
-
- } else {
- setButtonsForRemote();
- }
-
- } else {
- if (operation.transferWasRequested()) {
- setButtonsForTransferring();
- /* TODO WIP COMMENT
- mContainerActivity.onFileStateChanged(); // this is not working; FileDownloader won't do NOTHING at all until this method finishes, so
- // checking the service to see if the file is downloading results in FALSE
- */
- } else {
- Toast msg = Toast.makeText(getActivity(), R.string.sync_file_nothing_to_do_msg, Toast.LENGTH_LONG);
- msg.show();
- if (file.isDown()) {
- setButtonsForDown();
-
- } else {
- setButtonsForRemote();
- }
- }
- }
- }
-
-