@Override
 public void onValueChanged(BgSeekBar seekBar, int value, boolean fromUser, boolean usingKeys) {
   if (ignoreChanges) return;
   hsv.h = barH.getValue() / 360.0;
   hsv.s = barS.getValue() / 100.0;
   hsv.v = barV.getValue() / 100.0;
   currentColor = hsv.toRGB(false);
   if (seekBar == barH) {
     updateGS();
     updateGV();
   } else if (seekBar == barS) {
     updateGH();
     updateGV();
   } else if (seekBar == barV) {
     updateGH();
     updateGS();
   }
   ignoreChanges = true;
   txtH.setText(Integer.toString((int) (hsv.h * 360.0)));
   txtS.setText(Integer.toString((int) (hsv.s * 100.0)));
   txtV.setText(Integer.toString((int) (hsv.v * 100.0)));
   txt.setText(ColorUtils.toHexColor(currentColor));
   ignoreChanges = false;
   barH.invalidate();
   barS.invalidate();
   barV.invalidate();
   bgCurrent.setColor(currentColor);
   lblCurrent.invalidate();
 }
 @Override
 public void afterTextChanged(Editable s) {
   if (ignoreChanges) return;
   final View f = getFocusedChild();
   if (f == txtH || f == txtS || f == txtV) {
     int nh, ns, nv;
     try {
       nh = Integer.parseInt(txtH.getText().toString());
       if (nh > 360 || nh < 0) return;
       ns = Integer.parseInt(txtS.getText().toString());
       if (ns > 100 || ns < 0) return;
       nv = Integer.parseInt(txtV.getText().toString());
       if (nv > 100 || nv < 0) return;
       hsv.h = (double) nh / 360.0;
       hsv.s = (double) ns / 100.0;
       hsv.v = (double) nv / 100.0;
     } catch (Throwable ex) {
       return;
     }
     ignoreChanges = true;
     currentColor = hsv.toRGB(false);
     barH.setValue(nh);
     barS.setValue(ns);
     barV.setValue(nv);
     txt.setText(ColorUtils.toHexColor(currentColor));
     ignoreChanges = false;
   } else {
     String cs = s.toString().trim();
     if (cs.length() < 6) return;
     if (cs.charAt(0) == '#') cs = cs.substring(1).trim();
     if (cs.length() != 6) return;
     int c = ColorUtils.parseHexColor(cs);
     if (c == 0) return;
     currentColor = c;
     hsv.fromRGB(c);
     ignoreChanges = true;
     c = (int) (hsv.h * 360.0);
     barH.setValue(c);
     txtH.setText(Integer.toString(c));
     c = (int) (hsv.s * 100.0);
     barS.setValue(c);
     txtS.setText(Integer.toString(c));
     c = (int) (hsv.v * 100.0);
     barV.setValue(c);
     txtV.setText(Integer.toString(c));
     ignoreChanges = false;
   }
   updateGH();
   updateGS();
   updateGV();
   barH.invalidate();
   barS.invalidate();
   barV.invalidate();
   bgCurrent.setColor(currentColor);
   lblCurrent.invalidate();
 }