Ejemplo n.º 1
0
  @Override
  public void onColorChanged(int color) {
    mNewColor.setColor(color);

    if (mListener != null) {
      mListener.onColorChanged(color);
    }
  }
Ejemplo n.º 2
0
  private void setUp(int color) {
    boolean isLandscapeLayout = false;

    LayoutInflater inflater =
        (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View layout = inflater.inflate(R.layout.dialog_color_picker, null);

    setView(layout);

    setTitle("Pick a Color");
    // setIcon(android.R.drawable.ic_dialog_info);

    LinearLayout landscapeLayout =
        (LinearLayout) layout.findViewById(R.id.dialog_color_picker_extra_layout_landscape);

    if (landscapeLayout != null) {
      isLandscapeLayout = true;
    }

    mColorPicker = (ColorPickerView) layout.findViewById(R.id.color_picker_view);
    mOldColor = (ColorPanelView) layout.findViewById(R.id.color_panel_old);
    mNewColor = (ColorPanelView) layout.findViewById(R.id.color_panel_new);

    if (!isLandscapeLayout) {
      ((LinearLayout) mOldColor.getParent())
          .setPadding(
              Math.round(mColorPicker.getDrawingOffset()),
              0,
              Math.round(mColorPicker.getDrawingOffset()),
              0);

    } else {
      landscapeLayout.setPadding(0, 0, Math.round(mColorPicker.getDrawingOffset()), 0);
      setTitle(null);
    }

    mColorPicker.setOnColorChangedListener(this);

    mOldColor.setColor(color);
    mColorPicker.setColor(color, true);
  }