Add ImageBoundsListener to the zoomable controller
Summary: In this diff, I've added an interface ImageBoundsListener to the zoomable controller so that actions can be performed after we know that the image bounds have been set.
@@ -29,6 +29,11 @@ import java.lang.annotation.RetentionPolicy;
public class DefaultZoomableController
implements ZoomableController, TransformGestureDetector.Listener {
+ /** Interface for handling call backs when the image bounds are set. */
+ public interface ImageBoundsListener {
+ void onImageBoundsSet(RectF imageBounds);
+ }
+
@IntDef(flag=true, value={
LIMIT_NONE,
LIMIT_TRANSLATION_X,
@@ -53,6 +58,8 @@ public class DefaultZoomableController
private TransformGestureDetector mGestureDetector;
+ private @Nullable ImageBoundsListener mImageBoundsListener;
+
private @Nullable Listener mListener = null;
private boolean mIsEnabled = false;
@@ -195,6 +202,9 @@ public class DefaultZoomableController
if (!imageBounds.equals(mImageBounds)) {
mImageBounds.set(imageBounds);
onTransformChanged();
+ if (mImageBoundsListener != null) {
+ mImageBoundsListener.onImageBoundsSet(mImageBounds);
+ }
}
}
@@ -219,6 +229,16 @@ public class DefaultZoomableController
return mViewBounds;
}
+ /** Sets the image bounds listener. */
+ public void setImageBoundsListener(@Nullable ImageBoundsListener imageBoundsListener) {
+ mImageBoundsListener = imageBoundsListener;
+ }
+
+ /** Gets the image bounds listener. */
+ public @Nullable ImageBoundsListener getImageBoundsListener() {
+ return mImageBoundsListener;
+ }
+
/**
* Returns true if the zoomable transform is identity matrix.
*/
