diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-23 13:51:02 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-23 13:51:02 +0100 |
commit | 750b58b3b7fad5ec068d43e39d74d55eb52e5058 (patch) | |
tree | 36dc588de3ec04c27ed48116648968f35a9a70b4 | |
parent | ff7bb967cce1fdfe64fe3126c11e5c7d3f3ffb12 (diff) |
Remove com.orbekk.same.Same.
– Remove references from GameController.
(GameController is now perfectly broken and should be refactored to
using Variables)
-rw-r--r-- | same-android/src/main/java/com/orbekk/same/GameController.java | 30 | ||||
-rw-r--r-- | same/src/main/java/com/orbekk/same/Same.java | 73 |
2 files changed, 11 insertions, 92 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/GameController.java b/same-android/src/main/java/com/orbekk/same/GameController.java index 144d6af..b8ea7ad 100644 --- a/same-android/src/main/java/com/orbekk/same/GameController.java +++ b/same-android/src/main/java/com/orbekk/same/GameController.java @@ -6,18 +6,17 @@ import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.orbekk.same.SameInterface; import com.orbekk.same.StateChangedListener; import com.orbekk.same.UpdateConflict; import android.graphics.Paint; -public class GameController implements StateChangedListener { +public class GameController { private Logger logger = LoggerFactory.getLogger(getClass()); private List<Player> remotePlayers = new ArrayList<Player>(); private Player localPlayer; private ChangeListener changeListener = null; - private SameInterface same; +// private SameInterface same; public static class Player { public Paint color; @@ -38,27 +37,20 @@ public class GameController implements StateChangedListener { return player; } - public static GameController create(Player localPlayer, - SameInterface same) { - GameController controller = new GameController(localPlayer, same); - same.addStateChangedListener(controller); + public static GameController create(Player localPlayer) { + GameController controller = new GameController(localPlayer); +// same.addStateChangedListener(controller); return controller; } - GameController(Player localPlayer, SameInterface same) { + GameController(Player localPlayer) { this.localPlayer = localPlayer; - this.same = same; } - public void setMyPosition(float x, float y) { + public void setMyPosition(float x, float y) throws UpdateConflict { this.localPlayer.posX = x; this.localPlayer.posY = y; changeListener.playerStatesChanged(); - try { - same.set("position", x + "," + y); - } catch (UpdateConflict e) { - logger.warn("Update failed.", e); - } } public Player getLocalPlayer() { @@ -73,8 +65,8 @@ public class GameController implements StateChangedListener { this.changeListener = listener; } - @Override - public void stateChanged(String id, String data) { - logger.info("StateChanged({}, {})", id, data); - } +// @Override +// public void stateChanged(String id, String data) { +// logger.info("StateChanged({}, {})", id, data); +// } } diff --git a/same/src/main/java/com/orbekk/same/Same.java b/same/src/main/java/com/orbekk/same/Same.java deleted file mode 100644 index b152be4..0000000 --- a/same/src/main/java/com/orbekk/same/Same.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.orbekk.same; - -import java.util.ArrayList; -import java.util.List; - -import org.codehaus.jackson.type.TypeReference; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class Same implements SameInterface { - private Logger logger = LoggerFactory.getLogger(getClass()); - private Client client; - private StateChangedProxy stateChangedProxy = new StateChangedProxy(); - - private class StateChangedProxy implements StateChangedListener { - public List<StateChangedListener> listeners = - new ArrayList<StateChangedListener>(); - - @Override - public void stateChanged(String id, String data) { - for (StateChangedListener listener : listeners) { - listener.stateChanged(id, data); - } - } - } - - public static Same createSame(Client client) { - Same same = new Same(client); - client.setStateChangedListener(same.stateChangedProxy); - return same; - } - - Same(Client client) { - this.client = client; - } - - @Override - public String get(String id) { - return client.lib_get(id); - } - - @Override - public <T> T get(String id, TypeReference<T> type) { - return client.lib_get(id, type); - } - - @Override - public List<String> getList(String id) { - return client.lib_get(id, new TypeReference<List<String>>() { }); - } - - @Override - public void set(String id, String data) throws UpdateConflict { - client.lib_set(id, data); - } - - @Override - public void setObject(String id, Object data) { - throw new RuntimeException("Not implemented."); - } - - @Override - public void addStateChangedListener(StateChangedListener listener) { - stateChangedProxy.listeners.add(listener); - } - - @Override - public void removeStateChangedListener(StateChangedListener listener) { - stateChangedProxy.listeners.remove(listener); - } - -} |