Archived
Added error handling on refresh. Fixed a bug which made callback to CategoryChooser be always called on dismiss, not only when a category was actually chosen.
This commit is contained in:
1 parent
8aa1911bcb
commit
8d589b088d
5 files changed
+28
-15
No files matched your search
@@ -16,7 +16,7 @@ import android.widget.AdapterView.OnItemClickListener;
|
||||
|
||||
public class ChooseCategoryDialog extends Dialog {
|
||||
private final Callback callback;
|
||||
private String chosenCategory = Event.ALL;
|
||||
private String chosenCategory = null;
|
||||
|
||||
public interface Callback {
|
||||
public void run(String ... message);
|
||||
@@ -24,7 +24,9 @@ public class ChooseCategoryDialog extends Dialog {
|
||||
|
||||
private class OnDismiss implements OnDismissListener {
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
callback.run(chosenCategory);
|
||||
if (chosenCategory != null) {
|
||||
callback.run(chosenCategory);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,9 +167,13 @@ public class ProgramListActivity extends BaseDnsActivity {
|
||||
lc.execute();
|
||||
}
|
||||
};
|
||||
|
||||
Dialog dialog = new ChooseCategoryDialog(this, callback, dataHandler.getCategories());
|
||||
dialog.show();
|
||||
|
||||
if (dataHandler != null) {
|
||||
Dialog dialog = new ChooseCategoryDialog(this, callback, dataHandler.getCategories());
|
||||
dialog.show();
|
||||
} else {
|
||||
Toast.makeText(this, R.string.error_loading, Toast.LENGTH_SHORT);
|
||||
}
|
||||
}
|
||||
|
||||
protected class ListCreator extends AsyncTask<Void, Void, Boolean> {
|
||||
@@ -183,6 +187,10 @@ public class ProgramListActivity extends BaseDnsActivity {
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
if (forcedUpdate) {
|
||||
dataHandler = null;
|
||||
}
|
||||
|
||||
ListView list = (ListView)findViewById(R.id.event_list);
|
||||
list.setVisibility(View.GONE);
|
||||
|
||||
@@ -196,9 +204,11 @@ public class ProgramListActivity extends BaseDnsActivity {
|
||||
// YAY = Fetch the feed.
|
||||
// NAY = Inform about no connection.
|
||||
try {
|
||||
NodeList itemNodes = feed.fetch(this.forcedUpdate);
|
||||
dataHandler = parser.parse(itemNodes);
|
||||
return true;
|
||||
if (dataHandler == null) {
|
||||
NodeList itemNodes = feed.fetch(this.forcedUpdate);
|
||||
dataHandler = parser.parse(itemNodes);
|
||||
}
|
||||
return true;
|
||||
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user