diff options
Diffstat (limited to 'vdrmanager/src/de')
6 files changed, 128 insertions, 47 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java index 721e839..709cb46 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java @@ -12,7 +12,7 @@ import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars; * Class for EPG events * @author bju */ -public class Epg extends Event { +public class Epg extends Event implements Timerable { private Timer timer; @@ -25,6 +25,7 @@ public class Epg extends Event { title = mapSpecialChars(words[4]); description = words.length > 5 ? mapSpecialChars(words[5]): ""; shortText = words.length > 6 ? mapSpecialChars(words[6]) : ""; + channelId = words.length > 7 ? mapSpecialChars(words[7]) : ""; } @@ -43,4 +44,8 @@ public class Epg extends Event { return timer.getTimerState(); } } + + public Timer createTimer() { + return new Timer(this); + } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java index 6d32177..7be01e2 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Event.java @@ -13,26 +13,23 @@ import android.text.TextUtils; public abstract class Event { protected String channelNumber; + protected String channelId; protected String channelName; + protected String title; protected String shortText; protected String description; protected Date start; protected Date stop; - public Event(){ - - } - - public Timer createTimer() { - return new Timer(this); - } - public abstract Timer getTimer(); - + public long getDuration(){ + long millis = getStop().getTime() - getStart().getTime(); + return millis; + } - public TimerState getTimerState() { - return TimerState.None; + public Event(){ + } public void setChannelNumber(String channelNumber) { @@ -85,6 +82,11 @@ public abstract class Event { return title; } + public String getChannelId() { + return channelId; + } + + public String getShortText() { if (TextUtils.isEmpty(shortText) == false) { return shortText; @@ -110,15 +112,11 @@ public abstract class Event { return stop; } - - - public enum TimerState { - None, - Active, - Inactive, - Recording, - Recorded - ; + public String getStreamId(){ + if(channelId != null){ + return channelId; + } + return channelNumber; } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java index 3f85891..b01aee5 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/EventListItem.java @@ -73,11 +73,11 @@ public class EventListItem extends Event { // this.epg = epg; // this.rec = null; // } - - @Override - public TimerState getTimerState() { - return event.getTimerState(); - } +// +// @Override +// public TimerState getTimerState() { +// return event.getTimerState(); +// } public EventListItem(final String header) { this.header = header; @@ -130,10 +130,35 @@ public class EventListItem extends Event { .append(formatter.getTime()); return text.toString(); } - + + + @Override + public long getDuration() { + if(event != null){ + return event.getDuration(); + } + return super.getDuration(); + } + + @Override + public String getChannelId() { + if(event != null){ + return event.getChannelId(); + } + return null; + } + @Override - public Timer getTimer() { - return event.getTimer(); + public String getStreamId() { + if(event == null){ + return null; + } + return event.getStreamId(); } +// +// @Override +// public Timer getTimer() { +// return event.getTimer(); +// } }
\ No newline at end of file diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java index bab52d0..26c3ca4 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Recording.java @@ -22,7 +22,12 @@ public class Recording extends Event{ description = mapSpecialChars(words[idx++]); fileName = mapSpecialChars(words[idx++]); fileSize = Integer.valueOf(words[idx++]); - + if(idx < words.length){ + channelId = words[idx++]; + } + if(idx < words.length){ + realDuration = Long.parseLong(words[idx++]) * 1000; + } } private String fileName; @@ -30,6 +35,23 @@ public class Recording extends Event{ private int fileSize; private int index; + + private long realDuration = -1; + + /** + * in millis + * @return + */ + public long getRealDuration() { + return realDuration; + } + + public long getDuration(){ + if(realDuration != -1){ + return realDuration; + } + return super.getDuration(); + } public int getIndex() { return index; @@ -55,18 +77,7 @@ public class Recording extends Event{ this.fileName = fileName; } - public TimerState getTimerState() { - return TimerState.Recorded; - } - public String toCommandLine(){ return String.valueOf(index); } - - @Override - public Timer getTimer() { - return null; - } - - } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java index 397453b..0dd375a 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timer.java @@ -15,17 +15,17 @@ import de.bjusystems.vdrmanager.utils.svdrp.SetTimerClient.TimerOperation; * * @author bju */ -public class Timer extends Event { +public class Timer extends Event implements Timerable{ private static final int ENABLED = 1; private static final int INSTANT = 2; private static final int VPS = 4; private static final int RECORDING = 8; - private final int number; + private int number; private int flags; - private final int priority; - private final int lifetime; + private int priority; + private int lifetime; /** * Constructs a timer from SvdrpHelper result line @@ -69,9 +69,26 @@ public class Timer extends Event { this.description = values[11]; // if real description, set it } + if(values.length > 12 ){ + this.channelId = values[12]; + } + + description = Utils.mapSpecialChars(description); } + + public Timer copy(){ + Timer t = new Timer(this); + t.flags = flags; + t.number = number; + t.priority = priority; + t.lifetime = lifetime; + t.start = new Date(start.getTime()); + t.stop = new Date(stop.getTime()); + return t; + } + public Timer(final Event event) { final Preferences prefs = Preferences.getPreferences(); @@ -79,6 +96,7 @@ public class Timer extends Event { this.flags = ENABLED; this.channelNumber = event.getChannelNumber(); this.channelName = event.getChannelName(); + this.channelId = event.getChannelId(); this.priority = prefs.getTimerDefaultPriority(); this.lifetime = prefs.getTimerDefaultLifetime(); @@ -91,11 +109,11 @@ public class Timer extends Event { this.description = event.getDescription(); } - public String toCommandLine(TimerOperation op) { + public String toCommandLine() { final StringBuilder line = new StringBuilder(); - line.append(number).append(":"); + //line.append(number).append(":"); line.append(flags).append(":"); line.append(channelNumber).append(":"); @@ -173,4 +191,8 @@ public class Timer extends Event { public Timer getTimer() { return this; } + + public Timer createTimer() { + return new Timer(this); + } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Timerable.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timerable.java new file mode 100644 index 0000000..f3f648e --- /dev/null +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Timerable.java @@ -0,0 +1,20 @@ +package de.bjusystems.vdrmanager.data; + + +public interface Timerable { + + public enum TimerState { + None, + Active, + Inactive, + Recording, + Recorded + ; + } + + public Timer createTimer(); + + public abstract Timer getTimer(); + + public TimerState getTimerState(); +} |