@Override
  public void onClick(View view) {
    ScriptTabActivity activity = (ScriptTabActivity) view.getContext();

    BrickTextDialog editDialog =
        new BrickTextDialog() {
          @Override
          protected void initialize() {
            input.setText(String.valueOf(changeGhostEffect));
            input.setInputType(
                InputType.TYPE_CLASS_NUMBER
                    | InputType.TYPE_NUMBER_FLAG_DECIMAL
                    | InputType.TYPE_NUMBER_FLAG_SIGNED);
            input.setSelectAllOnFocus(true);
          }

          @Override
          protected boolean handleOkButton() {
            try {
              changeGhostEffect = Double.parseDouble(input.getText().toString());
            } catch (NumberFormatException exception) {
              Toast.makeText(getActivity(), R.string.error_no_number_entered, Toast.LENGTH_SHORT)
                  .show();
            }

            return true;
          }
        };

    editDialog.show(activity.getSupportFragmentManager(), "dialog_change_ghost_effect_brick");
  }
Example #2
0
  @Override
  public void onClick(final View view) {
    ScriptActivity activity = (ScriptActivity) view.getContext();

    BrickTextDialog editDialog =
        new BrickTextDialog() {
          @Override
          protected void initialize() {
            if (view.getId() == R.id.brick_glide_to_edit_text_x) {
              input.setText(String.valueOf(xDestination));
              input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else if (view.getId() == R.id.brick_glide_to_edit_text_y) {
              input.setText(String.valueOf(yDestination));
              input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);
            } else if (view.getId() == R.id.brick_glide_to_edit_text_duration) {
              input.setText(String.valueOf(durationInMilliSeconds / 1000.0));
              input.setInputType(
                  InputType.TYPE_CLASS_NUMBER
                      | InputType.TYPE_NUMBER_FLAG_DECIMAL
                      | InputType.TYPE_NUMBER_FLAG_SIGNED);
            }

            input.setSelectAllOnFocus(true);
          }

          @Override
          protected boolean handleOkButton() {
            try {
              if (view.getId() == R.id.brick_glide_to_edit_text_x) {
                xDestination = Integer.parseInt(input.getText().toString());
              } else if (view.getId() == R.id.brick_glide_to_edit_text_y) {
                yDestination = Integer.parseInt(input.getText().toString());
              } else if (view.getId() == R.id.brick_glide_to_edit_text_duration) {
                durationInMilliSeconds =
                    (int) Math.round(Double.parseDouble(input.getText().toString()) * 1000);
              }
            } catch (NumberFormatException exception) {
              Toast.makeText(getActivity(), R.string.error_no_number_entered, Toast.LENGTH_SHORT)
                  .show();
            }

            return true;
          }
        };

    editDialog.show(activity.getSupportFragmentManager(), "dialog_glide_to_brick");
  }