コード例 #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);
  }
コード例 #2
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);
    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) {
            }
          }
        });
  }
コード例 #3
0
 public int getColor() {
   return mColorPicker.getColor();
 }
コード例 #4
0
 public void setAlphaSliderVisible(boolean visible) {
   mColorPicker.setAlphaSliderVisible(visible);
 }
コード例 #5
0
 @Override
 public void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onRestoreInstanceState(savedInstanceState);
   mOldColor.setColor(savedInstanceState.getInt("old_color"));
   mColorPicker.setColor(savedInstanceState.getInt("new_color"), true);
 }