private void setUp(int color, boolean alphaSlider) { mColorPickerView = (ColorPickerView) findViewById(R.id.color_picker_view); mOldColorPanel = (ColorPanelView) findViewById(R.id.old_color_panel); mNewColorPanel = (ColorPanelView) findViewById(R.id.new_color_panel); mOkButton = (Button) findViewById(R.id.ok_button); mCancelButton = (Button) findViewById(R.id.cancel_button); ((LinearLayout) mOldColorPanel.getParent()) .setPadding( Math.round(mColorPickerView.getDrawingOffset()), 0, Math.round(mColorPickerView.getDrawingOffset()), 0); mColorPickerView.setOnColorChangedListener( new ColorPickerView.OnColorChangedListener() { @Override public void onColorChanged(int color) { mNewColorPanel.setColor(color); } }); mOldColorPanel.setColor(color); mColorPickerView.setColor(color, true); mColorPickerView.setAlphaSliderVisible(alphaSlider); mColorPickerView.setSliderTrackerColor(0xffCECECE); mColorPickerView.setBorderColor(0xff7E7E7E); mOldColorPanel.setBorderColor(mColorPickerView.getBorderColor()); mNewColorPanel.setBorderColor(mColorPickerView.getBorderColor()); mOkButton.setOnClickListener(this); mCancelButton.setOnClickListener(this); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.ok_button: Intent i = new Intent(); i.putExtra(RESULT_COLOR, mColorPickerView.getColor()); setResult(Activity.RESULT_OK, i); finish(); break; case R.id.cancel_button: setResult(Activity.RESULT_CANCELED); finish(); break; } }