package org.edx.mobile.view;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.bumptech.glide.Glide;

import org.edx.mobile.R;

import it.sephiroth.android.library.imagezoom.ImageViewTouch;

public class CropImageActivity extends Activity {
    public static final String EXTRA_IMAGE_URI = "imageUri";

    public static Intent newIntent(@NonNull Context context, @NonNull Uri imageUri) {
        return new Intent(context, CropImageActivity.class)
                .putExtra(EXTRA_IMAGE_URI, imageUri);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_crop_image);
        final ImageViewTouch imageView = (ImageViewTouch) findViewById(R.id.image);
        final Uri imageUri = getIntent().getParcelableExtra(EXTRA_IMAGE_URI);
        Glide.with(this).load(imageUri).dontAnimate().into(imageView);
    }
}

@@ -285,16 +285,180 @@
 e.Glide;
+%0Aimport com.bumptech.glide.load.resource.drawable.GlideDrawable;%0Aimport com.bumptech.glide.request.RequestListener;%0Aimport com.bumptech.glide.request.target.Target;
 %0A%0Aimport
@@ -538,16 +538,82 @@
 ewTouch;
+%0Aimport it.sephiroth.android.library.imagezoom.ImageViewTouchBase;
 %0A%0Apublic
@@ -1180,32 +1180,103 @@
 Id(R.id.image);%0A
+        imageView.setDisplayType(ImageViewTouchBase.DisplayType.NONE);%0A
         final Ur
@@ -1337,16 +1337,16 @@
 E_URI);%0A
-
         
@@ -1391,16 +1391,789 @@
 imate().
+listener(new RequestListener%3CUri, GlideDrawable%3E() %7B%0A            @Override%0A            public boolean onException(Exception e, Uri model, Target%3CGlideDrawable%3E target, boolean isFirstResource) %7B%0A                return false;%0A            %7D%0A%0A            @Override%0A            public boolean onResourceReady(GlideDrawable resource, Uri model, Target%3CGlideDrawable%3E target, boolean isFromMemoryCache, boolean isFirstResource) %7B%0A                final float minZoom = Math.max(%0A                        (float)resource.getIntrinsicWidth() / imageView.getWidth(),%0A                        (float)resource.getIntrinsicHeight() / imageView.getHeight());%0A                imageView.setImageDrawable(resource, null, minZoom, 10.0f);%0A                return true;%0A            %7D%0A        %7D).
 into(ima

Set minimum scale so crop is always valid