summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-20 03:59:26 +0200
committerlado <herrlado@gmail.com>2011-10-20 03:59:26 +0200
commit21095973db377685363ff5c0efb945c0534d3070 (patch)
tree9a5152256ac9ed9349035ebee36482e97e5d5beb /vdrmanager/src/de/bjusystems
parenta7b027068cb070ebf519246917b5409543df212d (diff)
downloadvdr-manager-21095973db377685363ff5c0efb945c0534d3070.tar.gz
vdr-manager-21095973db377685363ff5c0efb945c0534d3070.tar.bz2
timer support, recording support + epg details for all of them
Diffstat (limited to 'vdrmanager/src/de/bjusystems')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java (renamed from vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java)213
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java26
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java29
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java190
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java29
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java202
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/SimpleGestureFilter.java3
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java86
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java2
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java259
10 files changed, 395 insertions, 644 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
index d298de1..09ee612 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java
@@ -1,8 +1,12 @@
package de.bjusystems.vdrmanager.gui;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
import java.util.Date;
+import java.util.List;
-import android.app.Activity;
+import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
@@ -15,28 +19,28 @@ import android.view.MotionEvent;
import android.view.View;
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;
-import de.bjusystems.vdrmanager.data.Epg;
-import de.bjusystems.vdrmanager.data.EventFormatter;
+import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.gui.SimpleGestureFilter.SimpleGestureListener;
-import de.bjusystems.vdrmanager.tasks.DeleteTimerTask;
-import de.bjusystems.vdrmanager.tasks.ToggleTimerTask;
import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
+import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
/**
* @author lado
*
*/
-public abstract class BaseEpgListActivity extends BaseActivity implements
+public abstract class BaseEventListActivity<T extends Event> extends
+ BaseActivity implements OnItemClickListener,SvdrpAsyncListener<T>,
SimpleGestureListener {
- private static final int REQUEST_CODE_TIMED_EDIT = 41;
-
private SimpleGestureFilter detector;
protected EpgClient epgClient;
@@ -57,6 +61,9 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
abstract protected int getWindowTitle();
+ protected List<Event> results = new ArrayList<Event>();
+
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -72,17 +79,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
.getParcelableExtra(Intents.CURRENT_CHANNEL);
}
- protected void deleteTimer(final EventListItem item) {
-
- final DeleteTimerTask task = new DeleteTimerTask(this, item.getEpg()
- .getTimer()) {
- @Override
- public void finished() {
- refresh();
- }
- };
- task.start();
- }
+
/*
* (non-Javadoc)
@@ -104,6 +101,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
}
+
/*
* (non-Javadoc)
*
@@ -116,27 +114,11 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
.getMenuInfo();
final EventListItem event = adapter.getItem(info.position);
+
switch (item.getItemId()) {
- case R.id.epg_item_menu_timer_add:
- case R.id.epg_item_menu_timer_modify: {
- prepareTimer(event);
- final Intent intent = new Intent();
- intent.setClass(this, TimerDetailsActivity.class);
- startActivityForResult(intent, REQUEST_CODE_TIMED_EDIT);
- break;
- }
- case R.id.epg_item_menu_timer_delete: {
- deleteTimer(event);
- break;
- }
- case R.id.epg_item_menu_timer_toggle: {
- toggleTimer(event);
- break;
- }
case R.id.epg_item_menu_live_tv: {
- Utils.stream(this, event.getEvent());
+ Utils.stream(this, event);
break;
-
}
}
@@ -156,7 +138,7 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
switch (item.getItemId()) {
case R.id.epg_menu_search:
- //startSearchManager();
+ // startSearchManager();
super.onSearchRequested();
break;
case R.id.epg_menu_times:
@@ -179,62 +161,18 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
final ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
- if (v.getId() == R.id.whatson_list) {
- final MenuInflater inflater = getMenuInflater();
+ //if (v.getId() == R.id.whatson_list) {
final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
// set menu title
final EventListItem item = adapter.getItem(info.position);
- final EventFormatter formatter = new EventFormatter(item);
- menu.setHeaderTitle(formatter.getTitle());
-
- inflater.inflate(R.menu.epg_list_item_menu, menu);
-
- // remove unneeded menu items
- if (item.getEpg().getTimer() != null) {
- menu.findItem(R.id.epg_item_menu_timer_add).setVisible(false);
- menu.findItem(R.id.epg_item_menu_timer_modify).setVisible(true);
- menu.findItem(R.id.epg_item_menu_timer_delete).setVisible(true);
- final MenuItem enableMenuItem = menu
- .findItem(R.id.epg_item_menu_timer_toggle);
- enableMenuItem.setVisible(true);
- enableMenuItem
- .setTitle(item.getEpg().getTimer().isEnabled() ? R.string.epg_item_menu_timer_disable
- : R.string.epg_item_menu_timer_enable);
- }
-
- if (item.isLive()) {
+
+ if (item.isLive()) {
menu.findItem(R.id.epg_item_menu_live_tv).setVisible(true);
}
- }
-
- }
+ //}
- protected void toggleTimer(final EventListItem item) {
- final ToggleTimerTask task = new ToggleTimerTask(this, item.getEpg()
- .getTimer()) {
- @Override
- public void finished() {
- refresh();
- }
- };
- task.start();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see android.app.Activity#onActivityResult(int, int,
- * android.content.Intent)
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == REQUEST_CODE_TIMED_EDIT) {
- if (resultCode == Activity.RESULT_OK) {
- refresh();
- }
- }
}
/**
@@ -279,47 +217,73 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
}
}
- public void svdrpEvent(final SvdrpEvent event, final Epg result) {
+ 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);
+ break;
case CONNECTING:
break;
+ case CONNECTED:
+ results.clear();
+ break;
case CONNECT_ERROR:
case FINISHED_ABNORMALY:
case LOGIN_ERROR:
switchNoConnection();
break;
case FINISHED_SUCCESS:
- finishedSuccess();
+ if (finishedSuccess() == false) {
+ say(R.string.epg_no_items);
+ }
break;
case RESULT_RECEIVED:
+ resultReceived(result);
break;
}
}
- @Override
- protected void onRestoreInstanceState(Bundle savedInstanceState) {
- super.onRestoreInstanceState(savedInstanceState);
- int index = savedInstanceState.getInt("INDEX");
- int top = savedInstanceState.getInt("TOP");
- listView.setSelectionFromTop(index, top);
+ protected void resultReceived(Event result) {
+ results.add(result);
}
- @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) {
+ return;
+ }
+ dialog.dismiss();
}
- protected abstract void finishedSuccess();
+ /**
+ * @return false, if no results found
+ */
+ protected abstract boolean finishedSuccess();
public boolean onSearchRequested() {
InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
@@ -343,8 +307,49 @@ public abstract class BaseEpgListActivity extends BaseActivity implements
}
public void onDoubleTap() {
- // TODO Auto-generated method stub
}
+ protected void sortItemsByChannel(List<Event> result) {
+ final Comparator<Event> comparator = new Comparator<Event>() {
+
+ public int compare(final Event item1, final Event item2) {
+ return Integer.valueOf(item1.getChannelNumber()).compareTo(
+ Integer.valueOf(item2.getChannelNumber()));
+ }
+ };
+ Collections.sort(result, comparator);
+ }
+
+ protected void sortItemsByTime(List<Event> result) {
+ final Comparator<Event> comparator = new Comparator<Event>() {
+
+ public int compare(final Event item1, final Event item2) {
+ int c = item1.getStart().compareTo(item2.getStart());
+ if (c != 0) {
+ return c;
+ }
+ return Integer.valueOf(item1.getChannelNumber()).compareTo(
+ Integer.valueOf(item2.getChannelNumber()));
+ }
+ };
+ Collections.sort(result, comparator);
+ }
+
+ 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();
+ }
+
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index 8c52801..b0a7c01 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -20,8 +20,10 @@ import de.bjusystems.vdrmanager.app.Intents;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Epg;
+import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.Preferences;
+import de.bjusystems.vdrmanager.data.Timer;
import de.bjusystems.vdrmanager.gui.SimpleGestureFilter.SimpleGestureListener;
import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
@@ -64,17 +66,17 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
// current event
final VdrManagerApp app = (VdrManagerApp) getApplication();
epgs = app.getCurrentEpgList();
- Epg epg = app.getCurrentEvent();
+ Event epg = app.getCurrentEvent();
counter = 0;
- for(Epg e : epgs){
+ for(Event e : epgs){
if(epg == e){
break;
}
counter++;
}
-
+
new AsyncTask<Void,Void,Void>(){
@@ -102,7 +104,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
app.clearActivitiesToFinish();
}
- public void publishEPG(Epg event) {
+ public void publishEPG(Event event) {
String cn = event.getChannelName();
@@ -177,7 +179,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
// setThisAsOnClickListener(R.id.epg_event_right);
// set button text
- if (event.getTimer() == null) {
+ if (event instanceof Timer) {
// timeButton.setText(R.string.epg_event_create_timer_text);
} else {
// timeButton.setText(R.string.epg_event_modify_timer_text);
@@ -213,7 +215,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
final VdrManagerApp app = (VdrManagerApp) getApplication();
switch (v.getId()) {
case R.id.epg_event_livetv:
- Epg event = app.getCurrentEvent();
+ Event event = app.getCurrentEvent();
Utils.stream(this, event.getChannelNumber());
break;
case R.id.epg_event_create_timer:
@@ -241,7 +243,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}
private void prevEPG() {
- Epg epg;
+ Event epg;
if (counter == 0) {
epg = epgs.get(0);
} else {
@@ -252,7 +254,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}
- List<Epg> epgs = null;
+ List<Event> epgs = null;
int counter = 0;
public void initEPGs() {
@@ -260,10 +262,10 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
if (epgs != null) {
return;
}
- epgs = new ArrayList<Epg>();
+ epgs = new ArrayList<Event>();
final VdrManagerApp app = (VdrManagerApp) getApplication();
- final Epg event = app.getCurrentEvent();
+ final Event event = app.getCurrentEvent();
EpgClient c = new EpgClient(new Channel() {
@Override
public String getName() {
@@ -289,7 +291,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
}
epgs.addAll(e);
- Epg fe = epgs.get(0);
+ Event fe = epgs.get(0);
if (event.getStart().equals(fe.getStart()) == false) {
epgs.set(0, event);
;
@@ -300,7 +302,7 @@ public class EpgDetailsActivity extends Activity implements OnClickListener,
if(counter < epgs.size() - 1){
counter ++ ;
}
- Epg epg = epgs.get(counter);
+ Event epg = epgs.get(counter);
publishEPG(epg);
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java
index 4dba61d..85aae19 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java
@@ -14,6 +14,7 @@ import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Epg;
import de.bjusystems.vdrmanager.data.EpgSearchParams;
+import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
@@ -27,11 +28,9 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
*
* @author bju
*/
-public class EpgSearchListActivity extends BaseEpgListActivity implements
+public class EpgSearchListActivity extends BaseEventListActivity<Epg> implements
OnItemClickListener, SvdrpAsyncListener<Epg> {
- public List<Epg> results;
-
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -43,9 +42,9 @@ public class EpgSearchListActivity extends BaseEpgListActivity implements
highlight = query.trim();
}
}
- adapter = new ChannelEventAdapter(this);
+ adapter = new TimeEventAdapter(this);
adapter.setHideDescription(false);
-
+ startEpgQuery();
// Create adapter for EPG list
listView = (ListView) findViewById(R.id.whatson_list);
listView.setAdapter(adapter);
@@ -62,7 +61,7 @@ public class EpgSearchListActivity extends BaseEpgListActivity implements
protected void onResume() {
super.onResume();
// adapter.notifyDataSetChanged();
- startEpgQuery();
+
}
@@ -95,6 +94,8 @@ public class EpgSearchListActivity extends BaseEpgListActivity implements
// start task
task.run();
}
+
+
/*
* (non-Javadoc) TODO this method also should be used in startEpgQuery on
@@ -103,14 +104,14 @@ public class EpgSearchListActivity extends BaseEpgListActivity implements
* @see de.bjusystems.vdrmanager.gui.BaseEpgListActivity#finishedSuccess()
*/
@Override
- protected void finishedSuccess() {
+ protected boolean finishedSuccess() {
adapter.clear();
adapter.highlight = this.highlight;
Calendar cal = Calendar.getInstance();
int day = -1;
- results = epgClient.getResults();
- for (Epg e : results) {
+ sortItemsByTime(results);
+ for (Event e : results) {
cal.setTime(e.getStart());
int eday = cal.get(Calendar.DAY_OF_YEAR);
if (eday != day) {
@@ -118,14 +119,14 @@ public class EpgSearchListActivity extends BaseEpgListActivity implements
adapter.add(new EventListItem(new DateFormatter(cal)
.getDailyHeader()));
}
- adapter.add(new EventListItem(e));
+ adapter.add(new EventListItem((Epg)e));
}
listView.setSelectionAfterHeaderView();
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
+ dismiss(progress);
+ return results.isEmpty() == false;
}
+
+
public void svdrpException(final SvdrpException exception) {
if (progress != null) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
index 98adbb9..3f7fc4d 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventAdapter.java
@@ -4,11 +4,6 @@ import java.util.ArrayList;
import java.util.List;
import android.content.Context;
-import android.graphics.Color;
-import android.text.Spannable;
-import android.text.SpannableString;
-import android.text.TextUtils;
-import android.text.style.ForegroundColorSpan;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
@@ -17,6 +12,7 @@ import android.widget.ArrayAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import android.widget.ImageView;
+import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import de.bjusystems.vdrmanager.R;
@@ -43,6 +39,9 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
inflater = LayoutInflater.from(context);
}
+
+
+
@Override
public void add(EventListItem object) {
items.add(object);
@@ -53,11 +52,25 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
public View getView(final int position, final View convertView,
final ViewGroup parent) {
+ // get item
+ final EventListItem item = getItem(position);
+
+ if (item.isHeader()) {
+ return getHeaderView(item, convertView, parent);
+ } else {
+ return getEventView(item, convertView, parent);
+ }
+
+ }
+
+ private View getEventView(EventListItem item, View convertView,
+ ViewGroup parent) {
+
EventListItemHolder itemHolder = new EventListItemHolder();
// recycle view?
View view = convertView;
- if (view == null) {
+ if (view == null || view instanceof ListView == false) {
view = inflater.inflate(layout, null);
itemHolder = new EventListItemHolder();
@@ -83,92 +96,99 @@ abstract class EventAdapter extends ArrayAdapter<EventListItem> implements
itemHolder = (EventListItemHolder) view.getTag();
}
- // get item
- final EventListItem item = getItem(position);
- // fill item
- if (item.isHeader()) {
- view.setPadding(view.getPaddingLeft(), 0, view.getPaddingRight(), 0);
- view.setBackgroundColor(Color.DKGRAY);
- itemHolder.state.setVisibility(View.GONE);
- itemHolder.channel.setVisibility(View.VISIBLE);
- itemHolder.channel.setText(item.getHeader());
- itemHolder.title.setVisibility(View.GONE);
- itemHolder.time.setVisibility(View.GONE);
- itemHolder.progress.setVisibility(View.GONE);
- itemHolder.shortText.setVisibility(View.GONE);
- itemHolder.duration.setVisibility(View.GONE);
- itemHolder.description.setVisibility(View.GONE);
+// itemHolder.title.setVisibility(View.VISIBLE);
+ itemHolder.state.setVisibility(View.VISIBLE);
+ //itemHolder.shortText.setVisibility(View.VISIBLE);
+ //itemHolder.duration.setVisibility(View.VISIBLE);
+ // itemHolder.state.setVisibility(View.);
+ switch (item.getTimerState()) {
+ case Active:
+ //itemHolder.state.setVisibility(View.VISIBLE);
+ itemHolder.state.setImageResource(R.drawable.timer_active);
+ break;
+ case Inactive:
+ //itemHolder.state.setVisibility(View.VISIBLE);
+ itemHolder.state.setImageResource(R.drawable.timer_inactive);
+ break;
+ case Recording:
+ //itemHolder.state.setVisibility(View.VISIBLE);
+ itemHolder.state.setImageResource(R.drawable.timer_recording);
+ break;
+ case None:
+ //itemHolder.state.setVisibility(View.GONE);
+ itemHolder.state.setImageResource(R.drawable.timer_none);
+ break;
+ }
+
+ final EventFormatter formatter = getEventFormatter(item);
+ itemHolder.time.setText(formatter.getTime());
+ if (hideChannelName) {
+ itemHolder.channel.setVisibility(View.GONE);
} else {
+ itemHolder.channel.setText(item.getChannelName());
+ }
- view.setBackgroundColor(Color.BLACK);
- // itemHolder.channel.setVisibility(View.VISIBLE);
- itemHolder.time.setVisibility(View.VISIBLE);
- itemHolder.title.setVisibility(View.VISIBLE);
- itemHolder.state.setVisibility(View.VISIBLE);
- // itemHolder.channel.setVisibility(View.VISIBLE);
- itemHolder.shortText.setVisibility(View.VISIBLE);
- itemHolder.duration.setVisibility(View.VISIBLE);
- // itemHolder.state.setVisibility(View.);
- switch (item.getTimerState()) {
- case Active:
- itemHolder.state.setImageResource(R.drawable.timer_active);
- break;
- case Inactive:
- itemHolder.state.setImageResource(R.drawable.timer_inactive);
- break;
- case Recording:
- itemHolder.state.setImageResource(R.drawable.timer_recording);
- break;
- case None:
- itemHolder.state.setImageResource(R.drawable.timer_none);
- break;
- }
- final EventFormatter formatter = getEventFormatter(item.getEvent());
- itemHolder.time.setText(formatter.getTime());
- if (hideChannelName) {
- itemHolder.channel.setVisibility(View.GONE);
- } else {
- itemHolder.channel.setText(item.getChannelName());
- }
+ CharSequence title = Utils.highlight(formatter.getTitle(), highlight);
+ CharSequence shortText = Utils.highlight(formatter.getShortText(),
+ highlight);
+ itemHolder.title.setText(title);
+ itemHolder.shortText.setText(shortText);
- CharSequence title = Utils.highlight(formatter.getTitle(),
- highlight);
- CharSequence shortText = Utils.highlight(formatter.getShortText(),
- highlight);
- itemHolder.title.setText(title);
- itemHolder.shortText.setText(shortText);
-
- if (hideDescription == false) {
- Pair<Boolean, CharSequence> desc = Utils.highlight2(
- formatter.getDescription(), highlight);
- if (desc.first == true) {
- itemHolder.description.setVisibility(View.VISIBLE);
- itemHolder.description.setText(desc.second);
- }
+ if (hideDescription == false) {
+ Pair<Boolean, CharSequence> desc = Utils.highlight2(
+ formatter.getDescription(), highlight);
+ if (desc.first == true) {
+ itemHolder.description.setVisibility(View.VISIBLE);
+ itemHolder.description.setText(desc.second);
}
+ }
- int p = Utils.getProgress(item);
- if (p == -1) {
- itemHolder.progress.setVisibility(View.GONE);
- // itemHolder.time.setTypeface(null, Typeface.NORMAL);
- // itemHolder.title.setTypeface(null, Typeface.NORMAL);
- // itemHolder.shortText.setTypeface(null, Typeface.NORMAL);
- int dura = Utils.getDuration(item);
- itemHolder.duration.setText(getContext().getString(
- R.string.epg_duration_template, dura));
- } else {
- itemHolder.progress.setVisibility(View.VISIBLE);
- itemHolder.progress.setProgress(p);
- // itemHolder.time.setTypeface(null, Typeface.BOLD);
- // itemHolder.title.setTypeface(null, Typeface.BOLD);
- // itemHolder.shortText.setTypeface(null, Typeface.BOLD);
- int dura = Utils.getDuration(item);
- int rest = dura - (dura * p / 100);
- itemHolder.duration.setText(getContext().getString(
- R.string.epg_duration_template_live, rest, dura));
- }
+ int p = Utils.getProgress(item);
+ if (p == -1) {
+ itemHolder.progress.setVisibility(View.GONE);
+ // itemHolder.time.setTypeface(null, Typeface.NORMAL);
+ // itemHolder.title.setTypeface(null, Typeface.NORMAL);
+ // itemHolder.shortText.setTypeface(null, Typeface.NORMAL);
+ int dura = Utils.getDuration(item);
+ itemHolder.duration.setText(getContext().getString(
+ R.string.epg_duration_template, dura));
+ } else {
+ itemHolder.progress.setVisibility(View.VISIBLE);
+ itemHolder.progress.setProgress(p);
+ // itemHolder.time.setTypeface(null, Typeface.BOLD);
+ // itemHolder.title.setTypeface(null, Typeface.BOLD);
+ // itemHolder.shortText.setTypeface(null, Typeface.BOLD);
+ int dura = Utils.getDuration(item);
+ int rest = dura - (dura * p / 100);
+ itemHolder.duration.setText(getContext().getString(
+ R.string.epg_duration_template_live, rest, dura));
+ }
+
+ return view;
+ }
+
+ class EventListItemHeaderHolder {
+ public TextView header;
+ }
+
+ private View getHeaderView(EventListItem item, View convertView,
+ ViewGroup parent) {
+
+ EventListItemHeaderHolder itemHolder = new EventListItemHeaderHolder();
+
+ // recycle view?
+ View view = convertView;
+ if (view == null || convertView instanceof TextView == false) {
+ view = inflater.inflate(R.layout.header_item, null);
+
+ itemHolder = new EventListItemHeaderHolder();
+
+ itemHolder.header = (TextView) view.findViewById(R.id.header_item);
+ } else {
+ itemHolder = (EventListItemHeaderHolder) view.getTag();
}
+ itemHolder.header.setText(item.getHeader());
return view;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
index 476bdd9..f481244 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
@@ -5,10 +5,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
-import android.app.SearchManager;
-import android.content.Intent;
import android.os.Bundle;
-import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -21,24 +18,23 @@ import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Epg;
+import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.ChannelClient;
import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
/**
* This class is used for showing what's current running on all channels
*
* @author bju
*/
-public class EventEpgListActivity extends BaseEpgListActivity implements
- OnItemClickListener, OnItemSelectedListener, SvdrpAsyncListener<Epg> {
+public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements
+ OnItemClickListener, OnItemSelectedListener {
- private final static ArrayList<Epg> CACHE = new ArrayList<Epg>();
+ private final static ArrayList<Event> CACHE = new ArrayList<Event>();
protected static Date nextForceCache = null;
@@ -149,7 +145,8 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
if (useCache(channel) && !force) {
Calendar cal = Calendar.getInstance();
int day = -1;
- for (Epg e : CACHE) {
+ for (Event i : CACHE) {
+ Epg e = (Epg)i;
cal.setTime(e.getStart());
int eday = cal.get(Calendar.DAY_OF_YEAR);
if (eday != day) {
@@ -189,7 +186,7 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
* @see de.bjusystems.vdrmanager.gui.BaseEpgListActivity#finishedSuccess()
*/
@Override
- protected void finishedSuccess() {
+ protected boolean finishedSuccess() {
adapter.clear();
CACHE.clear();
Date now = new Date();
@@ -212,16 +209,8 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
}
cachedChannel = currentChannel;
listView.setSelectionAfterHeaderView();
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
- }
-
- public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
+ dismiss(progress);
+ return CACHE.isEmpty() == false;
}
protected void prepareTimer(final EventListItem item) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
index 20ba517..8dfc530 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
@@ -2,55 +2,38 @@ package de.bjusystems.vdrmanager.gui;
import java.util.Calendar;
-import android.content.Intent;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.MenuInflater;
-import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
-import android.widget.AdapterView.OnItemClickListener;
+import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ListView;
-import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
-import de.bjusystems.vdrmanager.app.VdrManagerApp;
-import de.bjusystems.vdrmanager.data.Epg;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.data.Recording;
-import de.bjusystems.vdrmanager.data.Timer;
-import de.bjusystems.vdrmanager.tasks.DeleteTimerTask;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
/**
* This class is used for showing what's current running on all channels
*
* @author bju
*/
-public class RecordingListActivity extends BaseActivity implements
- OnItemClickListener, SvdrpAsyncListener<Recording> {
+public class RecordingListActivity extends BaseEventListActivity<Recording>
+ implements OnItemLongClickListener, SvdrpAsyncListener<Recording> {
RecordingClient recordingClient;
- EventAdapter adapter;
- SvdrpProgressDialog progress;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- // set title
- setTitle(R.string.action_menu_recordings);
-
- // Attach view
- setContentView(getMainLayout());
-
// create an adapter
adapter = new RecordingAdapter(this);
@@ -59,8 +42,9 @@ public class RecordingListActivity extends BaseActivity implements
listView.setAdapter(adapter);
// set click listener
+ listView.setOnItemLongClickListener(this);
+ // register EPG item click
listView.setOnItemClickListener(this);
-
// context menu wanted
registerForContextMenu(listView);
@@ -73,25 +57,19 @@ public class RecordingListActivity extends BaseActivity implements
super.onResume();
}
- protected void updateWindowTitle(int topic, int subtopic) {
- String title;
- title = getString(topic);
- if (subtopic != -1) {
- title += " > " + getString(subtopic);
- }
- setTitle(title);
- }
-
@Override
protected void onPause() {
super.onPause();
if (recordingClient != null) {
recordingClient.abort();
}
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
+ dismiss(progress);
+ }
+
+ @Override
+ protected void prepareTimer(EventListItem event) {
+ getApp().setCurrentEvent(event);
+ getApp().setCurrentEpgList(results);
}
@Override
@@ -112,47 +90,25 @@ public class RecordingListActivity extends BaseActivity implements
}
}
- @Override
- public boolean onContextItemSelected(final MenuItem item) {
-
- final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
- .getMenuInfo();
- final EventListItem event = adapter.getItem(info.position);
-
- switch (item.getItemId()) {
- case R.id.recording_item_menu_delete: {
-
- break;
- }
- case R.id.recording_item_menu_stream: {
- break;
- }
- }
- return true;
- }
-
- public void onItemClick(final AdapterView<?> parent, final View view,
- final int position, final long id) {
-
- // save selected item
- final Timer timer = adapter.getItem(position).getTimer();
- if (timer == null) {
- // header click
- return;
- }
-
- final VdrManagerApp app = (VdrManagerApp) getApplication();
- app.setCurrentTimer(timer);
-
- // after timer editing return to the timer list
- app.setNextActivity(RecordingListActivity.class);
- app.clearActivitiesToFinish();
-
- // show timer details
- final Intent intent = new Intent();
- intent.setClass(this, TimerDetailsActivity.class);
- startActivity(intent);
- }
+ // @Override
+ // public boolean onContextItemSelected(final MenuItem item) {
+ //
+ // final AdapterView.AdapterContextMenuInfo info =
+ // (AdapterView.AdapterContextMenuInfo) item
+ // .getMenuInfo();
+ // final EventListItem event = adapter.getItem(info.position);
+ //
+ // switch (item.getItemId()) {
+ // case R.id.recording_item_menu_delete: {
+ //
+ // break;
+ // }
+ // case R.id.recording_item_menu_stream: {
+ // break;
+ // }
+ // }
+ // return true;
+ // }
private void startRecordingQuery() {
@@ -173,72 +129,6 @@ public class RecordingListActivity extends BaseActivity implements
task.run();
}
-
- private void dismiss(){
- if (progress != null) {
- progress.dismiss();
- }
- }
-
- public void svdrpEvent(final SvdrpEvent event, final Recording result) {
-
- if (progress != null) {
- progress.svdrpEvent(event);
- }
-
- switch (event) {
- case CONNECTING:
- break;
- case FINISHED_ABNORMALY:
- case CONNECT_ERROR:
- switchNoConnection();// TODO pass arg, what is the problem
- case LOGIN_ERROR:
- dismiss();
- switchNoConnection();
- break;
- case FINISHED_SUCCESS:
- adapter.clear();
- Calendar cal = Calendar.getInstance();
- int day = -1;
- for (final Recording rec : recordingClient.getResults()) {
- cal.setTime(rec.getStart());
- int eday = cal.get(Calendar.DAY_OF_YEAR);
- if (eday != day) {
- day = eday;
- adapter.add(new EventListItem(new DateFormatter(cal)
- .getDailyHeader()));
- }
- adapter.add(new EventListItem(rec));
- }
- // adapter.sortItems();
- dismiss();
- if (recordingClient.getResults().isEmpty()) {
- Toast.makeText(RecordingListActivity.this,
- R.string.epg_no_items, Toast.LENGTH_SHORT).show();
- }
- break;
- }
- }
-
- public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
- }
-
- private void deleteTimer(final EventListItem item) {
-
- final DeleteTimerTask task = new DeleteTimerTask(this, item.getTimer()) {
- @Override
- public void finished() {
- // refresh epg list after return
- final VdrManagerApp app = (VdrManagerApp) getApplication();
- app.setReload(true);
- }
- };
- task.start();
- }
-
protected void retry() {
startRecordingQuery();
}
@@ -252,5 +142,35 @@ public class RecordingListActivity extends BaseActivity implements
return R.layout.recording_list;
}
+ @Override
+ protected int getWindowTitle() {
+ return R.string.remux_title;
+ }
+
+ @Override
+ protected boolean finishedSuccess() {
+ adapter.clear();
+ Calendar cal = Calendar.getInstance();
+ int day = -1;
+ for (final Recording rec : recordingClient.getResults()) {
+ results.add(rec);
+ cal.setTime(rec.getStart());
+ int eday = cal.get(Calendar.DAY_OF_YEAR);
+ if (eday != day) {
+ day = eday;
+ adapter.add(new EventListItem(new DateFormatter(cal)
+ .getDailyHeader()));
+ }
+ adapter.add(new EventListItem(rec));
+ }
+ // adapter.sortItems();
+ return results.isEmpty() == false;
+ }
+
+ public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2,
+ long arg3) {
+
+ return false;
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SimpleGestureFilter.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SimpleGestureFilter.java
index 85b6b5d..2afe23a 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/SimpleGestureFilter.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/SimpleGestureFilter.java
@@ -120,6 +120,7 @@ public class SimpleGestureFilter extends SimpleOnGestureListener{
result = true;
}
+ /*
else if(velocityY > this.swipe_Min_Velocity && yDistance > this.swipe_Min_Distance){
if(e1.getY() > e2.getY()) // bottom to up
this.listener.onSwipe(SWIPE_UP);
@@ -128,7 +129,7 @@ public class SimpleGestureFilter extends SimpleOnGestureListener{
result = true;
}
-
+*/
return result;
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
index e6fcb1f..f237a89 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
@@ -1,12 +1,10 @@
package de.bjusystems.vdrmanager.gui;
import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
-import java.util.List;
import android.os.Bundle;
+import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
@@ -14,27 +12,27 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
+import android.widget.TextView;
import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Epg;
import de.bjusystems.vdrmanager.data.EpgSearchTimeValue;
import de.bjusystems.vdrmanager.data.EpgSearchTimeValues;
+import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.EpgClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
/**
* This class is used for showing what's current running on all channels
*
* @author bju
*/
-public class TimeEpgListActivity extends BaseEpgListActivity implements
- OnItemClickListener, OnItemSelectedListener, SvdrpAsyncListener<Epg> {
+public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements
+ OnItemClickListener, OnItemSelectedListener {
Spinner timeSpinner;
@@ -42,16 +40,14 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
protected static Date nextForceCache = null;
- private final static ArrayList<Epg> CACHE = new ArrayList<Epg>();
+ private final static ArrayList<Event> CACHE = new ArrayList<Event>();
private static String cachedTime = null;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
-
// create adapter for time spinner
timeSpinnerAdapter = new ArrayAdapter<EpgSearchTimeValue>(this,
android.R.layout.simple_spinner_item);
@@ -81,6 +77,10 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
}
+ private void addCustom() {
+
+ }
+
private void fillTimeSpinnerValues() {
final EpgSearchTimeValues values = new EpgSearchTimeValues(this);
timeSpinnerAdapter.clear();
@@ -88,17 +88,15 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
timeSpinnerAdapter.add(value);
}
}
-
+
private int currentPostion = 0;
@Override
protected void onPause() {
super.onPause();
-
- }
+ }
-
@Override
protected void onResume() {
super.onResume();
@@ -152,8 +150,8 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
adapter.add(new EventListItem(new DateFormatter(CACHE.get(0)
.getStart()).getDailyHeader()));
}
- for (Epg e : CACHE) {
- adapter.add(new EventListItem(e));
+ for (Event e : CACHE) {
+ adapter.add(new EventListItem((Epg) e));
}
// adapter.sortItems();
listView.setSelectionAfterHeaderView();
@@ -163,6 +161,7 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
clearCache();
epgClient = new EpgClient(time);
+ epgClient.setResultInfoEnabled(true);
// remove old listeners
// epgClient.clearSvdrpListener();
@@ -181,7 +180,7 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
}
@Override
- protected void finishedSuccess() {
+ protected boolean finishedSuccess() {
// get spinner value
final EpgSearchTimeValue selection = (EpgSearchTimeValue) timeSpinner
.getSelectedItem();
@@ -190,41 +189,22 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
nextForceCache = FUTURE;
cachedTime = selection.getValue();
Date now = new Date();
- List<Epg> results = epgClient.getResults();
sortItemsByChannel(results);
if (results.isEmpty() == false) {
adapter.add(new EventListItem(new DateFormatter(results.get(0)
.getStart()).getDailyHeader()));
}
- for (Epg e : results) {
+ for (Event e : results) {
CACHE.add(e);
- adapter.add(new EventListItem(e));
+ adapter.add(new EventListItem((Epg) e));
if (e.getStop().before(nextForceCache) && e.getStop().after(now)) {
nextForceCache = e.getStop();
}
}
listView.setSelectionAfterHeaderView();
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
- }
+ dismiss(progress);
+ return CACHE.isEmpty() == false;
- public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
- }
-
- private void sortItemsByChannel(List<Epg> result) {
- final Comparator<Epg> comparator = new Comparator<Epg>() {
-
- public int compare(final Epg item1, final Epg item2) {
- return Integer.valueOf(item1.getChannelNumber()).compareTo(
- Integer.valueOf(item2.getChannelNumber()));
- }
- };
- Collections.sort(result, comparator);
}
protected void prepareTimer(final EventListItem item) {
@@ -253,31 +233,32 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
protected void retry() {
refresh();
}
-
+
@Override
protected int getWindowTitle() {
return R.string.epg_by_time;
}
-
- private void nextEvent(){
+ private void nextEvent() {
int pos = timeSpinner.getSelectedItemPosition();
- if(pos + 1 >= timeSpinnerAdapter.getCount()){
- Toast.makeText(this, R.string.navigae_at_the_end, Toast.LENGTH_SHORT).show();
+ if (pos + 1 >= timeSpinnerAdapter.getCount()) {
+ Toast.makeText(this, R.string.navigae_at_the_end,
+ Toast.LENGTH_SHORT).show();
return;
}
- timeSpinner.setSelection(pos+1, true);
+ timeSpinner.setSelection(pos + 1, true);
}
-
- private void prevEvent(){
+
+ private void prevEvent() {
int pos = timeSpinner.getSelectedItemPosition();
- if(pos <= 0){
- Toast.makeText(this, R.string.navigae_at_the_start, Toast.LENGTH_SHORT).show();
+ if (pos <= 0) {
+ Toast.makeText(this, R.string.navigae_at_the_start,
+ Toast.LENGTH_SHORT).show();
return;
}
- timeSpinner.setSelection(pos-1, true);
+ timeSpinner.setSelection(pos - 1, true);
}
-
+
@Override
public void onSwipe(int direction) {
switch (direction) {
@@ -289,5 +270,4 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
break;
}
}
-
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java
index 10f1822..5a79c30 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerDetailsActivity.java
@@ -120,7 +120,7 @@ public class TimerDetailsActivity extends Activity implements OnClickListener,
.getText().toString());
// create client for saving the timer
- setTimerClient = new SetTimerClient(timer, false);
+ //setTimerClient = new SetTimerClient(timer, false);
// create backgound task
final SvdrpAsyncTask<Timer, SvdrpClient<Timer>> task = new SvdrpAsyncTask<Timer, SvdrpClient<Timer>>(
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java
index 7cf96c0..f796fa6 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java
@@ -1,28 +1,18 @@
package de.bjusystems.vdrmanager.gui;
-import android.content.Intent;
+import java.util.Calendar;
+
import android.os.Bundle;
-import android.view.ContextMenu;
-import android.view.ContextMenu.ContextMenuInfo;
-import android.view.MenuInflater;
-import android.view.MenuItem;
-import android.view.View;
-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.VdrManagerApp;
-import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.data.Timer;
-import de.bjusystems.vdrmanager.tasks.DeleteTimerTask;
-import de.bjusystems.vdrmanager.tasks.ToggleTimerTask;
+import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpClient;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
-import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException;
import de.bjusystems.vdrmanager.utils.svdrp.TimerClient;
/**
@@ -30,23 +20,17 @@ import de.bjusystems.vdrmanager.utils.svdrp.TimerClient;
*
* @author bju
*/
-public class TimerListActivity extends BaseActivity implements
+public class TimerListActivity extends BaseTimerEditActivity<Timer> implements
OnItemClickListener, SvdrpAsyncListener<Timer> {
-
- private static final int REQUEST_CODE_TIMED_EDIT = 41;
-
TimerClient timerClient;
- EventAdapter adapter;
- SvdrpProgressDialog progress;
+
+
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
- // set title
- setTitle(R.string.action_menu_timers);
-
// Attach view
setContentView(getMainLayout());
@@ -54,8 +38,10 @@ public class TimerListActivity extends BaseActivity implements
adapter = new TimeEventAdapter(this);
// attach adapter to ListView
- final ListView listView = (ListView) findViewById(R.id.timer_list);
+ listView = (ListView) findViewById(R.id.timer_list);
listView.setAdapter(adapter);
+ listView.setFastScrollEnabled(true);
+ listView.setTextFilterEnabled(true);
// set click listener
listView.setOnItemClickListener(this);
@@ -70,25 +56,6 @@ public class TimerListActivity extends BaseActivity implements
@Override
protected void onResume() {
super.onResume();
- reloadIfNeeded();
- }
-
- private void reloadIfNeeded() {
-
- final VdrManagerApp app = (VdrManagerApp) getApplication();
- if (app.isReload()) {
- app.setReload(false);
- startTimerQuery();
- }
- }
-
- protected void updateWindowTitle(int topic, int subtopic) {
- String title;
- title = getString(topic);
- if (subtopic != -1) {
- title += " > " + getString(subtopic);
- }
- setTitle(title);
}
@Override
@@ -97,81 +64,9 @@ public class TimerListActivity extends BaseActivity implements
if (timerClient != null) {
timerClient.abort();
}
- if (progress != null) {
- progress.dismiss();
- progress = null;
- }
+ dismiss(progress);
}
- @Override
- public void onCreateContextMenu(final ContextMenu menu, final View v,
- final ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
-
- if (v.getId() == R.id.timer_list) {
- final MenuInflater inflater = getMenuInflater();
- final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
-
- // set menu title
- final EventListItem item = adapter.getItem(info.position);
- final EventFormatter formatter = new EventFormatter(item);
- menu.setHeaderTitle(formatter.getTitle());
-
- inflater.inflate(R.menu.epg_list_item_menu, menu);
-
- // remove unneeded menu items
- menu.findItem(R.id.epg_item_menu_timer_add).setVisible(false);
- final MenuItem enableMenuItem = menu
- .findItem(R.id.epg_item_menu_timer_toggle);
- enableMenuItem
- .setTitle(item.getTimer().isEnabled() ? R.string.epg_item_menu_timer_disable
- : R.string.epg_item_menu_timer_enable);
- }
- }
-//
-// @Override
-// public boolean onContextItemSelected(final MenuItem item) {
-//
-// final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
-// .getMenuInfo();
-// final EventListItem event = adapter.getItem(info.position);
-//
-// switch (item.getItemId()) {
-// case R.id.epg_item_menu_timer_modify: {
-// onItemClick(null, null, info.position, 0);
-// break;
-// }
-// case R.id.epg_item_menu_timer_delete: {
-// deleteTimer(event);
-// break;
-// }
-// case R.id.epg_item_menu_timer_toggle: {
-// toggleTimer(event);
-// }
-// }
-//
-// return true;
-// }
-
- public void onItemClick(final AdapterView<?> parent, final View view,
- final int position, final long id) {
-
- // save selected item
- final Timer timer = adapter.getItem(position).getTimer();
- if (timer == null) {
- // header click
- return;
- }
-
-
- //timer.getChannelName()
- //timer.getEvent();
-
- // show details
- final Intent intent = new Intent();
- intent.setClass(this, EpgDetailsActivity.class);
- startActivity(intent);
- }
private void startTimerQuery() {
@@ -192,118 +87,56 @@ public class TimerListActivity extends BaseActivity implements
task.run();
}
- public void svdrpEvent(final SvdrpEvent event, final Timer result) {
-
- if (progress != null) {
- progress.svdrpEvent(event);
- }
- switch (event) {
- case CONNECTING:
- break;
- case FINISHED_ABNORMALY:
- case CONNECT_ERROR:
- switchNoConnection();// TODO pass arg, what is the problem
- case LOGIN_ERROR:
- progress.dismiss();
- switchNoConnection();
- break;
- case FINISHED_SUCCESS:
- adapter.clear();
- for (final Timer timer : timerClient.getResults()) {
- adapter.add(new EventListItem(timer));
- }
- // adapter.sortItems();
- progress.dismiss();
- progress = null;
- if (timerClient.getResults().isEmpty()) {
- Toast.makeText(TimerListActivity.this, R.string.epg_no_items,
- Toast.LENGTH_SHORT).show();
- }
- break;
- }
- }
-
- public void svdrpException(final SvdrpException exception) {
- if (progress != null) {
- progress.svdrpException(exception);
- }
+ @Override
+ protected Timer getTimer(EventListItem item) {
+ return item.getTimer();
}
-
- private void deleteTimer(final EventListItem item) {
-
- final DeleteTimerTask task = new DeleteTimerTask(this, item.getTimer()) {
- @Override
- public void finished() {
- // refresh epg list after return
- final VdrManagerApp app = (VdrManagerApp) getApplication();
- app.setReload(true);
- reloadIfNeeded();
+ protected void prepareTimer(final EventListItem item) {
+ final VdrManagerApp app = (VdrManagerApp) getApplication();
+ // remember event for details view and timer things
+ app.setCurrentEvent(item.getTimer());
+ app.setCurrentEpgList(results);
+ }
+
+ protected boolean finishedSuccess() {
+ adapter.clear();
+ for(Timer e : timerClient.getResults()){
+ results.add(e);
+ Calendar cal = Calendar.getInstance();
+ int day = -1;
+ cal.setTime(e.getStart());
+ int eday = cal.get(Calendar.DAY_OF_YEAR);
+ if (eday != day) {
+ day = eday;
+ adapter.add(new EventListItem(new DateFormatter(cal)
+ .getDailyHeader()));
}
- };
- task.start();
- }
-
- @Override
- public boolean onContextItemSelected(final MenuItem item) {
-
- final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
- .getMenuInfo();
- final EventListItem event = adapter.getItem(info.position);
-
- switch (item.getItemId()) {
- case R.id.epg_item_menu_timer_add:
- case R.id.epg_item_menu_timer_modify: {
- //prepareTimer(event);
- final Intent intent = new Intent();
- intent.setClass(this, TimerDetailsActivity.class);
- startActivityForResult(intent, REQUEST_CODE_TIMED_EDIT);
- break;
- }
- case R.id.epg_item_menu_timer_delete: {
- deleteTimer(event);
- break;
+ adapter.add(new EventListItem(e));
}
- case R.id.epg_item_menu_timer_toggle: {
- toggleTimer(event);
- break;
- }
- case R.id.epg_item_menu_live_tv: {
- Utils.stream(this, event.getEvent());
- break;
-
- }
- }
-
- return true;
+ listView.setSelectionAfterHeaderView();
+ dismiss(progress);
+ return results.isEmpty() == false;
}
-
-
- private void toggleTimer(final EventListItem item) {
- final ToggleTimerTask task = new ToggleTimerTask(this, item.getTimer()) {
- @Override
- public void finished() {
- // refresh epg list after return
- final VdrManagerApp app = (VdrManagerApp) getApplication();
- app.setReload(true);
- reloadIfNeeded();
- }
- };
- task.start();
+ @Override
+ protected int getWindowTitle() {
+ return R.string.action_menu_timers;
}
- protected void retry() {
- startTimerQuery();
+ @Override
+ protected int getMainLayout() {
+ return R.layout.timer_list;
}
+ @Override
protected void refresh() {
startTimerQuery();
}
@Override
- protected int getMainLayout() {
- return R.layout.timer_list;
+ protected void retry() {
+ refresh();
}
}