Search in sources :

Example 11 with PhotoView

use of uk.co.senab.photoview.PhotoView in project PhotoNoter by yydcdut.

the class PhotoDetailPagerAdapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, int position) {
    final PhotoView photoView = new PhotoView(container.getContext());
    ImageLoader.getInstance().displayImage("file:/" + mPhotoPathList.get(position), photoView);
    container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    photoView.setOnPhotoTapListener(this);
    return photoView;
}
Also used : PhotoView(uk.co.senab.photoview.PhotoView)

Example 12 with PhotoView

use of uk.co.senab.photoview.PhotoView in project ride-read-android by Ride-Read.

the class ImageFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View mview = inflater.inflate(R.layout.imagefragment, container, false);
    photoView = (PhotoView) mview.findViewById(R.id.photoview);
    Glide.with(this).load(imgUrl).thumbnail(0.5f).fitCenter().into(photoView);
    return mview;
}
Also used : PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View) Nullable(android.support.annotation.Nullable)

Example 13 with PhotoView

use of uk.co.senab.photoview.PhotoView in project GomoTest by suReZj.

the class viewPager_adapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, int position) {
    PhotoView photoView = new PhotoView(container.getContext());
    Glide.with(container.getContext()).load(list.get(position).getPath()).into(photoView);
    // Now just add PhotoView to ViewPager and return it
    container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    return photoView;
}
Also used : PhotoView(uk.co.senab.photoview.PhotoView)

Example 14 with PhotoView

use of uk.co.senab.photoview.PhotoView in project SeaStar by 13120241790.

the class PreviewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(io.rong.imkit.R.layout.rc_fr_photo2, container, false);
    mPhotoView = (PhotoView) view.findViewById(io.rong.imkit.R.id.rc_icon);
    initPhoto(uri);
    return view;
}
Also used : View(android.view.View) PhotoView(uk.co.senab.photoview.PhotoView)

Example 15 with PhotoView

use of uk.co.senab.photoview.PhotoView in project weiciyuan by qii.

the class GifPictureFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.gallery_gif_layout, container, false);
    gifImageView = (PhotoView) view.findViewById(R.id.gif);
    if (SettingUtility.allowClickToCloseGallery()) {
        gifImageView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

            @Override
            public void onViewTap(View view, float x, float y) {
                getActivity().onBackPressed();
            }
        });
    }
    LongClickListener longClickListener = ((ContainerFragment) getParentFragment()).getLongClickListener();
    gifImageView.setOnLongClickListener(longClickListener);
    String path = getArguments().getString("path");
    boolean animateIn = getArguments().getBoolean("animationIn");
    final AnimationRect rect = getArguments().getParcelable("rect");
    File gifFile = new File(path);
    try {
        GifDrawable gifFromFile = new GifDrawable(gifFile);
        gifImageView.setImageDrawable(gifFromFile);
    } catch (IOException e) {
        e.printStackTrace();
    }
    final ClipImageView photoView = (ClipImageView) view.findViewById(R.id.cover);
    Bitmap bitmap = ImageUtility.decodeBitmapFromSDCard(path, IMAGEVIEW_SOFT_LAYER_MAX_WIDTH, IMAGEVIEW_SOFT_LAYER_MAX_HEIGHT);
    photoView.setImageBitmap(bitmap);
    if (!animateIn) {
        photoView.setVisibility(View.INVISIBLE);
        return view;
    }
    gifImageView.setVisibility(View.INVISIBLE);
    final Runnable endAction = new Runnable() {

        @Override
        public void run() {
            Bundle bundle = getArguments();
            bundle.putBoolean("animationIn", false);
            photoView.setVisibility(View.INVISIBLE);
            gifImageView.setVisibility(View.VISIBLE);
        }
    };
    photoView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

        @Override
        public boolean onPreDraw() {
            if (rect == null) {
                photoView.getViewTreeObserver().removeOnPreDrawListener(this);
                endAction.run();
                return true;
            }
            final Rect startBounds = new Rect(rect.scaledBitmapRect);
            final Rect finalBounds = AnimationUtility.getBitmapRectFromImageView(photoView);
            if (finalBounds == null) {
                photoView.getViewTreeObserver().removeOnPreDrawListener(this);
                endAction.run();
                return true;
            }
            float startScale = (float) finalBounds.width() / startBounds.width();
            if (startScale * startBounds.height() > finalBounds.height()) {
                startScale = (float) finalBounds.height() / startBounds.height();
            }
            int oriBitmapScaledWidth = (int) (finalBounds.width() / startScale);
            int oriBitmapScaledHeight = (int) (finalBounds.height() / startScale);
            int thumbnailAndOriDeltaRightSize = Math.abs(rect.scaledBitmapRect.width() - oriBitmapScaledWidth);
            int thumbnailAndOriDeltaBottomSize = Math.abs(rect.scaledBitmapRect.height() - oriBitmapScaledHeight);
            float thumbnailAndOriDeltaWidth = (float) thumbnailAndOriDeltaRightSize / (float) oriBitmapScaledWidth;
            float thumbnailAndOriDeltaHeight = (float) thumbnailAndOriDeltaBottomSize / (float) oriBitmapScaledHeight;
            int deltaTop = startBounds.top - finalBounds.top;
            int deltaLeft = startBounds.left - finalBounds.left;
            photoView.setPivotY((photoView.getHeight() - finalBounds.height()) / 2);
            photoView.setPivotX((photoView.getWidth() - finalBounds.width()) / 2);
            photoView.setScaleX(1 / startScale);
            photoView.setScaleY(1 / startScale);
            photoView.setTranslationX(deltaLeft);
            photoView.setTranslationY(deltaTop);
            photoView.animate().translationY(0).translationX(0).scaleY(1).scaleX(1).setDuration(ANIMATION_DURATION).setInterpolator(new AccelerateDecelerateInterpolator()).withEndAction(endAction);
            if (rect.type == AnimationRect.TYPE_EXTEND_V || rect.type == AnimationRect.TYPE_EXTEND_H) {
                AnimatorSet animationSet = new AnimatorSet();
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
                animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipBottom", thumbnailAndOriDeltaHeight, 0));
                animationSet.start();
            } else {
                AnimatorSet animationSet = new AnimatorSet();
                animationSet.setDuration(ANIMATION_DURATION);
                animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
                float clipRectH = ((float) (oriBitmapScaledWidth - oriBitmapScaledWidth * thumbnailAndOriDeltaWidth - rect.widgetWidth) / 2) / (float) oriBitmapScaledWidth;
                float clipRectV = ((float) (oriBitmapScaledHeight - oriBitmapScaledHeight * thumbnailAndOriDeltaHeight - rect.widgetHeight) / 2) / (float) oriBitmapScaledHeight;
                animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipHorizontal", clipRectH, 0));
                animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipVertical", clipRectV, 0));
                animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipBottom", thumbnailAndOriDeltaHeight, 0));
                animationSet.playTogether(ObjectAnimator.ofFloat(photoView, "clipRight", thumbnailAndOriDeltaWidth, 0));
                animationSet.start();
            }
            photoView.getViewTreeObserver().removeOnPreDrawListener(this);
            return true;
        }
    });
    return view;
}
Also used : Rect(android.graphics.Rect) AnimationRect(org.qii.weiciyuan.support.lib.AnimationRect) Bundle(android.os.Bundle) AnimationRect(org.qii.weiciyuan.support.lib.AnimationRect) GifDrawable(pl.droidsonroids.gif.GifDrawable) AnimatorSet(android.animation.AnimatorSet) IOException(java.io.IOException) PhotoView(uk.co.senab.photoview.PhotoView) ClipImageView(org.qii.weiciyuan.support.lib.ClipImageView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) Bitmap(android.graphics.Bitmap) ClipImageView(org.qii.weiciyuan.support.lib.ClipImageView) AccelerateDecelerateInterpolator(android.view.animation.AccelerateDecelerateInterpolator) File(java.io.File) ViewTreeObserver(android.view.ViewTreeObserver)

Aggregations

PhotoView (uk.co.senab.photoview.PhotoView)16 View (android.view.View)12 PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)8 Bitmap (android.graphics.Bitmap)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 AnimatorSet (android.animation.AnimatorSet)2 Rect (android.graphics.Rect)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 Bundle (android.os.Bundle)2 Nullable (android.support.annotation.Nullable)2 ViewTreeObserver (android.view.ViewTreeObserver)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 WebView (android.webkit.WebView)2 File (java.io.File)2 AnimationRect (org.qii.weiciyuan.support.lib.AnimationRect)2 CircleProgressView (org.qii.weiciyuan.support.lib.CircleProgressView)2 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1