aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/ui/logs
diff options
context:
space:
mode:
authorKiwiStone <Kiwi.Stone@web.de>2013-11-28 01:01:58 +0100
committerKiwiStone <Kiwi.Stone@web.de>2013-11-29 23:23:27 +0100
commit22a2231d2c1f4f4d4197c42b1e33dc6eaba33d65 (patch)
tree8ec0642b2edcffd6bfbf605f9e90a6d0257a8a0a /main/src/cgeo/geocaching/ui/logs
parenta15ec8969fa9e26c0adaf4d5aefc91b9c7be2d12 (diff)
downloadcgeo-22a2231d2c1f4f4d4197c42b1e33dc6eaba33d65.zip
cgeo-22a2231d2c1f4f4d4197c42b1e33dc6eaba33d65.tar.gz
cgeo-22a2231d2c1f4f4d4197c42b1e33dc6eaba33d65.tar.bz2
fixes #3354 - Position not saved on logbook screen
Diffstat (limited to 'main/src/cgeo/geocaching/ui/logs')
-rw-r--r--main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java
index 8da711e..873094e 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());
}
+ /**
+ * 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;
+ }
} \ No newline at end of file