Попытка сохранить фотографию Просмотр состояния масштабирования при изменении ориентации или применении операции - PullRequest
0 голосов
/ 26 февраля 2019

На самом деле пытается сохранить увеличить состояние просмотр фотографий , запутался в том, что передать в getDisplayMatrix () и как получитьпараметр getDisplayMatrix Получил это, находясь внутри getDisplayMatrix (getDisplayMatrix (Matrix) в PhotoView не может быть применен) Просмотр фотографий это код `

 mPhotoView.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            public boolean onPreDraw() {

                mPhotoView.getViewTreeObserver().removeOnPreDrawListener(this);
                mViewHeight = mPhotoView.getMeasuredHeight();
                mViewWidth = mPhotoView.getMeasuredWidth();

                Matrix matrix = new Matrix();
                **Matrix theMatrix = mPhotoView.getDisplayMatrix();**

//                Matrix theMatrix = mPhotoView.getDisplayMatrix();
                theMatrix.getValues(mBaseMatrixValues);
                float mScreenBase = mBaseMatrixValues[0];
                int theWidth = mPhotoView.getWidth();

                if (savedInstanceState != null) {
                    float[] theFloats = new float[9];
                    float theZoom = savedInstanceState.getFloat("ZoomLevel");
                    RectF theRect = savedInstanceState.getParcelable("RectF");
                    theFloats[0] = theZoom;
                    theFloats[4] = theZoom;
                    theFloats[2] = (theRect.left * mScreenBase) - (theZoom * mBaseMatrixValues[2]) + (mViewWidth / 2); //Left
                    theFloats[5] = (theRect.top * mScreenBase) - (theZoom * mBaseMatrixValues[5]) + (mViewHeight / 2); //Top
                    theFloats[8] = (float) 1.0;

                    theFloats = CheckBoundaries(theZoom, theFloats, theRect);

                    theMatrix.setValues(theFloats);
                    mPhotoView.setDisplayMatrix(theMatrix); //Sets the mSuppMatrix in the PhotoViewAttacher

                    Matrix theImageViewMatrix = mPhotoView.getImageMatrix(); //Gets the new mDrawMatrix
                    mPhotoView.setImageMatrix(theImageViewMatrix); //And applies it to the PhotoView (catches out of boundaries problems)
                }
                return true;
            }
        });
    }`

я следовал этому примеру Android PhotoView Сохранить масштаб после изменения ориентации

Пожалуйста, помогите заранее Спасибо

...