Fix. [BUG] Some storages do not work when uploading content from other apps Drive

This commit is contained in:
jabarros 2016-05-20 14:29:15 +02:00 committed by David A. Velasco
parent e34d76a126
commit 7225b9f631
4 changed files with 29 additions and 7 deletions

View file

@ -189,6 +189,16 @@ public class FileDisplayActivity extends HookActivity
//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");
}

View file

@ -145,6 +145,16 @@ public class ReceiveExternalFilesActivity extends FileActivity
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

View file

@ -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);
}
}
}

View file

@ -189,12 +189,10 @@ public class UriUploader {
// 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(