mirror of
https://github.com/nextcloud/android.git
synced 2024-12-18 06:51:55 +03:00
re-use second fragment if available
This commit is contained in:
parent
8ec2a1de46
commit
c4331a10fa
2 changed files with 17 additions and 26 deletions
|
@ -83,12 +83,12 @@ import com.owncloud.android.services.observer.FileObserverService;
|
|||
import com.owncloud.android.syncadapter.FileSyncAdapter;
|
||||
import com.owncloud.android.ui.dialog.SortingOrderDialogFragment;
|
||||
import com.owncloud.android.ui.events.TokenPushEvent;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.ContactListFragment;
|
||||
import com.owncloud.android.ui.fragment.ExtendedListFragment;
|
||||
import com.owncloud.android.ui.fragment.FileDetailFragment;
|
||||
import com.owncloud.android.ui.fragment.FileFragment;
|
||||
import com.owncloud.android.ui.fragment.OCFileListFragment;
|
||||
import com.owncloud.android.ui.fragment.TaskRetainerFragment;
|
||||
import com.owncloud.android.ui.fragment.contactsbackup.ContactListFragment;
|
||||
import com.owncloud.android.ui.helpers.UriUploader;
|
||||
import com.owncloud.android.ui.preview.PreviewImageActivity;
|
||||
import com.owncloud.android.ui.preview.PreviewImageFragment;
|
||||
|
@ -428,7 +428,12 @@ public class FileDisplayActivity extends HookActivity
|
|||
|
||||
/// Second fragment
|
||||
OCFile file = getFile();
|
||||
Fragment secondFragment = chooseInitialSecondFragment(file);
|
||||
|
||||
Fragment secondFragment = getSecondFragment();
|
||||
if (secondFragment == null) {
|
||||
secondFragment = chooseInitialSecondFragment(file);
|
||||
}
|
||||
|
||||
if (secondFragment != null) {
|
||||
setSecondFragment(secondFragment);
|
||||
updateFragmentsVisibility(true);
|
||||
|
@ -467,13 +472,9 @@ public class FileDisplayActivity extends HookActivity
|
|||
Fragment secondFragment = null;
|
||||
if (file != null && !file.isFolder()) {
|
||||
if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
|
||||
int startPlaybackPosition =
|
||||
getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
|
||||
boolean autoplay =
|
||||
getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
|
||||
secondFragment = new PreviewMediaFragment(file, getAccount(),
|
||||
startPlaybackPosition, autoplay);
|
||||
|
||||
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 if (file.isDown() && PreviewTextFragment.canBePreviewed(file)) {
|
||||
secondFragment = null;
|
||||
} else {
|
||||
|
@ -547,8 +548,7 @@ public class FileDisplayActivity extends HookActivity
|
|||
}
|
||||
|
||||
public FileFragment getSecondFragment() {
|
||||
Fragment second = getSupportFragmentManager().findFragmentByTag(
|
||||
FileDisplayActivity.TAG_SECOND_FRAGMENT);
|
||||
Fragment second = getSupportFragmentManager().findFragmentByTag(FileDisplayActivity.TAG_SECOND_FRAGMENT);
|
||||
if (second != null) {
|
||||
return (FileFragment) second;
|
||||
}
|
||||
|
|
|
@ -234,14 +234,11 @@ public class PreviewMediaFragment extends FileFragment implements
|
|||
if (!file.isDown()) {
|
||||
throw new IllegalStateException("There is no local file to preview");
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
file = (OCFile) savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
|
||||
} else {
|
||||
file = savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_FILE);
|
||||
setFile(file);
|
||||
mAccount = savedInstanceState.getParcelable(PreviewMediaFragment.EXTRA_ACCOUNT);
|
||||
mSavedPlaybackPosition =
|
||||
savedInstanceState.getInt(PreviewMediaFragment.EXTRA_PLAY_POSITION);
|
||||
mSavedPlaybackPosition = savedInstanceState.getInt(PreviewMediaFragment.EXTRA_PLAY_POSITION);
|
||||
mAutoplay = savedInstanceState.getBoolean(PreviewMediaFragment.EXTRA_PLAYING);
|
||||
|
||||
}
|
||||
|
@ -251,15 +248,12 @@ public class PreviewMediaFragment extends FileFragment implements
|
|||
mVideoPreview.setVisibility(View.VISIBLE);
|
||||
mImagePreview.setVisibility(View.GONE);
|
||||
prepareVideo();
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mVideoPreview.setVisibility(View.GONE);
|
||||
mImagePreview.setVisibility(View.VISIBLE);
|
||||
extractAndSetCoverArt(file);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -307,11 +301,8 @@ public class PreviewMediaFragment extends FileFragment implements
|
|||
}
|
||||
else {
|
||||
if (mMediaServiceBinder != null) {
|
||||
outState.putInt(
|
||||
PreviewMediaFragment.EXTRA_PLAY_POSITION,
|
||||
mMediaServiceBinder.getCurrentPosition());
|
||||
outState.putBoolean(
|
||||
PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying());
|
||||
outState.putInt(PreviewMediaFragment.EXTRA_PLAY_POSITION, mMediaServiceBinder.getCurrentPosition());
|
||||
outState.putBoolean(PreviewMediaFragment.EXTRA_PLAYING, mMediaServiceBinder.isPlaying());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue