/** * The default {@code super.onSaveInstanceState} and {@code onRestoreInstanceState} don't restore * the position on the map as expected (if the instance of {@link TileView} remains the same). For * this reason and if a new {@link TileView} instance is created, we have to save the current * scale and position on the map, to restore them later when the {@link TileView} is recreated. */ @Override public Parcelable onSaveInstanceState() { Parcelable superState = super.onSaveInstanceState(); SavedState ss = new SavedState(superState); ss.mScale = getScale(); ss.mSavedCenterX = getScrollX() + getHalfWidth(); ss.mSavedCenterY = getScrollY() + getHalfHeight(); return ss; }