+ protected void onAccountSet(boolean stateWasRecovered) {
+ if (getAccount() != null) {
+ mStorageManager = new FileDataStorageManager(getAccount(), getContentResolver());
+
+ } else {
+ Log_OC.wtf(TAG, "onAccountChanged was called with NULL account associated!");
+ }
+ }
+
+
+ public FileDataStorageManager getStorageManager() {
+ return mStorageManager;
+ }
+
+
+ public OnRemoteOperationListener getRemoteOperationListener() {
+ return this;
+ }
+
+
+ public Handler getHandler() {
+ return mHandler;
+ }
+
+ public FileOperationsHelper getFileOperationsHelper() {
+ return mFileOperationsHelper;
+ }
+
+ /**
+ *
+ * @param operation Removal operation performed.
+ * @param result Result of the removal.
+ */
+ @Override
+ public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+ Log_OC.d(TAG, "Received result of operation in FileActivity - common behaviour for all the FileActivities ");
+ if (operation instanceof CreateShareOperation) {
+ onCreateShareOperationFinish((CreateShareOperation) operation, result);
+ }
+ }
+
+ private void onCreateShareOperationFinish(CreateShareOperation operation, RemoteOperationResult result) {
+ dismissLoadingDialog();
+ if (result.isSuccess()) {
+ Intent sendIntent = operation.getSendIntent();
+ startActivity(sendIntent);
+
+ } else if (result.getCode() == ResultCode.FILE_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);
+ t.show();
+ }
+ }
+
+
+ /**
+ * Show loading dialog
+ */
+ public void showLoadingDialog() {
+ // Construct dialog
+ LoadingDialog loading = new LoadingDialog(getResources().getString(R.string.wait_a_moment));
+ FragmentManager fm = getSupportFragmentManager();
+ FragmentTransaction ft = fm.beginTransaction();
+ loading.show(ft, DIALOG_WAIT_TAG);
+
+ }
+
+
+ /**
+ * Dismiss loading dialog
+ */
+ public void dismissLoadingDialog(){
+ Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
+ if (frag != null) {
+ LoadingDialog loading = (LoadingDialog) frag;
+ loading.dismiss();
+ }
+ }
+