PhotoViewerTest.Droid.PhotoViewDroidAttacher.SetImageViewMatrix C# (CSharp) Method

SetImageViewMatrix() public method

public SetImageViewMatrix ( Matrix matrix ) : void
matrix Matrix
return void
        public void SetImageViewMatrix(Matrix matrix)
        {
            ImageView imageView = GetImageView();
            if (null != imageView) {

                CheckImageViewScaleType();
                imageView.ImageMatrix=(matrix);

                // Call MatrixChangedListener if needed
                if (null != mMatrixChangeListener) {
                    RectF displayRect = GetDisplayRect(matrix);
                    if (null != displayRect) {
                        mMatrixChangeListener.OnMatrixChanged(displayRect);
                    }
                }
            }
        }

Usage Example

            public void Run()
            {
                if (mScroller.IsFinished())
                {
                    return;                     // remaining post that should not be handled
                }
                ImageView imageView = photoViewAttacher.GetImageView();

                if (null != imageView && mScroller.ComputeScrollOffset())
                {
                    int newX = mScroller.GetCurrX();
                    int newY = mScroller.GetCurrY();
                    if (photoViewAttacher.DEBUG)
                    {
                        LogManager.GetLogger().d(
                            LOG_TAG,
                            "fling run(). CurrentX:" + mCurrentX + " CurrentY:"
                            + mCurrentY + " NewX:" + newX + " NewY:"
                            + newY);
                    }
                    photoViewAttacher.mSuppMatrix.PostTranslate(mCurrentX - newX, mCurrentY - newY);
                    photoViewAttacher.SetImageViewMatrix(photoViewAttacher.GetDrawMatrix());
                    mCurrentX = newX;
                    mCurrentY = newY;
                    Compat.PostOnAnimation(imageView, this);
                }
            }