summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java120
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java121
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java31
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java98
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java32
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java17
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java60
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java10
8 files changed, 249 insertions, 240 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
index 629f2a6..5e2e49c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
@@ -1,48 +1,70 @@
package de.bjusystems.vdrmanager.gui;
-import de.bjusystems.vdrmanager.R;
-import de.bjusystems.vdrmanager.app.VdrManagerApp;
-import de.bjusystems.vdrmanager.data.Channel;
import android.app.Activity;
+import android.app.AlertDialog;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
+import android.widget.ListView;
+import android.widget.Toast;
+import android.widget.ViewFlipper;
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.app.VdrManagerApp;
+import de.bjusystems.vdrmanager.data.Channel;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
-public abstract class BaseActivity extends Activity implements OnClickListener{
-
+public abstract class BaseActivity<T extends ListView> extends Activity
+ implements OnClickListener {
public static final int MENU_GROUP_REFRESH = 99;
-
+
public static final int MENU_REFRESH = 99;
+
+ protected T listView;
+ protected ViewFlipper flipper;
+
+ protected SvdrpProgressDialog progress;
+
abstract protected int getMainLayout();
-
- protected void switchNoConnection(){
+
+ public void svdrpException(final SvdrpException exception) {
+ // Log.w(TAG, exception);
+ alert(getString(R.string.vdr_error_text, exception.getMessage()));
+ }
+
+ protected void switchNoConnection() {
View view = findViewById(R.id.main_content);
- if(view != null){
+ if (view != null) {
view.setVisibility(View.GONE);
}
- findViewById(R.id.no_connection_layout).setVisibility(View.VISIBLE);
- Button b = (Button) findViewById(R.id.retry_button);
+ view = findViewById(R.id.no_connection_layout);
+ if (view != null) {
+ view.setVisibility(View.VISIBLE);
+ }
+ Button b = (Button) findViewById(R.id.retry_button);
b.setOnClickListener(this);
}
public void onClick(View v) {
- if(v.getId() == R.id.retry_button){
- findViewById(R.id.no_connection_layout).setVisibility(View.GONE);
- View view = findViewById(R.id.main_content);
- if(view != null){
+ if (v.getId() == R.id.retry_button) {
+ View view = findViewById(R.id.no_connection_layout);
+ if (view != null) {
+ view.setVisibility(View.GONE);
+ }
+ view = findViewById(R.id.main_content);
+ if (view != null) {
view.setVisibility(View.VISIBLE);
}
retry();
}
}
-
+
protected void updateWindowTitle(int topic, int subtopic) {
String title;
- title = getString(topic);
+ title = getString(topic);
if (subtopic != -1) {
title += " > " + getString(subtopic);
}
@@ -57,7 +79,6 @@ public abstract class BaseActivity extends Activity implements OnClickListener{
setTitle(title);
}
-
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
MenuItem item;
@@ -66,40 +87,69 @@ public abstract class BaseActivity extends Activity implements OnClickListener{
item.setAlphabeticShortcut('r');
return true;
}
-
- abstract protected void refresh();
-
- abstract protected void retry();
-
+
+ abstract protected void refresh();
+
+ abstract protected void retry();
+
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_REFRESH:
+ backupViewSelection();
refresh();
return true;
-
default:
return false;
}
}
-
protected void setAsCurrent(Channel channel) {
getApp().setCurrentChannel(channel);
}
-
- protected VdrManagerApp getApp(){
+ protected VdrManagerApp getApp() {
final VdrManagerApp app = (VdrManagerApp) getApplication();
return app;
}
-
- //protected Channel getCurrentChannel(){
- //final Channel channel = ((VdrManagerApp) getApplication())
- //.getCurrentChannel();
- //return channel;
-// }
-
-
+ // protected Channel getCurrentChannel(){
+ // final Channel channel = ((VdrManagerApp) getApplication())
+ // .getCurrentChannel();
+ // return channel;
+ // }
+
+ protected void say(int res) {
+ Toast.makeText(this, res, Toast.LENGTH_SHORT).show();
+ }
+
+ protected void say(String msg) {
+ Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
+ }
+
+ protected void alert(String msg) {
+ new AlertDialog.Builder(this)//
+ .setMessage(msg)//
+ .setPositiveButton(android.R.string.ok, null)//
+ .create()//
+ .show();//
+ }
+
+ protected void alert(int resId) {
+ alert(getString(resId));
+ }
+
+ protected void restoreViewSelection() {
+ listView.setSelectionFromTop(index, top);
+ }
+
+ protected void backupViewSelection() {
+ index = listView.getFirstVisiblePosition();
+ View v = listView.getChildAt(0);
+ top = (v == null) ? 0 : v.getTop();
+ }
+
+ int index;
+ int top;
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
index e8dd66b..7174803 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
@@ -10,6 +10,7 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
@@ -21,7 +22,6 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
-import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.Intents;
import de.bjusystems.vdrmanager.data.Channel;
@@ -38,8 +38,10 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
*
*/
public abstract class BaseEventListActivity<T extends Event> extends
- BaseActivity implements OnItemClickListener, SvdrpAsyncListener<T>,
- SimpleGestureListener {
+ BaseActivity<ListView> implements OnItemClickListener,
+ SvdrpAsyncListener<T>, SimpleGestureListener {
+
+ public static final String TAG = BaseEventListActivity.class.getName();
public static final int MENU_GROUP_SHARE = 90;
@@ -51,8 +53,6 @@ public abstract class BaseEventListActivity<T extends Event> extends
protected EventAdapter adapter;
- protected SvdrpProgressDialog progress;
-
protected String highlight = null;
protected static final Date FUTURE = new Date(Long.MAX_VALUE);
@@ -61,8 +61,6 @@ public abstract class BaseEventListActivity<T extends Event> extends
protected Channel currentChannel = null;
- protected ListView listView;
-
abstract protected int getWindowTitle();
protected List<Event> results = new ArrayList<Event>();
@@ -82,6 +80,16 @@ public abstract class BaseEventListActivity<T extends Event> extends
.getParcelableExtra(Intents.CURRENT_CHANNEL);
}
+ private boolean refreshViewOnResume = false;
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ if (refreshViewOnResume) {
+ adapter.notifyDataSetChanged();
+ }
+ }
+
/*
* (non-Javadoc)
*
@@ -130,7 +138,7 @@ public abstract class BaseEventListActivity<T extends Event> extends
return super.onContextItemSelected(item);
}
- return true;
+ return true;
}
/*
@@ -167,7 +175,6 @@ public abstract class BaseEventListActivity<T extends Event> extends
@Override
public void onCreateContextMenu(final ContextMenu menu, final View v,
final ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
// if (v.getId() == R.id.whatson_list) {
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
@@ -175,12 +182,14 @@ public abstract class BaseEventListActivity<T extends Event> extends
// set menu title
final EventListItem item = adapter.getItem(info.position);
+ MenuItem mi = menu.findItem(R.id.epg_item_menu_live_tv);
if (item.isLive()) {
- menu.findItem(R.id.epg_item_menu_live_tv).setVisible(true);
+ mi.setVisible(true);
+ } else {
+ mi.setVisible(false);
}
-
menu.add(MENU_GROUP_SHARE, MENU_SHARE, 0, R.string.share);
- // }
+ super.onCreateContextMenu(menu, v, menuInfo);
}
@@ -217,40 +226,48 @@ public abstract class BaseEventListActivity<T extends Event> extends
@Override
protected void onPause() {
super.onPause();
- if (epgClient != null) {
- epgClient.abort();
- }
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
+ refreshViewOnResume = true;
+ // if (epgClient != null) {
+ // epgClient.abort();
+ // }
+ // if (progress != null) {
+ // progress.dismiss();
+ // progress = null;
+ // }
}
public void svdrpEvent(final SvdrpEvent event, final T result) {
- if (progress != null) {
- progress.svdrpEvent(event);
- }
-
switch (event) {
- case ERROR:
- Toast.makeText(this, R.string.epg_client_errors, Toast.LENGTH_SHORT)
- .show();
- dismiss(progress);
+ case ABORTED:
+ alert(R.string.aborted);
break;
- case CONNECTING:
+ case ERROR:
+ alert(R.string.epg_client_errors);
+ // say(R.string.epg_client_errors);
+ // dismiss(progress);
break;
+ // case CONNECTING:
+ // break;
case CONNECTED:
results.clear();
break;
case CONNECT_ERROR:
+ say(R.string.progress_connect_error);
+ switchNoConnection();
+ break;
case FINISHED_ABNORMALY:
+ alert(R.string.progress_connect_finished_abnormal);
+ switchNoConnection();
+ break;
case LOGIN_ERROR:
switchNoConnection();
break;
case FINISHED_SUCCESS:
if (finishedSuccess() == false) {
say(R.string.epg_no_items);
+ } else {
+ restoreViewSelection();
}
break;
case RESULT_RECEIVED:
@@ -263,24 +280,23 @@ public abstract class BaseEventListActivity<T extends Event> extends
results.add(result);
}
- //
- // @Override
- // protected void onRestoreInstanceState(Bundle savedInstanceState) {
- // super.onRestoreInstanceState(savedInstanceState);
- // int index = savedInstanceState.getInt("INDEX");
- // int top = savedInstanceState.getInt("TOP");
- // listView.setSelectionFromTop(index, top);
- // }
- //
- // @Override
- // protected void onSaveInstanceState(Bundle outState) {
- // int index = listView.getFirstVisiblePosition();
- // View v = listView.getChildAt(0);
- // int top = (v == null) ? 0 : v.getTop();
- // outState.putInt("INDEX", index);
- // outState.putInt("TOP", top);
- // super.onSaveInstanceState(outState);
- // }
+ @Override
+ protected void onRestoreInstanceState(Bundle savedInstanceState) {
+ super.onRestoreInstanceState(savedInstanceState);
+ int index = savedInstanceState.getInt("INDEX");
+ int top = savedInstanceState.getInt("TOP");
+ listView.setSelectionFromTop(index, top);
+ }
+
+ @Override
+ protected void onSaveInstanceState(Bundle outState) {
+ int index = listView.getFirstVisiblePosition();
+ View v = listView.getChildAt(0);
+ int top = (v == null) ? 0 : v.getTop();
+ outState.putInt("INDEX", index);
+ outState.putInt("TOP", top);
+ super.onSaveInstanceState(outState);
+ }
protected void dismiss(AlertDialog dialog) {
if (dialog == null) {
@@ -346,17 +362,8 @@ public abstract class BaseEventListActivity<T extends Event> extends
}
public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
- }
-
- protected void say(int res) {
- Toast.makeText(this, res, Toast.LENGTH_SHORT).show();
- }
-
- protected void say(String msg) {
- Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
+ Log.w(TAG, exception);
+ alert(getString(R.string.vdr_error_text, exception.getMessage()));
}
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
index c4fc5fd..55cc468 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
@@ -21,7 +21,6 @@ import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;
import de.bjusystems.vdrmanager.R;
-import de.bjusystems.vdrmanager.data.Epg;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
@@ -30,7 +29,6 @@ import de.bjusystems.vdrmanager.tasks.CreateTimerTask;
import de.bjusystems.vdrmanager.tasks.DeleteTimerTask;
import de.bjusystems.vdrmanager.tasks.ModifyTimerTask;
import de.bjusystems.vdrmanager.tasks.ToggleTimerTask;
-import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation;
public abstract class BaseTimerEditActivity<T extends Event> extends
@@ -64,24 +62,25 @@ public abstract class BaseTimerEditActivity<T extends Event> extends
case CREATE:
tView.modifyButton.setVisibility(View.GONE);
tView.saveButton.setVisibility(View.VISIBLE);
- tView.saveButton.setText(R.string.timer_details_save_title);
+ tView.saveButton.setText(R.string.timer_details_create_title);
break;
case MODIFY:
tView.saveButton.setVisibility(View.GONE);
tView.modifyButton.setVisibility(View.VISIBLE);
+ tView.saveButton.setText(R.string.timer_details_save_title);
+ break;
}
}
private void updateDisplay() {
- final DateFormatter dateFormatter = new DateFormatter(timer.getStart());
+ EventFormatter f = new EventFormatter(timer,true);
tView.channel.setText(timer.getChannelNumber() + " "
+ timer.getChannelName());
- tView.title.setText(timer.getTitle());
- tView.dateField.setText(dateFormatter.getDateString());
- tView.startField.setText(dateFormatter.getTimeString());
- tView.endField.setText(new DateFormatter(timer.getStop())
- .getTimeString());
+ tView.title.setText(f.getTitle());
+ tView.dateField.setText(f.getDate());
+ tView.startField.setText(f.getTime());
+ tView.endField.setText(f.getStop());
}
protected Timer getTimer(EventListItem item) {
@@ -258,38 +257,44 @@ public abstract class BaseTimerEditActivity<T extends Event> extends
say(R.string.done);
break;
}
+
+ default:
+ super.onClick(view);
}
}
private void modifyTimer(Timer timer) {
+ backupViewSelection();
final ModifyTimerTask task = new ModifyTimerTask(this, timer) {
@Override
public void finished() {
refresh();
- say(R.string.done);
+ //say(R.string.done);
}
};
task.start();
}
protected void deleteTimer(final Timer timer) {
-
+ backupViewSelection();
final DeleteTimerTask task = new DeleteTimerTask(this, timer) {
@Override
public void finished() {
refresh();
- say(R.string.done);
+ restoreViewSelection();
+ //say(R.string.done);
}
};
task.start();
}
private void createTimer(Timer timer) {
+ backupViewSelection();
final CreateTimerTask task = new CreateTimerTask(this, timer) {
@Override
public void finished() {
refresh();
- say(R.string.done);
+ //say(R.string.done);
}
};
task.start();
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
index a2249b9..1c2c4ff 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java
@@ -3,15 +3,12 @@ package de.bjusystems.vdrmanager.gui;
import java.util.ArrayList;
import java.util.HashMap;
-import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
-import android.text.Editable;
-import android.text.TextUtils;
-import android.text.TextWatcher;
+import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
@@ -19,15 +16,12 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
-import android.widget.ArrayAdapter;
-import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.Intents;
-import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient;
@@ -42,14 +36,16 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
*
* @author bju
*/
-public class ChannelListActivity extends BaseActivity implements
+public class ChannelListActivity extends BaseActivity<ExpandableListView> implements
OnChildClickListener, OnGroupClickListener, SvdrpAsyncListener<Channel> {
+ private static final String TAG = ChannelListActivity.class.getName();
ChannelClient channelClient;
+
ChannelAdapter adapter;
+
Preferences prefs;
- SvdrpProgressDialog progress;
-
+
public static final int MENU_GROUP = 0;
public static final int MENU_PROVIDER = 1;
public static final int MENU_NAME = 2;
@@ -59,7 +55,7 @@ public class ChannelListActivity extends BaseActivity implements
final static ArrayList<String> ALL_CHANNELS_GROUP = new ArrayList<String>(
1);
- ExpandableListView listView;
+ //ExpandableListView listView;
// @Override
// public boolean onKeyLongPress(int keyCode, KeyEvent event) {
@@ -79,6 +75,12 @@ public class ChannelListActivity extends BaseActivity implements
// return super.onKeyUp(keyCode, event);
// }
//
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ }
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -106,27 +108,12 @@ public class ChannelListActivity extends BaseActivity implements
//
@Override
- protected void onResume() {
- super.onResume();
-
- }
-
- @Override
protected void onPause() {
super.onPause();
- if (channelClient != null) {
- channelClient.abort();
- }
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
- if (groupByDialog != null) {
- groupByDialog.dismiss();
- }
}
private void startChannelQuery() {
+ backupViewSelection();
startChannelQuery(true);
}
@@ -140,10 +127,11 @@ public class ChannelListActivity extends BaseActivity implements
channelClient);
// create progress
- progress = new SvdrpProgressDialog(this, channelClient);
+ progress = new SvdrpProgressDialog<Channel>(this, channelClient);
// attach listener
task.addListener(this);
+ task.addListener(progress);
// start task
task.run();
@@ -152,20 +140,24 @@ public class ChannelListActivity extends BaseActivity implements
private void fillAdapter() {
switch (groupBy) {
case MENU_GROUP:
- adapter.fill(
- channelClient.getChannelGroups(),
- channelClient.getGroupChannels(), groupBy);
- listView.collapseGroup(0);
+ ArrayList<String> cgs = channelClient.getChannelGroups();
+ adapter.fill(cgs, channelClient.getGroupChannels(), groupBy);
+ if(cgs.size() == 1){
+ listView.expandGroup(0);
+ }
updateWindowTitle(
getString(R.string.action_menu_channels),
getString(R.string.groupby_window_title_templte,
getString(R.string.groupby_group)));
break;
case MENU_PROVIDER:
- adapter.fill(new ArrayList<String>(channelClient
- .getProviderChannels().keySet()), channelClient
+ ArrayList<String> gs = new ArrayList<String>(channelClient
+ .getProviderChannels().keySet());
+ adapter.fill(gs, channelClient
.getProviderChannels(), groupBy);
- listView.collapseGroup(0);
+ if(gs.size() == 1){
+ listView.expandGroup(0);
+ }
updateWindowTitle(
getString(R.string.action_menu_channels),
getString(R.string.groupby_window_title_templte,
@@ -190,36 +182,47 @@ public class ChannelListActivity extends BaseActivity implements
}
public void svdrpEvent(final SvdrpEvent event, final Channel result) {
-
- if (progress != null) {
- progress.svdrpEvent(event);
- }
-
switch (event) {
+ case ABORTED:
+ say(R.string.aborted);
+ break;
+ case ERROR:
+ say(R.string.epg_client_errors);
+ break;
case CONNECTING:
break;
case CONNECT_ERROR:
+ say(R.string.progress_connect_error);
+ switchNoConnection();
+ break;
+ case FINISHED_ABNORMALY:
+ say(R.string.progress_connect_finished_abnormal);
switchNoConnection();
break;
case LOGIN_ERROR:
switchNoConnection();
break;
- case FINISHED_SUCCESS:
case CACHE_HIT:
+ say(R.string.progress_cache_hit);
fillAdapter();
+ restoreViewSelection();
break;
- case FINISHED_ABNORMALY:
- switchNoConnection();
+ case FINISHED_SUCCESS:
+ fillAdapter();
+ restoreViewSelection();
break;
+
}
}
+
public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
+ progress.svdrpException(exception);
+ Log.w(TAG, exception);
+ alert(getString(R.string.vdr_error_text, exception.getMessage()));
}
+
public boolean onPrepareOptionsMenu(Menu menu) {
return super.onPrepareOptionsMenu(menu);
@@ -420,12 +423,13 @@ public class ChannelListActivity extends BaseActivity implements
@Override
protected void refresh() {
+ backupViewSelection();
startChannelQuery(false);
}
@Override
protected void retry() {
- startChannelQuery(false);
+ refresh();
}
@Override
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index ca492d5..40d54fe 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -44,7 +44,7 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
public class EpgDetailsActivity extends Activity implements OnClickListener,
SimpleGestureListener {
- public static String IMDB_URL = "http://www.%s/find?s=all&q=%s";
+ public static String IMDB_URL = "http://%s/find?s=all&q=%s";
private SimpleGestureFilter detector;
@@ -61,6 +61,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
super.onCreate(savedInstanceState);
Intent i = getIntent();
+
highlight = i.getStringExtra(Intents.HIGHLIGHT);
// Attach view
@@ -84,29 +85,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
counter++;
}
- new AsyncTask<Void, Void, Void>() {
-
- protected void onPreExecute() {
- // event_left.setEnabled(false);
- // event_right.setEnabled(false);
- };
-
- protected Void doInBackground(Void... params) {
- initEPGs();
- return null;
- };
-
- protected void onPostExecute(Void result) {
- // event_left.setEnabled(true);
- // event_right.setEnabled(true);
- };
-
- }.execute((Void) null);
-
publishEPG(epg);
-
- // TODO was ist das?
- app.clearActivitiesToFinish();
}
private void setState(ImageView view, int res) {
@@ -280,9 +259,10 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}
- List<Event> epgs = null;
+ List<Event> epgs = new ArrayList<Event>();
+
int counter = 0;
-
+/*
public void initEPGs() {
if (epgs != null) {
@@ -323,7 +303,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
;
}
}
-
+*/
private void nextEPG() {
if (counter < epgs.size() - 1) {
counter++;
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
index f481244..257eea5 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
@@ -77,7 +77,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
// Create adapter for EPG list
listView = (ListView) findViewById(R.id.whatson_list);
listView.setAdapter(adapter);
- listView.setFastScrollEnabled(true);
+ //listView.setFastScrollEnabled(true);
listView.setTextFilterEnabled(true);
registerForContextMenu(listView);
@@ -86,12 +86,6 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
- @Override
- protected void onResume() {
- super.onResume();
- // adapter.notifyDataSetChanged();
- // startEpgQuery();
- }
public void onItemSelected(final AdapterView<?> parent, final View view,
final int position, final long id) {
@@ -171,10 +165,12 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
epgClient);
// create progress
- progress = new SvdrpProgressDialog(this, epgClient);
+ progress = new SvdrpProgressDialog<Epg>(this, epgClient);
// attach listener
+ task.addListener(progress);
task.addListener(this);
+
// start task
task.run();
}
@@ -208,7 +204,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
}
cachedChannel = currentChannel;
- listView.setSelectionAfterHeaderView();
+ //listView.setSelectionAfterHeaderView();
dismiss(progress);
return CACHE.isEmpty() == false;
}
@@ -252,8 +248,7 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
private void prevEvent() {
int pos = channelSpinner.getSelectedItemPosition();
if (pos <= 0) {
- Toast.makeText(this, R.string.navigae_at_the_start,
- Toast.LENGTH_SHORT).show();
+ say(R.string.navigae_at_the_start);
return;
}
channelSpinner.setSelection(pos - 1, true);
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
index 8997214..f3468f8 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SvdrpProgressDialog.java
@@ -2,22 +2,20 @@ package de.bjusystems.vdrmanager.gui;
import android.app.Activity;
import android.app.ProgressDialog;
-import android.util.Log;
-import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
-public class SvdrpProgressDialog extends ProgressDialog {
-
- private static final String TAG = SvdrpProgressDialog.class.getName();
+public class SvdrpProgressDialog<T> extends ProgressDialog implements
+ SvdrpAsyncListener<T> {
ProgressDialog progress;
Activity activity;
SvdrpClient<? extends Object> client;
public SvdrpProgressDialog(final Activity activity,
- final SvdrpClient<? extends Object> client) {
+ final SvdrpClient<T> client) {
super(activity);
this.activity = activity;
this.client = client;
@@ -28,24 +26,25 @@ public class SvdrpProgressDialog extends ProgressDialog {
svdrpEvent(event, null);
}
- public void svdrpEvent(final SvdrpEvent event, Throwable error) {
- switch (event) {
+ public void svdrpEvent(final SvdrpEvent sevent, T e) {
+ switch (sevent) {
+ case ABORTED:
+ case CONNECT_ERROR:
+ case ERROR:
+ case LOGIN_ERROR:
+ case FINISHED_ABNORMALY:
+ case FINISHED_SUCCESS:
+ case CACHE_HIT:
+ progress.dismiss();
+ break;
case CONNECTING:
progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
setMessage(R.string.progress_connect);
progress.show();
break;
- case CONNECT_ERROR:
- progress.dismiss();
- showToast(R.string.progress_connect_error);
- break;
case LOGGED_IN:
setMessage(R.string.progress_login);
break;
- case LOGIN_ERROR:
- progress.dismiss();
- showToast(R.string.progress_login_error);
- break;
case COMMAND_SENT:
setMessage(client.getProgressTextId());
break;
@@ -56,27 +55,11 @@ public class SvdrpProgressDialog extends ProgressDialog {
break;
case DISCONNECTED:
break;
- case FINISHED_ABNORMALY:
- progress.dismiss();
- if (error == null) {
- showToast(R.string.progress_connect_finished_abnormal);
- } else {
- showToast(R.string.progress_connect_finished_abnormal_arg,
- error.getMessage());
- }
- case FINISHED_SUCCESS:
- progress.dismiss();
- break;
- case CACHE_HIT:
- progress.dismiss();
- setMessage(R.string.progress_cache_hit);
- break;
}
}
public void svdrpException(final SvdrpException exception) {
- Log.w(TAG, String.valueOf(activity), exception);
- showToast(R.string.vdr_error_text, exception.getMessage());
+ progress.dismiss();
}
private void setMessage(final int resId, Object... args) {
@@ -86,17 +69,8 @@ public class SvdrpProgressDialog extends ProgressDialog {
progress.setMessage(activity.getString(resId, args));
}
}
-
- private void showToast(final int resId, Object... args) {
- progress.dismiss();
- final CharSequence text = args.length == 0 ? activity.getString(resId)
- : activity.getString(resId, args);
- final int duration = Toast.LENGTH_SHORT;
- final Toast toast = Toast.makeText(activity, text, duration);
- toast.show();
- }
- public void dismiss(){
+ public void dismiss() {
progress.dismiss();
}
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
index f237a89..dfa7e6c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
@@ -77,9 +77,7 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
- private void addCustom() {
- }
private void fillTimeSpinnerValues() {
final EpgSearchTimeValues values = new EpgSearchTimeValues(this);
@@ -89,7 +87,6 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
}
- private int currentPostion = 0;
@Override
protected void onPause() {
@@ -97,10 +94,6 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
}
- @Override
- protected void onResume() {
- super.onResume();
- }
public void onItemSelected(final AdapterView<?> parent, final View view,
final int position, final long id) {
@@ -171,8 +164,9 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
epgClient);
// create progress
- progress = new SvdrpProgressDialog(this, epgClient);
+ progress = new SvdrpProgressDialog<Epg>(this, epgClient);
// attach listener
+ task.addListener(progress);
task.addListener(this);
// start task