use of androidx.fragment.app.FragmentManager in project bitcoin-wallet by bitcoin-wallet.
the class WalletActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.application = getWalletApplication();
this.config = application.getConfiguration();
walletActivityViewModel = new ViewModelProvider(this).get(AbstractWalletActivityViewModel.class);
viewModel = new ViewModelProvider(this).get(WalletActivityViewModel.class);
setContentView(R.layout.wallet_content);
contentView = findViewById(android.R.id.content);
exchangeRatesFragment = findViewById(R.id.wallet_main_twopanes_exchange_rates);
levitateView = contentView.findViewWithTag("levitate");
// Make view tagged with 'levitate' scroll away and quickly return.
if (levitateView != null) {
final CoordinatorLayout.LayoutParams layoutParams = new CoordinatorLayout.LayoutParams(levitateView.getLayoutParams().width, levitateView.getLayoutParams().height);
layoutParams.setBehavior(new QuickReturnBehavior());
levitateView.setLayoutParams(layoutParams);
levitateView.addOnLayoutChangeListener((v, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
final int height = bottom - top;
final View targetList = findViewById(R.id.wallet_transactions_list);
targetList.setPadding(targetList.getPaddingLeft(), height, targetList.getPaddingRight(), targetList.getPaddingBottom());
final View targetEmpty = findViewById(R.id.wallet_transactions_empty);
targetEmpty.setPadding(targetEmpty.getPaddingLeft(), height, targetEmpty.getPaddingRight(), targetEmpty.getPaddingBottom());
});
}
OnFirstPreDraw.listen(contentView, viewModel);
enterAnimation = buildEnterAnimation(contentView);
viewModel.walletEncrypted.observe(this, isEncrypted -> invalidateOptionsMenu());
viewModel.walletLegacyFallback.observe(this, isLegacyFallback -> invalidateOptionsMenu());
viewModel.showHelpDialog.observe(this, new Event.Observer<Integer>() {
@Override
protected void onEvent(final Integer messageResId) {
HelpDialogFragment.page(getSupportFragmentManager(), messageResId);
}
});
viewModel.showBackupWalletDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
BackupWalletActivity.start(WalletActivity.this);
}
});
viewModel.showRestoreWalletDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
RestoreWalletDialogFragment.showPick(getSupportFragmentManager());
}
});
viewModel.showEncryptKeysDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
EncryptKeysDialogFragment.show(getSupportFragmentManager());
}
});
viewModel.showReportIssueDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
ReportIssueDialogFragment.show(getSupportFragmentManager(), R.string.report_issue_dialog_title_issue, R.string.report_issue_dialog_message_issue, Constants.REPORT_SUBJECT_ISSUE, null);
}
});
viewModel.showReportCrashDialog.observe(this, new Event.Observer<Void>() {
@Override
protected void onEvent(final Void v) {
ReportIssueDialogFragment.show(getSupportFragmentManager(), R.string.report_issue_dialog_title_crash, R.string.report_issue_dialog_message_crash, Constants.REPORT_SUBJECT_CRASH, null);
}
});
viewModel.enterAnimation.observe(this, state -> {
if (state == WalletActivityViewModel.EnterAnimationState.WAITING) {
// API level 26: enterAnimation.setCurrentPlayTime(0);
for (final Animator animation : enterAnimation.getChildAnimations()) ((ValueAnimator) animation).setCurrentPlayTime(0);
} else if (state == WalletActivityViewModel.EnterAnimationState.ANIMATING) {
reportFullyDrawn();
enterAnimation.start();
enterAnimation.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(final Animator animation) {
viewModel.animationFinished();
}
});
} else if (state == WalletActivityViewModel.EnterAnimationState.FINISHED) {
getWindow().getDecorView().setBackground(null);
}
});
if (savedInstanceState == null)
viewModel.animateWhenLoadingFinished();
else
viewModel.animationFinished();
if (savedInstanceState == null && CrashReporter.hasSavedCrashTrace())
viewModel.showReportCrashDialog.setValue(Event.simple());
config.touchLastUsed();
handleIntent(getIntent());
final FragmentManager fragmentManager = getSupportFragmentManager();
MaybeMaintenanceFragment.add(fragmentManager);
AlertDialogsFragment.add(fragmentManager);
}
use of androidx.fragment.app.FragmentManager in project android by nextcloud.
the class SyncedFoldersActivity method onSyncFolderSettingsClick.
@Override
public void onSyncFolderSettingsClick(int section, SyncedFolderDisplayItem syncedFolderDisplayItem) {
FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(null);
syncedFolderPreferencesDialogFragment = SyncedFolderPreferencesDialogFragment.newInstance(syncedFolderDisplayItem, section);
syncedFolderPreferencesDialogFragment.show(ft, SYNCED_FOLDER_PREFERENCES_DIALOG_TAG);
}
use of androidx.fragment.app.FragmentManager in project android by nextcloud.
the class FileActivity method showUntrustedCertDialog.
/**
* Show untrusted cert dialog
*/
public void showUntrustedCertDialog(RemoteOperationResult result) {
// Show a dialog with the certificate info
FragmentManager fm = getSupportFragmentManager();
SslUntrustedCertDialog dialog = (SslUntrustedCertDialog) fm.findFragmentByTag(DIALOG_UNTRUSTED_CERT);
if (dialog == null) {
dialog = SslUntrustedCertDialog.newInstanceForFullSslError((CertificateCombinedException) result.getException());
FragmentTransaction ft = fm.beginTransaction();
dialog.show(ft, DIALOG_UNTRUSTED_CERT);
}
}
use of androidx.fragment.app.FragmentManager 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));
}
use of androidx.fragment.app.FragmentManager in project collect by opendatakit.
the class DialogFragmentUtilsTest method showIfNotShowing_whenActivityDestroyed_doesNotShowDialog.
@Test
public void showIfNotShowing_whenActivityDestroyed_doesNotShowDialog() {
ActivityController<FragmentActivity> activityController = Robolectric.buildActivity(FragmentActivity.class).setup();
activityController.pause().stop().destroy();
FragmentManager fragmentManager = activityController.get().getSupportFragmentManager();
DialogFragmentUtils.showIfNotShowing(DialogFragment.class, fragmentManager);
assertThat(fragmentManager.getFragments().size(), equalTo(0));
}
Aggregations