Search in sources :

Example 36 with FragmentManager

use of androidx.fragment.app.FragmentManager in project FirebaseUI-Android by firebase.

the class PhoneActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fui_activity_register_phone);
    final PhoneProviderResponseHandler handler = new ViewModelProvider(this).get(PhoneProviderResponseHandler.class);
    handler.init(getFlowParams());
    handler.getOperation().observe(this, new ResourceObserver<IdpResponse>(this, R.string.fui_progress_dialog_signing_in) {

        @Override
        protected void onSuccess(@NonNull IdpResponse response) {
            startSaveCredentials(handler.getCurrentUser(), response, null);
        }

        @Override
        protected void onFailure(@NonNull Exception e) {
            handleError(e);
        }
    });
    mPhoneVerifier = new ViewModelProvider(this).get(PhoneNumberVerificationHandler.class);
    mPhoneVerifier.init(getFlowParams());
    mPhoneVerifier.onRestoreInstanceState(savedInstanceState);
    mPhoneVerifier.getOperation().observe(this, new ResourceObserver<PhoneVerification>(this, R.string.fui_verifying) {

        @Override
        protected void onSuccess(@NonNull PhoneVerification verification) {
            if (verification.isAutoVerified()) {
                Toast.makeText(PhoneActivity.this, R.string.fui_auto_verified, Toast.LENGTH_LONG).show();
                FragmentManager manager = getSupportFragmentManager();
                if (manager.findFragmentByTag(SubmitConfirmationCodeFragment.TAG) != null) {
                    // Ensure the submit code screen isn't visible if there's no code to submit.
                    // It's possible to get into this state when an SMS is sent, but then
                    // automatically retrieved.
                    manager.popBackStack();
                }
            }
            handler.startSignIn(verification.getCredential(), new IdpResponse.Builder(new User.Builder(PhoneAuthProvider.PROVIDER_ID, null).setPhoneNumber(verification.getNumber()).build()).build());
        }

        @Override
        protected void onFailure(@NonNull Exception e) {
            if (e instanceof PhoneNumberVerificationRequiredException) {
                // already be visible so we have nothing to do.
                if (getSupportFragmentManager().findFragmentByTag(SubmitConfirmationCodeFragment.TAG) == null) {
                    showSubmitCodeFragment(((PhoneNumberVerificationRequiredException) e).getPhoneNumber());
                }
                // Clear existing errors
                handleError(null);
            } else {
                handleError(e);
            }
        }
    });
    if (savedInstanceState != null) {
        return;
    }
    Bundle params = getIntent().getExtras().getBundle(ExtraConstants.PARAMS);
    CheckPhoneNumberFragment fragment = CheckPhoneNumberFragment.newInstance(params);
    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_phone, fragment, CheckPhoneNumberFragment.TAG).disallowAddToBackStack().commit();
}
Also used : Bundle(android.os.Bundle) PhoneNumberVerificationRequiredException(com.firebase.ui.auth.data.model.PhoneNumberVerificationRequiredException) PhoneNumberVerificationRequiredException(com.firebase.ui.auth.data.model.PhoneNumberVerificationRequiredException) FirebaseAuthAnonymousUpgradeException(com.firebase.ui.auth.FirebaseAuthAnonymousUpgradeException) FirebaseUiException(com.firebase.ui.auth.FirebaseUiException) FirebaseAuthException(com.google.firebase.auth.FirebaseAuthException) FragmentManager(androidx.fragment.app.FragmentManager) PhoneProviderResponseHandler(com.firebase.ui.auth.viewmodel.phone.PhoneProviderResponseHandler) ViewModelProvider(androidx.lifecycle.ViewModelProvider) IdpResponse(com.firebase.ui.auth.IdpResponse)

Example 37 with FragmentManager

use of androidx.fragment.app.FragmentManager in project aware-client by denzilferreira.

the class ESM_Queue method onResume.

@Override
protected void onResume() {
    super.onResume();
    if (getQueueSize(getApplicationContext()) == 0)
        finish();
    try {
        FragmentManager fragmentManager = getSupportFragmentManager();
        Cursor current_esm;
        if (ESM.isESMVisible(getApplicationContext())) {
            current_esm = getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_VISIBLE, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1");
        } else {
            current_esm = getContentResolver().query(ESM_Data.CONTENT_URI, null, ESM_Data.STATUS + "=" + ESM.STATUS_NEW, null, ESM_Data.TIMESTAMP + " ASC LIMIT 1");
        }
        if (current_esm != null && current_esm.moveToFirst()) {
            int _id = current_esm.getInt(current_esm.getColumnIndex(ESM_Data._ID));
            // Fixed: set the esm as VISIBLE, to avoid displaying the same ESM twice due to changes in orientation
            ContentValues update_state = new ContentValues();
            update_state.put(ESM_Data.STATUS, ESM.STATUS_VISIBLE);
            getContentResolver().update(ESM_Data.CONTENT_URI, update_state, ESM_Data._ID + "=" + _id, null);
            // --
            // Load esm question JSON from database
            JSONObject esm_question = new JSONObject(current_esm.getString(current_esm.getColumnIndex(ESM_Data.JSON)));
            ESM_Question esm = esmFactory.getESM(esm_question.getInt(ESM_Question.esm_type), esm_question, current_esm.getInt(current_esm.getColumnIndex(ESM_Data._ID)));
            if (esm != null) {
                esm.show(fragmentManager, TAG);
            }
        }
        if (current_esm != null && !current_esm.isClosed())
            current_esm.close();
    } catch (JSONException e) {
        e.printStackTrace();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) JSONObject(org.json.JSONObject) ESM_Question(com.aware.ui.esms.ESM_Question) JSONException(org.json.JSONException) Cursor(android.database.Cursor)

Example 38 with FragmentManager

use of androidx.fragment.app.FragmentManager in project easypermissions by googlesamples.

the class BaseSupportPermissionsHelper method showRequestPermissionRationale.

@Override
public void showRequestPermissionRationale(@NonNull String rationale, @NonNull String positiveButton, @NonNull String negativeButton, @StyleRes int theme, int requestCode, @NonNull String... perms) {
    FragmentManager fm = getSupportFragmentManager();
    // Check if fragment is already showing
    Fragment fragment = fm.findFragmentByTag(RationaleDialogFragmentCompat.TAG);
    if (fragment instanceof RationaleDialogFragmentCompat) {
        Log.d(TAG, "Found existing fragment, not showing rationale.");
        return;
    }
    RationaleDialogFragmentCompat.newInstance(rationale, positiveButton, negativeButton, theme, requestCode, perms).showAllowingStateLoss(fm, RationaleDialogFragmentCompat.TAG);
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) RationaleDialogFragmentCompat(pub.devrel.easypermissions.RationaleDialogFragmentCompat) Fragment(androidx.fragment.app.Fragment)

Example 39 with FragmentManager

use of androidx.fragment.app.FragmentManager in project zype-android by zype.

the class ChromecastFragment method onAttach.

@Override
public void onAttach(Context context) {
    super.onAttach(context);
    Bundle extras = getArguments();
    if (extras == null) {
        throw new IllegalStateException("extras == null");
    }
    FragmentManager fm = getFragmentManager();
    VideoCastControllerFragment videoCastControllerFragment = (VideoCastControllerFragment) fm.findFragmentByTag(TASK_TAG);
    if (videoCastControllerFragment != null) {
        fm.beginTransaction().remove(videoCastControllerFragment).commit();
    }
    videoCastControllerFragment = VideoCastControllerFragment.newInstance(extras);
    fm.beginTransaction().add(videoCastControllerFragment, TASK_TAG).commit();
    mControllerListener = videoCastControllerFragment;
    try {
        mListener = (OnVideoAudioListener) context;
    } catch (ClassCastException e) {
        throw new ClassCastException(context.toString() + " must implement OnVideoAudioListener");
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) Bundle(android.os.Bundle)

Example 40 with FragmentManager

use of androidx.fragment.app.FragmentManager in project zype-android by zype.

the class VideoDetailActivity method showSections.

private void showSections(String videoId) {
    pagerSections = findViewById(R.id.pagerSections);
    tabs = findViewById(R.id.tabs);
    layoutSummary = findViewById(R.id.layoutSummary);
    if (hasOptions(videoId)) {
        pagerSections.setAdapter(new VideoDetailPagerAdapter(this, getSupportFragmentManager(), videoId));
        tabs.setupWithViewPager(pagerSections);
        pagerSections.setVisibility(View.VISIBLE);
        tabs.setVisibility(View.VISIBLE);
        layoutSummary.setVisibility(GONE);
    } else {
        pagerSections.setVisibility(GONE);
        tabs.setVisibility(GONE);
        layoutSummary.setVisibility(View.VISIBLE);
        FragmentManager fm = getSupportFragmentManager();
        Fragment fragment = SummaryFragment.newInstance();
        fm.beginTransaction().replace(R.id.layoutSummary, fragment, SummaryFragment.TAG).commit();
    }
}
Also used : FragmentManager(androidx.fragment.app.FragmentManager) VideoDetailPagerAdapter(com.zype.android.ui.video_details.VideoDetailPagerAdapter) Fragment(androidx.fragment.app.Fragment) ThumbnailFragment(com.zype.android.ui.player.ThumbnailFragment) SummaryFragment(com.zype.android.ui.video_details.fragments.summary.SummaryFragment) PlayerFragment(com.zype.android.ui.player.v2.PlayerFragment)

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