summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorTom Hennen <TomHennen@users.noreply.github.com>2015-03-04 20:12:27 -0500
committerTom Hennen <TomHennen@users.noreply.github.com>2015-03-04 20:12:27 -0500
commit1f68352013fc487d691e07f9f340c423faa7a662 (patch)
tree25da9d3a6a819f9ba507fcab62ef4059357f4369 /app
parent32b1e6aac1b8fe8c4a60824536d968e801850eb2 (diff)
parent83090581889ea62e39a79b7c0ca53b15f65a91d4 (diff)
downloadAntennaPod-1f68352013fc487d691e07f9f340c423faa7a662.zip
Merge pull request #655 from mfietz/issue-551
Persist scroll position in Queue view
Diffstat (limited to 'app')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
index 913b544a5..ebfe03382 100644
--- a/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
+++ b/app/src/main/java/de/danoeh/antennapod/fragment/QueueFragment.java
@@ -3,6 +3,7 @@ package de.danoeh.antennapod.fragment;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
+import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
@@ -66,6 +67,10 @@ public class QueueFragment extends Fragment {
private boolean viewsCreated = false;
private boolean isUpdatingFeeds = false;
+ private static final String PREFS = "QueueFragment";
+ private static final String PREF_KEY_LIST_TOP = "list_top";
+ private static final String PREF_KEY_LIST_SELECTION = "list_selection";
+
private AtomicReference<Activity> activity = new AtomicReference<Activity>();
private DownloadObserver downloadObserver = null;
@@ -104,6 +109,18 @@ public class QueueFragment extends Fragment {
}
@Override
+ public void onPause() {
+ super.onPause();
+ SharedPreferences prefs = getActivity().getSharedPreferences(PREFS, Context.MODE_PRIVATE);
+ SharedPreferences.Editor editor = prefs.edit();
+ View v = listView.getChildAt(0);
+ int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
+ editor.putInt(PREF_KEY_LIST_SELECTION, listView.getFirstVisiblePosition());
+ editor.putInt(PREF_KEY_LIST_TOP, top);
+ editor.commit();
+ }
+
+ @Override
public void onStop() {
super.onStop();
EventDistributor.getInstance().unregister(contentUpdate);
@@ -329,6 +346,11 @@ public class QueueFragment extends Fragment {
}
listAdapter.notifyDataSetChanged();
+ SharedPreferences prefs = getActivity().getSharedPreferences(PREFS, Context.MODE_PRIVATE);
+ int listSelection = prefs.getInt(PREF_KEY_LIST_SELECTION, 0);
+ int top = prefs.getInt(PREF_KEY_LIST_TOP, 0);
+ listView.setSelectionFromTop(listSelection, top);
+
// we need to refresh the options menu because it sometimes
// needs data that may have just been loaded.
getActivity().supportInvalidateOptionsMenu();