Java Code Examples for uk.co.senab.photoview.PhotoViewAttacher#update()

The following examples show how to use uk.co.senab.photoview.PhotoViewAttacher#update() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BoxingRawImageFragment.java    From boxing with Apache License 2.0 6 votes vote down vote up
@Override
public void onSuccess() {
    if (mWr.get() == null || mWr.get().mImageView == null) {
        return;
    }
    mWr.get().dismissProgressDialog();
    Drawable drawable = mWr.get().mImageView.getDrawable();
    PhotoViewAttacher attacher = mWr.get().mAttacher;
    if (attacher != null) {
        if (drawable.getIntrinsicHeight() > (drawable.getIntrinsicWidth() << 2)) {
            // handle the super height image.
            int scale = drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth();
            scale = Math.min(MAX_SCALE, scale);
            attacher.setMaximumScale(scale);
            attacher.setScale(scale, true);
        }
        attacher.update();
    }
    BoxingViewActivity activity = mWr.get().getThisActivity();
    if (activity != null && activity.mGallery != null) {
        activity.mGallery.setVisibility(View.VISIBLE);
    }
}
 
Example 2
Source File: ViewPagerPhotoViewFragment.java    From RotatePhotoView with Apache License 2.0 6 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    PhotoView photoView = new PhotoView(container.getContext());
    photoView.setImageResource(sDrawables[position]);
    PhotoViewAttacher attacher = new PhotoViewAttacher(photoView);
    attacher.setRotatable(true);
    attacher.setToRightAngle(true);
    attacher.setOnRotateListener(new PhotoViewAttacher.OnRotateListener() {
        @Override
        public void onRotate(int degree) {
            //do something
        }
    });
    attacher.update();
    // Now just add PhotoView to ViewPager and return it
    container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return photoView;
}
 
Example 3
Source File: PDFPagerAdapter.java    From fangzhuishushenqi with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("NewApi")
public Object instantiateItem(ViewGroup container, int position) {
    View v = inflater.inflate(R.layout.view_pdf_page, container, false);
    ImageView iv = (ImageView) v.findViewById(R.id.imageView);

    if (renderer == null || getCount() < position) {
        return v;
    }

    PdfRenderer.Page page = getPDFPage(renderer, position);

    Bitmap bitmap = bitmapContainer.get(position);
    page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
    page.close();

    PhotoViewAttacher attacher = new PhotoViewAttacher(iv);
    attacher.setScale(scale.getScale(), scale.getCenterX(), scale.getCenterY(), true);
    attacher.setOnMatrixChangeListener(this);

    attachers.put(position, new WeakReference<PhotoViewAttacher>(attacher));

    iv.setImageBitmap(bitmap);
    attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (pageClickListener != null) {
                pageClickListener.onPageTap(view, x, y);
            }
        }
    });
    attacher.update();
    container.addView(v, 0);

    return v;
}
 
Example 4
Source File: PDFPagerAdapter.java    From BookReader with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("NewApi")
public Object instantiateItem(ViewGroup container, int position) {
    View v = inflater.inflate(R.layout.view_pdf_page, container, false);
    ImageView iv = (ImageView) v.findViewById(R.id.imageView);

    if (renderer == null || getCount() < position) {
        return v;
    }

    PdfRenderer.Page page = getPDFPage(renderer, position);

    Bitmap bitmap = bitmapContainer.get(position);
    page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
    page.close();

    PhotoViewAttacher attacher = new PhotoViewAttacher(iv);
    attacher.setScale(scale.getScale(), scale.getCenterX(), scale.getCenterY(), true);
    attacher.setOnMatrixChangeListener(this);

    attachers.put(position, new WeakReference<PhotoViewAttacher>(attacher));

    iv.setImageBitmap(bitmap);
    attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
        @Override
        public void onPhotoTap(View view, float x, float y) {
            if (pageClickListener != null) {
                pageClickListener.onPageTap(view, x, y);
            }
        }
    });
    attacher.update();
    container.addView(v, 0);

    return v;
}
 
Example 5
Source File: DetailFragment.java    From Meizi with Apache License 2.0 5 votes vote down vote up
@Override
public void initSubViews(View view) {
    super.initSubViews(view);
    ImageLoader.loadImage(getArguments().getString("url"),
            meiziImageView, getContext());
    mAttacher = new PhotoViewAttacher(meiziImageView);
    mAttacher.update();
}
 
Example 6
Source File: ImageViewFragment.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mImageView = (ImageView) view;

    mAttacher = new PhotoViewAttacher(mImageView);
    mAttacher.update();

    PicassoProvider.getInstance(getActivity().getApplicationContext(), false)
            .load(getImageUrl())
            .networkPolicy(NetworkPolicy.NO_STORE, NetworkPolicy.OFFLINE)
            .memoryPolicy(MemoryPolicy.NO_STORE)
            .placeholder(R.mipmap.ic_stub_dashboard_item)
            .into(mImageView);
}
 
Example 7
Source File: PictureFragment.java    From Tweetin with Apache License 2.0 5 votes vote down vote up
private void load() {
    progressWheel.setVisibility(View.VISIBLE);
    reloadView.setVisibility(View.GONE);
    pictureView.setVisibility(View.GONE);

    ImageRequest imageRequest = new ImageRequest(
            pictureURL,
            new Response.Listener<Bitmap>() {
                @Override
                public void onResponse(Bitmap bitmap) {
                    originBitmap = bitmap;

                    pictureView.setImageBitmap(bitmap);
                    PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(pictureView);
                    photoViewAttacher.setZoomable(true);
                    photoViewAttacher.update();

                    progressWheel.setVisibility(View.GONE);
                    reloadView.setVisibility(View.GONE);
                    pictureView.setVisibility(View.VISIBLE);
                }
            },
            0,
            0,
            Bitmap.Config.ARGB_8888,
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    progressWheel.setVisibility(View.GONE);
                    reloadView.setVisibility(View.VISIBLE);
                    pictureView.setVisibility(View.GONE);
                }
            }
    );
    requestQueue.add(imageRequest);
}
 
Example 8
Source File: GirlDetailFragment.java    From NiceRead with Apache License 2.0 4 votes vote down vote up
@Override
protected void initView() {
    ImageLoader.load(mActivity, mUrl, mImageView);
    PhotoViewAttacher attacher = new PhotoViewAttacher(mImageView);
    attacher.update();
}