From 0179c9628258f30c41121a1ff3a50fcebe44d776 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 27 Jun 2012 12:54:41 +0300 Subject: [PATCH] Adapt page switch animation duration to fling velocity Change-Id: I30e177b45b0e25d92fd7dea02ffe4e9c0731dce5 --- .../libreoffice/android/examples/DocumentLoader.java | 10 ++++++---- 1 file 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();