Search in sources :

Example 86 with Fragment

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);
}
Also used : User(com.nextcloud.client.account.User) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Example 87 with Fragment

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();
    }
}
Also used : OCFile(com.owncloud.android.datamodel.OCFile) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) OCFileListFragment(com.owncloud.android.ui.fragment.OCFileListFragment) UnifiedSearchFragment(com.owncloud.android.ui.fragment.UnifiedSearchFragment) Fragment(androidx.fragment.app.Fragment) TaskRetainerFragment(com.owncloud.android.ui.fragment.TaskRetainerFragment) FileFragment(com.owncloud.android.ui.fragment.FileFragment) PreviewTextStringFragment(com.owncloud.android.ui.preview.PreviewTextStringFragment) PreviewTextFragment(com.owncloud.android.ui.preview.PreviewTextFragment) PreviewTextFileFragment(com.owncloud.android.ui.preview.PreviewTextFileFragment) GalleryFragment(com.owncloud.android.ui.fragment.GalleryFragment) SortingOrderDialogFragment(com.owncloud.android.ui.dialog.SortingOrderDialogFragment) PreviewImageFragment(com.owncloud.android.ui.preview.PreviewImageFragment) PreviewMediaFragment(com.owncloud.android.ui.preview.PreviewMediaFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment) PreviewPdfFragment(com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)

Example 88 with Fragment

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();
    }
}
Also used : LoadingDialog(com.owncloud.android.ui.dialog.LoadingDialog) Fragment(androidx.fragment.app.Fragment) ConfirmationDialogFragment(com.owncloud.android.ui.dialog.ConfirmationDialogFragment) DialogFragment(androidx.fragment.app.DialogFragment) FileDetailSharingFragment(com.owncloud.android.ui.fragment.FileDetailSharingFragment) FileDetailFragment(com.owncloud.android.ui.fragment.FileDetailFragment)

Example 89 with Fragment

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();
    }
}
Also used : User(com.nextcloud.client.account.User) FragmentTransaction(androidx.fragment.app.FragmentTransaction) Fragment(androidx.fragment.app.Fragment) ConflictsResolveDialog(com.owncloud.android.ui.dialog.ConflictsResolveDialog)

Example 90 with Fragment

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));
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) Fragment(androidx.fragment.app.Fragment) DialogFragment(androidx.fragment.app.DialogFragment) Test(org.junit.Test)

Aggregations

Fragment (androidx.fragment.app.Fragment)239 FragmentTransaction (androidx.fragment.app.FragmentTransaction)54 Bundle (android.os.Bundle)46 FragmentManager (androidx.fragment.app.FragmentManager)38 FileFragment (com.owncloud.android.ui.fragment.FileFragment)23 DialogFragment (androidx.fragment.app.DialogFragment)22 View (android.view.View)21 FileDetailFragment (com.owncloud.android.ui.fragment.FileDetailFragment)20 OCFileListFragment (com.owncloud.android.ui.fragment.OCFileListFragment)20 Intent (android.content.Intent)19 SortingOrderDialogFragment (com.owncloud.android.ui.dialog.SortingOrderDialogFragment)19 GalleryFragment (com.owncloud.android.ui.fragment.GalleryFragment)18 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)18 UnifiedSearchFragment (com.owncloud.android.ui.fragment.UnifiedSearchFragment)18 PreviewImageFragment (com.owncloud.android.ui.preview.PreviewImageFragment)18 PreviewMediaFragment (com.owncloud.android.ui.preview.PreviewMediaFragment)18 PreviewTextFileFragment (com.owncloud.android.ui.preview.PreviewTextFileFragment)18 PreviewTextFragment (com.owncloud.android.ui.preview.PreviewTextFragment)18 PreviewTextStringFragment (com.owncloud.android.ui.preview.PreviewTextStringFragment)18 PreviewPdfFragment (com.owncloud.android.ui.preview.pdf.PreviewPdfFragment)18