summaryrefslogtreecommitdiff
path: root/vdrmanager
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2013-05-16 14:51:18 +0200
committerlado <herrlado@gmail.com>2013-05-16 14:51:18 +0200
commit35de10e93fa69cf3ffe440195b37427d664749ad (patch)
treefe8803fce546e6f7569cb25af9e9e596313d2b81 /vdrmanager
parent612cf3729bf532e100b520118e4fa7d567b13f41 (diff)
downloadvdr-manager-35de10e93fa69cf3ffe440195b37427d664749ad.tar.gz
vdr-manager-35de10e93fa69cf3ffe440195b37427d664749ad.tar.bz2
Bug #1372
Diffstat (limited to 'vdrmanager')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java1
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java10
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java8
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java57
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java17
5 files changed, 60 insertions, 33 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
index 2b7b0d1..d8ca9ec 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Channel.java
@@ -63,7 +63,6 @@ public class Channel implements Parcelable {
}
public Channel(final String channelData) {
- System.err.println(channelData);
String[] words = StringUtils.splitPreserveAllTokens(channelData,
C.DATA_SEPARATOR);
this.number = Integer.valueOf(words[0].substring(1));
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java
index 1fb8ed7..c64990c 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Epg.java
@@ -4,7 +4,7 @@ import java.util.Date;
import de.bjusystems.vdrmanager.StringUtils;
import de.bjusystems.vdrmanager.app.C;
-
+import de.bjusystems.vdrmanager.gui.Utils;
import static de.bjusystems.vdrmanager.gui.Utils.mapSpecialChars;
/**
@@ -46,13 +46,7 @@ public class Epg extends Event implements Timerable {
public void setTimer(final Timer timer) {
this.timer = timer;
- if (start.before(timer.getStart())) {
- timerMatch = TimerMatch.End;
- } else if (stop.after(timer.getStop())) {
- timerMatch = TimerMatch.Begin;
- } else {
- timerMatch = TimerMatch.Full;
- }
+ timerMatch = Utils.getTimerMatch(this, timer);
}
public TimerState getTimerState() {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
index 03866fe..b377144 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseTimerEditActivity.java
@@ -14,6 +14,7 @@ import de.bjusystems.vdrmanager.data.EpgCache;
import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventListItem;
import de.bjusystems.vdrmanager.data.Timer;
+import de.bjusystems.vdrmanager.data.TimerMatch;
import de.bjusystems.vdrmanager.data.Timerable;
import de.bjusystems.vdrmanager.tasks.DeleteTimerTask;
import de.bjusystems.vdrmanager.tasks.ToggleTimerTask;
@@ -114,7 +115,10 @@ public abstract class BaseTimerEditActivity<T extends Event> extends
inflater.inflate(R.menu.epg_list_item_menu, menu);
Timer timer = getTimer(item);
// remove unneeded menu items
- if (timer != null) {
+ if (timer == null || (Utils.getTimerMatch(item, timer) == TimerMatch.Full == false)) { //Bug #1372
+ super.onCreateContextMenu(menu, v, menuInfo);
+ } else {
+
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);
@@ -126,7 +130,7 @@ public abstract class BaseTimerEditActivity<T extends Event> extends
: R.string.epg_item_menu_timer_enable);
}
- super.onCreateContextMenu(menu, v, menuInfo);
+
}
protected Timer createTimer(EventListItem item) {
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
index 42c8e23..1762f43 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgDetailsActivity.java
@@ -71,17 +71,17 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
private String highlight = null;
- private Event cEvent;
+ //private Event cEvent;
// private ImageView state;
private boolean modifed = false;
- private int current;
+ //private int current;
private ViewPager pager;
- private Timerable timerable = null;
+ //private Timerable timerable = null;
class Adapter extends PagerAdapter implements TitleProvider {
@@ -156,10 +156,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
finish();
}
- cEvent = epg;
+ final Event cEvent = epg;
if (epg instanceof Timerable) {
- timerable = (Timerable) epg;
+ //timerable = (Timerable) cEvent;
}
new VoidAsyncTask() {
@@ -206,9 +206,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
// TitlePageIndicator indicator = (TitlePageIndicator)
// findViewById(R.id.indicator);
pager.setAdapter(adapter);
- cEvent = epgs.get(counter);
+ //cEvent = epgs.get(counter);
pager.setCurrentItem(counter);
- current = counter;
+ onPageSelected(counter);
+ //current = counter;
// indicator.setViewPager(pager);
// publishEPG(epg);
@@ -235,6 +236,12 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
Event event = epgs.get(position);
+ Timerable timerable = null;
+
+ if(event instanceof Timerable){
+ timerable = (Timerable)event;
+ }
+
view.setTag(event);
// view.setTag(event);
@@ -293,10 +300,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
.findViewById(R.id.epg_detail_description);
textView.setText(Utils.highlight(formatter.getDescription(), highlight));
- if (cEvent.getAudio().isEmpty() == false) {
+ if (event.getAudio().isEmpty() == false) {
final TextView audioTracks = (TextView) view
.findViewById(R.id.epg_detail_audio);
- audioTracks.setText(Utils.formatAudio(this, cEvent.getAudio()));
+ audioTracks.setText(Utils.formatAudio(this, event.getAudio()));
} else {
view.findViewById(R.id.audio_image).setVisibility(View.GONE);
}
@@ -466,6 +473,9 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
}
public void onClick(final View v) {
+
+ final Event cEvent = epgs.get(pager.getCurrentItem());
+
switch (v.getId()) {
case R.id.epg_event_livetv:
if (cEvent instanceof Recording) {
@@ -478,8 +488,9 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
final ArrayAdapter<Wrapper> ada = new ArrayAdapter<Wrapper>(this,
android.R.layout.simple_dropdown_item_1line);
final Timer timer = getTimer(cEvent);
+ TimerMatch tm = Utils.getTimerMatch(cEvent, timer);
// remove unneeded menu items
- if (timer != null) {
+ if (timer != null && tm == TimerMatch.Full) {
ada.add(new Wrapper(R.string.epg_item_menu_timer_modify));
ada.add(new Wrapper(R.string.epg_item_menu_timer_delete));
if (timer.isEnabled()) {
@@ -489,7 +500,6 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
}
} else if (cEvent instanceof Recording) {
ada.add(new Wrapper(R.string.epg_item_menu_timer_delete));
-
} else {
ada.add(new Wrapper(R.string.epg_item_menu_timer_add));
if (Utils.isLive(cEvent) && (cEvent instanceof Timerable) && ((Timerable)cEvent).getTimer() == null) {
@@ -501,7 +511,8 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
public void onClick(DialogInterface dialog, int which) {
final Timer t;
if (timer == null) {
- t = timerable.createTimer();
+ //t = timerable.createTimer();
+ t = null;
} else {
t = timer;
}
@@ -631,8 +642,10 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
}
@Override
- public boolean onOptionsItemSelected(
- com.actionbarsherlock.view.MenuItem item) {
+ public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
+
+ Event cEvent = epgs.get(pager.getCurrentItem());
+
if (item.getItemId() == R.id.epg_details_menu_share) {
shareEvent(cEvent);
return true;
@@ -678,7 +691,7 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
return;
}
- pager.getAdapter().notifyDataSetChanged();
+
// View view = pager.getChildAt(current);
// ImageView state = (ImageView)
// view.findViewById(R.id.epg_timer_state);
@@ -692,9 +705,9 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
// : R.drawable.timer_active);
} else if (requestCode == TimerDetailsActivity.REQUEST_CODE_TIMER_EDIT) {
modifed = true;
-
// ??
}
+ pager.getAdapter().notifyDataSetChanged();
}
@Override
@@ -707,19 +720,19 @@ public class EpgDetailsActivity extends ICSBaseActivity implements
}
}
- public void onPageScrollStateChanged(int arg0) {
+ public void onPageScrollStateChanged(int state){
}
- public void onPageScrolled(int arg0, float arg1, int arg2) {
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels){
}
- public void onPageSelected(int arg0) {
- current = arg0;
- cEvent = epgs.get(current);
+ public void onPageSelected(int position) {
+
+ Event cEvent = epgs.get(position);
String cn = cEvent.getChannelName();
// View view = pager.getChildAt(arg0);
// state = (ImageView) view.findViewById(R.id.epg_timer_state);
- setTitle(getString(R.string.epg_of_a_channel, cn, current + 1,
+ setTitle(getString(R.string.epg_of_a_channel, cn, position + 1,
epgs.size()));
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
index b0aae06..655792b 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java
@@ -35,6 +35,7 @@ import de.bjusystems.vdrmanager.data.Event;
import de.bjusystems.vdrmanager.data.EventFormatter;
import de.bjusystems.vdrmanager.data.Preferences;
import de.bjusystems.vdrmanager.data.Recording;
+import de.bjusystems.vdrmanager.data.Timer;
import de.bjusystems.vdrmanager.data.TimerMatch;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpAsyncTask;
import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent;
@@ -465,4 +466,20 @@ public class Utils {
}
+ public static TimerMatch getTimerMatch(Event event, Timer timer){
+ if(timer == null){
+ return null;
+ }
+ TimerMatch timerMatch = null;
+ Date start = event.getStart();
+ Date stop = event.getStop();
+ if (start.before(timer.getStart())) {
+ timerMatch = TimerMatch.End;
+ } else if (stop.after(timer.getStop())) {
+ timerMatch = TimerMatch.Begin;
+ } else {
+ timerMatch = TimerMatch.Full;
+ }
+ return timerMatch;
+ }
}