super.onStart();
resultTextView.setText(logging_in);
new HttpCallExecutableRunnable("/ok", null,
- toNonNull(getApplicationContext()), toNonNull(updateResultCallback)).execute();
+ toNonNull(getApplicationContext()), toNonNull(updateResultCallback), false).execute();
connection.refreshAdapter();
}
* Callback to run after the request returns
*/
private final ResultCallback callback;
+ /** If true, the task should be retried if it fails */
+ private final boolean mustRetryTask;
/**
* Constructs a SendHttpMessageAsyncTask which sends a binary message.
* @param headers the extra headers
* @param context the context instance
* @param resultCallback {@link ResultCallback} instance
+ * @param mustRetryTask true if this task should be retried if it fails
* @param data the message to send
*/
- public HttpCallExecutableRunnable(final String path, final @Nullable Collection<Header> headers, final Context context, final @Nullable ResultCallback resultCallback, final byte[] data){//NOPMD array is supposed to be immutable.
+ public HttpCallExecutableRunnable(final String path, final @Nullable Collection<Header> headers, final Context context, final @Nullable ResultCallback resultCallback, final boolean mustRetryTask, final byte[] data){//NOPMD array is supposed to be immutable.
this.path=path;
this.headers=headers;
this.context=context;
this.callback=resultCallback;
+ this.mustRetryTask=mustRetryTask;
this.data=data;
}
* @param headers the extra headers
* @param context the context instance
* @param resultCallback {@link ResultCallback} instance
+ * @param mustRetryTask true if this task should be retried if it fails
* @param message message to send
*/
- public HttpCallExecutableRunnable(final String path, final @Nullable Collection<Header> headers, final Context context, final @Nullable ResultCallback resultCallback, final String... message){
+ public HttpCallExecutableRunnable(final String path, final @Nullable Collection<Header> headers, final Context context, final @Nullable ResultCallback resultCallback, final boolean mustRetryTask, final String... message){
this.path=path;
this.headers=headers;
this.context=context;
this.callback=resultCallback;
+ this.mustRetryTask=mustRetryTask;
if(message.length == 0)
this.data=null;//NOPMD final field
else
e.printStackTrace();
if(callback != null)
callback.onError(toNonNull(context.getString(connection_error)));
+ if(mustRetryTask)
+ retry();
}
}
}
switch(address.protocol){
case HTTP:
new HttpCallExecutableRunnable("/send", toNonNull(Arrays.asList(
- new Header("X-Destination", toNonNull(address.data)))), context, null, message).execute();
+ new Header("X-Destination", toNonNull(address.data)))), context, null, true, message).execute();
break;
case SMS:
* @param context Context instance
*/
public static void pollServer(final Context context){
- new HttpCallExecutableRunnable("/get", null, context, new PollResultCallback(context)).execute();
+ new HttpCallExecutableRunnable("/get", null, context, new PollResultCallback(context), false).execute();
}
/**