+
+ private void createMinFragments() {
+ OCFileListFragment listOfFiles = new OCFileListFragment();
+ FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
+ transaction.add(R.id.left_fragment_container, listOfFiles, TAG_LIST_OF_FILES);
+ transaction.commit();
+ }
+
+ private void initFragmentsWithFile() {
+ if (getAccount() != null && getFile() != null) {
+ /// First fragment
+ OCFileListFragment listOfFiles = getListOfFilesFragment();
+ if (listOfFiles != null) {
+ listOfFiles.listDirectory(getCurrentDir());
+ } else {
+ Log.e(TAG, "Still have a chance to lose the initializacion of list fragment >(");
+ }
+
+ /// Second fragment
+ OCFile file = getFile();
+ Fragment secondFragment = chooseInitialSecondFragment(file);
+ if (secondFragment != null) {
+ setSecondFragment(secondFragment);
+ updateFragmentsVisibility(true);
+ updateNavigationElementsInActionBar(file);
+
+ } else {
+ cleanSecondFragment();
+ }
+
+ } else {
+ Log.wtf(TAG, "initFragments() called with invalid NULLs!");
+ if (getAccount() == null) {
+ Log.wtf(TAG, "\t account is NULL");
+ }
+ if (getFile() == null) {
+ Log.wtf(TAG, "\t file is NULL");
+ }
+ }
+ }
+
+ private Fragment chooseInitialSecondFragment(OCFile file) {
+ Fragment secondFragment = null;
+ if (file != null && !file.isDirectory()) {
+ if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)
+ && file.getLastSyncDateForProperties() > 0 // temporal fix
+ ) {
+ int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
+ boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
+ secondFragment = new PreviewMediaFragment(file, getAccount(), startPlaybackPosition, autoplay);
+
+ } else {
+ secondFragment = new FileDetailFragment(file, getAccount());
+ }
+ }
+ return secondFragment;
+ }
+
+