Skip to content
Browse files

Version 1.05

- Stability improvements for schedule fetch while rotating
  • Loading branch information...
1 parent bd068ba commit 79e35f13dffcf4a490d8d2bcce41018ed58e49ee @tuxmobil committed Aug 11, 2011
View
2 AndroidManifest.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="nerd.tuxmobil.fahrplan.camp11" android:versionCode="5" android:versionName="1.04">
+ package="nerd.tuxmobil.fahrplan.camp11" android:versionCode="6" android:versionName="1.05">
<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="7"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.VIBRATE"></uses-permission>
View
3 src/nerd/tuxmobil/fahrplan/camp11/CustomHttpClient.java
@@ -37,7 +37,8 @@
HTTP_CANNOT_PARSE_CONTENT,
HTTP_ENTITY_ENCODING_FAILURE,
HTTP_WRONG_HTTP_CREDENTIALS,
- HTTP_CONNECT_TIMEOUT
+ HTTP_CONNECT_TIMEOUT,
+ HTTP_CANCELLED
}
private static String httpCredentials = "";
View
109 src/nerd/tuxmobil/fahrplan/camp11/Fahrplan.java
@@ -93,6 +93,7 @@ public void onCreate(Bundle savedInstanceState) {
fetcher = new FetchFahrplan();
parser = new FahrplanParser();
scale = getResources().getDisplayMetrics().density;
+ progress = null;
trackColors = new HashMap<String, Integer>();
trackColors.put("Hacking", R.drawable.hacking_event_border);
@@ -200,6 +201,7 @@ public void onClick(View v) {
switch (MyApp.task_running) {
case FETCH:
Log.d(LOG_TAG, "fetch was pending, restart");
+ MyApp.task_running = TASKS.NONE;
fetchFahrplan();
viewDay(false);
break;
@@ -225,8 +227,8 @@ public void onClick(View v) {
public void parseFahrplan() {
if (MyApp.numdays == 0) {
// initial load
- progress.setMessage(getResources().getString(
- R.string.progress_processing_data));
+ progress = ProgressDialog.show(this, "", getResources().getString(
+ R.string.progress_processing_data), true);
} else {
statusLineText
.setText(getString(R.string.progress_processing_data));
@@ -252,6 +254,10 @@ public void onDestroy() {
if (lecturedb != null) lecturedb.close();
if (highlightdb != null) highlightdb.close();
if (alarmdb != null) alarmdb.close();
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
+ }
}
@Override
@@ -283,19 +289,24 @@ public boolean onCreateOptionsMenu(Menu menu) {
}
public void fetchFahrplan() {
- if (MyApp.numdays == 0) {
- // initial load
- progress = ProgressDialog.show(this, "", getResources().getString(
- R.string.progress_loading_data), true);
+ if (MyApp.task_running == TASKS.NONE) {
+ MyApp.task_running = TASKS.FETCH;
+ fetcher.fetch(this, "/camp/2011/Fahrplan/schedule.en.xml", global);
+ if (MyApp.numdays == 0) {
+ // initial load
+ Log.d(LOG_TAG, "fetchFahrplan with numdays == 0");
+ progress = ProgressDialog.show(this, "", getResources().getString(
+ R.string.progress_loading_data), true);
+ } else {
+ refreshBtn.setVisibility(View.GONE);
+ actionBar.setProgressBarVisibility(View.VISIBLE);
+ statusLineText.setText(getString(R.string.progress_loading_data));
+ statusBar.setVisibility(View.VISIBLE);
+ statusBar.startAnimation(slideUpIn);
+ }
} else {
- refreshBtn.setVisibility(View.GONE);
- actionBar.setProgressBarVisibility(View.VISIBLE);
- statusLineText.setText(getString(R.string.progress_loading_data));
- statusBar.setVisibility(View.VISIBLE);
- statusBar.startAnimation(slideUpIn);
+ Log.d(LOG_TAG, "fetch already in progress");
}
- MyApp.task_running = TASKS.FETCH;
- fetcher.fetch(this, "/camp/2011/Fahrplan/schedule.en.xml", global);
}
public boolean onOptionsItemSelected(MenuItem item) {
@@ -464,41 +475,72 @@ public void onGotResponse(HTTP_STATUS status, String response) {
MyApp.task_running = TASKS.NONE;
if (status != HTTP_STATUS.HTTP_OK) {
switch (status) {
- case HTTP_LOGIN_FAIL_UNTRUSTED_CERTIFICATE: {
- if (MyApp.numdays == 0) {
+ case HTTP_CANCELLED:
+ break;
+ case HTTP_LOGIN_FAIL_UNTRUSTED_CERTIFICATE: {
+ UntrustedCertDialogs.acceptKeyDialog(
+ R.string.dlg_certificate_message_fmt, this,
+ new cert_accepted() {
+
+ @Override
+ public void cert_accepted() {
+ Log.d(LOG_TAG, "fetch on cert accepted.");
+ fetchFahrplan();
+ }
+ }, (Object) null);
+ }
+ break;
+ }
+ CustomHttpClient.showHttpError(this, global, status);
+ if (MyApp.numdays == 0) {
+ if (progress != null) {
progress.dismiss();
+ progress = null;
+ }
+ } else {
+ actionBar.setProgressBarVisibility(View.GONE);
+ statusBar.startAnimation(slideDownOut);
+ statusBar.setVisibility(View.GONE);
+ refreshBtn.setVisibility(View.VISIBLE);
+ if (MyApp.numdays == 0) {
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
+ }
} else {
actionBar.setProgressBarVisibility(View.GONE);
statusBar.startAnimation(slideDownOut);
statusBar.setVisibility(View.GONE);
refreshBtn.setVisibility(View.VISIBLE);
}
- UntrustedCertDialogs.acceptKeyDialog(
- R.string.dlg_certificate_message_fmt, this,
- new cert_accepted() {
-
- @Override
- public void cert_accepted() {
- Log.d(LOG_TAG, "fetch on cert accepted.");
- fetchFahrplan();
- }
- }, (Object) null);
}
- break;
+ setProgressBarIndeterminateVisibility(false);
+ return;
+ }
+ Log.d(LOG_TAG, "yehhahh");
+ if (MyApp.numdays == 0) {
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
}
- CustomHttpClient.showHttpError(this, global, status);
+ } else {
+ actionBar.setProgressBarVisibility(View.GONE);
+ statusBar.startAnimation(slideDownOut);
+ statusBar.setVisibility(View.GONE);
+ refreshBtn.setVisibility(View.VISIBLE);
if (MyApp.numdays == 0) {
- progress.dismiss();
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
+ }
} else {
actionBar.setProgressBarVisibility(View.GONE);
statusBar.startAnimation(slideDownOut);
statusBar.setVisibility(View.GONE);
refreshBtn.setVisibility(View.VISIBLE);
}
- setProgressBarIndeterminateVisibility(false);
- return;
}
- Log.d(LOG_TAG, "yehhahh");
+ setProgressBarIndeterminateVisibility(false);
MyApp.fahrplan_xml = response;
parseFahrplan();
@@ -881,7 +923,10 @@ public void onParseDone(Boolean result, String version) {
setProgressBarIndeterminateVisibility(false);
if (MyApp.numdays == 0) {
- progress.dismiss();
+ if (progress != null) {
+ progress.dismiss();
+ progress = null;
+ }
} else {
actionBar.setProgressBarVisibility(View.GONE);
statusBar.startAnimation(slideDownOut);
View
3 src/nerd/tuxmobil/fahrplan/camp11/MyApp.java
@@ -17,7 +17,8 @@
enum TASKS {
NONE,
FETCH,
- PARSE
+ PARSE,
+ FETCH_CANCELLED
}
// requestCodes für startActivityForResult

0 comments on commit 79e35f1

Please sign in to comment.
Something went wrong with that request. Please try again.