@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(!ViewConfiguration.get(getActivity()).hasPermanentMenuKey()); setUpActionBar(); onFormulaChangedListener = (OnFormulaChangedListener) ((ScriptActivity) getActivity()).getFragment(ScriptActivity.FRAGMENT_SCRIPTS); formulaBrick = (FormulaBrick) getArguments().getSerializable(FORMULA_BRICK_BUNDLE_ARGUMENT); currentBrickField = Brick.BrickField.valueOf(getArguments().getString(BRICKFIELD_BUNDLE_ARGUMENT)); cloneFormulaBrick(formulaBrick); currentFormula = clonedFormulaBrick.getFormulaWithBrickField(currentBrickField); }
private static void showFragment( View view, FormulaBrick formulaBrick, Brick.BrickField brickField, boolean showCustomView) { Activity activity = (Activity) view.getContext(); FormulaEditorFragment formulaEditorFragment = (FormulaEditorFragment) activity.getFragmentManager().findFragmentByTag(FORMULA_EDITOR_FRAGMENT_TAG); FragmentManager fragmentManager = activity.getFragmentManager(); FragmentTransaction fragTransaction = fragmentManager.beginTransaction(); if (formulaEditorFragment == null) { formulaEditorFragment = new FormulaEditorFragment(); formulaEditorFragment.showCustomView = showCustomView; Bundle bundle = new Bundle(); bundle.putSerializable(FORMULA_BRICK_BUNDLE_ARGUMENT, formulaBrick); bundle.putString(BRICKFIELD_BUNDLE_ARGUMENT, brickField.name()); formulaEditorFragment.setArguments(bundle); fragTransaction.add( R.id.fragment_container, formulaEditorFragment, FORMULA_EDITOR_FRAGMENT_TAG); fragTransaction.hide(fragmentManager.findFragmentByTag(ScriptFragment.TAG)); fragTransaction.show(formulaEditorFragment); BottomBar.hideBottomBar(activity); } else if (formulaEditorFragment.isHidden()) { formulaEditorFragment.showCustomView = showCustomView; formulaEditorFragment.updateBrickViewAndFormula(formulaBrick, brickField); fragTransaction.hide(fragmentManager.findFragmentByTag(ScriptFragment.TAG)); fragTransaction.show(formulaEditorFragment); BottomBar.hideBottomBar(activity); } else { refreshUserBrickParameterValuesIfNecessary(formulaBrick, brickField, formulaEditorFragment); formulaEditorFragment.showCustomView = false; formulaEditorFragment.updateBrickView(); formulaEditorFragment.setInputFormula(brickField, SET_FORMULA_ON_SWITCH_EDIT_TEXT); } fragTransaction.commit(); }