diff options
author | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-04-19 18:14:56 +0200 |
---|---|---|
committer | Martin Fietz <marf@hadiko-99-4.hadiko.uni-karlsruhe.de> | 2015-04-19 18:14:56 +0200 |
commit | efa35fed9c05281def2d4f61ec0614deb8ebede3 (patch) | |
tree | c2a7a95416ef1d1b6a3379fec25039148f81808f /app | |
parent | 5ffb0460b3cb3c251b28da0a156a7c2e4be159bd (diff) | |
download | AntennaPod-efa35fed9c05281def2d4f61ec0614deb8ebede3.zip |
Start: Restore last feed
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java index 093d9aef9..246af8d12 100644 --- a/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java +++ b/app/src/main/java/de/danoeh/antennapod/activity/MainActivity.java @@ -140,7 +140,6 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity navAdapter.registerDataSetObserver(new DataSetObserver() { @Override public void onChanged() { - Log.d(TAG, "NavListAdapter dataSet onChanged()"); selectedNavListIndex = getSelectedNavListIndex(); } }); @@ -162,11 +161,9 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity String lastFragment = getLastNavFragment(); if(ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) { loadFragment(lastFragment, null); - } else { // last fragment was not a list, but a feed - long feedId = Long.valueOf(lastFragment); - loadFeedFragmentById(feedId); } - + // else: lastFragment contains feed id - drawer data is not loaded yet, + // so loading is postponed until then } externalPlayerFragment = new ExternalPlayerFragment(); transaction.replace(R.id.playerFragment, externalPlayerFragment); @@ -178,7 +175,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity private void saveLastNavFragment(String tag) { SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE); SharedPreferences.Editor edit = prefs.edit(); - edit.putString(PREF_LAST_FRAGMENT_TAG, tag); + if(tag != null) { + edit.putString(PREF_LAST_FRAGMENT_TAG, tag); + } else { + edit.remove(PREF_LAST_FRAGMENT_TAG); + } edit.commit(); } @@ -531,6 +532,13 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity navDrawerData = result; navAdapter.notifyDataSetChanged(); + String lastFragment = getLastNavFragment(); + if(!ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) { + long feedId = Long.valueOf(lastFragment); + loadFeedFragmentById(feedId); + saveLastNavFragment(null); + } + if (handleIntent) { handleNavIntent(); } |