[Libreoffice-commits] .: 2 commits - android/experimental
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Mon Nov 26 00:31:04 PST 2012
android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java | 24 +++++++---
1 file changed, 19 insertions(+), 5 deletions(-)
New commits:
commit 33ab92fe567081c9f704262c2bc959f0498b06d5
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Nov 26 09:30:38 2012 +0100
android: make this a bit more readable
Change-Id: I765458daa808245ec736a3d184ba64c2dcd3a10b
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 4817bac..96ae150 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -182,7 +182,9 @@ public class DocumentLoader
flipper.showNext();
- getPageViewerAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE).display(getCurrentPageViewer().currentPageNumber + PAGECACHE_PLUSMINUS);
+ // The entry after the next, both child index and next is 0..PAGECACHE_SIZE.
+ int next = (flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE;
+ getPageViewerAt(next).display(getCurrentPageViewer().currentPageNumber + PAGECACHE_PLUSMINUS);
return true;
} else if (event2.getX() - event1.getX() > 120) {
if (getCurrentPageViewer().currentPageNumber == 0)
@@ -201,7 +203,9 @@ public class DocumentLoader
flipper.showPrevious();
- getPageViewerAt((flipper.getDisplayedChild() + PAGECACHE_SIZE - PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE).display(getCurrentPageViewer().currentPageNumber - PAGECACHE_PLUSMINUS);
+ // The entry before the previous, both child index and previous is 0..PAGECACHE_SIZE.
+ int previous = (flipper.getDisplayedChild() + PAGECACHE_SIZE - PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE;
+ getPageViewerAt(previous).display(getCurrentPageViewer().currentPageNumber - PAGECACHE_PLUSMINUS);
return true;
}
commit 593e4a11edb42cf7311ee341b0dbb1e7b1497c1c
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Mon Nov 26 09:30:08 2012 +0100
android: extract duplicated casts to helper methods
Change-Id: Ib77731839ad9e46626a7a07d4b2c6c7e32d4bba1
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 fcf9fae..4817bac 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -145,6 +145,16 @@ public class DocumentLoader
Bundle extras;
+ PageViewer getPageViewerAt(int index)
+ {
+ return (PageViewer)flipper.getChildAt(index);
+ }
+
+ PageViewer getCurrentPageViewer()
+ {
+ return (PageViewer)flipper.getCurrentView();
+ }
+
class GestureListener
extends GestureDetector.SimpleOnGestureListener
{
@@ -156,7 +166,7 @@ public class DocumentLoader
{
Log.i(TAG, "onFling: " + event1 + " " + event2);
if (event1.getX() - event2.getX() > 120) {
- if (((PageViewer)flipper.getCurrentView()).currentPageNumber == documentContext.pageCount-1)
+ if (getCurrentPageViewer().currentPageNumber == documentContext.pageCount-1)
return false;
Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0,
@@ -172,10 +182,10 @@ public class DocumentLoader
flipper.showNext();
- ((PageViewer)flipper.getChildAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display(((PageViewer)flipper.getCurrentView()).currentPageNumber + PAGECACHE_PLUSMINUS);
+ getPageViewerAt((flipper.getDisplayedChild() + PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE).display(getCurrentPageViewer().currentPageNumber + PAGECACHE_PLUSMINUS);
return true;
} else if (event2.getX() - event1.getX() > 120) {
- if (((PageViewer)flipper.getCurrentView()).currentPageNumber == 0)
+ if (getCurrentPageViewer().currentPageNumber == 0)
return false;
Animation inFromLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0,
@@ -191,7 +201,7 @@ public class DocumentLoader
flipper.showPrevious();
- ((PageViewer)flipper.getChildAt((flipper.getDisplayedChild() + PAGECACHE_SIZE - PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE)).display(((PageViewer)flipper.getCurrentView()).currentPageNumber - PAGECACHE_PLUSMINUS);
+ getPageViewerAt((flipper.getDisplayedChild() + PAGECACHE_SIZE - PAGECACHE_PLUSMINUS) % PAGECACHE_SIZE).display(getCurrentPageViewer().currentPageNumber - PAGECACHE_PLUSMINUS);
return true;
}
@@ -938,7 +948,7 @@ public class DocumentLoader
public Object onRetainNonConfigurationInstance() {
ArrayList ret = new ArrayList(2);
ret.add(bootstrapContext);
- documentContext.currentPageNumber = ((PageViewer)flipper.getCurrentView()).currentPageNumber;
+ documentContext.currentPageNumber = getCurrentPageViewer().currentPageNumber;
ret.add(documentContext);
return ret;
}
More information about the Libreoffice-commits
mailing list