Skip to content

Commit 239e568

Browse files
author
Devendra
committed
replacing history with detailedHistory
1 parent 5645f19 commit 239e568

45 files changed

Lines changed: 161 additions & 817 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎android/Pubnub-Android-3.6.0.jar‎

-1.17 KB
Binary file not shown.
-1.17 KB
Binary file not shown.

‎android/examples/PubnubExample/res/values/strings.xml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<string name="pubnub">Pubnub</string>
55
<string name="hello_world">Hello world!</string>
66
<string name="menu_settings">Settings</string>
7-
<string name="btnDetailedHistoryText">History</string>
87
<string name="btnPresenceText">Presence</string>
98
<string name="btnSubscribeText">Subscribe</string>
109
<string name="btnPublishText">Publish</string>
@@ -21,7 +20,7 @@
2120
<string name="option1">Subscribe</string>
2221
<string name="option2">Publish</string>
2322
<string name="option3">Presence</string>
24-
<string name="option4">Detailed History</string>
23+
<string name="option4">History</string>
2524
<string name="option5">Here Now</string>
2625
<string name="option6">Unsubscribe</string>
2726
<string name="option7">Presence-Unsubscribe</string>
@@ -39,4 +38,4 @@
3938
<string name="option19">Toggle Cache Busting</string>
4039
<string name="option20">Set Presence Expiry</string>
4140
<string name="option21">Set UUID</string>
42-
</resources>
41+
</resources>

‎android/examples/PubnubExample/src/com/pubnub/examples/pubnubExample/MainActivity.java‎

Lines changed: 40 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
117117
return true;
118118

119119
case R.id.option4:
120-
detailedHistory();
120+
history();
121121
return true;
122122

123123
case R.id.option5:
@@ -296,13 +296,10 @@ private void subscribe() {
296296
@Override
297297
public void onClick(DialogInterface dialog, int which) {
298298

299-
Hashtable args = new Hashtable(1);
300-
301-
String message = input.getText().toString();
302-
args.put("channel", message);
299+
String channel = input.getText().toString();
303300

304301
try {
305-
pubnub.subscribe(args, new Callback() {
302+
pubnub.subscribe(channel, new Callback() {
306303
@Override
307304
public void connectCallback(String channel,
308305
Object message) {
@@ -372,51 +369,7 @@ private void _publish(final String channel) {
372369

373370
@Override
374371
public void onClick(DialogInterface dialog, int which) {
375-
Hashtable args = new Hashtable(2);
376-
377-
String message = etMessage.getText().toString();
378-
379-
if (args.get("message") == null) {
380-
try {
381-
Integer i = Integer.parseInt(message);
382-
args.put("message", i);
383-
} catch (Exception e) {
384-
385-
}
386-
}
387-
if (args.get("message") == null) {
388-
try {
389-
Double d = Double.parseDouble(message);
390-
args.put("message", d);
391-
} catch (Exception e) {
392-
393-
}
394-
}
395-
if (args.get("message") == null) {
396-
try {
397-
JSONArray js = new JSONArray(message);
398-
args.put("message", js);
399-
} catch (Exception e) {
400-
401-
}
402-
}
403-
if (args.get("message") == null) {
404-
try {
405-
JSONObject js = new JSONObject(message);
406-
args.put("message", js);
407-
} catch (Exception e) {
408-
409-
}
410-
}
411-
if (args.get("message") == null) {
412-
args.put("message", message);
413-
}
414-
415-
// Publish Message
416-
417-
args.put("channel", channel); // Channel Name
418-
419-
pubnub.publish(args, new Callback() {
372+
Callback publishCallback = new Callback() {
420373
@Override
421374
public void successCallback(String channel,
422375
Object message) {
@@ -427,13 +380,41 @@ public void errorCallback(String channel,
427380
PubnubError error) {
428381
notifyUser("PUBLISH : " + error);
429382
}
430-
});
383+
};
384+
385+
String message = etMessage.getText().toString();
386+
387+
try {
388+
Integer i = Integer.parseInt(message);
389+
pubnub.publish(channel, i, publishCallback);
390+
return;
391+
} catch (Exception e) {}
392+
393+
try {
394+
Double d = Double.parseDouble(message);
395+
pubnub.publish(channel, d, publishCallback);
396+
return;
397+
} catch (Exception e) {}
398+
399+
400+
try {
401+
JSONArray js = new JSONArray(message);
402+
pubnub.publish(channel, js, publishCallback);
403+
return;
404+
} catch (Exception e) {}
405+
406+
try {
407+
JSONObject js = new JSONObject(message);
408+
pubnub.publish(channel, js, publishCallback);
409+
return;
410+
} catch (Exception e) {}
411+
412+
pubnub.publish(channel, message, publishCallback);
431413
}
432414

433415
});
434416
AlertDialog alert = builder.create();
435417
alert.show();
436-
437418
}
438419

439420
private void publish() {
@@ -497,29 +478,29 @@ public void errorCallback(String channel,
497478
alert.show();
498479
}
499480

500-
private void detailedHistory() {
481+
private void history() {
501482

502483
AlertDialog.Builder builder = new AlertDialog.Builder(this);
503-
builder.setTitle("Detailed History");
484+
builder.setTitle("History");
504485
builder.setMessage("Enter channel name");
505486
final EditText input = new EditText(this);
506487
builder.setView(input);
507-
builder.setPositiveButton("Get detailed history",
488+
builder.setPositiveButton("Get history",
508489
new DialogInterface.OnClickListener() {
509490

510491
@Override
511492
public void onClick(DialogInterface dialog, int which) {
512493
String channel = input.getText().toString();
513-
pubnub.detailedHistory(channel, 2, new Callback() {
494+
pubnub.history(channel, 2, new Callback() {
514495
@Override
515496
public void successCallback(String channel,
516497
Object message) {
517-
notifyUser("DETAILED HISTORY : " + message);
498+
notifyUser("HISTORY : " + message);
518499
}
519500
@Override
520501
public void errorCallback(String channel,
521502
PubnubError error) {
522-
notifyUser("DETAILED HISTORY : " + error);
503+
notifyUser("HISTORY : " + error);
523504
}
524505
});
525506
}
-1.17 KB
Binary file not shown.
-1.23 KB
Binary file not shown.

‎blackberry/examples/PubnubExample/src/com/pubnub/examples/blackberry/DetailedHistory.java‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎blackberry/examples/PubnubExample/src/com/pubnub/examples/blackberry/History.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ public void errorCallback(String channel, PubnubError error) {
4343
}
4444
});
4545
}
46+
4647
}

‎blackberry/examples/PubnubExample/src/com/pubnub/examples/blackberry/PubnubDemoConsoleScreen.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ public PubnubDemoConsoleScreen() {
2525
addMenuItem(new Presence(_pubnub).getMenuItem());
2626
addMenuItem(new Unsubscribe(_pubnub).getMenuItem());
2727
addMenuItem(new History(_pubnub).getMenuItem());
28-
addMenuItem(new DetailedHistory(_pubnub).getMenuItem());
2928
addMenuItem(new HereNow(_pubnub).getMenuItem());
3029
addMenuItem(new AuthKeyConfig(_pubnub).getMenuItem());
3130
addMenuItem(new DisconnectAndResubscribe(_pubnub).getMenuItem());
@@ -34,4 +33,4 @@ public PubnubDemoConsoleScreen() {
3433
}
3534

3635

37-
}
36+
}
-2.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)