summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-20 14:44:24 +0200
committerlado <herrlado@gmail.com>2011-10-20 14:44:24 +0200
commit3b7807d4f061c6711c22b52be7ef34bc4f210b74 (patch)
tree3eb10fa28ef782e6bca646938e14fc6048fcc939 /vdrmanager/src/de/bjusystems
parent8bd0d127edac4b6e3bec63e22738f631a574bf56 (diff)
downloadvdr-manager-3b7807d4f061c6711c22b52be7ef34bc4f210b74.tar.gz
vdr-manager-3b7807d4f061c6711c22b52be7ef34bc4f210b74.tar.bz2
add support for deleting recordings
Diffstat (limited to 'vdrmanager/src/de/bjusystems')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java54
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java34
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java47
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/tasks/DeleteRecordingTask.java17
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/DelRecordingClient.java49
5 files changed, 148 insertions, 53 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java
index 995a55b..1f1fd8f 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java
@@ -2,17 +2,16 @@ package de.bjusystems.vdrmanager.data;
import de.bjusystems.vdrmanager.gui.Utils;
-
/**
* @author lado
- *
- * TODO auf Event Interface umstellen und die Aufrufen an event delegieren. Das hier ist nicht gut.
+ *
+ * TODO auf Event Interface umstellen und die Aufrufen an event
+ * delegieren. Das hier ist nicht gut.
*/
public class EventListItem extends BaseEvent {
-
Event event;
-
+
public Event getEvent() {
return event;
}
@@ -25,19 +24,18 @@ public class EventListItem extends BaseEvent {
private final Timer timer;
private final Epg epg;
private final String header;
-
-//
-// public EventListItem(final Event event){
-// if(event instanceof Recording){
-// this((Recording)event);
-// } else if (event instanceof Timer){
-// this((Timer)event);
-// } else {
-// this((Epg)event);
-// }
-// throw new IllegalArgumentException("Uknown event type " + event);
-// }
+ //
+ // public EventListItem(final Event event){
+ // if(event instanceof Recording){
+ // this((Recording)event);
+ // } else if (event instanceof Timer){
+ // this((Timer)event);
+ // } else {
+ // this((Epg)event);
+ // }
+ // throw new IllegalArgumentException("Uknown event type " + event);
+ // }
public EventListItem(final Recording rec) {
super(rec);
@@ -65,10 +63,10 @@ public class EventListItem extends BaseEvent {
this.epg = epg;
this.rec = null;
}
-
+
@Override
public TimerState getTimerState() {
- if(epg != null){
+ if (epg != null) {
return epg.getTimerState();
}
return super.getTimerState();
@@ -89,7 +87,6 @@ public class EventListItem extends BaseEvent {
return timer != null;
}
-
public String getHeader() {
return header;
}
@@ -102,11 +99,15 @@ public class EventListItem extends BaseEvent {
return epg;
}
-// public Event getEvent() {
-// return event;
-// }
-//
- public boolean isLive(){
+ public Recording getRecording() {
+ return rec;
+ }
+
+ // public Event getEvent() {
+ // return event;
+ // }
+ //
+ public boolean isLive() {
return Utils.isLive(this);
}
@@ -121,7 +122,8 @@ public class EventListItem extends BaseEvent {
text.append(isTimer() ? "Timer: " : "Event: ");
text.append("Channel: ").append(getChannelNumber());
text.append(" (").append(getChannelName()).append("), ");
- text.append("Zeit: ").append(formatter.getDate()).append(" ").append(formatter.getTime());
+ text.append("Zeit: ").append(formatter.getDate()).append(" ")
+ .append(formatter.getTime());
return text.toString();
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
index c0481f7..75fe9af 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java
@@ -7,19 +7,32 @@ public class Recording extends BaseEvent{
public Recording(String line) {
final String[] words = line.split(":");
- start = new Date(Long.parseLong(words[0])*1000);
- stop = new Date(Long.parseLong(words[1]) * 1000);
- fileSize = Integer.valueOf(words[2]);
- channelName = words[3];
- title = words[4];
- shortText = words[5];
- description = words[6];
- fileName = words[7];
+ int idx = 0;
+ index = Integer.valueOf(words[idx++]);
+ start = new Date(Long.parseLong(words[idx++]) * 1000);
+ stop = new Date(Long.parseLong(words[idx++]) * 1000);
+ channelName = words[idx++];
+ title = words[idx++];
+ shortText = words[idx++];
+ description = words[idx++];
+ fileName = words[idx++];
+ fileSize = Integer.valueOf(words[idx++]);
+
}
private String fileName;
private int fileSize;
+
+ private int index;
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
public int getFileSize() {
return fileSize;
@@ -40,5 +53,10 @@ public class Recording extends BaseEvent{
public TimerState getTimerState() {
return TimerState.Recorded;
}
+
+ public String toCommandLine(){
+ return String.valueOf(index);
+ }
+
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
index 8dfc530..6c5cb66 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java
@@ -6,6 +6,7 @@ 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.OnItemLongClickListener;
@@ -14,6 +15,7 @@ import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.data.Recording;
+import de.bjusystems.vdrmanager.tasks.DeleteRecordingTask;
import de.bjusystems.vdrmanager.utils.date.DateFormatter;
import de.bjusystems.vdrmanager.utils.svdrp.RecordingClient;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncListener;
@@ -90,25 +92,32 @@ public class RecordingListActivity extends BaseEventListActivity<Recording>
}
}
- // @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;
- // }
+ @Override
+ public boolean onContextItemSelected(final MenuItem item) {
+
+ final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item
+ .getMenuInfo();
+ final EventListItem event = adapter.getItem(info.position);
+ Recording rec = event.getRecording();
+ switch (item.getItemId()) {
+ case R.id.recording_item_menu_delete: {
+ DeleteRecordingTask drt = new DeleteRecordingTask(this,rec) {
+ @Override
+ public void finished() {
+ dismiss(progress);
+ refresh();
+ }
+ };
+ drt.start();
+ break;
+ }
+ case R.id.recording_item_menu_stream: {
+ say("Sorry, not yet. It would be. File -> "+ rec.getFileName());
+ break;
+ }
+ }
+ return true;
+ }
private void startRecordingQuery() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/tasks/DeleteRecordingTask.java b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/DeleteRecordingTask.java
new file mode 100644
index 0000000..255a6a6
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/tasks/DeleteRecordingTask.java
@@ -0,0 +1,17 @@
+package de.bjusystems.vdrmanager.tasks;
+
+import android.app.Activity;
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.data.Recording;
+import de.bjusystems.vdrmanager.utils.svdrp.DelRecordingClient;
+
+public abstract class DeleteRecordingTask extends AsyncProgressTask<Recording> {
+ public DeleteRecordingTask(final Activity activity, final Recording r) {
+ super(activity, new DelRecordingClient(r) {
+ @Override
+ public int getProgressTextId() {
+ return R.string.progress_recording_delete;
+ }
+ });
+ }
+}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/DelRecordingClient.java b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/DelRecordingClient.java
new file mode 100644
index 0000000..a6b2f8f
--- /dev/null
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/utils/svdrp/DelRecordingClient.java
@@ -0,0 +1,49 @@
+package de.bjusystems.vdrmanager.utils.svdrp;
+
+import de.bjusystems.vdrmanager.R;
+import de.bjusystems.vdrmanager.data.Recording;
+
+/**
+ * Class for deleting a record
+ * @author lado
+ *
+ */
+public class DelRecordingClient extends SvdrpClient<Recording> {
+
+ /** current recording */
+ Recording recording;
+
+ /**
+ * Constructor
+ * Recording
+ */
+ public DelRecordingClient(final Recording recording) {
+ super();
+ this.recording = recording;
+ }
+
+ /**
+ * Starts the request
+ */
+ @Override
+ public void run() throws SvdrpException {
+
+ final StringBuilder command = new StringBuilder();
+
+ command.append("drecording ");
+ command.append(recording.toCommandLine());
+ runCommand(command.toString());
+ }
+
+
+ @Override
+ public int getProgressTextId() {
+ return R.string.progress_timer_save;
+ }
+
+ @Override
+ protected Recording parseAnswer(String line) {
+ return null;
+ }
+}
+