Skip to content

Commit

Permalink
Fix. [BUG] Some storages do not work when uploading content from othe…
Browse files Browse the repository at this point in the history
…r apps Drive
  • Loading branch information
jabarros authored and davivel committed May 23, 2016
1 parent e34d76a commit 7225b9f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
10 changes: 10 additions & 0 deletions src/com/owncloud/android/ui/activity/FileDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,16 @@ protected void onCreate(Bundle savedInstanceState) {
//getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);

// Init Fragment without UI to retain AsyncTask across configuration changes
FragmentManager fm = getSupportFragmentManager();
TaskRetainerFragment taskRetainerFragment =
(TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
if (taskRetainerFragment == null) {
taskRetainerFragment = new TaskRetainerFragment();
fm.beginTransaction()
.add(taskRetainerFragment, TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT).commit();
} // else, Fragment already created and retained across configuration change

Log_OC.v(TAG, "onCreate() end");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ protected void onCreate(Bundle savedInstanceState) {
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);

// Init Fragment without UI to retain AsyncTask across configuration changes
FragmentManager fm = getSupportFragmentManager();
TaskRetainerFragment taskRetainerFragment =
(TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
if (taskRetainerFragment == null) {
taskRetainerFragment = new TaskRetainerFragment();
fm.beginTransaction()
.add(taskRetainerFragment, TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT).commit();
} // else, Fragment already created and retained across configuration change

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public class TaskRetainerFragment extends Fragment {
public void onAttach(Context context) {
super.onAttach(context);
if (mTask != null) {
mTask.setListener((CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener) context);
if (context instanceof ReceiveExternalFilesActivity) {
mTask.setListener((CopyAndUploadContentUrisTask.OnCopyTmpFilesTaskListener) context);
} else {
mTask.setListener(null);
}
}
}

Expand Down
10 changes: 4 additions & 6 deletions src/com/owncloud/android/ui/helpers/UriUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,12 +189,10 @@ private void copyThenUpload(Uri[] sourceUris, String[] remotePaths) {
// Init Fragment without UI to retain AsyncTask across configuration changes
TaskRetainerFragment taskRetainerFragment =
(TaskRetainerFragment) fm.findFragmentByTag(TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT);
if (taskRetainerFragment == null) {
taskRetainerFragment = new TaskRetainerFragment();
fm.beginTransaction()
.add(taskRetainerFragment, TaskRetainerFragment.FTAG_TASK_RETAINER_FRAGMENT).commit();
} // else, Fragment was created before
taskRetainerFragment.setTask(copyTask);

if (taskRetainerFragment != null) {
taskRetainerFragment.setTask(copyTask);
}

copyTask.execute(
CopyAndUploadContentUrisTask.makeParamsToExecute(
Expand Down

0 comments on commit 7225b9f

Please sign in to comment.