From 03f3970d64fa31d39886a85a6dc674236fa31284 Mon Sep 17 00:00:00 2001 From: RickDB Date: Fri, 15 Jan 2016 19:54:18 +0100 Subject: [PATCH] Create separate multicast function and restore old static color on cancel colorwheel --- atmoorb/src/com/EvilCorp/atmoorb/ColorPicker.java | 6 +++++- atmoorb/src/com/EvilCorp/atmoorb/ColorPickerDialog.java | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/atmoorb/src/com/EvilCorp/atmoorb/ColorPicker.java b/atmoorb/src/com/EvilCorp/atmoorb/ColorPicker.java index cbdcefd..6638d93 100644 --- a/atmoorb/src/com/EvilCorp/atmoorb/ColorPicker.java +++ b/atmoorb/src/com/EvilCorp/atmoorb/ColorPicker.java @@ -240,13 +240,17 @@ protected void onDraw(Canvas canvas) { } int color = getColor(); + sendApiColorCommand(color); + } + + public void sendApiColorCommand(int color) + { cRed = Color.red(color); cGreen = Color.green(color); cBlue = Color.blue(color); cCommand = "static"; new SendMultiCastData().execute(""); } - private void drawPointerArrow(Canvas canvas) { int centerX = getWidth() / 2; diff --git a/atmoorb/src/com/EvilCorp/atmoorb/ColorPickerDialog.java b/atmoorb/src/com/EvilCorp/atmoorb/ColorPickerDialog.java index 7c951f4..a9f8183 100644 --- a/atmoorb/src/com/EvilCorp/atmoorb/ColorPickerDialog.java +++ b/atmoorb/src/com/EvilCorp/atmoorb/ColorPickerDialog.java @@ -10,6 +10,8 @@ public class ColorPickerDialog extends AlertDialog { private ColorPicker colorPickerView; private final OnColorSelectedListener onColorSelectedListener; + private int oldColor; + public ColorPickerDialog(Context context, int initialColor, String cOrbIDs, String cOrbLedCount, OnColorSelectedListener onColorSelectedListener) { super(context); @@ -22,6 +24,7 @@ public ColorPickerDialog(Context context, int initialColor, String cOrbIDs, Stri colorPickerView = new ColorPicker(context); colorPickerView.setColor(initialColor); + oldColor = initialColor; colorPickerView.cOrbIDs = cOrbIDs; colorPickerView.cOrbLedCount = cOrbLedCount; @@ -42,6 +45,7 @@ public void onClick(DialogInterface dialog, int which) { onColorSelectedListener.onColorSelected(selectedColor); break; case BUTTON_NEGATIVE: + colorPickerView.sendApiColorCommand(oldColor); dialog.dismiss(); break; }