Ejemplo n.º 1
0
  public void onActivityCreated(Bundle savedInstanceState) {
    picker = (ColorPicker) findViewById(R.id.picker1);
    OpacityBar opacityBar = (OpacityBar) findViewById(R.id.opacitybar1);
    SaturationBar saturationBar = (SaturationBar) findViewById(R.id.saturationbar1);

    picker.addOpacityBar(opacityBar);
    picker.addSaturationBar(saturationBar);
    picker.setOldCenterColor(picker.getColor());
    picker.setOnColorChangedListener(this);

    picker2 = (ColorPicker) findViewById(R.id.picker2);
    OpacityBar opacityBar2 = (OpacityBar) findViewById(R.id.opacitybar2);
    SaturationBar saturationBar2 = (SaturationBar) findViewById(R.id.saturationbar2);

    picker2.addOpacityBar(opacityBar2);
    picker2.addSaturationBar(saturationBar2);
    picker2.setOldCenterColor(picker2.getColor());
    picker2.setOnColorChangedListener(this);

    super.onActivityCreated(savedInstanceState);
  }
Ejemplo n.º 2
0
  protected void refreshBackgroundColors() {
    int leftColor =
        Color.argb(
            (int) (Color.alpha(picker.getColor()) * 0.5),
            Color.red(picker.getColor()),
            Color.green(picker.getColor()),
            Color.blue(picker.getColor()));
    int[] backColors = {leftColor, 0x00000000};
    ((LinearLayout) getActivity().findViewById(R.id.gradient_left))
        .setBackgroundDrawable(new GradientDrawable(Orientation.BOTTOM_TOP, backColors));

    int rightColor =
        Color.argb(
            (int) (Color.alpha(picker2.getColor()) * 0.5),
            Color.red(picker2.getColor()),
            Color.green(picker2.getColor()),
            Color.blue(picker2.getColor()));
    int[] backColors2 = {rightColor, 0x00000000};
    ((LinearLayout) getActivity().findViewById(R.id.gradient_right))
        .setBackgroundDrawable(new GradientDrawable(Orientation.BOTTOM_TOP, backColors2));
  }
Ejemplo n.º 3
0
  @Override
  public void onColorChanged(int color) {
    picker.setOldCenterColor(picker.getColor());
    picker2.setOldCenterColor(picker2.getColor());
    refreshBackgroundColors();

    if (!requestPending) {
      requestPending = true;
      AsyncHttpClient client = new AsyncHttpClient();
      client.get(
          SettingsFragment.ip
              + "color?color&"
              + colorToString(Color.red(picker.getColor()) * getAlpha(picker.getColor()))
              + "&"
              + colorToString(Color.green(picker.getColor()) * getAlpha(picker.getColor()))
              + "&"
              + colorToString(Color.blue(picker.getColor()) * getAlpha(picker.getColor()))
              + "&"
              + colorToString(Color.red(picker2.getColor()) * getAlpha(picker2.getColor()))
              + "&"
              + colorToString(Color.green(picker2.getColor()) * getAlpha(picker2.getColor()))
              + "&"
              + colorToString(Color.blue(picker2.getColor()) * getAlpha(picker2.getColor()))
              + "",
          new AsyncHttpResponseHandler() {
            @Override
            public void onFinish() {
              requestPending = false;
            }
          });
    }
  }