Exemplo n.º 1
0
  private void setUp(int color) {

    LayoutInflater inflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.dialog_color_picker, null);

    setContentView(layout);

    setTitle(R.string.dialog_color_picker);

    mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
    mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
    mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);

    ((LinearLayout) mOldColor.getParent())
        .setPadding(
            Math.round(mColorPicker.getDrawingOffset()),
            0,
            Math.round(mColorPicker.getDrawingOffset()),
            0);

    mOldColor.setOnClickListener(this);
    mNewColor.setOnClickListener(this);
    mColorPicker.setOnColorChangedListener(this);
    mOldColor.setColor(color);
    mColorPicker.setColor(color, true);
  }
  private void setUp(int color) {

    LayoutInflater inflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.dialog_color_picker, null);

    setContentView(layout);

    setTitle(R.string.dialog_color_picker);

    mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
    mOldColor = (ColorPickerPanelView) layout.findViewById(R.id.old_color_panel);
    mNewColor = (ColorPickerPanelView) layout.findViewById(R.id.new_color_panel);
    mHex = (EditText) layout.findViewById(R.id.hex);
    mSetButton = (Button) layout.findViewById(R.id.enter);
    mDefaultColor = (Button) layout.findViewById(R.id.default_color);

    ((LinearLayout) mOldColor.getParent())
        .setPadding(
            Math.round(mColorPicker.getDrawingOffset()),
            0,
            Math.round(mColorPicker.getDrawingOffset()),
            0);

    mOldColor.setOnClickListener(this);
    mNewColor.setOnClickListener(this);
    mColorPicker.setOnColorChangedListener(this);
    mOldColor.setColor(color);
    mColorPicker.setColor(color, true);
    mHex.setText(ColorPickerSetting.convertToARGB(color));
    mSetButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            String text = mHex.getText().toString();
            try {
              int newColor = ColorPickerSetting.convertToColorInt(text);
              mColorPicker.setColor(newColor, true);
            } catch (Exception e) {
            }
          }
        });
    mDefaultColor.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            try {
              int newColor = 0xFFFFFFFF;
              mColorPicker.setColor(newColor, true);
            } catch (Exception e) {
            }
          }
        });
  }