diff options
author | lado <herrlado@gmail.com> | 2013-02-25 01:12:30 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2013-02-25 01:12:30 +0100 |
commit | 6ad4d12110219b25d9c7517631174e5551c053c3 (patch) | |
tree | a416362cdd3213ae42ee4f34b2775aae6115e58d /vdrmanager/src/de | |
parent | 7f29b3a3644019c68c953d205f1a5802510db6ec (diff) | |
download | vdr-manager-6ad4d12110219b25d9c7517631174e5551c053c3.tar.gz vdr-manager-6ad4d12110219b25d9c7517631174e5551c053c3.tar.bz2 |
Feature #1273
Diffstat (limited to 'vdrmanager/src/de')
9 files changed, 135 insertions, 3 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) { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java index dbc7826..a744e28 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/BaseEventListActivity.java @@ -193,9 +193,6 @@ public abstract class BaseEventListActivity<T extends Event> extends final com.actionbarsherlock.view.MenuItem item) { switch (item.getItemId()) { - case R.id.epg_list_menu_channels: - startActivity(new Intent(this, ChannelListActivity.class)); - return true; case R.id.epg_list_sort_menu: { diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index f126baf..60134fb 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -604,4 +604,9 @@ public class ChannelListActivity extends return channelClient; } + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_CHANNELS; + } + }
\ No newline at end of file diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java index b9c426b..7a52e63 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EpgSearchListActivity.java @@ -175,4 +175,14 @@ public class EpgSearchListActivity extends BaseTimerEditActivity<Epg> implements return true; } + @Override + protected int getListNavigationIndex() { + return -1; + } + + @Override + protected boolean hasListNavigation() { + return false; + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java index 91ef2d4..6bf93da 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/EventEpgListActivity.java @@ -414,6 +414,11 @@ public class EventEpgListActivity extends BaseTimerEditActivity<Epg> implements } } + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_EPG_BY_CHANNEL; + } + // @Override // protected void timerModified() { // cachedChannel = null; diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java index 573f45f..56f91bd 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/RecordingListActivity.java @@ -280,4 +280,9 @@ public class RecordingListActivity extends BaseEventListActivity<Recording> return false; } + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_RECORDINGS; + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java index 92ab1eb..2893583 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimeEpgListActivity.java @@ -389,4 +389,10 @@ public class TimeEpgListActivity extends BaseTimerEditActivity<Epg> implements } } + + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_EPG_BY_TIME; + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java index edb5325..3ba957a 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/TimerListActivity.java @@ -228,4 +228,9 @@ public class TimerListActivity extends BaseTimerEditActivity<Timer> implements return super.onCreateOptionsMenu(menu); } + @Override + protected int getListNavigationIndex() { + return LIST_NAVIGATION_TIMERS; + } + } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java index fb4ea49..20730da 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/Utils.java @@ -417,4 +417,5 @@ public class Utils { DateUtils.FORMAT_SHOW_TIME).toString(); } + } |