bugfix (IITCm crashed if an unvalid URI was given)
This commit is contained in:
parent
06b3061715
commit
2501f5c82f
@ -24,19 +24,25 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
|
|||||||
|
|
||||||
private final IITC_Mobile mIitc;
|
private final IITC_Mobile mIitc;
|
||||||
|
|
||||||
public CheckHttpResponse(IITC_Mobile iitc) {
|
public CheckHttpResponse(final IITC_Mobile iitc) {
|
||||||
mIitc = iitc;
|
mIitc = iitc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean doInBackground(String... urls) {
|
protected Boolean doInBackground(final String... urls) {
|
||||||
// check http responses and disable splash screen on error
|
// check http responses and disable splash screen on error
|
||||||
HttpGet httpRequest = new HttpGet(urls[0]);
|
HttpGet httpRequest = null;
|
||||||
HttpClient httpclient = new DefaultHttpClient();
|
try {
|
||||||
|
httpRequest = new HttpGet(urls[0]);
|
||||||
|
} catch (final IllegalArgumentException e) {
|
||||||
|
Log.w(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final HttpClient httpclient = new DefaultHttpClient();
|
||||||
HttpResponse response = null;
|
HttpResponse response = null;
|
||||||
try {
|
try {
|
||||||
response = httpclient.execute(httpRequest);
|
response = httpclient.execute(httpRequest);
|
||||||
int code = response.getStatusLine().getStatusCode();
|
final int code = response.getStatusLine().getStatusCode();
|
||||||
if (code != HttpStatus.SC_OK) {
|
if (code != HttpStatus.SC_OK) {
|
||||||
Log.d("received error code: " + code);
|
Log.d("received error code: " + code);
|
||||||
mIitc.runOnUiThread(new Runnable() {
|
mIitc.runOnUiThread(new Runnable() {
|
||||||
@ -46,11 +52,9 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO: remove when google login issue is fixed
|
// TODO: remove when google login issue is fixed
|
||||||
if (urls[0].contains("uberauth=WILL_NOT_SIGN_IN")) {
|
if (urls[0].contains("uberauth=WILL_NOT_SIGN_IN")) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (final IOException e) {
|
||||||
Log.w(e);
|
Log.w(e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@ -60,10 +64,10 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
|
|||||||
* TEMPORARY WORKAROUND for Google login fail
|
* TEMPORARY WORKAROUND for Google login fail
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Boolean aBoolean) {
|
protected void onPostExecute(final Boolean aBoolean) {
|
||||||
if (aBoolean) {
|
if (aBoolean) {
|
||||||
Log.d("google auth error, redirecting to work-around page");
|
Log.d("google auth error, redirecting to work-around page");
|
||||||
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mIitc);
|
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(mIitc);
|
||||||
|
|
||||||
// set title
|
// set title
|
||||||
alertDialogBuilder.setTitle("LOGIN FAILED!");
|
alertDialogBuilder.setTitle("LOGIN FAILED!");
|
||||||
@ -79,14 +83,14 @@ public class CheckHttpResponse extends AsyncTask<String, Void, Boolean> {
|
|||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setNeutralButton("Reload now", new DialogInterface.OnClickListener() {
|
.setNeutralButton("Reload now", new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(final DialogInterface dialog, final int which) {
|
||||||
dialog.cancel();
|
dialog.cancel();
|
||||||
mIitc.reloadIITC();
|
mIitc.reloadIITC();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// create alert dialog
|
// create alert dialog
|
||||||
AlertDialog alertDialog = alertDialogBuilder.create();
|
final AlertDialog alertDialog = alertDialogBuilder.create();
|
||||||
|
|
||||||
// show it
|
// show it
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user