aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java')
-rw-r--r--main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java36
1 files changed, 35 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java
index 8fe3866..0a327f3 100644
--- a/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java
+++ b/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java
@@ -11,6 +11,7 @@ import cgeo.geocaching.ui.UserActionsClickListener;
import org.apache.commons.lang3.StringUtils;
import android.content.res.Resources;
+import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
@@ -109,4 +110,37 @@ public class CacheLogsViewCreator extends LogsViewCreator {
return new UserActionsClickListener(getCache());
}
-} \ No newline at end of file
+ /**
+ * Get the state of the current view
+ *
+ * @return the state encapsulated in a bundle
+ */
+ @Override
+ public Bundle getViewState() {
+ if (view == null) {
+ return null;
+ }
+ int position = view.getFirstVisiblePosition();
+ View child = view.getChildAt(0);
+ int positionFromTop = (child == null) ? 0 : child.getTop();
+ Bundle state = new Bundle();
+ state.putInt("position", position);
+ state.putInt("positionFromTop", positionFromTop);
+ return state;
+ }
+
+ /**
+ * Restore a previously stored state of the view
+ *
+ */
+ @Override
+ public void setViewState(Bundle state) {
+ if (view == null) {
+ return;
+ }
+ int logViewPosition = state.getInt("position");
+ int logViewPositionFromTop = state.getInt("positionFromTop");
+ view.setSelectionFromTop(logViewPosition, logViewPositionFromTop);
+ return;
+ }
+}