Skip to content

Commit

Permalink
update .gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
taywils committed Jul 22, 2014
1 parent f99b11a commit 0e08408
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
10 changes: 5 additions & 5 deletions .gitignore
@@ -1,4 +1,9 @@
# Intellij
.idea/
*.iml
*.iws
.gradle

/local.properties
/.idea/workspace.xml
.DS_Store
Expand Down Expand Up @@ -36,8 +41,3 @@ Thumbs.db
#.idea/workspace.xml - remove # and delete .idea if it better suit your needs.
.gradle
build/

# Intellij
.idea/
*.iml
*.iws
2 changes: 1 addition & 1 deletion MyApplication.iml
Expand Up @@ -12,7 +12,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/me/taywils/myapplication/MyActivity.java
Expand Up @@ -19,8 +19,8 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);

this.testSocketIoClient();
this.paintView = (PaintView)findViewById(R.id.activity_my_view_whiteboard);
this.testSocketIoClient();
}

@Override
Expand Down Expand Up @@ -90,6 +90,8 @@ public void buttonSnapshotClick(View view) {
protected void testSocketIoClient() {
try {
paintClient = new PaintClient();
paintClient.setPaintView(paintView);
paintClient.setContext(this);
} catch(Exception exception) {
Log.e("EXCEPTION", exception.getMessage());
}
Expand Down
38 changes: 33 additions & 5 deletions app/src/main/java/me/taywils/myapplication/PaintClient.java
@@ -1,11 +1,13 @@
package me.taywils.myapplication;

import android.content.Context;
import android.util.Log;

import com.github.nkzawa.emitter.Emitter;
import com.github.nkzawa.socketio.client.IO;
import com.github.nkzawa.socketio.client.Socket;

import org.json.JSONArray;
import org.json.JSONObject;

import java.net.URI;
Expand All @@ -18,11 +20,21 @@ public class PaintClient {
private final int BOARD_COLS = 500;
private Socket socket;
private boolean board[][] = new boolean[BOARD_ROWS][BOARD_COLS];
private PaintView pv;
private Context context;

public PaintClient() {
initSocket();
}

public void setContext(Context context) {
this.context = context;
}

public void setPaintView(PaintView paintView) {
pv = paintView;
}

public void initSocket() {
try {
final String serverUrlString = "http://warm-fortress-2906.herokuapp.com";
Expand All @@ -42,28 +54,44 @@ public void initSocket() {
@Override
public void call(Object... args) {
emitDebug();
Log.d("CONNECTED TO SERVER", "Sending debug message");
Log.d("onConnect", "Sending debug message");
}
});

socket.on("debug", new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d("onDebug", args[0].toString());
}
});

socket.on("clear", new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d("onClear", args[0].toString());
pv.clearCanvas();
}
});

socket.on("newClient", new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d("SERVER RESPONSE", args[0].toString());
Log.d("onNewClient", args[0].toString());
JSONArray jsonBoard = (JSONArray)args[0];
}
});

socket.on("debug", new Emitter.Listener() {
socket.on("paint", new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d("SERVER RESPONSE", args[0].toString());
Log.d("onPaint", args[0].toString());
}
});

socket.on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {
@Override
public void call(Object... args) {
Log.d("DISCONNECT", "Disconnected from server");
Log.d("onDisconnect", "Disconnected from server");
}
});
/* END socket_event_handlers */
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/me/taywils/myapplication/PaintView.java
Expand Up @@ -12,8 +12,6 @@
import android.graphics.Path;
import android.view.MotionEvent;

import java.util.Random;

public class PaintView extends View {
private Bitmap bitmap;
private Canvas canvas;
Expand Down

0 comments on commit 0e08408

Please sign in to comment.