Search in sources :

Example 1 with PhotoView

use of com.github.chrisbanes.photoview.PhotoView in project Palm300Heroes by nicolite.

the class ShowImageAdapter method instantiateItem.

@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
    final PhotoView imageView = new PhotoView(context);
    final PhotoViewAttacher attacher = new PhotoViewAttacher(imageView);
    Glide.with(context).load(images.get(position)).placeholder(R.drawable.img_loading).error(R.drawable.img_error).skipMemoryCache(true).crossFade().centerCrop().into(new SimpleTarget<GlideDrawable>() {

        @Override
        public void onLoadStarted(Drawable placeholder) {
            super.onLoadStarted(placeholder);
            imageView.setImageDrawable(placeholder);
            attacher.update();
        }

        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            imageView.setImageDrawable(resource);
            attacher.update();
        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            imageView.setImageDrawable(errorDrawable);
            attacher.update();
        }
    });
    container.addView(imageView);
    return imageView;
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Drawable(android.graphics.drawable.Drawable) PhotoViewAttacher(com.github.chrisbanes.photoview.PhotoViewAttacher) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) NonNull(android.support.annotation.NonNull)

Example 2 with PhotoView

use of com.github.chrisbanes.photoview.PhotoView in project ForPDA by RadiationX.

the class ImagesAdapter method loadImage.

private void loadImage(View imageLayout, int position) {
    assert imageLayout != null;
    CircularProgressView progressBar = (CircularProgressView) imageLayout.findViewById(R.id.progress_bar);
    PhotoView photoView = (PhotoView) imageLayout.findViewById(R.id.photo_view);
    if (crop)
        photoView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    if (clickListener != null)
        photoView.setOnClickListener(v -> clickListener.itemClick(v, position));
    imageLoader.displayImage(urls.get(position), photoView, options, new SimpleImageLoadingListener() {

        @Override
        public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            progressBar.setVisibility(View.GONE);
        // delayedHide(1000);
        }

        @Override
        public void onLoadingCancelled(String imageUri, View view) {
            progressBar.setVisibility(View.GONE);
        }

        @Override
        public void onLoadingStarted(String imageUri, View view) {
            progressBar.setVisibility(View.VISIBLE);
            if (progressBar.isIndeterminate()) {
                progressBar.setIndeterminate(false);
                progressBar.stopAnimation();
            }
        }
    }, (s, view, i, i1) -> progressBar.setProgress((int) (100F * i / i1)));
    photoView.setOnPhotoTapListener(tapListener);
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) Context(android.content.Context) LayoutInflater(android.view.LayoutInflater) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) PagerAdapter(android.support.v4.view.PagerAdapter) ImageLoader(com.nostra13.universalimageloader.core.ImageLoader) DisplayImageOptions(com.nostra13.universalimageloader.core.DisplayImageOptions) ViewGroup(android.view.ViewGroup) List(java.util.List) Bitmap(android.graphics.Bitmap) OnPhotoTapListener(com.github.chrisbanes.photoview.OnPhotoTapListener) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) View(android.view.View) App(forpdateam.ru.forpda.App) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) R(forpdateam.ru.forpda.R) Log(android.util.Log) SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) FailReason(com.nostra13.universalimageloader.core.assist.FailReason) CircularProgressView(com.github.rahatarmanahmed.cpv.CircularProgressView) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View)

Example 3 with PhotoView

use of com.github.chrisbanes.photoview.PhotoView in project PhotoView by chrisbanes.

the class ImmersiveActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_immersive);
    PhotoView photoView = findViewById(R.id.photo_view);
    Picasso.with(this).load("http://pbs.twimg.com/media/Bist9mvIYAAeAyQ.jpg").into(photoView);
    photoView.setOnPhotoTapListener(new OnPhotoTapListener() {

        @Override
        public void onPhotoTap(ImageView view, float x, float y) {
        // fullScreen();
        }
    });
    fullScreen();
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) OnPhotoTapListener(com.github.chrisbanes.photoview.OnPhotoTapListener) ImageView(android.widget.ImageView)

Example 4 with PhotoView

use of com.github.chrisbanes.photoview.PhotoView in project PhotoView by chrisbanes.

the class PicassoSampleActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_simple);
    final PhotoView photoView = findViewById(R.id.iv_photo);
    Picasso.with(this).load("https://images.unsplash.com/photo-1577643816920-65b43ba99fba?ixlib=rb-1.2.1&auto=format&fit=crop&w=3300&q=80").into(photoView);
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView)

Example 5 with PhotoView

use of com.github.chrisbanes.photoview.PhotoView in project CustomViews by AndroidStudy233.

the class ImagePreviewAdapter method destroyItem.

@Override
public void destroyItem(ViewGroup container, int position, Object object) {
    View view = (View) object;
    final PhotoView imageView = view.findViewById(R.id.pv);
    if (imageView != null) {
        Drawable drawable = imageView.getDrawable();
        if (drawable == null) {
            drawable = imageView.getBackground();
        }
        if (drawable != null) {
            drawable.setCallback(null);
        }
    }
    container.removeView((View) object);
}
Also used : PhotoView(com.github.chrisbanes.photoview.PhotoView) Drawable(android.graphics.drawable.Drawable) PhotoView(com.github.chrisbanes.photoview.PhotoView) ImageView(android.widget.ImageView) View(android.view.View)

Aggregations

PhotoView (com.github.chrisbanes.photoview.PhotoView)14 View (android.view.View)11 ImageView (android.widget.ImageView)6 Drawable (android.graphics.drawable.Drawable)5 Bundle (android.os.Bundle)4 NonNull (android.support.annotation.NonNull)3 Nullable (android.support.annotation.Nullable)3 ViewGroup (android.view.ViewGroup)3 PhotoViewAttacher (com.github.chrisbanes.photoview.PhotoViewAttacher)3 Bitmap (android.graphics.Bitmap)2 PagerAdapter (android.support.v4.view.PagerAdapter)2 MotionEvent (android.view.MotionEvent)2 ProgressBar (android.widget.ProgressBar)2 TextView (android.widget.TextView)2 BindView (butterknife.BindView)2 TouchImageView (com.dante.custom.TouchImageView)2 OnOutsidePhotoTapListener (com.github.chrisbanes.photoview.OnOutsidePhotoTapListener)2 OnPhotoTapListener (com.github.chrisbanes.photoview.OnPhotoTapListener)2 OnSingleFlingListener (com.github.chrisbanes.photoview.OnSingleFlingListener)2 Callback (com.squareup.picasso.Callback)2