summaryrefslogtreecommitdiff
path: root/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
diff options
context:
space:
mode:
authorlado <herrlado@gmail.com>2013-02-25 01:12:30 +0100
committerlado <herrlado@gmail.com>2013-02-25 01:12:30 +0100
commit6ad4d12110219b25d9c7517631174e5551c053c3 (patch)
treea416362cdd3213ae42ee4f34b2775aae6115e58d /vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
parent7f29b3a3644019c68c953d205f1a5802510db6ec (diff)
downloadvdr-manager-6ad4d12110219b25d9c7517631174e5551c053c3.tar.gz
vdr-manager-6ad4d12110219b25d9c7517631174e5551c053c3.tar.bz2
Feature #1273
Diffstat (limited to 'vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java')
-rw-r--r--vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
index 5e43e92..d4f6f32 100644
--- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
+++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseActivity.java
@@ -1,5 +1,7 @@
package de.bjusystems.vdrmanager.gui;
+import com.actionbarsherlock.app.ActionBar.OnNavigationListener;
+
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Intent;
@@ -7,8 +9,10 @@ import android.content.res.Configuration;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
+import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
+import android.widget.SpinnerAdapter;
import android.widget.ViewFlipper;
import de.bjusystems.vdrmanager.R;
import de.bjusystems.vdrmanager.app.VdrManagerApp;
@@ -129,6 +133,81 @@ public abstract class BaseActivity<Result, T extends ListView> extends
// setTitle(title);
// }
+ abstract protected int getListNavigationIndex();
+
+ public static final int LIST_NAVIGATION_CHANNELS = 0;
+ public static final int LIST_NAVIGATION_EPG_BY_TIME = 1;
+ public static final int LIST_NAVIGATION_EPG_BY_CHANNEL = 2;
+ public static final int LIST_NAVIGATION_RECORDINGS = 3;
+ public static final int LIST_NAVIGATION_TIMERS = 4;
+
+ protected boolean hasListNavigation(){
+ return true;
+ }
+
+ protected void initListNavigation(){
+
+ if(hasListNavigation() == false){
+ return;
+ }
+
+ getSupportActionBar().setDisplayShowTitleEnabled(false);
+
+ getSupportActionBar().setNavigationMode(
+ getSupportActionBar().NAVIGATION_MODE_LIST);
+
+ ArrayAdapter<CharSequence> mSpinnerAdapter = ArrayAdapter
+ .createFromResource(this, R.array.navigation_array,
+ android.R.layout.simple_spinner_dropdown_item);
+
+ getSupportActionBar().setListNavigationCallbacks(mSpinnerAdapter,
+ new OnNavigationListener() {
+
+ private boolean firstHit = true;
+
+ @Override
+ public boolean onNavigationItemSelected(int itemPosition,
+ long itemId) {
+
+ if (firstHit == true) {
+ firstHit = false;
+ return false;
+ }
+ switch (itemPosition) {
+
+ case LIST_NAVIGATION_CHANNELS: {
+ startActivity(ChannelListActivity.class);
+ return true;
+ }
+ case LIST_NAVIGATION_EPG_BY_TIME: {
+ startActivity(TimeEpgListActivity.class);
+ return true;
+ }
+
+ case LIST_NAVIGATION_EPG_BY_CHANNEL: {
+ startActivity(EventEpgListActivity.class);
+ return true;
+ }
+
+ case LIST_NAVIGATION_RECORDINGS: {
+ startActivity(RecordingListActivity.class);
+ return true;
+ }
+
+ case LIST_NAVIGATION_TIMERS: {
+ startActivity(TimerListActivity.class);
+ return true;
+ }
+
+ }
+ return false;
+ }
+ });
+ getSupportActionBar().setSelectedNavigationItem(
+ getListNavigationIndex());
+
+ }
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -138,6 +217,18 @@ public abstract class BaseActivity<Result, T extends ListView> extends
initActionBar();
+ initListNavigation();
+
+ // new OnNavigationListener() {
+ // @Override
+ // public boolean onNavigationItemSelected(int itemPosition, long
+ // itemId) {
+ // System.err.println("itemPosition: "+ itemPosition +", itemId:" +
+ // itemId);
+ // rturn false;
+ // }
+ // });
+
// your logic for click listner
// setListenerForActionBarCustomView(actionBarView);
@@ -149,6 +240,13 @@ public abstract class BaseActivity<Result, T extends ListView> extends
}
+ public void startActivity(Class<?> clazz) {
+ Intent intent = new Intent(Intent.ACTION_VIEW);
+ intent.setClass(this, clazz);
+ startActivity(intent);
+ finish();
+ }
+
@Override
public boolean onCreateOptionsMenu(
final com.actionbarsherlock.view.Menu menu) {