projects
/
fonbot.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
62f5262
)
Stop long polling on error
author
Marius Gavrilescu
<marius@ieval.ro>
Wed, 31 Jul 2013 05:20:52 +0000
(08:20 +0300)
committer
Marius Gavrilescu
<marius@ieval.ro>
Wed, 31 Jul 2013 05:20:52 +0000
(08:20 +0300)
src/ro/ieval/fonbot/FonBotMainActivity.java
patch
|
blob
|
blame
|
history
src/ro/ieval/fonbot/FonBotMainService.java
patch
|
blob
|
blame
|
history
src/ro/ieval/fonbot/PollResultCallback.java
patch
|
blob
|
blame
|
history
diff --git
a/src/ro/ieval/fonbot/FonBotMainActivity.java
b/src/ro/ieval/fonbot/FonBotMainActivity.java
index b879be0c203c1a2c90548d43f66e4cec730ce609..2c2a49d2b11b0087f39fbf819ff99e811bd9a9e1 100644
(file)
--- a/
src/ro/ieval/fonbot/FonBotMainActivity.java
+++ b/
src/ro/ieval/fonbot/FonBotMainActivity.java
@@
-173,8
+173,10
@@
public final class FonBotMainActivity extends ListActivity {
resultTextView.setText(message);
if(error)
resultTextView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.cross, 0, 0);
resultTextView.setText(message);
if(error)
resultTextView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.cross, 0, 0);
- else
+ else
{
resultTextView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tick, 0, 0);
resultTextView.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.tick, 0, 0);
+ startService(new Intent(FonBotMainActivity.this, FonBotMainService.class));
+ }
}
});
}
}
});
}
diff --git
a/src/ro/ieval/fonbot/FonBotMainService.java
b/src/ro/ieval/fonbot/FonBotMainService.java
index 38e0a29d0cbb8b4fd8a850ba28474b3e5ea54ccb..13dc1316449a081c7e656eea6679e606955d44e1 100644
(file)
--- a/
src/ro/ieval/fonbot/FonBotMainService.java
+++ b/
src/ro/ieval/fonbot/FonBotMainService.java
@@
-80,6
+80,7
@@
public final class FonBotMainService extends Service {
runnable.run();
} catch (final Exception ex){
ex.printStackTrace();
runnable.run();
} catch (final Exception ex){
ex.printStackTrace();
+ break;
}
Log.d("LongPollRunnable", "Long polling stopped");
}
}
Log.d("LongPollRunnable", "Long polling stopped");
}
diff --git
a/src/ro/ieval/fonbot/PollResultCallback.java
b/src/ro/ieval/fonbot/PollResultCallback.java
index 370ec11d9b8582fcc9bca6696f846caf11d035c4..46e3eda83e39cc4ed15455ea0fc64f05f6c4f787 100644
(file)
--- a/
src/ro/ieval/fonbot/PollResultCallback.java
+++ b/
src/ro/ieval/fonbot/PollResultCallback.java
@@
-55,8
+55,11
@@
final class PollResultCallback implements ResultCallback {
@Override
public void onResult(final int responseCode, final String responseMessage, final @Nullable InputStream inputStream) {
@Override
public void onResult(final int responseCode, final String responseMessage, final @Nullable InputStream inputStream) {
- if(responseCode!=200 || inputStream==null)
+ if(responseCode != 200 || inputStream==null){
+ if(responseCode != 204)
+ throw new RuntimeException("Bad HTTP response code: "+responseCode);
return;
return;
+ }
final Handler handler=new Handler(Looper.getMainLooper());
final Handler handler=new Handler(Looper.getMainLooper());
@@
-99,6
+102,7
@@
final class PollResultCallback implements ResultCallback {
@Override
public void onError(final String error) {
Log.e("PollResultCallback", "onError: "+error);
@Override
public void onError(final String error) {
Log.e("PollResultCallback", "onError: "+error);
+ throw new RuntimeException(error);
}
}
}
}
This page took
0.012268 seconds
and
4
git commands to generate.