diff --git a/.gitignore b/.gitignore
index a374eb6..c9789bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
example/bin
example/gen
+example/local.properties
main/bin/
main/gen/
+main/local.properties
diff --git a/example/AndroidManifest.xml b/example/AndroidManifest.xml
index 2cb5ec7..8002d09 100644
--- a/example/AndroidManifest.xml
+++ b/example/AndroidManifest.xml
@@ -25,6 +25,7 @@
+
diff --git a/example/build.xml b/example/build.xml
new file mode 100644
index 0000000..603b851
--- /dev/null
+++ b/example/build.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/example/proguard-project.txt b/example/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/example/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/example/src/com/polites/android/example/ChangeImage.java b/example/src/com/polites/android/example/ChangeImage.java
new file mode 100644
index 0000000..316e16b
--- /dev/null
+++ b/example/src/com/polites/android/example/ChangeImage.java
@@ -0,0 +1,39 @@
+package com.polites.android.example;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.view.ViewGroup;
+import android.widget.LinearLayout.LayoutParams;
+import com.polites.android.GestureImageView;
+
+public class ChangeImage extends Activity {
+
+ private GestureImageView view;
+ private static final int IMAGE_LOAD = 10001;
+ private final Handler handler = new Handler() {
+
+ @Override
+ public void handleMessage(Message msg) {
+ if(msg.what == IMAGE_LOAD) {
+ view.setImageResource(R.drawable.image);
+ view.redraw();
+ }
+ super.handleMessage(msg);
+ }
+ };
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.empty);
+ LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
+ view = new GestureImageView(this);
+ view.setImageResource(R.drawable.square);
+ view.setLayoutParams(params);
+ ViewGroup layout = (ViewGroup) findViewById(R.id.layout);
+ layout.addView(view);
+ handler.sendEmptyMessageDelayed(IMAGE_LOAD, 5000);
+ }
+}
\ No newline at end of file
diff --git a/example/src/com/polites/android/example/Main.java b/example/src/com/polites/android/example/Main.java
index 3692c6e..33f8d2f 100644
--- a/example/src/com/polites/android/example/Main.java
+++ b/example/src/com/polites/android/example/Main.java
@@ -40,6 +40,7 @@ public class Main extends ListActivity {
"Single Image Programmatic with onClick event",
"Single Image Programmatic with start scale & position",
"Single Image XML Layout with start scale & position",
+ "Change Image (With delayed load)",
"Double Image (With delayed load)",
"ScaleType CENTER Large",
"ScaleType CENTER_CROP Large",
@@ -61,6 +62,7 @@ public class Main extends ListActivity {
StandardImageProgrammaticWithOnClick.class,
StandardImageProgrammaticWithStartSettings.class,
StandardImageXMLWithStartSettings.class,
+ ChangeImage.class,
DoubleImage.class,
ScaleTypeCenter.class,
ScaleTypeCenterCrop.class,
diff --git a/main/local.properties b/main/local.properties
deleted file mode 100644
index 13de829..0000000
--- a/main/local.properties
+++ /dev/null
@@ -1,10 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must *NOT* be checked in Version Control Systems,
-# as it contains information specific to your local configuration.
-
-# location of the SDK. This is only used by Ant
-# For customization when using a Version Control System, please read the
-# header note.
-sdk.dir=/android
diff --git a/main/proguard-project.txt b/main/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/main/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/main/src/com/polites/android/GestureImageView.java b/main/src/com/polites/android/GestureImageView.java
index b0d72c6..f964ba0 100644
--- a/main/src/com/polites/android/GestureImageView.java
+++ b/main/src/com/polites/android/GestureImageView.java
@@ -373,11 +373,15 @@ protected void initImage() {
if(colorFilter != null) {
this.drawable.setColorFilter(colorFilter);
}
+ // Keppel.Cao
+ layout = false;
+ startingScale = -1.0f;
}
-
if(!layout) {
requestLayout();
- redraw();
+ // Keppel.Cao
+ // redraw();
+ reset();
}
}
@@ -494,6 +498,16 @@ public void reset() {
redraw();
}
+ public void setTo(float newX, float newY, float newScale) {
+ x = newX;
+ y = newY;
+ scaleAdjust = newScale;
+ if (gestureImageViewTouchListener != null) {
+ gestureImageViewTouchListener.setTo(newX, newY, newScale);
+ }
+ redraw();
+ }
+
public void setRotation(float rotation) {
this.rotation = rotation;
}
diff --git a/main/src/com/polites/android/GestureImageViewTouchListener.java b/main/src/com/polites/android/GestureImageViewTouchListener.java
index 42e6cda..de8481c 100644
--- a/main/src/com/polites/android/GestureImageViewTouchListener.java
+++ b/main/src/com/polites/android/GestureImageViewTouchListener.java
@@ -359,6 +359,7 @@ protected void handleUp() {
multiTouch = false;
+ //currentScale = image.getScale(); // fix by silentw for issue #27
initialDistance = 0;
lastScale = currentScale;
@@ -453,7 +454,7 @@ protected boolean handleDrag(float x, float y) {
return false;
}
-
+
public void reset() {
currentScale = startingScale;
next.x = centerX;
@@ -463,7 +464,17 @@ public void reset() {
image.setPosition(next.x, next.y);
image.redraw();
}
-
+
+ public void setTo(float newX, float newY, float newScale) {
+ currentScale = newScale;
+ lastScale = newScale;
+ next.x = newX;
+ next.y = newY;
+ calculateBoundaries();
+ image.setScale(currentScale);
+ image.setPosition(next.x, next.y);
+ image.redraw();
+ }
public float getMaxScale() {
return maxScale;