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();
}
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();
}
}
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);
}
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");
}
}
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();
}
}
Aggregations