@Override
  public View getView(Context context, int brickId, BaseAdapter baseAdapter) {
    if (animationState) {
      return view;
    }
    if (view == null) {
      alphaValue = 255;
    }
    view = View.inflate(context, R.layout.brick_nxt_motor_stop, null);
    view = getViewWithAlpha(alphaValue);

    setCheckboxView(R.id.brick_nxt_motor_stop_checkbox);
    final Brick brickInstance = this;
    checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(brickInstance, isChecked);
          }
        });

    ArrayAdapter<CharSequence> motorAdapter =
        ArrayAdapter.createFromResource(
            context, R.array.nxt_stop_motor_chooser, android.R.layout.simple_spinner_item);
    motorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Spinner motorSpinner = (Spinner) view.findViewById(R.id.stop_motor_spinner);
    motorSpinner.setOnItemSelectedListener(this);

    if (!(checkbox.getVisibility() == View.VISIBLE)) {
      motorSpinner.setClickable(true);
      motorSpinner.setEnabled(true);
    } else {
      motorSpinner.setClickable(false);
      motorSpinner.setEnabled(false);
    }

    motorSpinner.setAdapter(motorAdapter);
    motorSpinner.setSelection(motorEnum.ordinal());
    return view;
  }
示例#2
0
  @Override
  public View getView(final Context context, int brickId, BaseAdapter adapter) {
    View view = View.inflate(context, R.layout.brick_play_sound, null);

    Spinner soundbrickSpinner = (Spinner) view.findViewById(R.id.playsound_spinner);
    soundbrickSpinner.setAdapter(createSoundAdapter(context));
    soundbrickSpinner.setClickable(true);
    soundbrickSpinner.setFocusable(true);
    soundbrickSpinner.setOnItemSelectedListener(this);

    if (sprite.getSoundList().contains(sound)) {
      soundbrickSpinner.setSelection(sprite.getSoundList().indexOf(sound) + 1, true);
    } else {
      soundbrickSpinner.setSelection(0);
    }

    return view;
  }
  @Override
  public View getView(Context context, int brickId, BaseAdapter baseAdapter) {
    if (animationState) {
      return view;
    }
    if (view == null) {
      alphaValue = 255;
    }

    view = View.inflate(context, R.layout.brick_nxt_motor_action, null);
    view = getViewWithAlpha(alphaValue);
    setCheckboxView(R.id.brick_nxt_motor_action_checkbox);

    final Brick brickInstance = this;
    checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(brickInstance, isChecked);
          }
        });

    TextView textSpeed = (TextView) view.findViewById(R.id.motor_action_speed_text_view);
    editSpeed = (EditText) view.findViewById(R.id.motor_action_speed_edit_text);
    speed.setTextFieldId(R.id.motor_action_speed_edit_text);
    speed.refreshTextField(view);

    textSpeed.setVisibility(View.GONE);
    editSpeed.setVisibility(View.VISIBLE);

    editSpeed.setOnClickListener(this);

    ArrayAdapter<CharSequence> motorAdapter =
        ArrayAdapter.createFromResource(
            context, R.array.nxt_motor_chooser, android.R.layout.simple_spinner_item);
    motorAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner motorSpinner = (Spinner) view.findViewById(R.id.lego_motor_action_spinner);

    if (!(checkbox.getVisibility() == View.VISIBLE)) {
      motorSpinner.setClickable(true);
      motorSpinner.setEnabled(true);
    } else {
      motorSpinner.setClickable(false);
      motorSpinner.setEnabled(false);
    }

    motorSpinner.setAdapter(motorAdapter);
    motorSpinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
            motorEnum = Motor.values()[position];
            motor = motorEnum.name();
            adapterView = arg0;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    motorSpinner.setSelection(motorEnum.ordinal());

    return view;
  }
示例#4
0
  @Override
  public View getView(final Context context, int brickId, BaseAdapter baseAdapter) {
    if (animationState) {
      return view;
    }

    LayoutInflater inflater =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    view = inflater.inflate(R.layout.brick_point_to, null);
    view = getViewWithAlpha(alphaValue);

    setCheckboxView(R.id.brick_point_to_checkbox);

    final Brick brickInstance = this;
    checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(brickInstance, isChecked);
          }
        });

    final Spinner spinner = (Spinner) view.findViewById(R.id.brick_point_to_spinner);
    spinner.setFocusableInTouchMode(false);
    spinner.setFocusable(false);
    if (!(checkbox.getVisibility() == View.VISIBLE)) {
      spinner.setClickable(true);
      spinner.setEnabled(true);
    } else {
      spinner.setClickable(false);
      spinner.setEnabled(false);
    }

    final ArrayAdapter<String> spinnerAdapter = getArrayAdapterFromSpriteList(context);

    spinnerAdapterWrapper = new SpinnerAdapterWrapper(context, spinner, spinnerAdapter);

    spinner.setAdapter(spinnerAdapterWrapper);

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            String itemSelected = parent.getSelectedItem().toString();

            if (itemSelected.equals(context.getString(R.string.new_broadcast_message))) {
              pointedObject = null;
            } else {
              final ArrayList<Sprite> spriteList =
                  (ArrayList<Sprite>)
                      ProjectManager.getInstance().getCurrentProject().getSpriteList();

              for (Sprite sprite : spriteList) {
                String spriteName = sprite.getName();
                if (spriteName.equals(itemSelected)) {
                  pointedObject = sprite;
                  break;
                }
              }
            }
            adapterView = parent;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    setSpinnerSelection(spinner);

    return view;
  }
 public void updateUi() {
   domainNameAdapter = new ArrayAdapter<String>(this, R.layout.spinner_item, domainNameList);
   domainName.setAdapter(domainNameAdapter);
   domainName.setClickable(true);
   wireSubmitButton();
 }
示例#6
0
  @Override
  public View getView(Context context, int brickId, BaseAdapter baseAdapter) {

    if (animationState) {
      return view;
    }
    if (view == null) {
      alphaValue = 255;
    }

    view = View.inflate(context, R.layout.brick_phiro_rgb_light, null);
    setCheckboxView(R.id.brick_phiro_rgb_led_action_checkbox);

    final Brick brickInstance = this;
    checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(brickInstance, isChecked);
          }
        });

    TextView textRed =
        (TextView) view.findViewById(R.id.brick_phiro_rgb_led_red_prototype_text_view);
    editRedValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_red_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_RED)
        .setTextFieldId(R.id.brick_phiro_rgb_led_action_red_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_RED).refreshTextField(view);

    textRed.setVisibility(View.GONE);
    editRedValue.setVisibility(View.VISIBLE);

    editRedValue.setOnClickListener(this);

    TextView textGreen =
        (TextView) view.findViewById(R.id.brick_phiro_rgb_led_green_prototype_text_view);
    editGreenValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_green_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_GREEN)
        .setTextFieldId(R.id.brick_phiro_rgb_led_action_green_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_GREEN).refreshTextField(view);

    textGreen.setVisibility(View.GONE);
    editGreenValue.setVisibility(View.VISIBLE);

    editGreenValue.setOnClickListener(this);

    TextView textBlue =
        (TextView) view.findViewById(R.id.brick_phiro_rgb_led_blue_prototype_text_view);
    editBlueValue = (TextView) view.findViewById(R.id.brick_phiro_rgb_led_action_blue_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_BLUE)
        .setTextFieldId(R.id.brick_phiro_rgb_led_action_blue_edit_text);
    getFormulaWithBrickField(BrickField.PHIRO_LIGHT_BLUE).refreshTextField(view);

    textBlue.setVisibility(View.GONE);
    editBlueValue.setVisibility(View.VISIBLE);

    editBlueValue.setOnClickListener(this);

    ArrayAdapter<CharSequence> eyeAdapter =
        ArrayAdapter.createFromResource(
            context,
            R.array.brick_phiro_select_light_spinner,
            android.R.layout.simple_spinner_item);
    eyeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    Spinner eyeSpinner = (Spinner) view.findViewById(R.id.brick_phiro_rgb_light_spinner);

    if (!(checkbox.getVisibility() == View.VISIBLE)) {
      eyeSpinner.setClickable(true);
      eyeSpinner.setEnabled(true);
    } else {
      eyeSpinner.setClickable(false);
      eyeSpinner.setEnabled(false);
    }

    eyeSpinner.setAdapter(eyeAdapter);
    eyeSpinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(AdapterView<?> arg0, View arg1, int position, long arg3) {
            eyeEnum = Eye.values()[position];
            eye = eyeEnum.name();
            adapterView = arg0;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {}
        });

    eyeSpinner.setSelection(eyeEnum.ordinal());

    return view;
  }
示例#7
0
  @Override
  public View getView(final Context context, int brickId, BaseAdapter baseAdapter) {
    if (animationState) {
      return view;
    }

    view = View.inflate(context, R.layout.brick_change_variable_by, null);
    view = getViewWithAlpha(alphaValue);
    setCheckboxView(R.id.brick_change_variable_checkbox);
    final Brick brickInstance = this;

    checkbox.setOnCheckedChangeListener(
        new OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            checked = isChecked;
            adapter.handleCheck(brickInstance, isChecked);
          }
        });

    TextView prototypeText =
        (TextView) view.findViewById(R.id.brick_change_variable_prototype_view);
    TextView textField = (TextView) view.findViewById(R.id.brick_change_variable_edit_text);
    prototypeText.setVisibility(View.GONE);
    getFormulaWithBrickField(BrickField.VARIABLE_CHANGE)
        .setTextFieldId(R.id.brick_change_variable_edit_text);
    getFormulaWithBrickField(BrickField.VARIABLE_CHANGE).refreshTextField(view);
    textField.setVisibility(View.VISIBLE);
    textField.setOnClickListener(this);

    Spinner variableSpinner = (Spinner) view.findViewById(R.id.change_variable_spinner);

    UserBrick currentBrick = ProjectManager.getInstance().getCurrentUserBrick();
    int userBrickId = (currentBrick == null ? -1 : currentBrick.getUserBrickId());

    DataAdapter dataAdapter =
        ProjectManager.getInstance()
            .getCurrentProject()
            .getDataContainer()
            .createDataAdapter(
                context, userBrickId, ProjectManager.getInstance().getCurrentSprite(), inUserBrick);
    UserVariableAdapterWrapper userVariableAdapterWrapper =
        new UserVariableAdapterWrapper(context, dataAdapter);
    userVariableAdapterWrapper.setItemLayout(
        android.R.layout.simple_spinner_item, android.R.id.text1);

    variableSpinner.setAdapter(userVariableAdapterWrapper);

    if (!(checkbox.getVisibility() == View.VISIBLE)) {
      variableSpinner.setClickable(true);
      variableSpinner.setEnabled(true);
    } else {
      variableSpinner.setClickable(false);
      variableSpinner.setFocusable(false);
    }

    setSpinnerSelection(variableSpinner, null);

    variableSpinner.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View view, MotionEvent event) {
            if (event.getAction() == MotionEvent.ACTION_UP
                && ((Spinner) view).getSelectedItemPosition() == 0
                && ((Spinner) view).getAdapter().getCount() == 1) {
              NewDataDialog dialog =
                  new NewDataDialog((Spinner) view, NewDataDialog.DialogType.USER_VARIABLE);
              dialog.addVariableDialogListener(ChangeVariableBrick.this);
              dialog.show(
                  ((SherlockFragmentActivity) view.getContext()).getSupportFragmentManager(),
                  NewDataDialog.DIALOG_FRAGMENT_TAG);
              return true;
            }
            return false;
          }
        });

    variableSpinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {
          @Override
          public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0
                && ((UserVariableAdapterWrapper) parent.getAdapter()).isTouchInDropDownView()) {
              NewDataDialog dialog =
                  new NewDataDialog((Spinner) parent, NewDataDialog.DialogType.USER_VARIABLE);
              dialog.addVariableDialogListener(ChangeVariableBrick.this);
              dialog.show(
                  ((SherlockFragmentActivity) view.getContext()).getSupportFragmentManager(),
                  NewDataDialog.DIALOG_FRAGMENT_TAG);
            }
            ((UserVariableAdapterWrapper) parent.getAdapter()).resetIsTouchInDropDownView();
            userVariable = (UserVariable) parent.getItemAtPosition(position);
            adapterView = parent;
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            userVariable = null;
          }
        });

    return view;
  }