summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/adapter
diff options
context:
space:
mode:
authorMartin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de>2015-04-17 13:16:14 +0200
committerMartin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de>2015-04-18 22:12:40 +0200
commit4aa68e74e099f7a18ee339a70d8a7ec0fdb6dffa (patch)
treed630a843b7f28089d3be49f318274b5fbd23ad62 /app/src/main/java/de/danoeh/antennapod/adapter
parentfc124a5f1a9b7c6ccc4167ffae3a5897baae71ca (diff)
downloadAntennaPod-4aa68e74e099f7a18ee339a70d8a7ec0fdb6dffa.zip
Bux fixes, tests
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/adapter')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java28
1 files changed, 12 insertions, 16 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
index c763c7b61..907093ad6 100644
--- a/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
+++ b/app/src/main/java/de/danoeh/antennapod/adapter/NavListAdapter.java
@@ -36,7 +36,8 @@ import de.danoeh.antennapod.fragment.QueueFragment;
/**
* BaseAdapter for the navigation drawer
*/
-public class NavListAdapter extends BaseAdapter {
+public class NavListAdapter extends BaseAdapter
+ implements SharedPreferences.OnSharedPreferenceChangeListener {
public static final int VIEW_TYPE_COUNT = 3;
public static final int VIEW_TYPE_NAV = 0;
public static final int VIEW_TYPE_SECTION_DIVIDER = 1;
@@ -48,17 +49,6 @@ public class NavListAdapter extends BaseAdapter {
private ItemAccess itemAccess;
private Context context;
- private SharedPreferences.OnSharedPreferenceChangeListener listener =
- new SharedPreferences.OnSharedPreferenceChangeListener() {
- @Override
- public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
- if(key.equals(UserPreferences.PREF_HIDDEN_DRAWER_ITEMS)) {
- loadItems();
- }
- }
- };
-
-
public NavListAdapter(ItemAccess itemAccess, Context context) {
this.itemAccess = itemAccess;
this.context = context;
@@ -67,7 +57,13 @@ public class NavListAdapter extends BaseAdapter {
loadItems();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
- prefs.registerOnSharedPreferenceChangeListener(listener);
+ prefs.registerOnSharedPreferenceChangeListener(this);
+ }
+
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (key.equals(UserPreferences.PREF_HIDDEN_DRAWER_ITEMS)) {
+ loadItems();
+ }
}
private void loadItems() {
@@ -122,7 +118,7 @@ public class NavListAdapter extends BaseAdapter {
@Override
public int getCount() {
- return tags.size() + itemAccess.getCount() + (tags.size() > 0 ? 1 : 0);
+ return getSubscriptionOffset() + itemAccess.getCount();
}
@Override
@@ -146,7 +142,7 @@ public class NavListAdapter extends BaseAdapter {
public int getItemViewType(int position) {
if (0 <= position && position < tags.size()) {
return VIEW_TYPE_NAV;
- } else if (position < tags.size() + 1) {
+ } else if (position < getSubscriptionOffset()) {
return VIEW_TYPE_SECTION_DIVIDER;
} else {
return VIEW_TYPE_SUBSCRIPTION;
@@ -159,7 +155,7 @@ public class NavListAdapter extends BaseAdapter {
}
public int getSubscriptionOffset() {
- return tags.size() + 1;
+ return tags.size() > 0 ? tags.size() + 1 : 0;
}