Example usage for android.widget ImageView isInEditMode

List of usage examples for android.widget ImageView isInEditMode

Introduction

In this page you can find the example usage for android.widget ImageView isInEditMode.

Prototype

public boolean isInEditMode() 

Source Link

Document

Indicates whether this View is currently in edit mode.

Usage

From source file:com.huyn.demogroup.freechild.FixedViewAttacher.java

public FixedViewAttacher(ImageView imageView) {
    mImageView = imageView;//w w w. ja v a  2s  .c  o m

    if (imageView.isInEditMode()) {
        return;
    }

    View parent = (View) mImageView.getParent();
    parent.setOnTouchListener(this);
    parent.addOnLayoutChangeListener(this);

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });
}

From source file:com.huyn.demogroup.leaveblank.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;//from  ww  w .  j  av  a2 s  .c  o m
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });
}

From source file:com.tjw.selectimage.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;/*w  w w .java  2s.co m*/
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            if (displayRect != null) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:com.github.chrisbanes.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;/*from   w  ww .ja  v  a  2s  . c  om*/
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            final float x = e.getX(), y = e.getY();

            if (mViewTapListener != null) {
                mViewTapListener.onViewTap(mImageView, x, y);
            }

            if (displayRect != null) {

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:com.frank.protean.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;/* w w  w . j av  a  2  s.  co  m*/
    imageView.setOnTouchListener(this);
    imageView.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), onGestureListener);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            final float x = e.getX(), y = e.getY();

            if (mViewTapListener != null) {
                mViewTapListener.onViewTap(mImageView, x, y);
            }

            if (displayRect != null) {

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:com.huyn.demogroup.zoomageview.view.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = imageView;/*from  w  w  w.  java  2 s  . c  o  m*/
    View parent = (View) mImageView.getParent();
    parent.setOnTouchListener(this);
    parent.addOnLayoutChangeListener(this);

    if (imageView.isInEditMode()) {
        return;
    }

    mBaseRotation = 0.0f;

    // Create Gesture Detectors...
    mScaleDragDetector = new CustomGestureDetector(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (mLongClickListener != null) {
                        mLongClickListener.onLongClick(mImageView);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new GestureDetector.OnDoubleTapListener() {
        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            if (mIsDragging) {
                return false;
            }
            if (mOnClickListener != null) {
                mOnClickListener.onClick(mImageView);
            }
            final RectF displayRect = getDisplayRect();

            if (displayRect != null) {
                final float x = e.getX(), y = e.getY();

                // Check to see if the user tapped on the photo
                if (displayRect.contains(x, y)) {

                    float xResult = (x - displayRect.left) / displayRect.width();
                    float yResult = (y - displayRect.top) / displayRect.height();

                    if (mPhotoTapListener != null) {
                        mPhotoTapListener.onPhotoTap(mImageView, xResult, yResult);
                    }
                    return true;
                } else {
                    if (mOutsidePhotoTapListener != null) {
                        mOutsidePhotoTapListener.onOutsidePhotoTap(mImageView);
                    }
                }
            }
            return false;
        }

        @Override
        public boolean onDoubleTap(MotionEvent ev) {
            try {
                float scale = getScale();
                float x = ev.getX();
                float y = ev.getY();

                if (scale < getMediumScale()) {
                    setScale(getMediumScale(), x, y, true);
                } else if (scale >= getMediumScale() && scale < getMaximumScale()) {
                    setScale(getMaximumScale(), x, y, true);
                } else {
                    setScale(getMinimumScale(), x, y, true);
                }
            } catch (ArrayIndexOutOfBoundsException e) {
                // Can sometimes happen when getX() and getY() is called
            }

            return true;
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            // Wait for the confirmed onDoubleTap() instead
            return false;
        }
    });
}

From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setOnTouchListener(this);

    mViewTreeObserver = imageView.getViewTreeObserver();
    mViewTreeObserver.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (!imageView.isInEditMode()) {
        // Create Gesture Detectors...
        mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

        mGestureDetector = new GestureDetector(imageView.getContext(),
                new GestureDetector.SimpleOnGestureListener() {

                    // forward long click listener
                    @Override/*from w ww.j ava2s  .  com*/
                    public void onLongPress(MotionEvent e) {
                        if (null != mLongClickListener) {
                            mLongClickListener.onLongClick(mImageView.get());
                        }
                    }
                });

        mGestureDetector.setOnDoubleTapListener(this);

        // Finally, update the UI so that we're zoomable
        setZoomable(true);
    }
}

From source file:com.ycl.framework.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(final ImageView imageView) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;//from   ww  w  .j av a2  s .c  om
    }
    // Create Gesture Detectors...
    mScaleDragDetector = com.ycl.framework.photoview.gestures.VersionedGestureDetector
            .newInstance(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));

    // Finally, update the UI so that we're zoomable
    setZoomable(true);
}

From source file:com.zirkler.czannotationviewsample.AnnotationView.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;/*  w  ww.j a va  2  s  .  c  o m*/
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView(), e);
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}

From source file:com.sflib.CustomView.photoview.PhotoViewAttacher.java

public PhotoViewAttacher(ImageView imageView, boolean zoomable) {
    mImageView = new WeakReference<ImageView>(imageView);

    imageView.setDrawingCacheEnabled(true);
    imageView.setOnTouchListener(this);

    ViewTreeObserver observer = imageView.getViewTreeObserver();
    if (null != observer)
        observer.addOnGlobalLayoutListener(this);

    // Make sure we using MATRIX Scale Type
    setImageViewScaleTypeMatrix(imageView);

    if (imageView.isInEditMode()) {
        return;/* ww w  .  j a  va2s  .  c  o  m*/
    }
    // Create Gesture Detectors...
    mScaleDragDetector = VersionedGestureDetector.newInstance(imageView.getContext(), this);

    mGestureDetector = new GestureDetector(imageView.getContext(),
            new GestureDetector.SimpleOnGestureListener() {

                // forward long click listener
                @Override
                public void onLongPress(MotionEvent e) {
                    if (null != mLongClickListener) {
                        mLongClickListener.onLongClick(getImageView());
                    }
                }

                @Override
                public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
                    if (mSingleFlingListener != null) {
                        if (getScale() > DEFAULT_MIN_SCALE) {
                            return false;
                        }

                        if (MotionEventCompat.getPointerCount(e1) > SINGLE_TOUCH
                                || MotionEventCompat.getPointerCount(e2) > SINGLE_TOUCH) {
                            return false;
                        }

                        return mSingleFlingListener.onFling(e1, e2, velocityX, velocityY);
                    }
                    return false;
                }
            });

    mGestureDetector.setOnDoubleTapListener(new DefaultOnDoubleTapListener(this));
    mBaseRotation = 0.0f;

    // Finally, update the UI so that we're zoomable
    setZoomable(zoomable);
}