+ Fragment newFragment = null;
+ OCFile file = getFile();
+ Account account = getAccount();
+ if (PreviewMediaFragment.canBePreviewed(file) && mode == MODE_PREVIEW) {
+ if (file.isDown()) {
+ int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
+ boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
+ newFragment = new PreviewMediaFragment(file, account, startPlaybackPosition, autoplay);
+
+ } else {
+ newFragment = new FileDetailFragment(file, account);
+ mWaitingToPreview = true;
+ }
+
+ } else {
+ newFragment = new FileDetailFragment(file, account);
+ }
+ FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
+ ft.replace(R.id.fragment, newFragment, FileDetailFragment.FTAG);
+ ft.commit();
+ }
+
+ @Override
+ public void onActivityResult (int requestCode, int resultCode, Intent data) {
+ Log_OC.e(TAG, "onActivityResult");
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ @Override
+ public void onConfigurationChanged (Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+ if (mStarted) {
+ checkConfigurationChange(newConfig);
+ } else {
+ mNewConfigurationChangeToApplyOnStart = newConfig;
+ }
+ }
+
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ outState.putBoolean(KEY_WAITING_TO_PREVIEW, mWaitingToPreview);
+ }
+
+
+ @Override
+ public void onStart() {
+ super.onStart();
+ Log_OC.e(TAG, "onStart");
+ if (mNewConfigurationChangeToApplyOnStart != null && !isRedirectingToSetupAccount()) {
+ checkConfigurationChange(mNewConfigurationChangeToApplyOnStart);
+ mNewConfigurationChangeToApplyOnStart = null;
+ }
+ mStarted = true;
+ }
+
+ private void checkConfigurationChange(Configuration newConfig) {
+ finish();
+ Intent intent = null;
+ OCFile file = getFile();
+ Account account = getAccount();
+ if ((newConfig.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) >= Configuration.SCREENLAYOUT_SIZE_LARGE
+ && newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
+
+ intent = new Intent(this, FileDisplayActivity.class);
+ intent.putExtra(EXTRA_FILE, file);
+ intent.putExtra(EXTRA_ACCOUNT, account);
+ intent.putExtra(EXTRA_MODE, getIntent().getIntExtra(EXTRA_MODE, MODE_PREVIEW));
+ intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ Fragment fragment = getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);
+ if (fragment != null && file != null && fragment instanceof PreviewMediaFragment && file.isVideo()) {
+ PreviewMediaFragment videoFragment = (PreviewMediaFragment)fragment;
+ intent.putExtra(PreviewVideoActivity.EXTRA_START_POSITION, videoFragment.getPosition());
+ intent.putExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, videoFragment.isPlaying());
+ }