use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method refreshDetailsFragmentIfVisible.
protected void refreshDetailsFragmentIfVisible(String downloadEvent, String downloadedRemotePath, boolean success) {
Fragment leftFragment = getLeftFragment();
if (leftFragment instanceof FileDetailFragment) {
boolean waitedPreview = mWaitingToPreview != null && mWaitingToPreview.getRemotePath().equals(downloadedRemotePath);
FileDetailFragment detailsFragment = (FileDetailFragment) leftFragment;
OCFile fileInFragment = detailsFragment.getFile();
if (fileInFragment != null && !downloadedRemotePath.equals(fileInFragment.getRemotePath())) {
// the user browsed to other file ; forget the automatic preview
mWaitingToPreview = null;
} else if (downloadEvent.equals(FileDownloader.getDownloadAddedMessage())) {
// grant that the right panel updates the progress bar
detailsFragment.listenForTransferProgress();
detailsFragment.updateFileDetails(true, false);
} else if (downloadEvent.equals(FileDownloader.getDownloadFinishMessage())) {
// update the right panel
boolean detailsFragmentChanged = false;
if (waitedPreview) {
if (success) {
// update the file from database, for the local storage path
mWaitingToPreview = getStorageManager().getFileById(mWaitingToPreview.getFileId());
if (PreviewMediaFragment.canBePreviewed(mWaitingToPreview)) {
startMediaPreview(mWaitingToPreview, 0, true, true, true);
detailsFragmentChanged = true;
} else if (MimeTypeUtil.isVCard(mWaitingToPreview.getMimeType())) {
startContactListFragment(mWaitingToPreview);
detailsFragmentChanged = true;
} else if (PreviewTextFileFragment.canBePreviewed(mWaitingToPreview)) {
startTextPreview(mWaitingToPreview, true);
detailsFragmentChanged = true;
} else if (MimeTypeUtil.isPDF(mWaitingToPreview)) {
startPdfPreview(mWaitingToPreview);
detailsFragmentChanged = true;
} else {
getFileOperationsHelper().openFile(mWaitingToPreview);
}
}
mWaitingToPreview = null;
}
if (!detailsFragmentChanged) {
detailsFragment.updateFileDetails(false, success);
}
}
}
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method onTransferStateChanged.
/**
* {@inheritDoc}
*/
@Override
public void onTransferStateChanged(OCFile file, boolean downloading, boolean uploading) {
updateListOfFilesFragment(false);
Fragment leftFragment = getLeftFragment();
Optional<User> optionalUser = getUser();
if (leftFragment instanceof FileDetailFragment && file.equals(((FileDetailFragment) leftFragment).getFile()) && optionalUser.isPresent()) {
final User currentUser = optionalUser.get();
if (downloading || uploading) {
((FileDetailFragment) leftFragment).updateFileDetails(file, currentUser);
} else {
if (!file.fileExists()) {
cleanSecondFragment();
} else {
((FileDetailFragment) leftFragment).updateFileDetails(false, true);
}
}
}
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method chooseInitialSecondFragment.
@Deprecated
private Fragment chooseInitialSecondFragment(OCFile file, User user) {
Fragment secondFragment = null;
if (file != null && !file.isFolder()) {
if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
long startPlaybackPosition = getIntent().getLongExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
secondFragment = PreviewMediaFragment.newInstance(file, user, startPlaybackPosition, autoplay);
} else if (file.isDown() && PreviewTextFileFragment.canBePreviewed(file)) {
secondFragment = null;
} else {
secondFragment = FileDetailFragment.newInstance(file, user);
}
}
return secondFragment;
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method onResume.
@Override
protected void onResume() {
Log_OC.v(TAG, "onResume() start");
super.onResume();
// Instead of onPostCreate, starting the loading in onResume for children fragments
Fragment leftFragment = getLeftFragment();
// Listen for sync messages
if (!(leftFragment instanceof OCFileListFragment) || !((OCFileListFragment) leftFragment).isSearchFragment()) {
IntentFilter syncIntentFilter = new IntentFilter(FileSyncAdapter.EVENT_FULL_SYNC_START);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_END);
syncIntentFilter.addAction(FileSyncAdapter.EVENT_FULL_SYNC_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED);
syncIntentFilter.addAction(RefreshFolderOperation.EVENT_SINGLE_FOLDER_SHARES_SYNCED);
mSyncBroadcastReceiver = new SyncBroadcastReceiver();
localBroadcastManager.registerReceiver(mSyncBroadcastReceiver, syncIntentFilter);
}
if (!(leftFragment instanceof OCFileListFragment)) {
if (leftFragment instanceof FileFragment) {
super.updateActionBarTitleAndHomeButton(((FileFragment) leftFragment).getFile());
}
return;
}
OCFileListFragment ocFileListFragment = (OCFileListFragment) leftFragment;
ocFileListFragment.setLoading(mSyncInProgress);
syncAndUpdateFolder(false);
OCFile startFile = null;
if (getIntent() != null && getIntent().getParcelableExtra(EXTRA_FILE) != null) {
startFile = getIntent().getParcelableExtra(EXTRA_FILE);
setFile(startFile);
}
// refresh list of files
if (searchView != null && !TextUtils.isEmpty(searchQuery)) {
searchView.setQuery(searchQuery, false);
} else if (!ocFileListFragment.isSearchFragment() && startFile == null) {
updateListOfFilesFragment(false);
ocFileListFragment.registerFabListener();
} else {
ocFileListFragment.listDirectory(startFile, false, false);
updateActionBarTitleAndHomeButton(startFile);
}
// Listen for upload messages
IntentFilter uploadIntentFilter = new IntentFilter(FileUploader.getUploadFinishMessage());
mUploadFinishReceiver = new UploadFinishReceiver();
localBroadcastManager.registerReceiver(mUploadFinishReceiver, uploadIntentFilter);
// Listen for download messages
IntentFilter downloadIntentFilter = new IntentFilter(FileDownloader.getDownloadAddedMessage());
downloadIntentFilter.addAction(FileDownloader.getDownloadFinishMessage());
mDownloadFinishReceiver = new DownloadFinishReceiver();
localBroadcastManager.registerReceiver(mDownloadFinishReceiver, downloadIntentFilter);
// setup drawer
menuItemId = getIntent().getIntExtra(FileDisplayActivity.DRAWER_MENU_ID, menuItemId);
if (menuItemId == -1) {
if (MainApp.isOnlyOnDevice()) {
setDrawerMenuItemChecked(R.id.nav_on_device);
setupToolbar();
} else {
setDrawerMenuItemChecked(R.id.nav_all_files);
setupHomeSearchToolbarWithSortAndListButtons();
}
} else {
if (menuItemId == R.id.nav_all_files) {
setupHomeSearchToolbarWithSortAndListButtons();
} else {
setupToolbar();
}
setDrawerMenuItemChecked(menuItemId);
}
if (ocFileListFragment instanceof GalleryFragment) {
updateActionBarTitleAndHomeButtonByString(getString(R.string.drawer_item_gallery));
}
Log_OC.v(TAG, "onResume() end");
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method startRichWorkspacePreview.
/**
* Starts rich workspace preview for a folder.
*
* @param folder {@link OCFile} to preview its rich workspace.
*/
public void startRichWorkspacePreview(OCFile folder) {
showSortListGroup(false);
Bundle args = new Bundle();
args.putParcelable(EXTRA_FILE, folder);
Fragment textPreviewFragment = Fragment.instantiate(getApplicationContext(), PreviewTextStringFragment.class.getName(), args);
setLeftFragment(textPreviewFragment);
binding.rightFragmentContainer.setVisibility(View.GONE);
super.updateActionBarTitleAndHomeButton(folder);
}
Aggregations