From a06a1440b18320787c5022b3753aa1218c07d065 Mon Sep 17 00:00:00 2001 From: lado Date: Sun, 6 Nov 2011 18:22:06 +0100 Subject: some defensive actions --- .../vdrmanager/gui/EpgDetailsActivity.java | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'vdrmanager/src') diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java index f0622be..c699d24 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java @@ -80,11 +80,14 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, event_left = (ImageButton) findViewById(R.id.epg_event_left); event_right = (ImageButton) findViewById(R.id.epg_event_right); state = (ImageView) findViewById(R.id.epg_timer_state); - + + final Event epg = getApp().getCurrentEvent(); + if(epg == null){ + finish(); + } + new VoidAsyncTask() { - private Event epg; - @Override protected void onPreExecute() { setProgressBarIndeterminateVisibility(true); @@ -95,7 +98,6 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, // current event final VdrManagerApp app = (VdrManagerApp) getApplication(); epgs = app.getCurrentEpgList(); - epg = app.getCurrentEvent(); counter = 0; for (Event e : epgs) { @@ -104,6 +106,9 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, } counter++; } + if(counter > epgs.size()){ + counter = -1; + } return (Void) null; } @@ -130,6 +135,10 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, cEvent = event; + if(cEvent == null){ + return; + } + String cn = event.getChannelName(); setTitle(getString(R.string.epg_of_a_channel, cn, counter + 1, epgs.size())); @@ -404,6 +413,9 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, } private void prevEPG() { + if(counter == -1){ + return; + } Event epg; if (counter == 0) { say(R.string.navigae_at_the_start); @@ -441,6 +453,9 @@ public class EpgDetailsActivity extends Activity implements OnClickListener, * } } */ private void nextEPG() { + if(counter == -1){ + return; + } if (counter < epgs.size() - 1) { counter++; Event epg = epgs.get(counter); -- cgit v1.2.3