use of androidx.fragment.app.FragmentManager in project IITB-App by wncc.
the class Utils method changeTheme.
public static void changeTheme(SettingsFragment fragment, boolean darkTheme) {
isDarkTheme = darkTheme;
FragmentActivity fragmentActivity = fragment.getActivity();
fragmentActivity.setTheme(darkTheme ? R.style.AppThemeDark : R.style.AppTheme);
// Set background color of activity
fragmentActivity.findViewById(R.id.drawer_layout).setBackgroundColor(getAttrColor(fragmentActivity, R.attr.themeColor));
// Put in a new settings fragment
Fragment newFragment = new SettingsFragment();
newFragment.setArguments(fragment.getArguments());
FragmentManager fm = fragmentActivity.getSupportFragmentManager();
fm.popBackStack();
FragmentTransaction ft = fm.beginTransaction();
ft.addToBackStack(getTag(fragment));
ft.replace(R.id.framelayout_for_fragment, newFragment, getTag(fragment)).commit();
}
use of androidx.fragment.app.FragmentManager in project zype-android by zype.
the class PaywallActivity method showPaywallFragment.
private void showPaywallFragment(PaywallType paywallType) {
FragmentManager fragmentManager = getSupportFragmentManager();
switch(paywallType) {
case PLAYLIST_TVOD:
PaywallPlaylistTvodFragment fragment = PaywallPlaylistTvodFragment.getInstance();
fragmentManager.beginTransaction().replace(R.id.content, fragment, PaywallPlaylistTvodFragment.TAG).commit();
break;
}
}
use of androidx.fragment.app.FragmentManager in project J2ME-Loader by nikita36078.
the class DonationsActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
FragmentManager fragmentManager = getSupportFragmentManager();
Fragment fragment = fragmentManager.findFragmentByTag("donationsFragment");
if (fragment != null) {
fragment.onActivityResult(requestCode, resultCode, data);
}
}
use of androidx.fragment.app.FragmentManager in project mopub-android-mediation by mopub.
the class MoPubSampleActivity method onNavChangeConsent.
private void onNavChangeConsent(boolean grant) {
final FragmentManager manager = getSupportFragmentManager();
final MoPubListFragment listFragment = (MoPubListFragment) manager.findFragmentByTag(LIST_FRAGMENT_TAG);
if (listFragment == null) {
MoPubLog.log(CUSTOM, getString(R.string.list_fragment_not_found));
// fragment is not ready to update the consent
return;
}
if (!listFragment.onChangeConsent(grant)) {
// fragment is not ready to update the consent
return;
}
final NavigationView navigationView = findViewById(R.id.nav_view);
navigationView.getMenu().findItem(R.id.nav_privacy_grant).setChecked(grant);
navigationView.getMenu().findItem(R.id.nav_privacy_revoke).setChecked(!grant);
}
use of androidx.fragment.app.FragmentManager in project bitcoin-wallet by bitcoin-wallet.
the class SweepWalletFragment method onCreate.
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.fragmentManager = getChildFragmentManager();
setHasOptionsMenu(true);
if (!Constants.ENABLE_SWEEP_WALLET)
throw new IllegalStateException("ENABLE_SWEEP_WALLET is disabled");
walletActivityViewModel = new ViewModelProvider(activity).get(AbstractWalletActivityViewModel.class);
walletActivityViewModel.wallet.observe(this, wallet -> updateView());
viewModel = new ViewModelProvider(this).get(SweepWalletViewModel.class);
viewModel.getDynamicFees().observe(this, dynamicFees -> updateView());
viewModel.progress.observe(this, new ProgressDialogFragment.Observer(fragmentManager));
viewModel.privateKeyToSweep.observe(this, privateKeyToSweep -> updateView());
viewModel.walletToSweep.observe(this, walletToSweep -> {
if (walletToSweep != null) {
balanceView.setVisibility(View.VISIBLE);
final MonetaryFormat btcFormat = config.getFormat();
final MonetarySpannable balanceSpannable = new MonetarySpannable(btcFormat, walletToSweep.getBalance(BalanceType.ESTIMATED));
balanceSpannable.applyMarkup(null, null);
final SpannableStringBuilder balance = new SpannableStringBuilder(balanceSpannable);
balance.insert(0, ": ");
balance.insert(0, getString(R.string.sweep_wallet_fragment_balance));
balanceView.setText(balance);
} else {
balanceView.setVisibility(View.GONE);
}
updateView();
});
viewModel.sentTransaction.observe(this, transaction -> {
if (viewModel.state == SweepWalletViewModel.State.SENDING) {
final TransactionConfidence confidence = transaction.getConfidence();
final ConfidenceType confidenceType = confidence.getConfidenceType();
final int numBroadcastPeers = confidence.numBroadcastPeers();
if (confidenceType == ConfidenceType.DEAD)
setState(SweepWalletViewModel.State.FAILED);
else if (numBroadcastPeers > 1 || confidenceType == ConfidenceType.BUILDING)
setState(SweepWalletViewModel.State.SENT);
}
updateView();
});
viewModel.showDialog.observe(this, new DialogEvent.Observer(activity));
viewModel.showDialogWithRetryRequestBalance.observe(this, new DialogEvent.Observer(activity) {
@Override
protected void onBuildButtons(final DialogBuilder dialog) {
dialog.setPositiveButton(R.string.button_retry, (d, which) -> requestWalletBalance());
dialog.setNegativeButton(R.string.button_dismiss, null);
}
});
backgroundThread = new HandlerThread("backgroundThread", Process.THREAD_PRIORITY_BACKGROUND);
backgroundThread.start();
backgroundHandler = new Handler(backgroundThread.getLooper());
if (savedInstanceState == null) {
final Intent intent = activity.getIntent();
if (intent.hasExtra(SweepWalletActivity.INTENT_EXTRA_KEY)) {
final PrefixedChecksummedBytes privateKeyToSweep = (PrefixedChecksummedBytes) intent.getSerializableExtra(SweepWalletActivity.INTENT_EXTRA_KEY);
viewModel.privateKeyToSweep.setValue(privateKeyToSweep);
// delay until fragment is resumed
handler.post(maybeDecodeKeyRunnable);
}
}
}
Aggregations