Пример #1
0
  private void onUserDismiss() {
    refreshFormulaPreviewString(currentFormula.getTrimmedFormulaString(getActivity()));
    formulaEditorEditText.endEdit();
    currentFormula.prepareToRemove();

    Activity activity = getActivity();
    FragmentManager fragmentManager = activity.getFragmentManager();
    FragmentTransaction fragTransaction = fragmentManager.beginTransaction();
    fragTransaction.hide(this);
    fragTransaction.show(fragmentManager.findFragmentByTag(ScriptFragment.TAG));
    fragTransaction.commit();

    resetActionBar();

    BottomBar.showBottomBar(activity);
    BottomBar.showPlayButton(activity);
  }
Пример #2
0
  private void setInputFormula(Brick.BrickField brickField, int mode) {

    switch (mode) {
      case SET_FORMULA_ON_CREATE_VIEW:
        formulaEditorEditText.enterNewFormula(currentFormula.getInternFormulaState());
        currentFormula.highlightTextField(brickView);
        refreshFormulaPreviewString();
        break;

      case SET_FORMULA_ON_SWITCH_EDIT_TEXT:
        Formula newFormula = clonedFormulaBrick.getFormulaWithBrickField(brickField);
        if (currentFormula == newFormula && formulaEditorEditText.hasChanges()) {
          formulaEditorEditText.quickSelect();
          break;
        }
        if (formulaEditorEditText.hasChanges()) {
          confirmSwitchEditTextTimeStamp[0] = confirmSwitchEditTextTimeStamp[1];
          confirmSwitchEditTextTimeStamp[1] = System.currentTimeMillis();
          confirmSwitchEditTextCounter++;
          if (!saveFormulaIfPossible()) {
            return;
          }
        }
        MenuItem undo = currentMenu.findItem(R.id.menu_undo);
        if (undo != null) {
          undo.setIcon(R.drawable.icon_undo_disabled);
          undo.setEnabled(false);
        }

        MenuItem redo = currentMenu.findItem(R.id.menu_redo);
        redo.setIcon(R.drawable.icon_redo_disabled);
        redo.setEnabled(false);

        formulaEditorEditText.endEdit();
        currentBrickField = brickField;
        currentFormula = newFormula;
        formulaEditorEditText.enterNewFormula(newFormula.getInternFormulaState());
        refreshFormulaPreviewString();
        break;
      default:
        break;
    }
  }