Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions main/.classpath
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
2 changes: 1 addition & 1 deletion main/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
# project structure.

# Project target.
target=android-7
target=android-16
android.library=true
22 changes: 15 additions & 7 deletions main/src/com/polites/android/GestureImageView.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.io.InputStream;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;

import android.content.Context;
import android.content.res.Configuration;
import android.database.Cursor;
Expand Down Expand Up @@ -263,12 +264,8 @@ protected void computeStartingScale(int imageWidth, int imageHeight, int measure
break;

case CENTER_INSIDE:
if(isLandscape()) {
startingScale = fitScaleHorizontal;
}
else {
startingScale = fitScaleVertical;
}
// FIX center inside should not crop the image
startingScale = Math.min(fitScaleHorizontal, fitScaleVertical);
break;
}
}
Expand Down Expand Up @@ -373,11 +370,15 @@ protected void initImage() {
if(colorFilter != null) {
this.drawable.setColorFilter(colorFilter);
}
// Keppel.Cao
layout = false;
startingScale = -1.0f;
}

if(!layout) {
requestLayout();
redraw();
// redraw();
reset();
}
}

Expand Down Expand Up @@ -709,4 +710,11 @@ else if(deviceOrientation == Configuration.ORIENTATION_PORTRAIT) {
public int getDeviceOrientation() {
return deviceOrientation;
}

public boolean isZoomed() {
if (gestureImageViewTouchListener != null) {
return gestureImageViewTouchListener.isZoomed();
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class GestureImageViewTouchListener implements OnTouchListener {

private boolean touched = false;
private boolean inZoom = false;
private boolean isZoomed = false;

private float initialDistance;
private float lastScale = 1.0f;
Expand Down Expand Up @@ -136,6 +137,7 @@ public void onZoom(float scale, float x, float y) {
public void onComplete() {
inZoom = false;
handleUp();
isZoomed = zoomAnimation.getZoom() > 1.0;
}
});

Expand Down Expand Up @@ -279,6 +281,7 @@ public boolean onTouch(View v, MotionEvent event) {

if(event.getAction() == MotionEvent.ACTION_UP) {
handleUp();
isZoomed = !(lastScale == startingScale);
}
else if(event.getAction() == MotionEvent.ACTION_DOWN) {
stopAnimations();
Expand Down Expand Up @@ -537,4 +540,8 @@ protected void calculateBoundaries() {
boundaryBottom = centerY + diff;
}
}

public boolean isZoomed() {
return isZoomed;
}
}