Skip to content

Commit

Permalink
adding window option to android demo console app
Browse files Browse the repository at this point in the history
  • Loading branch information
Devendra committed Oct 23, 2013
1 parent 4cbdecf commit e6a3786
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
5 changes: 5 additions & 0 deletions android/examples/PubnubExample/res/layout/usage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/option15" />
<TextView
android:id="@+id/option16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/option16" />
</LinearLayout>

</LinearLayout>
2 changes: 1 addition & 1 deletion android/examples/PubnubExample/res/menu/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
<item android:id="@+id/option13" android:title="@string/option13" android:titleCondensed="@string/option13"></item>
<item android:id="@+id/option14" android:title="@string/option14" android:titleCondensed="@string/option14"></item>
<item android:id="@+id/option15" android:title="@string/option15" android:titleCondensed="@string/option15"></item>

<item android:id="@+id/option16" android:title="@string/option16" android:titleCondensed="@string/option16"></item>
</menu>
1 change: 1 addition & 0 deletions android/examples/PubnubExample/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<string name="option13">Set Retry Interval</string>
<string name="option14">Set Subscribe Timeout</string>
<string name="option15">Set Non Subscribe Timeout</string>
<string name="option16">Set Window Interval</string>


</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public boolean onOptionsItemSelected(MenuItem item) {
case R.id.option15:
setNonSubscribeTimeout();
return true;

case R.id.option16:
setWindowInterval();
return true;
default:
return super.onOptionsItemSelected(item);
}
Expand Down Expand Up @@ -564,6 +568,26 @@ public void onClick(DialogInterface dialog, int which) {
AlertDialog alert = builder.create();
alert.show();
}
private void setWindowInterval() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Set Window Interval");
builder.setMessage("Enter Window interval in milliseconds");
final EditText edInterval = new EditText(this);
edInterval.setInputType(InputType.TYPE_CLASS_NUMBER);
builder.setView(edInterval);
builder.setPositiveButton("Done",
new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
pubnub.setWindowInterval(Integer.parseInt(edInterval
.getText().toString()));
}

});
AlertDialog alert = builder.create();
alert.show();
}

private void toggleResumeOnReconnect() {
pubnub.setResumeOnReconnect(pubnub.isResumeOnReconnect() ? false : true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ private void setMaxRetries(int maxRetries) {
private void setRetryInterval(int retryInterval) {
pubnub.setRetryInterval(retryInterval);
}

private void setWindowInterval(int windowInterval) {
pubnub.setWindowInterval(windowInterval);
}
Expand Down
6 changes: 3 additions & 3 deletions java/srcPubnubApi/com/pubnub/api/PubnubCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public boolean isResumeOnReconnect() {
public void setRetryInterval(int retryInterval) {
subscribeManager.setRetryInterval(retryInterval);
}

/**
* This method sets window interval for subscribe.
* This method sets window interval for subscribe.
*
* @param windowInterval
* Window Interval in milliseconds
Expand All @@ -102,7 +102,7 @@ public void setWindowInterval(int windowInterval) {
public int getRetryInterval() {
return subscribeManager.retryInterval;
}

/**
* Returns current window interval for subscribe
* @return Current Window Interval in milliseconds
Expand Down
16 changes: 8 additions & 8 deletions java/srcPubnubApi/com/pubnub/api/RequestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public void setRetryInterval(int retryInterval) {
((SubscribeWorker) _workers[i]).setRetryInterval(retryInterval);
}
}

public void setWindowInterval(int windowInterval) {
this.windowInterval = windowInterval;
for (int i = 0; i < _workers.length; i++) {
Expand Down Expand Up @@ -325,14 +325,14 @@ abstract class AbstractSubscribeWorker extends Worker {
this.maxRetries = maxRetries;
this.retryInterval= retryInterval;
}

AbstractSubscribeWorker(Vector _requestQueue, int connectionTimeout,
int requestTimeout, int maxRetries, int retryInterval, int windowInterval, Hashtable headers) {
super(_requestQueue, connectionTimeout, requestTimeout, headers);
this.maxRetries = maxRetries;
this.retryInterval= retryInterval;
this.windowInterval = windowInterval;
}
super(_requestQueue, connectionTimeout, requestTimeout, headers);
this.maxRetries = maxRetries;
this.retryInterval= retryInterval;
this.windowInterval = windowInterval;
}

public void setMaxRetries(int maxRetries) {
this.maxRetries = maxRetries;
Expand All @@ -341,7 +341,7 @@ public void setMaxRetries(int maxRetries) {
public void setRetryInterval(int retryInterval) {
this.retryInterval = retryInterval;
}

public void setWindowInterval(int windowInterval) {
this.windowInterval = windowInterval;
}
Expand Down

0 comments on commit e6a3786

Please sign in to comment.