summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2011-10-12 12:04:06 +0200
committerlado <herrlado@gmail.com>2011-10-12 12:04:06 +0200
commit93f43c161df852a43a9779fd31da38d329dba0a4 (patch)
tree075ca0ded73ab2d1b5fef45d800e01c97be32901 /vdrmanager/src/de/bjusystems
parentde322866f18be4fbd002eb51f0c8697aa6dac9f2 (diff)
downloadvdr-manager-93f43c161df852a43a9779fd31da38d329dba0a4.tar.gz
vdr-manager-93f43c161df852a43a9779fd31da38d329dba0a4.tar.bz2
swipe left and right to switcg to the next or previois entry in the
dropdown list
Diffstat (limited to 'vdrmanager/src/de/bjusystems')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java24
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java47
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java32
3 files changed, 97 insertions, 6 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
index fa63073..c1530dc 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEpgListActivity.java
@@ -11,6 +11,7 @@ import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
+import android.view.MotionEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
@@ -21,16 +22,23 @@ import de.bjusystems.vdrmanager.data.Channel;
import de.bjusystems.vdrmanager.data.Epg;
import de.bjusystems.vdrmanager.data.EventFormatter;
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.SvdrpEvent;
-public abstract class BaseEpgListActivity extends BaseActivity {
+/**
+ * @author lado
+ *
+ */
+public abstract class BaseEpgListActivity extends BaseActivity implements SimpleGestureListener{
private static final int REQUEST_CODE_TIMED_EDIT = 41;
+ private SimpleGestureFilter detector;
+
protected EpgClient epgClient;
protected EventAdapter adapter;
@@ -54,6 +62,7 @@ public abstract class BaseEpgListActivity extends BaseActivity {
super.onCreate(savedInstanceState);
// Attach view
setContentView(getMainLayout());
+ detector = new SimpleGestureFilter(this, this);
setTitle(getWindowTitle());
initChannel();
}
@@ -302,5 +311,18 @@ public abstract class BaseEpgListActivity extends BaseActivity {
return true;
}
+ @Override
+ public boolean dispatchTouchEvent(MotionEvent me) {
+ this.detector.onTouchEvent(me);
+ return super.dispatchTouchEvent(me);
+ }
+
+ public void onSwipe(int direction) {
+
+ }
+ public void onDoubleTap() {
+ // TODO Auto-generated method stub
+
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
index f48bf72..4e0987d 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java
@@ -13,6 +13,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
+import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Channel;
@@ -42,6 +43,8 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
Spinner channelSpinner;
+ ArrayAdapter<Channel> channelSpinnerAdapter;
+
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -50,7 +53,7 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
final List<Channel> channels = ChannelClient.getChannels();
// create adapter for channel spinner
- final ArrayAdapter<Channel> channelSpinnerAdapter = new ArrayAdapter<Channel>(
+ channelSpinnerAdapter = new ArrayAdapter<Channel>(
this, android.R.layout.simple_spinner_item);
channelSpinnerAdapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
@@ -87,8 +90,8 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
@Override
protected void onResume() {
super.onResume();
- //adapter.notifyDataSetChanged();
- //startEpgQuery();
+ // adapter.notifyDataSetChanged();
+ // startEpgQuery();
}
public void onItemSelected(final AdapterView<?> parent, final View view,
@@ -176,8 +179,10 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
task.run();
}
- /* (non-Javadoc)
- * TODO this method also should be used in startEpgQuery on cache hit
+ /*
+ * (non-Javadoc) TODO this method also should be used in startEpgQuery on
+ * cache hit
+ *
* @see de.bjusystems.vdrmanager.gui.BaseEpgListActivity#finishedSuccess()
*/
@Override
@@ -241,4 +246,36 @@ public class EventEpgListActivity extends BaseEpgListActivity implements
protected int getWindowTitle() {
return R.string.epg_by_channel;
}
+
+ private void nextEvent() {
+ int pos = channelSpinner.getSelectedItemPosition();
+ if (pos + 1 >= channelSpinnerAdapter.getCount()) {
+ Toast.makeText(this, R.string.navigae_at_the_end,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ channelSpinner.setSelection(pos + 1, true);
+ }
+
+ private void prevEvent() {
+ int pos = channelSpinner.getSelectedItemPosition();
+ if (pos <= 0) {
+ Toast.makeText(this, R.string.navigae_at_the_start,
+ Toast.LENGTH_SHORT).show();
+ return;
+ }
+ channelSpinner.setSelection(pos - 1, true);
+ }
+
+ @Override
+ public void onSwipe(int direction) {
+ switch (direction) {
+ case SimpleGestureFilter.SWIPE_RIGHT:
+ prevEvent();
+ break;
+ case SimpleGestureFilter.SWIPE_LEFT:
+ nextEvent();
+ break;
+ }
+ }
}
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
index 488939b..e6fcb1f 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java
@@ -14,6 +14,7 @@ import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
+import android.widget.Toast;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
import de.bjusystems.vdrmanager.data.Epg;
@@ -257,5 +258,36 @@ public class TimeEpgListActivity extends BaseEpgListActivity implements
protected int getWindowTitle() {
return R.string.epg_by_time;
}
+
+
+ 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();
+ return;
+ }
+ timeSpinner.setSelection(pos+1, true);
+ }
+
+ private void prevEvent(){
+ int pos = timeSpinner.getSelectedItemPosition();
+ if(pos <= 0){
+ Toast.makeText(this, R.string.navigae_at_the_start, Toast.LENGTH_SHORT).show();
+ return;
+ }
+ timeSpinner.setSelection(pos-1, true);
+ }
+
+ @Override
+ public void onSwipe(int direction) {
+ switch (direction) {
+ case SimpleGestureFilter.SWIPE_RIGHT:
+ prevEvent();
+ break;
+ case SimpleGestureFilter.SWIPE_LEFT:
+ nextEvent();
+ break;
+ }
+ }
}