summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTor Lillqvist <tlillqvist@suse.com>2012-06-27 12:54:41 +0300
committerTor Lillqvist <tlillqvist@suse.com>2012-06-27 12:58:50 +0300
commit0179c9628258f30c41121a1ff3a50fcebe44d776 (patch)
tree681f19467bb1fced7e6cfa3deedb7b1b4822878a /android
parent5bfb819581bdc9e1f1c59e36a0d7fb21593b382b (diff)
Adapt page switch animation duration to fling velocity
Change-Id: I30e177b45b0e25d92fd7dea02ffe4e9c0731dce5
Diffstat (limited to 'android')
-rw-r--r--android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java10
1 files changed, 6 insertions, 4 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 25878577cc7d..677c6d43d272 100644
--- a/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
+++ b/android/experimental/DocumentLoader/src/org/libreoffice/android/examples/DocumentLoader.java
@@ -149,12 +149,13 @@ public class DocumentLoader
Animation inFromRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 1, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- inFromRight.setDuration(500);
+ int duration = Math.abs((int)((float)flipper.getWidth()/velocityX*1000f));
+ inFromRight.setDuration(duration);
flipper.setInAnimation(inFromRight);
Animation outToLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- outToLeft.setDuration(500);
+ outToLeft.setDuration(duration);
flipper.setOutAnimation(outToLeft);
flipper.showNext();
@@ -167,12 +168,13 @@ public class DocumentLoader
Animation inFromLeft = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- inFromLeft.setDuration(500);
+ int duration = Math.abs((int)((float)flipper.getWidth()/velocityX*1000f));
+ inFromLeft.setDuration(duration);
flipper.setInAnimation(inFromLeft);
Animation outToRight = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 1,
Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0);
- outToRight.setDuration(500);
+ outToRight.setDuration(duration);
flipper.setOutAnimation(outToRight);
flipper.showPrevious();