use of androidx.fragment.app.FragmentManager in project syncthing-android by syncthing.
the class MainActivity method onSaveInstanceState.
/**
* Saves current tab index and fragment states.
*/
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
FragmentManager fm = getSupportFragmentManager();
Consumer<Fragment> putFragment = fragment -> {
if (fragment != null && fragment.isAdded()) {
fm.putFragment(outState, fragment.getClass().getName(), fragment);
}
};
putFragment.accept(mFolderListFragment);
putFragment.accept(mDeviceListFragment);
putFragment.accept(mDrawerFragment);
outState.putInt("currentTab", mViewPager.getCurrentItem());
outState.putBoolean(BATTERY_DIALOG_DISMISSED, mBatteryOptimizationsDialog == null || !mBatteryOptimizationsDialog.isShowing());
outState.putBoolean(IS_SHOWING_RESTART_DIALOG, mRestartDialog != null && mRestartDialog.isShowing());
if (mQrCodeDialog != null && mQrCodeDialog.isShowing()) {
outState.putBoolean(IS_QRCODE_DIALOG_DISPLAYED, true);
ImageView qrCode = mQrCodeDialog.findViewById(R.id.qrcode_image_view);
TextView deviceID = mQrCodeDialog.findViewById(R.id.device_id);
outState.putParcelable(QRCODE_BITMAP_KEY, ((BitmapDrawable) qrCode.getDrawable()).getBitmap());
outState.putString(DEVICEID_KEY, deviceID.getText().toString());
}
Util.dismissDialogSafe(mRestartDialog, this);
}
use of androidx.fragment.app.FragmentManager in project Applozic-Android-SDK by AppLozic.
the class MainActivity method onNavigationDrawerItemSelected.
@Override
public void onNavigationDrawerItemSelected(int position) {
if (position == 1) {
Intent intent = new Intent(this, ConversationActivity.class);
if (ApplozicClient.getInstance(this).isContextBasedChat()) {
intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
}
startActivity(intent);
return;
}
/*
if (position == 1) {
ConversationFragment conversationFragment = new ConversationFragment();
Contact contact = new Contact(this, "mobicomkit");
mTitle = getString(R.string.user_id);
addFragment(this, conversationFragment, "conversationFragment");
conversationFragment.loadConversation(contact);
return;
}*/
if (position == 0) {
mTitle = getString(R.string.ecommerce);
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, EcommerceFragment.newInstance("", "")).commit();
return;
}
if (position == 2) {
Applozic.logoutUser(this, new AlLogoutHandler() {
@Override
public void onSuccess(Context context) {
Toast.makeText(getBaseContext(), getBaseContext().getString(R.string.log_out_successful), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(context, LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
startActivity(intent);
finish();
}
@Override
public void onFailure(Exception exception) {
AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
alertDialog.setTitle(getString(R.string.text_alert));
alertDialog.setMessage(exception.toString());
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok_alert), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
if (!isFinishing()) {
alertDialog.show();
}
}
});
}
if (position == 3) {
Map<String, String> messageMetaData = new HashMap<>();
messageMetaData.put(Message.MetaDataType.KEY.getValue(), Message.MetaDataType.HIDDEN.getValue());
Message message = new Message();
MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(MainActivity.this);
message.setContactIds("android");
message.setTo("android");
message.setContentType(Message.ContentType.CUSTOM.getValue());
message.setMessage("this is meta data hidden");
message.setMetadata(messageMetaData);
message.setStoreOnDevice(Boolean.TRUE);
message.setRead(Boolean.TRUE);
message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
message.setSendToDevice(Boolean.FALSE);
message.setType(Message.MessageType.MT_OUTBOX.getValue());
message.setDeviceKeyString(userPreferences.getDeviceKeyString());
message.setSource(Message.Source.MT_MOBILE_APP.getValue());
new MobiComConversationService(MainActivity.this).sendMessage(message);
}
FragmentManager fragmentManager = getSupportFragmentManager();
fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
}
use of androidx.fragment.app.FragmentManager in project prebid-mobile-android by prebid.
the class PrebidServerSettingsViewholder method openPrebidServerDialog.
private void openPrebidServerDialog() {
FragmentManager fragmentManager = ((AppCompatActivity) itemView.getContext()).getSupportFragmentManager();
PrebidServerDialog dialog = PrebidServerDialog.newInstance();
dialog.show(fragmentManager, PrebidServerDialog.TAG);
}
use of androidx.fragment.app.FragmentManager in project prebid-mobile-android by prebid.
the class PrebidServerSettingsViewholder method openInputDialog.
private void openInputDialog(String title, int type, int format, boolean shouldShowQrScanner) {
FragmentManager fragmentManager = ((AppCompatActivity) itemView.getContext()).getSupportFragmentManager();
InputDialog dialog = InputDialog.newInstance(title, type, format, shouldShowQrScanner);
dialog.show(fragmentManager, InputDialog.TAG);
}
use of androidx.fragment.app.FragmentManager in project Applozic-Android-SDK by AppLozic.
the class ContactSelectionActivity method addFragment.
public static void addFragment(FragmentActivity fragmentActivity, Fragment fragmentToAdd, String fragmentTag) {
FragmentManager supportFragmentManager = fragmentActivity.getSupportFragmentManager();
FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.layout_child_activity, fragmentToAdd, fragmentTag);
if (supportFragmentManager.getBackStackEntryCount() > 1) {
supportFragmentManager.popBackStack();
}
fragmentTransaction.addToBackStack(fragmentTag);
fragmentTransaction.commitAllowingStateLoss();
supportFragmentManager.executePendingTransactions();
}
Aggregations