Sitelet https://github.com/jhnie/java/commit/e6a37867eed41bada383d00d4f40caa9dbc4378b
Skip to content

Commit e6a3786

Browse files
author
Devendra
committed
adding window option to android demo console app
1 parent 4cbdecf commit e6a3786

7 files changed

Lines changed: 43 additions & 13 deletions

File tree

‎android/examples/PubnubExample/res/layout/usage.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@
120120
android:layout_width="wrap_content"
121121
android:layout_height="wrap_content"
122122
android:text="@string/option15" />
123+
<TextView
124+
android:id="@+id/option16"
125+
android:layout_width="wrap_content"
126+
android:layout_height="wrap_content"
127+
android:text="@string/option16" />
123128
</LinearLayout>
124129

125130
</LinearLayout>

‎android/examples/PubnubExample/res/menu/activity_main.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
<item android:id="@+id/option13" android:title="@string/option13" android:titleCondensed="@string/option13"></item>
1515
<item android:id="@+id/option14" android:title="@string/option14" android:titleCondensed="@string/option14"></item>
1616
<item android:id="@+id/option15" android:title="@string/option15" android:titleCondensed="@string/option15"></item>
17-
17+
<item android:id="@+id/option16" android:title="@string/option16" android:titleCondensed="@string/option16"></item>
1818
</menu>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<string name="option13">Set Retry Interval</string>
3535
<string name="option14">Set Subscribe Timeout</string>
3636
<string name="option15">Set Non Subscribe Timeout</string>
37+
<string name="option16">Set Window Interval</string>
3738

3839

3940
</resources>

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
163163
case R.id.option15:
164164
setNonSubscribeTimeout();
165165
return true;
166+
167+
case R.id.option16:
168+
setWindowInterval();
169+
return true;
166170
default:
167171
return super.onOptionsItemSelected(item);
168172
}
@@ -564,6 +568,26 @@ public void onClick(DialogInterface dialog, int which) {
564568
AlertDialog alert = builder.create();
565569
alert.show();
566570
}
571+
private void setWindowInterval() {
572+
AlertDialog.Builder builder = new AlertDialog.Builder(this);
573+
builder.setTitle("Set Window Interval");
574+
builder.setMessage("Enter Window interval in milliseconds");
575+
final EditText edInterval = new EditText(this);
576+
edInterval.setInputType(InputType.TYPE_CLASS_NUMBER);
577+
builder.setView(edInterval);
578+
builder.setPositiveButton("Done",
579+
new DialogInterface.OnClickListener() {
580+
581+
@Override
582+
public void onClick(DialogInterface dialog, int which) {
583+
pubnub.setWindowInterval(Integer.parseInt(edInterval
584+
.getText().toString()));
585+
}
586+
587+
});
588+
AlertDialog alert = builder.create();
589+
alert.show();
590+
}
567591

568592
private void toggleResumeOnReconnect() {
569593
pubnub.setResumeOnReconnect(pubnub.isResumeOnReconnect() ? false : true);

‎java/examples/src/com/pubnub/examples/PubnubDemoConsole.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ private void setMaxRetries(int maxRetries) {
504504
private void setRetryInterval(int retryInterval) {
505505
pubnub.setRetryInterval(retryInterval);
506506
}
507-
507+
508508
private void setWindowInterval(int windowInterval) {
509509
pubnub.setWindowInterval(windowInterval);
510510
}

‎java/srcPubnubApi/com/pubnub/api/PubnubCore.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ public boolean isResumeOnReconnect() {
8484
public void setRetryInterval(int retryInterval) {
8585
subscribeManager.setRetryInterval(retryInterval);
8686
}
87-
87+
8888
/**
89-
* This method sets window interval for subscribe.
89+
* This method sets window interval for subscribe.
9090
*
9191
* @param windowInterval
9292
* Window Interval in milliseconds
@@ -102,7 +102,7 @@ public void setWindowInterval(int windowInterval) {
102102
public int getRetryInterval() {
103103
return subscribeManager.retryInterval;
104104
}
105-
105+
106106
/**
107107
* Returns current window interval for subscribe
108108
* @return Current Window Interval in milliseconds

‎java/srcPubnubApi/com/pubnub/api/RequestManager.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public void setRetryInterval(int retryInterval) {
263263
((SubscribeWorker) _workers[i]).setRetryInterval(retryInterval);
264264
}
265265
}
266-
266+
267267
public void setWindowInterval(int windowInterval) {
268268
this.windowInterval = windowInterval;
269269
for (int i = 0; i < _workers.length; i++) {
@@ -325,14 +325,14 @@ abstract class AbstractSubscribeWorker extends Worker {
325325
this.maxRetries = maxRetries;
326326
this.retryInterval= retryInterval;
327327
}
328-
328+
329329
AbstractSubscribeWorker(Vector _requestQueue, int connectionTimeout,
330330
int requestTimeout, int maxRetries, int retryInterval, int windowInterval, Hashtable headers) {
331-
super(_requestQueue, connectionTimeout, requestTimeout, headers);
332-
this.maxRetries = maxRetries;
333-
this.retryInterval= retryInterval;
334-
this.windowInterval = windowInterval;
335-
}
331+
super(_requestQueue, connectionTimeout, requestTimeout, headers);
332+
this.maxRetries = maxRetries;
333+
this.retryInterval= retryInterval;
334+
this.windowInterval = windowInterval;
335+
}
336336

337337
public void setMaxRetries(int maxRetries) {
338338
this.maxRetries = maxRetries;
@@ -341,7 +341,7 @@ public void setMaxRetries(int maxRetries) {
341341
public void setRetryInterval(int retryInterval) {
342342
this.retryInterval = retryInterval;
343343
}
344-
344+
345345
public void setWindowInterval(int windowInterval) {
346346
this.windowInterval = windowInterval;
347347
}

0 commit comments

Comments
 (0)