fixed androidstduio derp
fixed stripes aren't loaded correctly
This commit is contained in:
@@ -227,153 +227,6 @@ public class AddControllerDialog extends DialogFragment implements DialogInterfa
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow(final DialogInterface dialog) {
|
||||
|
||||
final AlertDialog alertDialog = (AlertDialog) dialog;
|
||||
|
||||
addressText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
addressLayout.setError(null);
|
||||
}
|
||||
});
|
||||
|
||||
channelText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
channelLayout.setError(null);
|
||||
}
|
||||
});
|
||||
|
||||
i2cText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
i2cLayout.setError(null);
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
AddStripeDialog.instance.onResume();
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
});
|
||||
|
||||
alertDialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (i2cText.getText().toString().isEmpty() || !isNumeric(i2cText.getText().toString())) {
|
||||
i2cLayout.setError("No valid i2c device number");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!addressText.getText().toString().contains("0x") || !addressText.getText().toString().split("x")[1].matches("-?[0-9a-fA-F]+")) {
|
||||
addressLayout.setError("No valid hexdecimal address");
|
||||
return;
|
||||
}
|
||||
|
||||
if (channelText.getText().toString().isEmpty() || !isNumeric(channelText.getText().toString()) && Integer.parseInt(channelText
|
||||
.getText().toString()) <= 0) {
|
||||
channelLayout.setError("No valid channel amount");
|
||||
return;
|
||||
}
|
||||
|
||||
Controller c = new Controller();
|
||||
c.setAddress(addressText.getText().toString());
|
||||
c.setI2c_device(Integer.parseInt(i2cText.getText().toString()));
|
||||
c.setChannels(Integer.parseInt(channelText.getText().toString()));
|
||||
|
||||
LedDHelper helper = null;
|
||||
try {
|
||||
helper = ColorApplication.getInstance().getHelperForDaemon(dDaemon);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (helper != null) {
|
||||
try {
|
||||
helper.addController(c, new AddControllerCallback() {
|
||||
@Override
|
||||
public void onControllerAdded(final Controller controller) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content))
|
||||
.getChildAt(0), "Added Controller (" + controller.getId() + ")", Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
|
||||
dDaemon.getControllers().add(controller);
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddFailed(final String msg, String detail) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content))
|
||||
.getChildAt(0), "Error: " + msg, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConnectionFailed(final String message) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Snackbar.make(((ViewGroup) getActivity().getWindow().getDecorView().findViewById(android.R.id.content))
|
||||
.getChildAt(0), "Coudn't connect to" +
|
||||
" daemon at " + dDaemon + ": " + message, Snackbar.LENGTH_LONG).show();
|
||||
}
|
||||
});
|
||||
AddStripeDialog.instance.onResume();
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
} catch (JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static boolean isNumeric(String str) {
|
||||
NumberFormat formatter = NumberFormat.getInstance();
|
||||
ParsePosition pos = new ParsePosition(0);
|
||||
|
Reference in New Issue
Block a user