use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method startDownloadForPreview.
/**
* Requests the download of the received {@link OCFile} , updates the UI to monitor the download progress and
* prepares the activity to preview or open the file when the download finishes.
*
* @param file {@link OCFile} to download and preview.
*/
public void startDownloadForPreview(OCFile file) {
final User currentUser = getUser().orElseThrow(RuntimeException::new);
Fragment detailFragment = FileDetailFragment.newInstance(file, currentUser);
setLeftFragment(detailFragment);
mWaitingToPreview = file;
requestForDownload();
updateActionBarTitleAndHomeButton(file);
setFile(file);
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileDisplayActivity method refreshShowDetails.
private void refreshShowDetails() {
Fragment details = getLeftFragment();
if (details instanceof FileFragment) {
OCFile file = ((FileFragment) details).getFile();
if (file != null) {
file = getStorageManager().getFileByPath(file.getRemotePath());
if (details instanceof PreviewMediaFragment) {
// Refresh OCFile of the fragment
((PreviewMediaFragment) details).updateFile(file);
} else if (details instanceof PreviewTextFragment) {
// Refresh OCFile of the fragment
((PreviewTextFileFragment) details).updateFile(file);
} else {
showDetails(file);
}
}
supportInvalidateOptionsMenu();
}
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class FileActivity method dismissLoadingDialog.
/**
* Dismiss loading dialog
*/
public void dismissLoadingDialog() {
Fragment frag = getSupportFragmentManager().findFragmentByTag(DIALOG_WAIT_TAG);
if (frag != null) {
Log_OC.d(TAG, "dismiss loading dialog");
LoadingDialog loading = (LoadingDialog) frag;
loading.dismissAllowingStateLoss();
}
}
use of androidx.fragment.app.Fragment in project android by nextcloud.
the class ConflictsResolveActivity method startDialog.
private void startDialog() {
Optional<User> userOptional = getUser();
if (!userOptional.isPresent()) {
Log_OC.e(TAG, "User not present");
showErrorAndFinish();
}
// Check whether the file is contained in the current Account
Fragment prev = getSupportFragmentManager().findFragmentByTag("conflictDialog");
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
if (prev != null) {
fragmentTransaction.remove(prev);
}
if (existingFile != null && getStorageManager().fileExists(newFile.getRemotePath())) {
ConflictsResolveDialog dialog = ConflictsResolveDialog.newInstance(existingFile, newFile, userOptional.get());
dialog.show(fragmentTransaction, "conflictDialog");
} else {
// Account was changed to a different one - just finish
Log_OC.e(TAG, "Account was changed, finishing");
showErrorAndFinish();
}
}
use of androidx.fragment.app.Fragment in project collect by opendatakit.
the class DialogFragmentUtilsTest method showIfNotShowing_onlyEverOpensOneDialog.
@Test
public void showIfNotShowing_onlyEverOpensOneDialog() {
FragmentActivity activity = Robolectric.setupActivity(FragmentActivity.class);
FragmentManager fragmentManager = activity.getSupportFragmentManager();
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(1));
Fragment dialog1 = fragmentManager.getFragments().get(0);
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(1));
assertThat(fragmentManager.getFragments().get(0), equalTo(dialog1));
}
Aggregations