Start: Restore last feed
This commit is contained in:
parent
5ffb0460b3
commit
efa35fed9c
@ -140,7 +140,6 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
|
|||||||
navAdapter.registerDataSetObserver(new DataSetObserver() {
|
navAdapter.registerDataSetObserver(new DataSetObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
Log.d(TAG, "NavListAdapter dataSet onChanged()");
|
|
||||||
selectedNavListIndex = getSelectedNavListIndex();
|
selectedNavListIndex = getSelectedNavListIndex();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -162,11 +161,9 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
|
|||||||
String lastFragment = getLastNavFragment();
|
String lastFragment = getLastNavFragment();
|
||||||
if(ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
|
if(ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
|
||||||
loadFragment(lastFragment, null);
|
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();
|
externalPlayerFragment = new ExternalPlayerFragment();
|
||||||
transaction.replace(R.id.playerFragment, externalPlayerFragment);
|
transaction.replace(R.id.playerFragment, externalPlayerFragment);
|
||||||
@ -178,7 +175,11 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
|
|||||||
private void saveLastNavFragment(String tag) {
|
private void saveLastNavFragment(String tag) {
|
||||||
SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
SharedPreferences prefs = getSharedPreferences(PREF_NAME, MODE_PRIVATE);
|
||||||
SharedPreferences.Editor edit = prefs.edit();
|
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();
|
edit.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -531,6 +532,13 @@ public class MainActivity extends ActionBarActivity implements NavDrawerActivity
|
|||||||
navDrawerData = result;
|
navDrawerData = result;
|
||||||
navAdapter.notifyDataSetChanged();
|
navAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
String lastFragment = getLastNavFragment();
|
||||||
|
if(!ArrayUtils.contains(NAV_DRAWER_TAGS, lastFragment)) {
|
||||||
|
long feedId = Long.valueOf(lastFragment);
|
||||||
|
loadFeedFragmentById(feedId);
|
||||||
|
saveLastNavFragment(null);
|
||||||
|
}
|
||||||
|
|
||||||
if (handleIntent) {
|
if (handleIntent) {
|
||||||
handleNavIntent();
|
handleNavIntent();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user