diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-12-08 10:24:11 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-12-08 10:24:11 +0100 |
| commit | 1e12d6a1396b208614046cf00e88d008b3e08cba (patch) | |
| tree | 1e5e0a79b4f48c03d1b6b0cf9795a404feb0b440 /main/src/cgeo/geocaching/ui/logs | |
| parent | 20390fde6967e5a7c440d43f2d5a2b55bdb486b9 (diff) | |
| parent | 22a2231d2c1f4f4d4197c42b1e33dc6eaba33d65 (diff) | |
| download | cgeo-1e12d6a1396b208614046cf00e88d008b3e08cba.zip cgeo-1e12d6a1396b208614046cf00e88d008b3e08cba.tar.gz cgeo-1e12d6a1396b208614046cf00e88d008b3e08cba.tar.bz2 | |
Merge remote-tracking branch 'KiwiStone/issue-3354'
Diffstat (limited to 'main/src/cgeo/geocaching/ui/logs')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java | 36 |
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; + } +} |
