public class PhotoViewAttacher extends java.lang.Object implements IPhotoView, android.view.View.OnTouchListener, OnGestureListener, android.view.ViewTreeObserver.OnGlobalLayoutListener
| Modifier and Type | Class and Description |
|---|---|
static interface |
PhotoViewAttacher.OnMatrixChangedListener
Interface definition for a callback to be invoked when the internal Matrix has changed for
this View.
|
static interface |
PhotoViewAttacher.OnPhotoTapListener
Interface definition for a callback to be invoked when the Photo is tapped with a single
tap.
|
static interface |
PhotoViewAttacher.OnScaleChangeListener
Interface definition for callback to be invoked when attached ImageView scale changes
|
static interface |
PhotoViewAttacher.OnSingleFlingListener
Interface definition for a callback to be invoked when the ImageView is fling with a single
touch
|
static interface |
PhotoViewAttacher.OnViewTapListener
Interface definition for a callback to be invoked when the ImageView is tapped with a single
tap.
|
DEFAULT_MAX_SCALE, DEFAULT_MID_SCALE, DEFAULT_MIN_SCALE, DEFAULT_ZOOM_DURATION| Constructor and Description |
|---|
PhotoViewAttacher(android.widget.ImageView imageView) |
PhotoViewAttacher(android.widget.ImageView imageView,
boolean zoomable) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canZoom()
Returns true if the PhotoView is set to allow zooming of Photos.
|
void |
cleanup()
Clean-up the resources attached to this object.
|
void |
getDisplayMatrix(android.graphics.Matrix matrix)
Get the display matrix
|
android.graphics.RectF |
getDisplayRect()
Gets the Display Rectangle of the currently displayed Drawable.
|
android.graphics.Matrix |
getImageMatrix() |
android.widget.ImageView |
getImageView() |
IPhotoView |
getIPhotoViewImplementation()
Will return instance of IPhotoView (eg.
|
float |
getMaximumScale() |
float |
getMediumScale() |
float |
getMinimumScale() |
float |
getScale()
Returns the current scale value
|
android.widget.ImageView.ScaleType |
getScaleType()
Return the current scale type in use by the ImageView.
|
void |
getSuppMatrix(android.graphics.Matrix matrix)
Get the current support matrix
|
android.graphics.Bitmap |
getVisibleRectangleBitmap()
Extracts currently visible area to Bitmap object, if there is no image loaded yet or the
ImageView is already destroyed, returns
null |
void |
onDrag(float dx,
float dy) |
void |
onFling(float startX,
float startY,
float velocityX,
float velocityY) |
void |
onGlobalLayout() |
void |
onScale(float scaleFactor,
float focusX,
float focusY) |
boolean |
onTouch(android.view.View v,
android.view.MotionEvent ev) |
void |
setAllowParentInterceptOnEdge(boolean allow)
Whether to allow the ImageView's parent to intercept the touch event when the photo is scroll
to it's horizontal edge.
|
void |
setBaseRotation(float degrees) |
boolean |
setDisplayMatrix(android.graphics.Matrix finalMatrix)
Sets the Display Matrix of the currently displayed Drawable.
|
void |
setMaximumScale(float maximumScale)
Sets the maximum scale level.
|
void |
setMediumScale(float mediumScale)
Sets the medium scale level.
|
void |
setMinimumScale(float minimumScale)
Sets the minimum scale level.
|
void |
setOnDoubleTapListener(android.view.GestureDetector.OnDoubleTapListener newOnDoubleTapListener)
Sets custom double tap listener, to intercept default given functions.
|
void |
setOnLongClickListener(android.view.View.OnLongClickListener listener)
Register a callback to be invoked when the Photo displayed by this view is long-pressed.
|
void |
setOnMatrixChangeListener(PhotoViewAttacher.OnMatrixChangedListener listener)
Register a callback to be invoked when the Matrix has changed for this View.
|
void |
setOnPhotoTapListener(PhotoViewAttacher.OnPhotoTapListener listener)
Register a callback to be invoked when the Photo displayed by this View is tapped with a
single tap.
|
void |
setOnScaleChangeListener(PhotoViewAttacher.OnScaleChangeListener onScaleChangeListener)
Will report back about scale changes
|
void |
setOnSingleFlingListener(PhotoViewAttacher.OnSingleFlingListener onSingleFlingListener)
Will report back about fling(single touch)
|
void |
setOnViewTapListener(PhotoViewAttacher.OnViewTapListener listener)
Register a callback to be invoked when the View is tapped with a single tap.
|
void |
setRotationBy(float degrees)
Enables rotation via PhotoView internal functions.
|
void |
setRotationTo(float degrees)
Enables rotation via PhotoView internal functions.
|
void |
setScale(float scale)
Changes the current scale to the specified value.
|
void |
setScale(float scale,
boolean animate)
Changes the current scale to the specified value.
|
void |
setScale(float scale,
float focalX,
float focalY,
boolean animate)
Changes the current scale to the specified value, around the given focal point.
|
void |
setScaleLevels(float minimumScale,
float mediumScale,
float maximumScale)
Allows to set all three scale levels at once, so you don't run into problem with setting
medium/minimum scale before the maximum one
|
void |
setScaleType(android.widget.ImageView.ScaleType scaleType)
Controls how the image should be resized or moved to match the size of the ImageView.
|
void |
setZoomable(boolean zoomable)
Allows you to enable/disable the zoom functionality on the ImageView.
|
void |
setZoomInterpolator(android.view.animation.Interpolator interpolator)
Set the zoom interpolator
|
void |
setZoomTransitionDuration(int milliseconds)
Allows to change zoom transition speed, default value is 200 (PhotoViewAttacher.DEFAULT_ZOOM_DURATION).
|
void |
update() |
public PhotoViewAttacher(android.widget.ImageView imageView)
public PhotoViewAttacher(android.widget.ImageView imageView,
boolean zoomable)
public void setOnDoubleTapListener(android.view.GestureDetector.OnDoubleTapListener newOnDoubleTapListener)
IPhotoViewsetOnDoubleTapListener in interface IPhotoViewnewOnDoubleTapListener - custom OnDoubleTapListener to be set on ImageViewpublic void setOnScaleChangeListener(PhotoViewAttacher.OnScaleChangeListener onScaleChangeListener)
IPhotoViewsetOnScaleChangeListener in interface IPhotoViewonScaleChangeListener - OnScaleChangeListener instancepublic void setOnSingleFlingListener(PhotoViewAttacher.OnSingleFlingListener onSingleFlingListener)
IPhotoViewsetOnSingleFlingListener in interface IPhotoViewonSingleFlingListener - OnSingleFlingListener instancepublic boolean canZoom()
IPhotoViewcanZoom in interface IPhotoViewpublic void cleanup()
View.onDetachedFromWindow() or
from android.app.Activity#onDestroy(). This is automatically called if you are using
PhotoView.public android.graphics.RectF getDisplayRect()
IPhotoViewgetDisplayRect in interface IPhotoViewpublic boolean setDisplayMatrix(android.graphics.Matrix finalMatrix)
IPhotoViewsetDisplayMatrix in interface IPhotoViewfinalMatrix - target matrix to set PhotoView topublic void setBaseRotation(float degrees)
public void setRotationTo(float degrees)
IPhotoViewsetRotationTo in interface IPhotoViewdegrees - - Degree to rotate PhotoView to, should be in range 0 to 360public void setRotationBy(float degrees)
IPhotoViewsetRotationBy in interface IPhotoViewdegrees - - Degree to rotate PhotoView by, should be in range 0 to 360public android.widget.ImageView getImageView()
public float getMinimumScale()
getMinimumScale in interface IPhotoViewImageView.ScaleType.public float getMediumScale()
getMediumScale in interface IPhotoViewImageView.ScaleType.public float getMaximumScale()
getMaximumScale in interface IPhotoViewImageView.ScaleType.public float getScale()
IPhotoViewgetScale in interface IPhotoViewpublic android.widget.ImageView.ScaleType getScaleType()
IPhotoViewgetScaleType in interface IPhotoViewpublic void onDrag(float dx,
float dy)
onDrag in interface OnGestureListenerpublic void onFling(float startX,
float startY,
float velocityX,
float velocityY)
onFling in interface OnGestureListenerpublic void onGlobalLayout()
onGlobalLayout in interface android.view.ViewTreeObserver.OnGlobalLayoutListenerpublic void onScale(float scaleFactor,
float focusX,
float focusY)
onScale in interface OnGestureListenerpublic boolean onTouch(android.view.View v,
android.view.MotionEvent ev)
onTouch in interface android.view.View.OnTouchListenerpublic void setAllowParentInterceptOnEdge(boolean allow)
IPhotoViewsetAllowParentInterceptOnEdge in interface IPhotoViewallow - whether to allow intercepting by parent element or notpublic void setMinimumScale(float minimumScale)
IPhotoViewImageView.ScaleType.setMinimumScale in interface IPhotoViewminimumScale - minimum allowed scalepublic void setMediumScale(float mediumScale)
IPhotoViewImageView.ScaleType.setMediumScale in interface IPhotoViewmediumScale - medium scale presetpublic void setMaximumScale(float maximumScale)
IPhotoViewImageView.ScaleType.setMaximumScale in interface IPhotoViewmaximumScale - maximum allowed scale presetpublic void setScaleLevels(float minimumScale,
float mediumScale,
float maximumScale)
IPhotoViewsetScaleLevels in interface IPhotoViewminimumScale - minimum allowed scalemediumScale - medium allowed scalemaximumScale - maximum allowed scale presetpublic void setOnLongClickListener(android.view.View.OnLongClickListener listener)
IPhotoViewsetOnLongClickListener in interface IPhotoViewlistener - - Listener to be registered.public void setOnMatrixChangeListener(PhotoViewAttacher.OnMatrixChangedListener listener)
IPhotoViewsetOnMatrixChangeListener in interface IPhotoViewlistener - - Listener to be registered.public void setOnPhotoTapListener(PhotoViewAttacher.OnPhotoTapListener listener)
IPhotoViewsetOnPhotoTapListener in interface IPhotoViewlistener - - Listener to be registered.public void setOnViewTapListener(PhotoViewAttacher.OnViewTapListener listener)
IPhotoViewsetOnViewTapListener in interface IPhotoViewlistener - - Listener to be registered.public void setScale(float scale)
IPhotoViewsetScale in interface IPhotoViewscale - - Value to scale topublic void setScale(float scale,
boolean animate)
IPhotoViewsetScale in interface IPhotoViewscale - - Value to scale toanimate - - Whether to animate the scalepublic void setScale(float scale,
float focalX,
float focalY,
boolean animate)
IPhotoViewsetScale in interface IPhotoViewscale - - Value to scale tofocalX - - X Focus PointfocalY - - Y Focus Pointanimate - - Whether to animate the scalepublic void setZoomInterpolator(android.view.animation.Interpolator interpolator)
interpolator - the zoom interpolatorpublic void setScaleType(android.widget.ImageView.ScaleType scaleType)
IPhotoViewImageView.ScaleType.setScaleType in interface IPhotoViewscaleType - - The desired scaling mode.public void setZoomable(boolean zoomable)
IPhotoViewsetZoomable in interface IPhotoViewzoomable - - Whether the zoom functionality is enabled.public void update()
public void getDisplayMatrix(android.graphics.Matrix matrix)
getDisplayMatrix in interface IPhotoViewmatrix - target matrix to copy topublic void getSuppMatrix(android.graphics.Matrix matrix)
public android.graphics.Matrix getImageMatrix()
public android.graphics.Bitmap getVisibleRectangleBitmap()
IPhotoViewnullgetVisibleRectangleBitmap in interface IPhotoViewpublic void setZoomTransitionDuration(int milliseconds)
IPhotoViewsetZoomTransitionDuration in interface IPhotoViewmilliseconds - duration of zoom interpolationpublic IPhotoView getIPhotoViewImplementation()
IPhotoViewgetIPhotoViewImplementation in interface IPhotoView