Merge branch 'master' of github.com:neuf/DNSapp

This commit is contained in:
Lars Jansøn Engvik committed 2011-09-28 17:21:15 +02:00
commit b22c562fb5
4 files changed
+38 -6

No files matched your search

@@ -55,19 +55,19 @@ public class FeedFetcher {
/**
* Fetches list of events from the web.
* @param URL String containing address to the rss-feed.
* @param c Context from which this function is called.
* @param forcedUpdate specifies if we HAVE TO update local file, or let
* the function decide.
* @return Returns list of events as a XML NodeList
* @throws IOException Is thrown if the app cannot download the file from
* the internet and there is no local copy.
*/
public NodeList fetch() throws IOException {
public NodeList fetch(boolean forcedUpdate) throws IOException {
InputStream in = null;
NodeList itemNodes = null;
/* Update the local file if possible. */
try {
if (doesFileNeedUpdate(context)) {
if (forcedUpdate || doesFileNeedUpdate(context)) {
in = openHttpConnection();
saveFile(in, context);
}
@@ -8,6 +8,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
@@ -38,11 +41,34 @@ public class ProgramListActivity extends BaseDnsActivity {
this.feed = new FeedFetcher(this, feedURL);
this.parser = new XmlParser();
// Do we have intarwebs?
createList(false);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.layout.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_refresh:
this.createList(true);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
protected void createList(boolean forcedUpdate) {
// Do we have intarwebs?
// YAY = Fetch the feed.
// NAY = Inform about no connection.
try {
NodeList itemNodes = feed.fetch();
NodeList itemNodes = feed.fetch(forcedUpdate);
dataHandler = parser.parse(itemNodes);
} catch (IOException e) {