mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
Refactor onCreate: extract initTaskRetainerFragment method
This commit extracts the logic to initialize a fragment without UI on a seperate method called `initTaskRetainerFragment`.
This commit is contained in:
parent
23c8f86b7b
commit
2e6fca0c04
1 changed files with 13 additions and 11 deletions
|
@ -255,17 +255,7 @@ public class FileDisplayActivity extends FileActivity
|
|||
/// USER INTERFACE
|
||||
initLayout();
|
||||
initUI();
|
||||
|
||||
|
||||
// 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
|
||||
initTaskRetainerFragment();
|
||||
|
||||
if (Intent.ACTION_VIEW.equals(getIntent().getAction())) {
|
||||
handleOpenFileViaIntent(getIntent());
|
||||
|
@ -305,6 +295,18 @@ public class FileDisplayActivity extends FileActivity
|
|||
fastScrollUtils.fixAppBarForFastScroll(binding.appbar.appbar, binding.rootLayout);
|
||||
}
|
||||
|
||||
private void initTaskRetainerFragment() {
|
||||
// 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
|
||||
}
|
||||
|
||||
private void checkStoragePath() {
|
||||
String newStorage = Environment.getExternalStorageDirectory().getAbsolutePath();
|
||||
String storagePath = preferences.getStoragePath(newStorage);
|
||||
|
|
Loading…
Reference in a new issue