summaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorIain Billett <iainbillett@gmail.com>2012-08-10 12:30:38 +0100
committerIain Billett <iainbillett@gmail.com>2012-08-15 11:35:22 +0100
commit6078a319491c0342aba883ba498f92f056a5e85d (patch)
treeaa3c7ab873d7221ff7666c88635a90c2814614ce /android
parentrestore the old value for SID_ATTR_ZOOM (diff)
downloadcore-6078a319491c0342aba883ba498f92f056a5e85d.tar.gz
core-6078a319491c0342aba883ba498f92f056a5e85d.zip
Moved Animation code to DocumentViewer.
Change-Id: I3a21783a1ade19bd0c868f58137d244a13e0d132
Diffstat (limited to 'android')
-rw-r--r--android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java53
1 files changed, 31 insertions, 22 deletions
diff --git a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
index edfb13b383a4..b7da4b99cf52 100644
--- a/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
+++ b/android/experimental/LibreOffice4Android/src/org/libreoffice/android/DocumentLoader.java
@@ -148,33 +148,11 @@ public class DocumentLoader
if (event1.getX() - event2.getX() > 120) {
if (((PageViewer)flipper.getCurrentView()).currentPageNumber == pageCount-1)
return false;
-
- 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);
- 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);
- flipper.setOutAnimation(outToLeft);
-
documentViewer.nextPage();
return true;
} else if (event2.getX() - event1.getX() > 120) {
if (((PageViewer)flipper.getCurrentView()).currentPageNumber == 0)
return false;
-
- 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);
- 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);
- flipper.setOutAnimation(outToRight);
-
documentViewer.prevPage();
return true;
}
@@ -811,6 +789,11 @@ public class DocumentLoader
Log.i( TAG , "Page " + Integer.toString( newPage ) + " is out of Bounds [0," + Integer.toString(lastPage) + "]" );
return;
}
+ if( newPage - currentPage > 0 ){
+ setAnimationInFromRight();
+ }else{
+ setAnimationInFromLeft();
+ }
viewFlipper.addView( fetch( newPage ) );
viewFlipper.setDisplayedChild( 1 );//remove after so that transition has two pages.
viewFlipper.removeViewAt( 0 );
@@ -819,6 +802,32 @@ public class DocumentLoader
currentPage = newPage;
}
+ private void setAnimationInFromRight(){//going forward
+ 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);
+ viewFlipper.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);
+ viewFlipper.setOutAnimation(outToLeft);
+ return;
+ }
+
+ private void setAnimationInFromLeft(){
+ 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);
+ viewFlipper.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);
+ viewFlipper.setOutAnimation(outToRight);
+ return;
+ }
+
private PageViewer fetch( int page ){
int cacheIndex = pageNumbers.indexOf( page );
if( cacheIndex != -1 ){