Search in sources :

Example 6 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project glimmr by brk3.

the class PhotoViewerFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (BuildConfig.DEBUG)
        Log.d(getLogTag(), "onCreateView");
    mLayout = (RelativeLayout) inflater.inflate(R.layout.photoviewer_fragment, container, false);
    mVideoButton = (ImageView) mLayout.findViewById(R.id.play_video_overlay);
    mImageView = (ImageView) mLayout.findViewById(R.id.image);
    mAttacher = new PhotoViewAttacher(mImageView);
    mTextViewTitle = (TextView) mLayout.findViewById(R.id.textViewTitle);
    mTextViewAuthor = (TextView) mLayout.findViewById(R.id.textViewAuthor);
    mProgress = (ProgressBar) mLayout.findViewById(R.id.progress);
    mAttacher.setOnPhotoTapListener(new OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float x, float y) {
            BusProvider.getInstance().post(new PhotoViewerVisibilityChangeEvent(!mActionBar.isShowing(), PhotoViewerFragment.this));
        }
    });
    /* If this fragment is new as part of a set, update it's overlay
         * visibility based on the state of the actionbar */
    setOverlayVisibility(mActionBar.isShowing());
    displayImage();
    return mLayout;
}
Also used : OnPhotoTapListener(uk.co.senab.photoview.PhotoViewAttacher.OnPhotoTapListener) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView)

Example 7 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project LookLook by xinghongfei.

the class MeiziPhotoDescribeActivity method getData.

private void getData() {
    Glide.with(this).load(mImageUrl).centerCrop().listener(loadListener).diskCacheStrategy(DiskCacheStrategy.SOURCE).into(mShot);
    mPhotoViewAttacher = new PhotoViewAttacher(mShot);
    mToolbar.setNavigationIcon(R.drawable.ic_arrow_back);
    mToolbar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
        }
    });
    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            expandImageAndFinish();
        }
    });
}
Also used : PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) BindView(butterknife.BindView) View(android.view.View)

Example 8 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project Hummingbird-for-Android by xiprox.

the class FullscreenImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    int black = Color.parseColor("#000000");
    getWindow().setBackgroundDrawable(new ColorDrawable(black));
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().requestFeature(Window.FEATURE_CONTENT_TRANSITIONS);
        Transition sharedElem = TransitionInflater.from(this).inflateTransition(R.transition.move_transition);
        getWindow().setSharedElementEnterTransition(sharedElem);
        getWindow().setSharedElementExitTransition(sharedElem);
        getWindow().setStatusBarColor(black);
    }
    super.onCreate(savedInstanceState);
    ImageView mImageView = new ImageView(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
        mImageView.setTransitionName(TRANSITION_NAME_IMAGE);
    setContentView(mImageView);
    Bundle bundle = getIntent().getExtras();
    if (bundle != null && bundle.getString(ARG_IMAGE_URL) != null)
        mImageUrl = bundle.getString(ARG_IMAGE_URL);
    if (mImageUrl != null) {
        Picasso.with(this).load(mImageUrl).into(mImageView);
    } else {
        Toast.makeText(this, R.string.error_cant_load_image, Toast.LENGTH_SHORT).show();
        finish();
    }
    new PhotoViewAttacher(mImageView);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Bundle(android.os.Bundle) Transition(android.transition.Transition) ImageView(android.widget.ImageView) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

Example 9 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project BookReader by JustWayward.

the class PDFPagerAdapter method instantiateItem.

@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;
}
Also used : PdfRenderer(android.graphics.pdf.PdfRenderer) Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

Example 10 with PhotoViewAttacher

use of uk.co.senab.photoview.PhotoViewAttacher in project bdcodehelper by boredream.

the class ImageBrowserAdapter method instantiateItem.

@Override
public View instantiateItem(final ViewGroup container, int position) {
    final View rootView = View.inflate(context, R.layout.item_image_browser, null);
    int index = position % picUrls.size();
    final ProgressBar pb_loading = (ProgressBar) rootView.findViewById(R.id.pb_loading);
    final ImageView iv_image_browser = (ImageView) rootView.findViewById(R.id.iv_image_browser);
    final PhotoViewAttacher pva = new PhotoViewAttacher(iv_image_browser);
    String url = picUrls.get(index).getImageUrl();
    Glide.with(context).load(url).diskCacheStrategy(DiskCacheStrategy.ALL).centerCrop().crossFade().into(new SimpleTarget<GlideDrawable>() {

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            super.onLoadFailed(e, errorDrawable);
            pb_loading.setVisibility(View.GONE);
            iv_image_browser.setVisibility(View.VISIBLE);
        }

        @Override
        public void onLoadStarted(Drawable placeholder) {
            super.onLoadStarted(placeholder);
            pb_loading.setVisibility(View.VISIBLE);
            iv_image_browser.setVisibility(View.GONE);
        }

        @Override
        public void onResourceReady(GlideDrawable resource, GlideAnimation<? super GlideDrawable> glideAnimation) {
            pb_loading.setVisibility(View.GONE);
            iv_image_browser.setVisibility(View.VISIBLE);
            iv_image_browser.setImageDrawable(resource);
            pva.update();
        }
    });
    pva.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

        @Override
        public void onPhotoTap(View view, float x, float y) {
            context.onBackPressed();
        }
    });
    container.addView(rootView);
    return rootView;
}
Also used : GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable) Drawable(android.graphics.drawable.Drawable) ImageView(android.widget.ImageView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) ProgressBar(android.widget.ProgressBar) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

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