Search in sources :

Example 11 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project GeekNews by codeestX.

the class GirlDetailActivity method initEventAndData.

@Override
protected void initEventAndData() {
    setToolBar(toolBar, "");
    mRealmHelper = App.getAppComponent().realmHelper();
    Intent intent = getIntent();
    url = intent.getExtras().getString("url");
    id = intent.getExtras().getString("id");
    if (url != null) {
        Glide.with(mContext).load(url).asBitmap().into(new SimpleTarget<Bitmap>() {

            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                bitmap = resource;
                ivGirlDetail.setImageBitmap(resource);
                mAttacher = new PhotoViewAttacher(ivGirlDetail);
            }
        });
    }
}
Also used : Bitmap(android.graphics.Bitmap) Intent(android.content.Intent) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

Example 12 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project WordPress-Android by wordpress-mobile.

the class PhotoChooserPreviewActivity method loadImage.

private void loadImage() {
    // load a scaled version of the image to prevent OOM exception
    int maxWidth = DisplayUtils.getDisplayPixelWidth(this);
    byte[] bytes = ImageUtils.createThumbnailFromUri(this, mMediaUri, maxWidth, null, 0);
    if (bytes == null) {
        ToastUtils.showToast(this, R.string.error_media_load);
        delayedFinish();
        return;
    }
    Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
    if (bmp == null) {
        ToastUtils.showToast(this, R.string.error_media_load);
        delayedFinish();
        return;
    }
    mImageView.setImageBitmap(bmp);
    // attach the photo zoomer
    PhotoViewAttacher attacher = new PhotoViewAttacher(mImageView);
    attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float v, float v2) {
            finish();
        }
    });
    attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float v, float v2) {
            finish();
        }
    });
}
Also used : Bitmap(android.graphics.Bitmap) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) View(android.view.View) VideoView(android.widget.VideoView)

Example 13 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project WordPress-Android by wordpress-mobile.

the class ReaderPhotoView method setAttacher.

private void setAttacher() {
    PhotoViewAttacher attacher = new PhotoViewAttacher(mImageView);
    attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float v, float v2) {
            if (mPhotoViewListener != null) {
                mPhotoViewListener.onTapPhotoView();
            }
        }
    });
    attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float v, float v2) {
            if (mPhotoViewListener != null) {
                mPhotoViewListener.onTapPhotoView();
            }
        }
    });
}
Also used : PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 14 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project boxing by Bilibili.

the class BoxingRawImageFragment method onViewCreated.

@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mProgress = (ProgressBar) view.findViewById(R.id.loading);
    mImageView = (PhotoView) view.findViewById(R.id.photo_view);
    mAttacher = new PhotoViewAttacher(mImageView);
    mAttacher.setRotatable(true);
    mAttacher.setToRightAngle(true);
    ((AbsBoxingViewActivity) getActivity()).loadRawImage(mImageView, mMedia.getPath(), new BoxingCallback(this));
}
Also used : IBoxingCallback(com.bilibili.boxing.loader.IBoxingCallback) AbsBoxingViewActivity(com.bilibili.boxing.AbsBoxingViewActivity) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

Example 15 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project wh-app-android by WhiteHouse.

the class GalleryPhotoFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mPhotoDescription.setText(Html.fromHtml(prepDescription(mFeedItem.description())));
    Picasso.with(view.getContext()).load(mFeedItem.getBestThumbnailUrl(1500)).into(mPhotoView, new Callback() {

        @Override
        public void onSuccess() {
            mPhotoViewAttacher = new PhotoViewAttacher(mPhotoView) {

                @Override
                public boolean onTouch(View v, MotionEvent ev) {
                    switch(ev.getAction()) {
                        case MotionEvent.ACTION_DOWN:
                            mTouching = true;
                            decideDescriptionVisibility(getScale());
                            break;
                        case MotionEvent.ACTION_CANCEL:
                        case MotionEvent.ACTION_UP:
                            mTouching = false;
                            decideDescriptionVisibility(getScale());
                            break;
                    }
                    return super.onTouch(v, ev);
                }
            };
            mPhotoViewAttacher.setOnMatrixChangeListener(rectF -> {
                decideDescriptionVisibility(mPhotoViewAttacher.getScale());
                if (mPhotoViewAttacher.getScale() > 1.1f) {
                    mPhotoViewAttacher.setAllowParentInterceptOnEdge(false);
                } else {
                    mPhotoViewAttacher.setAllowParentInterceptOnEdge(true);
                }
            });
        }

        @Override
        public void onError() {
        }
    });
}
Also used : Bundle(android.os.Bundle) ButterKnife(butterknife.ButterKnife) LayoutInflater(android.view.LayoutInflater) ImageView(android.widget.ImageView) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) InjectView(butterknife.InjectView) GsonUtils(gov.whitehouse.util.GsonUtils) ViewGroup(android.view.ViewGroup) FeedItem(gov.whitehouse.data.model.FeedItem) Picasso(com.squareup.picasso.Picasso) TextView(android.widget.TextView) MotionEvent(android.view.MotionEvent) Html(android.text.Html) Menu(android.view.Menu) View(android.view.View) Callback(com.squareup.picasso.Callback) Nullable(android.support.annotation.Nullable) BaseFragment(gov.whitehouse.app.BaseFragment) R(gov.whitehouse.R) Callback(com.squareup.picasso.Callback) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) InjectView(butterknife.InjectView) TextView(android.widget.TextView) View(android.view.View) MotionEvent(android.view.MotionEvent)

Aggregations

PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)16 View (android.view.View)12 ImageView (android.widget.ImageView)11 Bitmap (android.graphics.Bitmap)4 Bundle (android.os.Bundle)4 TextView (android.widget.TextView)4 Intent (android.content.Intent)3 LinearLayout (android.widget.LinearLayout)3 ColorDrawable (android.graphics.drawable.ColorDrawable)2 Menu (android.view.Menu)2 ButterKnife (butterknife.ButterKnife)2 InjectView (butterknife.InjectView)2 NetworkedCacheableImageView (com.klinker.android.twitter.views.NetworkedCacheableImageView)2 CacheableBitmapDrawable (uk.co.senab.bitmapcache.CacheableBitmapDrawable)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Resources (android.content.res.Resources)1 TypedArray (android.content.res.TypedArray)1