public void update ( boolean animate ) { final Settings settings = imageView == null ? null : imageView . getController ( ) . getSettings ( ) ; if ( settings != null && getWidth ( ) > 0 && getHeight ( ) > 0 ) { // If aspect is specified we will automatically adjust movement area settings if ( aspect > 0f || aspect == ORIGINAL_ASPECT ) { final int width = getWidth ( ) - getPaddingLeft ( ) - getPaddingRight ( ) ; final int height = getHeight ( ) - getPaddingTop ( ) - getPaddingBottom ( ) ; final float realAspect = aspect == ORIGINAL_ASPECT ? settings . getImageW ( ) / ( float ) settings . getImageH ( ) : aspect ; // Setting movement area if ( realAspect > ( float ) width / ( float ) height ) { // Cropping area is wider settings . setMovementArea ( width , ( int ) ( width / realAspect ) ) ; } else { // Cropping area is higher settings . setMovementArea ( ( int ) ( height * realAspect ) , height ) ; } // Animating image to fit new movement area if ( animate ) { imageView . getController ( ) . animateKeepInBounds ( ) ; } else { imageView . getController ( ) . updateState ( ) ; } } startRect . set ( areaRect ) ; GravityUtils . getMovementAreaPosition ( settings , tmpRect ) ; endRect . set ( tmpRect ) ; stateScroller . forceFinished ( ) ; if ( animate ) { stateScroller . setDuration ( settings . getAnimationsDuration ( ) ) ; stateScroller . startScroll ( 0f , 1f ) ; animationEngine . start ( ) ; } else { setBounds ( endRect , endRounding ) ; } } }
Applies area size area position and corners rounding with optional animation .