2015-06-04 13:21:20 -07:00
|
|
|
package org.thoughtcrime.securesms.components;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.graphics.Bitmap;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.util.AttributeSet;
|
|
|
|
import android.widget.ImageView;
|
|
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
2016-10-16 19:05:07 -07:00
|
|
|
import com.bumptech.glide.load.engine.DiskCacheStrategy;
|
2015-07-15 13:42:59 -07:00
|
|
|
import com.bumptech.glide.load.resource.drawable.GlideDrawable;
|
2015-06-04 13:21:20 -07:00
|
|
|
import com.bumptech.glide.request.target.BitmapImageViewTarget;
|
2015-07-15 13:42:59 -07:00
|
|
|
import com.bumptech.glide.request.target.GlideDrawableImageViewTarget;
|
2015-06-04 13:21:20 -07:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
|
|
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
|
|
|
|
|
|
|
import uk.co.senab.photoview.PhotoViewAttacher;
|
|
|
|
|
|
|
|
public class ZoomingImageView extends ImageView {
|
|
|
|
private PhotoViewAttacher attacher = new PhotoViewAttacher(this);
|
|
|
|
|
|
|
|
public ZoomingImageView(Context context) {
|
|
|
|
super(context);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ZoomingImageView(Context context, AttributeSet attrs) {
|
|
|
|
super(context, attrs);
|
|
|
|
}
|
|
|
|
|
|
|
|
public ZoomingImageView(Context context, AttributeSet attrs, int defStyleAttr) {
|
|
|
|
super(context, attrs, defStyleAttr);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setImageUri(MasterSecret masterSecret, Uri uri) {
|
|
|
|
Glide.with(getContext())
|
|
|
|
.load(new DecryptableUri(masterSecret, uri))
|
2016-10-16 19:05:07 -07:00
|
|
|
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
2015-06-04 13:21:20 -07:00
|
|
|
.dontTransform()
|
|
|
|
.dontAnimate()
|
2015-07-15 13:42:59 -07:00
|
|
|
.into(new GlideDrawableImageViewTarget(this) {
|
|
|
|
@Override protected void setResource(GlideDrawable resource) {
|
2015-06-04 13:21:20 -07:00
|
|
|
super.setResource(resource);
|
|
|
|
attacher.update();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|