Skip to content

06. State

davemorrissey edited this page Nov 16, 2017 · 3 revisions

These public methods allow the state of the view to be inspected and changed.

Please see javadocs for complete and up-to-date documentation.

getCenter()

Returns the source coordinates currently at the center of the screen.

getScale()

Returns the current scale, expressed as a source image to screen image ratio.

getState()

Returns the current scale, center and orientation as a single object, which can be used to restore this state after a screen orientation change.

setScaleAndCenter(float, PointF)

Sets the scale and translate, placing the given source coordinates as close to the center of the screen as the pan limit allows. This will be done on the next draw. If you call this before the image is loaded, the scale and translate will be set once the image has loaded. Scale and translate values outside the ranges allowed by the view's settings will be ignored. Animations in progress will be interrupted, regardless of their interruptible flag.

resetScaleAndCenter()

Zooms the image out to minimum scale and centers it on the screen according to the view's settings.

isReady()

Call to find whether the view is initialised, has dimensions, and will display an image on the next draw. If a preview has been provided, it may be the preview that will be displayed and the full size image may still be loading. If no preview was provided, this is called once the base layer tiles of the full size image are loaded.

isImageLoaded()

Call to find whether the main image (base layer tiles where relevant) have been loaded. Before this event the view is blank unless a preview was provided.

getAppliedOrientation()

Returns the actual orientation of the image relative to the source file. This will be based on the source file's EXIF orientation if you're using ORIENTATION_USE_EXIF. Values are 0, 90, 180, 270.

recycle()

Releases all resources the view is using and resets the state, nulling any fields that use significant memory. After you have called this method, the view can be re-used by setting a new image. Settings are remembered but state (scale and center) is forgotten. You can restore these yourself if required.

getSWidth() / getSHeight()

Returns the dimensions of the source image, without taking the applied rotation into account.