Search in sources :

Example 41 with FragmentManager

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();
}
Also used : SettingsFragment(app.insti.fragment.SettingsFragment) FragmentManager(androidx.fragment.app.FragmentManager) FragmentActivity(androidx.fragment.app.FragmentActivity) FragmentTransaction(androidx.fragment.app.FragmentTransaction) TransitionTargetFragment(app.insti.fragment.TransitionTargetFragment) Fragment(androidx.fragment.app.Fragment) EventFragment(app.insti.fragment.EventFragment) SettingsFragment(app.insti.fragment.SettingsFragment) BodyFragment(app.insti.fragment.BodyFragment) UserFragment(app.insti.fragment.UserFragment)

Example 42 with FragmentManager

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;
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager)

Example 43 with FragmentManager

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);
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Fragment(androidx.fragment.app.Fragment) DonationsFragment(org.sufficientlysecure.donations.DonationsFragment)

Example 44 with FragmentManager

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);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) NavigationView(com.google.android.material.navigation.NavigationView)

Example 45 with FragmentManager

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);
        }
    }
}
Also used : MonetarySpannable(de.schildbach.wallet.util.MonetarySpannable) Bundle(android.os.Bundle) DumpedPrivateKey(org.bitcoinj.core.DumpedPrivateKey) Transaction(org.bitcoinj.core.Transaction) PackageManager(android.content.pm.PackageManager) Coin(org.bitcoinj.core.Coin) WalletTransaction(org.bitcoinj.wallet.WalletTransaction) LoggerFactory(org.slf4j.LoggerFactory) ScanActivity(de.schildbach.wallet.ui.scan.ScanActivity) AbstractWalletActivityViewModel(de.schildbach.wallet.ui.AbstractWalletActivityViewModel) Process(android.os.Process) NetworkParameters(org.bitcoinj.core.NetworkParameters) PrefixedChecksummedBytes(org.bitcoinj.core.PrefixedChecksummedBytes) SendRequest(org.bitcoinj.wallet.SendRequest) Handler(android.os.Handler) Map(java.util.Map) Fragment(androidx.fragment.app.Fragment) View(android.view.View) Button(android.widget.Button) R(de.schildbach.wallet.R) Configuration(de.schildbach.wallet.Configuration) Constants(de.schildbach.wallet.Constants) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) BalanceType(org.bitcoinj.wallet.Wallet.BalanceType) ConfidenceType(org.bitcoinj.core.TransactionConfidence.ConfidenceType) Set(java.util.Set) ComparisonChain(com.google.common.collect.ComparisonChain) ViewGroup(android.view.ViewGroup) Preconditions.checkState(androidx.core.util.Preconditions.checkState) ECKey(org.bitcoinj.core.ECKey) TextView(android.widget.TextView) Nullable(androidx.annotation.Nullable) TransactionsAdapter(de.schildbach.wallet.ui.TransactionsAdapter) TransactionOutput(org.bitcoinj.core.TransactionOutput) UTXO(org.bitcoinj.core.UTXO) Context(android.content.Context) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Wallet(org.bitcoinj.wallet.Wallet) Intent(android.content.Intent) HashMap(java.util.HashMap) TreeSet(java.util.TreeSet) MenuItem(android.view.MenuItem) AnimationUtils(android.view.animation.AnimationUtils) ProgressDialogFragment(de.schildbach.wallet.ui.ProgressDialogFragment) SpannableStringBuilder(android.text.SpannableStringBuilder) VerificationException(org.bitcoinj.core.VerificationException) MenuInflater(android.view.MenuInflater) Menu(android.view.Menu) DialogEvent(de.schildbach.wallet.ui.DialogEvent) Sha256Hash(org.bitcoinj.core.Sha256Hash) BIP38PrivateKey(org.bitcoinj.crypto.BIP38PrivateKey) FragmentManager(androidx.fragment.app.FragmentManager) TransactionOutPoint(org.bitcoinj.core.TransactionOutPoint) Logger(org.slf4j.Logger) ViewModelProvider(androidx.lifecycle.ViewModelProvider) LayoutInflater(android.view.LayoutInflater) MonetaryFormat(org.bitcoinj.utils.MonetaryFormat) Threading(org.bitcoinj.utils.Threading) AbstractWalletActivity(de.schildbach.wallet.ui.AbstractWalletActivity) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) HandlerThread(android.os.HandlerThread) TransactionInput(org.bitcoinj.core.TransactionInput) StringInputParser(de.schildbach.wallet.ui.InputParser.StringInputParser) WalletApplication(de.schildbach.wallet.WalletApplication) Comparator(java.util.Comparator) Activity(android.app.Activity) EditText(android.widget.EditText) MonetaryFormat(org.bitcoinj.utils.MonetaryFormat) PrefixedChecksummedBytes(org.bitcoinj.core.PrefixedChecksummedBytes) ProgressDialogFragment(de.schildbach.wallet.ui.ProgressDialogFragment) Handler(android.os.Handler) PaymentIntent(de.schildbach.wallet.data.PaymentIntent) Intent(android.content.Intent) MonetarySpannable(de.schildbach.wallet.util.MonetarySpannable) TransactionOutPoint(org.bitcoinj.core.TransactionOutPoint) ConfidenceType(org.bitcoinj.core.TransactionConfidence.ConfidenceType) DialogEvent(de.schildbach.wallet.ui.DialogEvent) HandlerThread(android.os.HandlerThread) AbstractWalletActivityViewModel(de.schildbach.wallet.ui.AbstractWalletActivityViewModel) DialogBuilder(de.schildbach.wallet.ui.DialogBuilder) TransactionConfidence(org.bitcoinj.core.TransactionConfidence) SpannableStringBuilder(android.text.SpannableStringBuilder) ViewModelProvider(androidx.lifecycle.ViewModelProvider)

Aggregations

FragmentManager (androidx.fragment.app.FragmentManager)170 FragmentTransaction (androidx.fragment.app.FragmentTransaction)55 Fragment (androidx.fragment.app.Fragment)42 Bundle (android.os.Bundle)28 Test (org.junit.Test)15 Intent (android.content.Intent)13 FragmentActivity (androidx.fragment.app.FragmentActivity)10 Activity (android.app.Activity)6 View (android.view.View)6 DialogFragment (androidx.fragment.app.DialogFragment)6 TaskRetainerFragment (com.owncloud.android.ui.fragment.TaskRetainerFragment)5 ArrayList (java.util.ArrayList)5 Context (android.content.Context)4 DialogInterface (android.content.DialogInterface)3 LayoutInflater (android.view.LayoutInflater)3 MenuInflater (android.view.MenuInflater)3 Window (android.view.Window)3 TextView (android.widget.TextView)3 ViewModelProvider (androidx.lifecycle.ViewModelProvider)3 SslUntrustedCertDialog (com.owncloud.android.ui.dialog.SslUntrustedCertDialog)3