Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'unstable' of git://github.com/samphippen/spe into devel…

…opment
  • Loading branch information...
commit f35fbddb6fca6fde375c9da89be30a96529633b4 2 parents 94ac82e + 2836ef7
Ben Barron Ben-Barron authored
32 src/uk/me/graphe/shared/messages/ToggleDrawWeightsMessage.java
View
@@ -0,0 +1,32 @@
+package uk.me.graphe.shared.messages;
+
+import uk.me.graphe.shared.jsonwrapper.JSONException;
+import uk.me.graphe.shared.jsonwrapper.JSONImplHolder;
+import uk.me.graphe.shared.jsonwrapper.JSONObject;
+
+public class ToggleDrawWeightsMessage extends Message {
+
+ private boolean mResult;
+
+ public ToggleDrawWeightsMessage(boolean x) {
+ mResult = x;
+ }
+
+ @Override
+ public String toJson() {
+ JSONObject repr = JSONImplHolder.make();
+ try {
+ repr.put("message", this.getMessage());
+ repr.put("toggle", mResult ? "yes" : "no");
+ } catch (JSONException jse) {
+ throw new Error(jse);
+ }
+ return repr.toString();
+ }
+
+ @Override
+ public String getMessage() {
+ return "tdwi";
+ }
+
+}
23 src/uk/me/graphe/shared/messages/factories/ToggleWeightFactory.java
View
@@ -0,0 +1,23 @@
+package uk.me.graphe.shared.messages.factories;
+
+import uk.me.graphe.shared.jsonwrapper.JSONException;
+import uk.me.graphe.shared.jsonwrapper.JSONObject;
+import uk.me.graphe.shared.messages.Message;
+import uk.me.graphe.shared.messages.ToggleDrawWeightsMessage;
+
+public class ToggleWeightFactory implements ConversionFactory {
+
+ @Override
+ public Message make(JSONObject o) {
+
+ try {
+ boolean result = o.getString("toggle").equals("yes");
+ return new ToggleDrawWeightsMessage(result);
+ } catch (JSONException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ throw new Error(e);
+ }
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.