use of com.annimon.stream.function.Consumer 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);
}
Aggregations