Search in sources :

Example 6 with PhotoViewAttacher

use of com.github.chrisbanes.photoview.PhotoViewAttacher in project Pix-Art-Messenger by kriztan.

the class ShowFullscreenMessageActivity method DisplayImage.

private void DisplayImage(final File file) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(new File(file.getPath()).getAbsolutePath(), options);
    height = options.outHeight;
    width = options.outWidth;
    rotation = getRotation(Uri.parse("file://" + file.getAbsolutePath()));
    Log.d(Config.LOGTAG, "Image height: " + height + ", width: " + width + ", rotation: " + rotation);
    if (useAutoRotateScreen()) {
        rotateScreen(width, height, rotation);
    }
    final PhotoViewAttacher mAttacher = new PhotoViewAttacher(mImage);
    mImage.setVisibility(View.VISIBLE);
    try {
        Glide.with(this).load(file).dontAnimate().into(new GlideDrawableImageViewTarget(mImage) {

            @Override
            public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> animation) {
                super.onResourceReady(resource, animation);
                mAttacher.update();
            }
        });
    } catch (Exception e) {
        Toast.makeText(this, getString(R.string.error_file_corrupt), Toast.LENGTH_LONG).show();
        e.printStackTrace();
    }
}
Also used : GlideDrawableImageViewTarget(com.bumptech.glide.request.target.GlideDrawableImageViewTarget) BitmapFactory(android.graphics.BitmapFactory) File(java.io.File) PhotoViewAttacher(com.github.chrisbanes.photoview.PhotoViewAttacher) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ActivityNotFoundException(android.content.ActivityNotFoundException) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Aggregations

PhotoViewAttacher (com.github.chrisbanes.photoview.PhotoViewAttacher)6 View (android.view.View)4 PhotoView (com.github.chrisbanes.photoview.PhotoView)4 ImageView (android.widget.ImageView)3 Bundle (android.os.Bundle)2 MotionEvent (android.view.MotionEvent)2 GlideDrawable (com.bumptech.glide.load.resource.drawable.GlideDrawable)2 OnOutsidePhotoTapListener (com.github.chrisbanes.photoview.OnOutsidePhotoTapListener)2 OnSingleFlingListener (com.github.chrisbanes.photoview.OnSingleFlingListener)2 Callback (com.squareup.picasso.Callback)2 File (java.io.File)2 ActivityNotFoundException (android.content.ActivityNotFoundException)1 Bitmap (android.graphics.Bitmap)1 BitmapFactory (android.graphics.BitmapFactory)1 Drawable (android.graphics.drawable.Drawable)1 NonNull (android.support.annotation.NonNull)1 Nullable (android.support.annotation.Nullable)1 AlertDialog (android.support.v7.app.AlertDialog)1 TextView (android.widget.TextView)1 BindView (butterknife.BindView)1