diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-11-13 13:35:55 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-11-13 14:25:52 +0100 |
commit | 677ca1d59618c592786292ac275497e0ce753604 (patch) | |
tree | f7905349d41ad83c14948152950792958c9dd364 /android | |
parent | a4053378b7a98d8a18415ba5acd8b69ba28793a2 (diff) |
android: remember displayed page during rotation in DocumentLoader
Change-Id: I1948dcc76026e4c906407932aa67371e5e9e8bb6
Diffstat (limited to 'android')
-rw-r--r-- | android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java index 8c9a71374196..806fcabd49ff 100644 --- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java +++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java @@ -917,6 +917,13 @@ public class DocumentLoader } @Override + public void onSaveInstanceState(Bundle savedInstance) + { + super.onSaveInstanceState(savedInstance); + savedInstance.putInt("currentPageNumber", ((PageViewer)flipper.getCurrentView()).currentPageNumber); + } + + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -978,11 +985,14 @@ public class DocumentLoader matchParent = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); - flipper.addView(new PageViewer(0), 0, matchParent); + int currentPageNumber = 0; + if (savedInstanceState != null) + currentPageNumber = savedInstanceState.getInt("currentPageNumber"); + flipper.addView(new PageViewer(currentPageNumber), 0, matchParent); for (int i = 0; i < PAGECACHE_PLUSMINUS; i++) - flipper.addView(new PageViewer(i+1), i+1, matchParent); + flipper.addView(new PageViewer(currentPageNumber+i+1), i+1, matchParent); for (int i = 0; i < PAGECACHE_PLUSMINUS; i++) - flipper.addView(new PageViewer(-1), PAGECACHE_PLUSMINUS + i+1, matchParent); + flipper.addView(new PageViewer(currentPageNumber+(i*-1)-1), PAGECACHE_PLUSMINUS + i+1, matchParent); setContentView(flipper); } |