Skip to content

Commit

Permalink
refactoring for common code base
Browse files Browse the repository at this point in the history
  • Loading branch information
Devendra committed Dec 28, 2012
1 parent 68ffd3b commit 41b6b67
Show file tree
Hide file tree
Showing 9 changed files with 958 additions and 1,552 deletions.
Expand Up @@ -3,7 +3,6 @@
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.Dialog;

import com.pubnub.api.Callback;
import com.pubnub.api.Pubnub;

/**
Expand All @@ -18,20 +17,9 @@ public class PubnubExample extends UiApplication
*/
public static void main(String[] args)
{
Pubnub pubnub = new Pubnub("demo", "demo", "demo", false);


pubnub.publish("hello_world1","I am blackberry client" , new Callback() {
public void successCallback(String channel, Object message) {
System.out.println(message.toString());
}

public void errorCallback(String channel, Object message) {
System.out.println(message.toString());
}

});
Pubnub.startHeartbeat(5000);

// Create a new instance of the application and make the currently
// running thread the application's event dispatch thread.
PubnubExample theApp = new PubnubExample();
Expand Down
Expand Up @@ -32,6 +32,10 @@ public PubnubExampleScreen()
// Set the displayed title of the screen
setTitle("PubnubExample");
add(new LabelField("Please select an item from the menu"));
add(new LabelField("Subscribe will listen on following channels: "));
add(new LabelField("hello_world1, hello_world2, hello_world3, hello_world4"));
add(new LabelField("Publish, history, detailedHistory, hereNow, Presence use hello_world"));


addMenuItem(new TimeMenuItem());
addMenuItem(new PublishMenuItem());
Expand All @@ -58,7 +62,7 @@ public void successCallback(String channel, Object message) {
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog(message.toString());
}
});
}
Expand All @@ -76,11 +80,11 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context) {

_pubnub.publish(channel, "Blackberry says hello world", new Callback() {
public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});

Expand All @@ -98,11 +102,11 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context)
{
_pubnub.hereNow(channel, new Callback() {
public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});
}
Expand All @@ -120,11 +124,11 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context)
{
_pubnub.history(channel, 1, new Callback() {
public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});
}
Expand All @@ -142,11 +146,11 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context)
{
_pubnub.detailedHistory(channel, 1, new Callback() {
public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});
}
Expand Down Expand Up @@ -179,7 +183,7 @@ public void reconnectCallback(String channel) {
}

public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});

Expand All @@ -202,11 +206,11 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context)
try {
_pubnub.presence(channel, new Callback() {
public void successCallback(String channel, Object message) {
PubnubExample.alertDialog(message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}

public void errorCallback(String channel, Object message) {
PubnubExample.alertDialog(channel + " : " + message.toString());
PubnubExample.alertDialog("Channel : " + channel + ", " + message.toString());
}
});
} catch (PubnubException e) {
Expand Down

0 comments on commit 41b6b67

Please sign in to comment.