Skip to content

Commit

Permalink
Can now be added to XML layout.
Browse files Browse the repository at this point in the history
Added support for setting bitmap to null without throwing exception.

Signed-off-by: Patrick Lackemacher <[email protected]>
  • Loading branch information
plackemacher authored and MikeOrtiz committed Feb 22, 2012
1 parent c357c0d commit 39bb8d4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="output" path="bin"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
10 changes: 8 additions & 2 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Android: TouchImageView
Created by: Mike Ortiz
Date: 9/17/2011
Updated by: Patrick Lackemacher
Date: 2/17/2012
----------------------
Adds panning and pinch zoom to Android ImageView.
Adds panning and pinch zoom to Android ImageView.

Update:
----------------------
Can now be added to XML layout.
Added support for setting bitmap to null without throwing exception.
Empty file removed README~
Empty file.
11 changes: 0 additions & 11 deletions default.properties

This file was deleted.

20 changes: 16 additions & 4 deletions src/com/example/touch/TouchImageView.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
* TouchImageView.java
* By: Michael Ortiz
* Updated By: Patrick Lackemacher
* -------------------
* Extends Android ImageView to include pinch zooming and panning.
*/
Expand All @@ -11,6 +12,7 @@
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.PointF;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
Expand Down Expand Up @@ -44,10 +46,18 @@ public class TouchImageView extends ImageView {

Context context;


public TouchImageView(Context context) {
super(context);
super.setClickable(true);
sharedConstructing(context);
}

public TouchImageView(Context context, AttributeSet attrs) {
super(context, attrs);
sharedConstructing(context);
}

private void sharedConstructing(Context context) {
super.setClickable(true);
this.context = context;
mScaleDetector = new ScaleGestureDetector(context, new ScaleListener());
matrix.setTranslate(1f, 1f);
Expand Down Expand Up @@ -129,8 +139,10 @@ else if (y + deltaY < -bottom)
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
bmWidth = bm.getWidth();
bmHeight = bm.getHeight();
if(bm != null) {
bmWidth = bm.getWidth();
bmHeight = bm.getHeight();
}
}

public void setMaxZoom(float x)
Expand Down

0 comments on commit 39bb8d4

Please sign in to comment.