Skip to content

Commit

Permalink
Merge pull request #278 from Sirelon/master
Browse files Browse the repository at this point in the history
HotFix for #271
  • Loading branch information
KucherenkoIhor authored Apr 3, 2017
2 parents 0add52a + 454e723 commit 62767ce
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ucrop/src/main/java/com/yalantis/ucrop/view/UCropView.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

public class UCropView extends FrameLayout {

private final GestureCropImageView mGestureCropImageView;
private GestureCropImageView mGestureCropImageView;
private final OverlayView mViewOverlay;

public UCropView(Context context, AttributeSet attrs) {
Expand All @@ -34,6 +34,10 @@ public UCropView(Context context, AttributeSet attrs, int defStyleAttr) {
a.recycle();


setListenersToViews();
}

private void setListenersToViews() {
mGestureCropImageView.setCropBoundsChangeListener(new CropBoundsChangeListener() {
@Override
public void onCropAspectRatioChanged(float cropRatio) {
Expand Down Expand Up @@ -63,4 +67,15 @@ public OverlayView getOverlayView() {
return mViewOverlay;
}

/**
* Method for reset state for UCropImageView such as rotation, scale, translation.
* Be careful: this method recreate UCropImageView instance and reattach it to layout.
*/
public void resetCropImageView() {
removeView(mGestureCropImageView);
mGestureCropImageView = new GestureCropImageView(getContext());
setListenersToViews();
mGestureCropImageView.setCropRect(getOverlayView().getCropViewRect());
addView(mGestureCropImageView, 0);
}
}

0 comments on commit 62767ce

Please sign in to comment.