Example usage for android.widget ImageView getTop

List of usage examples for android.widget ImageView getTop

Introduction

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

Prototype

@ViewDebug.CapturedViewProperty
public final int getTop() 

Source Link

Document

Top position of this view relative to its parent.

Usage

From source file:Main.java

private static void updateImageViewAfterScaleTypeChange(ImageView imageView) {
    // enforcing imageView to update its internal bounds/matrix immediately
    imageView.measure(MeasureSpec.makeMeasureSpec(imageView.getMeasuredWidth(), MeasureSpec.EXACTLY),
            MeasureSpec.makeMeasureSpec(imageView.getMeasuredHeight(), MeasureSpec.EXACTLY));
    imageView.layout(imageView.getLeft(), imageView.getTop(), imageView.getRight(), imageView.getBottom());
}

From source file:com.vuze.android.widget.SwipeRefreshLayoutExtra.java

private void layoutExtra(ImageView circleView) {
    if (mExtraView == null) {
        return;//from  w  ww  . ja va 2 s .co  m
    }
    final int width = getMeasuredWidth();

    int tvHeight = mExtraView.getMeasuredHeight();

    int circleHeight = circleView.getMeasuredHeight();
    int offset = circleView.getTop();

    int tvTop = offset + circleHeight;
    if (DEBUG_FOLLOW_THE_CIRLCE_HACK) {
        Log.d(TAG, "layoutExtra: " + tvTop + ";" + circleView.getVisibility());
    }
    mExtraView.layout(0, tvTop, width, tvTop + tvHeight);

    int visibility = mExtraView.getVisibility();
    int newVisibility = tvTop <= 0 ? View.GONE : View.VISIBLE;

    if (visibility != newVisibility) {
        if (DEBUG_FOLLOW_THE_CIRLCE_HACK) {
            Log.d(TAG, "layoutExtra: set " + (tvTop <= 0 ? "GONE" : "VISIBLE") + ";"
                    + AndroidUtils.getCompressedStackTrace());
        }
        mExtraView.setVisibility(newVisibility);
        if (listenerOnExtraViewVisiblityChange != null) {
            listenerOnExtraViewVisiblityChange.onExtraViewVisibilityChange(mExtraView, newVisibility);
        }
    }
}

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

@Override
public final void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView && mZoomEnabled) {
        final int top = imageView.getTop();
        final int right = imageView.getRight();
        final int bottom = imageView.getBottom();
        final int left = imageView.getLeft();

        /**/* w ww  . j av  a2 s  .  c  om*/
         * We need to check whether the ImageView's bounds have changed.
         * This would be easier if we targeted API 11+ as we could just use
         * View.OnLayoutChangeListener. Instead we have to replicate the
         * work, keeping track of the ImageView's bounds and then checking
         * if the values change.
         */
        if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
            // Update our base matrix, as the bounds have changed
            updateBaseMatrix(imageView.getDrawable());

            // Update values as something has changed
            mIvTop = top;
            mIvRight = right;
            mIvBottom = bottom;
            mIvLeft = left;
        }
    }
}

From source file:com.sociablue.nanodegree_p1.MovieListFragment.java

private void initializeFab(View rootView) {
    final RelativeLayout buttonContainer = (RelativeLayout) rootView.findViewById(R.id.menu_button_container);
    final FloatingActionButton Fab = (FloatingActionButton) rootView.findViewById(R.id.fab);
    final ImageView bottomBar = (ImageView) rootView.findViewById(R.id.menu_bottom_bar);
    final ImageView topBar = (ImageView) rootView.findViewById(R.id.menu_top_bar);
    Fab.setOnClickListener(new View.OnClickListener() {
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override/*from w  w w .ja va 2 s  .  co m*/
        public void onClick(View v) {

            //Menu Button Icon Animation
            //Setting up necessary variables
            long animationDuration = 500;
            float containerHeight = buttonContainer.getHeight();
            float containerCenterY = containerHeight / 2;
            float containerCenterX = buttonContainer.getWidth() / 2;
            float topBarCenter = topBar.getTop() + topBar.getHeight() / 2;
            float widthOfBar = topBar.getWidth();
            float heightOfBar = topBar.getHeight();
            final float distanceBetweenBars = (containerCenterY - topBarCenter);

            /**
             *TODO: Refactor block of code to use Value Property Animator. Should be more efficient to animate multiple properties
             *and objects at the same time. Also, will try to break intialization into smaller functions.
             */

            //Setting up animations of hamburger bars and rotation

            /**
             * Animation For Top Menu Button Icon Bar. Sliding from the top to rest on top of the middle bar.
             * Y Translation is 1/2 the height of the hamburger bar minus the distance.
             * Subtracting the distance from the height because the distance between bars is
             * calculated of the exact center of the button.
             * With out the subtraction the bar would translate slightly below the middle bar.
             */
            float yTranslation = heightOfBar / 2 - distanceBetweenBars;
            float xTranslation = widthOfBar / 2 + heightOfBar / 2;
            TranslateAnimation topBarTranslationAnim = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, 0F, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE, distanceBetweenBars);
            topBarTranslationAnim.setDuration((long) (animationDuration * 0.8));
            topBarTranslationAnim.setFillAfter(true);

            //Animation for bottom hamburger bar. Translates and Rotates to create 'X'
            AnimationSet bottomBarAnimation = new AnimationSet(true);
            bottomBarAnimation.setFillAfter(true);

            //Rotate to create cross. (The cross becomes the X after the button rotation completes"
            RotateAnimation bottomBarRotationAnimation = new RotateAnimation(0f, 90f,
                    Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 1f);
            bottomBarRotationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarRotationAnimation);

            //Translate to correct X alignment
            TranslateAnimation bottomBarTranslationAnimation = new TranslateAnimation(Animation.ABSOLUTE, 0f,
                    Animation.ABSOLUTE, -xTranslation, Animation.ABSOLUTE, 0f, Animation.ABSOLUTE,
                    -yTranslation);
            bottomBarTranslationAnimation.setDuration(animationDuration);
            bottomBarAnimation.addAnimation(bottomBarTranslationAnimation);

            //Button Specific Animations
            //Rotate Button Container
            RotateAnimation containerRotationAnimation = new RotateAnimation(0, 135f,
                    Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            containerRotationAnimation.setDuration(animationDuration);
            containerRotationAnimation.setFillAfter(true);

            //Animate change of button color between Active and Disabled colors that have been
            //defined in color.xml
            int activeColor = getResources().getColor(R.color.active_button);
            int disabledColor = getResources().getColor(R.color.disabled_button);

            //Need to use ValueAnimator because property animator does not support BackgroundTint
            ValueAnimator buttonColorAnimation = ValueAnimator.ofArgb(activeColor, disabledColor);
            buttonColorAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                @Override
                public void onAnimationUpdate(ValueAnimator animation) {
                    Fab.setBackgroundTintList(ColorStateList.valueOf((int) animation.getAnimatedValue()));
                }
            });
            buttonColorAnimation.setDuration(animationDuration);

            //Start all the animations
            topBar.startAnimation(topBarTranslationAnim);
            bottomBar.startAnimation(bottomBarAnimation);
            buttonContainer.startAnimation(containerRotationAnimation);
            buttonColorAnimation.start();

            //Toogle mMenu open and closed
            if (mMenu.isOpen()) {
                //If mMenu is open, do the reverse of the animation
                containerRotationAnimation
                        .setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                topBarTranslationAnim.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                bottomBarAnimation.setInterpolator(new ReverseInterpolator(new AccelerateInterpolator()));
                buttonColorAnimation.setInterpolator(new ReverseInterpolator(new LinearInterpolator()));
                mMenu.close();
            } else {
                bottomBarAnimation.setInterpolator(new AccelerateInterpolator());
                mMenu.open();
            }
        }
    });
}

From source file:uk.co.senab.photoview.PhotoViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**//  w ww.  j  a  v a 2 s .c o  m
             * We need to check whether the ImageView's bounds have changed.
             * This would be easier if we targeted API 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView's bounds and then checking
             * if the values change.
             */
            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix();

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            updateBaseMatrix();
        }

        if (!firstTimeRendered) {
            firstTimeRendered = true;
            renderBitmap();
        }
        calculateCurrentImageMatrix();
        imageView.setImageMatrix(currentImageMatrix);
    }
}

From source file:com.kf5.sdk.system.photoview.PhotoViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**//  w  ww  .  j a va2s.co m
             * We need to check whether the ImageView's bounds have changed.
             * This would be easier if we targeted IChatModel 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView's bounds and then checking
             * if the values change.
             */
            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix(imageView.getDrawable());

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            updateBaseMatrix(imageView.getDrawable());
        }
    }
}

From source file:com.cylan.jiafeigou.support.photoview.PhotoViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**/*from   w ww. j a va 2 s. co m*/
             * We need to check whether the ImageView'account bounds have changed.
             * This would be easier if we targeted API 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView'account bounds and then checking
             * if the values change.
             */
            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix(imageView.getDrawable());

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            updateBaseMatrix(imageView.getDrawable());
        }
    }
}

From source file:cn.golden.pinchzoomcanvasview.PinchZoomCanvasViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();
    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**//from   w  w w.  java 2s.  c  om
             * We need to check whether the ImageView's bounds have changed.
             * This would be easier if we targeted API 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView's bounds and then checking
             * if the values change.
             */
            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix(imageView.getDrawable());

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            if (!isInEdit) {
                updateBaseMatrix(imageView.getDrawable());
            }
        }
    }
}

From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**// w  w w . j a v  a  2s . c o m
             * We need to check whether the ImageView's bounds have changed.
             * This would be easier if we targeted API 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView's bounds and then checking
             * if the values change.
             */
            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix(imageView.getDrawable());

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            updateBaseMatrix(imageView.getDrawable());
        }
    }
}

From source file:com.mooc.viewpage_photoview_circleindicator.photoview.PhotoViewAttacher.java

@Override
public void onGlobalLayout() {
    ImageView imageView = getImageView();

    if (null != imageView) {
        if (mZoomEnabled) {
            final int top = imageView.getTop();
            final int right = imageView.getRight();
            final int bottom = imageView.getBottom();
            final int left = imageView.getLeft();

            /**/*from www.j  av  a 2 s . co  m*/
             * We need to check whether the ImageView's bounds have changed.
             * This would be easier if we targeted API 11+ as we could just use
             * View.OnLayoutChangeListener. Instead we have to replicate the
             * work, keeping track of the ImageView's bounds and then checking
             * if the values change.
             * ?
             */

            if (top != mIvTop || bottom != mIvBottom || left != mIvLeft || right != mIvRight) {
                // Update our base matrix, as the bounds have changed
                updateBaseMatrix(imageView.getDrawable(), false);

                // Update values as something has changed
                mIvTop = top;
                mIvRight = right;
                mIvBottom = bottom;
                mIvLeft = left;
            }
        } else {
            updateBaseMatrix(imageView.getDrawable(), false);
        }
    }
}