[Android] Blind fix at SlidingMenu
Edward Wang
git at videolan.org
Fri Sep 28 03:19:40 CEST 2012
vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Thu Sep 27 19:28:44 2012 -0400| [6f9599b7106bb67997194a2c2649632979772e9d] | committer: Edward Wang
Blind fix at SlidingMenu
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=6f9599b7106bb67997194a2c2649632979772e9d
---
java-libs/SlidingMenu/build.xml | 17 ++--
java-libs/SlidingMenu/res/values/ids.xml | 5 ++
.../slidingmenu/lib/CanvasTranformerBuilder.java | 95 ++++++++++++++++++++
3 files changed, 108 insertions(+), 9 deletions(-)
diff --git a/java-libs/SlidingMenu/build.xml b/java-libs/SlidingMenu/build.xml
index f60a254..828a18c 100644
--- a/java-libs/SlidingMenu/build.xml
+++ b/java-libs/SlidingMenu/build.xml
@@ -28,15 +28,6 @@
-->
<property file="ant.properties" />
- <!-- if sdk.dir was not set from one of the property file, then
- get it from the ANDROID_HOME env var.
- This must be done before we load project.properties since
- the proguard config can use sdk.dir -->
- <property environment="env" />
- <condition property="sdk.dir" value="${env.ANDROID_HOME}">
- <isset property="env.ANDROID_HOME" />
- </condition>
-
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
@@ -48,6 +39,14 @@
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
+ <property environment="env" />
+ <condition property="sdk.dir" value="${env.ANDROID_SDK}" >
+ <and>
+ <not><isset property="${env.ANDROID_SDK}"/></not>
+ <not><isset property="sdk.dir"/></not>
+ </and>
+ </condition>
+
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
diff --git a/java-libs/SlidingMenu/res/values/ids.xml b/java-libs/SlidingMenu/res/values/ids.xml
new file mode 100644
index 0000000..eac70c9
--- /dev/null
+++ b/java-libs/SlidingMenu/res/values/ids.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+ <item name="selected_view" type="id"/>
+
+</resources>
\ No newline at end of file
diff --git a/java-libs/SlidingMenu/src/com/slidingmenu/lib/CanvasTranformerBuilder.java b/java-libs/SlidingMenu/src/com/slidingmenu/lib/CanvasTranformerBuilder.java
new file mode 100644
index 0000000..d1a037d
--- /dev/null
+++ b/java-libs/SlidingMenu/src/com/slidingmenu/lib/CanvasTranformerBuilder.java
@@ -0,0 +1,95 @@
+package com.slidingmenu.lib;
+
+import android.graphics.Canvas;
+import android.view.animation.Interpolator;
+
+import com.slidingmenu.lib.SlidingMenu.CanvasTransformer;
+
+public class CanvasTranformerBuilder {
+
+ private CanvasTransformer mTrans;
+
+ private static Interpolator lin = new Interpolator() {
+ public float getInterpolation(float t) {
+ return t;
+ }
+ };
+
+ private void initTransformer() {
+ if (mTrans == null)
+ mTrans = new CanvasTransformer() {
+ public void transformCanvas(Canvas canvas, float percentOpen) { }
+ };
+ }
+
+ public CanvasTransformer zoom(final int openedX, final int closedX,
+ final int openedY, final int closedY,
+ final int px, final int py) {
+ return zoom(openedX, closedX, openedY, closedY, px, py, lin);
+ }
+
+ public CanvasTransformer zoom(final int openedX, final int closedX,
+ final int openedY, final int closedY,
+ final int px, final int py, final Interpolator interp) {
+ initTransformer();
+ mTrans = new CanvasTransformer() {
+ public void transformCanvas(Canvas canvas, float percentOpen) {
+ mTrans.transformCanvas(canvas, percentOpen);
+ float f = interp.getInterpolation(percentOpen);
+ canvas.scale((openedX - closedX) * f + closedX,
+ (openedY - closedY) * f + closedY, px, py);
+ }
+ };
+ return mTrans;
+ }
+
+ public CanvasTransformer rotate(final int openedDeg, final int closedDeg,
+ final int px, final int py) {
+ return rotate(openedDeg, closedDeg, px, py, lin);
+ }
+
+ public CanvasTransformer rotate(final int openedDeg, final int closedDeg,
+ final int px, final int py, final Interpolator interp) {
+ initTransformer();
+ mTrans = new CanvasTransformer() {
+ public void transformCanvas(Canvas canvas, float percentOpen) {
+ mTrans.transformCanvas(canvas, percentOpen);
+ float f = interp.getInterpolation(percentOpen);
+ canvas.rotate((openedDeg - closedDeg) * f + closedDeg,
+ px, py);
+ }
+ };
+ return mTrans;
+ }
+
+ public CanvasTransformer translate(final int openedX, final int closedX,
+ final int openedY, final int closedY) {
+ return translate(openedX, closedX, openedY, closedY, lin);
+ }
+
+ public CanvasTransformer translate(final int openedX, final int closedX,
+ final int openedY, final int closedY, final Interpolator interp) {
+ initTransformer();
+ mTrans = new CanvasTransformer() {
+ public void transformCanvas(Canvas canvas, float percentOpen) {
+ mTrans.transformCanvas(canvas, percentOpen);
+ float f = interp.getInterpolation(percentOpen);
+ canvas.translate((openedX - closedX) * f + closedX,
+ (openedY - closedY) * f + closedY);
+ }
+ };
+ return mTrans;
+ }
+
+ public CanvasTransformer concatTransformer(final CanvasTransformer t) {
+ initTransformer();
+ mTrans = new CanvasTransformer() {
+ public void transformCanvas(Canvas canvas, float percentOpen) {
+ mTrans.transformCanvas(canvas, percentOpen);
+ t.transformCanvas(canvas, percentOpen);
+ }
+ };
+ return mTrans;
+ }
+
+}
More information about the Android
mailing list