package com.davemorrissey.labs.subscaleview;

import android.app.Activity;
import android.graphics.PointF;
import android.os.Bundle;
import android.util.Log;
import com.davemorrissey.labs.subscaleview.R.id;

import java.io.IOException;

public class DemoActivity extends Activity {

    private static final String STATE_SCALE = "state-scale";
    private static final String STATE_CENTER = "state-center";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
            SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(id.imageView);
            imageView.setImageAsset("DSC00266.JPG");

            if (savedInstanceState != null && savedInstanceState.containsKey(STATE_SCALE) && savedInstanceState.containsKey(STATE_CENTER)) {
                imageView.setScaleAndCenter(savedInstanceState.getFloat(STATE_SCALE), (PointF)savedInstanceState.getParcelable(STATE_CENTER));
            }
        } catch (IOException e) {
            Log.e(DemoActivity.class.getSimpleName(), "Could not load asset", e);
        }
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        SubsamplingScaleImageView imageView = (SubsamplingScaleImageView)findViewById(id.imageView);
        outState.putFloat(STATE_SCALE, imageView.getScale());
        outState.putParcelable(STATE_CENTER, imageView.getCenter());
    }
}

@@ -381,16 +381,18 @@
 E_CENTER
+_X
  = %22stat
@@ -399,16 +399,85 @@
 e-center
+-x%22;%0A    private static final String STATE_CENTER_Y = %22state-center-y
 %22;%0A%0A    
@@ -841,16 +841,36 @@
  null &&
+%0A                   
  savedIn
@@ -908,16 +908,36 @@
 CALE) &&
+%0A                   
  savedIn
@@ -972,16 +972,88 @@
 E_CENTER
+_X) &&%0A                    savedInstanceState.containsKey(STATE_CENTER_Y
 )) %7B%0A   
@@ -1139,16 +1139,19 @@
 E), 
-(
+new 
 PointF
-)
+(
 save
@@ -1168,26 +1168,66 @@
 tate.get
-Parcelable
+Float(STATE_CENTER_X), savedInstanceState.getFloat
 (STATE_C
@@ -1231,16 +1231,19 @@
 E_CENTER
+_Y)
 ));%0A    
@@ -1662,24 +1662,105 @@
 etScale());%0A
+        PointF center = imageView.getCenter();%0A        if (center != null) %7B%0A    
         outS
@@ -1771,18 +1771,13 @@
 .put
-Parcelable
+Float
 (STA
@@ -1789,33 +1789,89 @@
 NTER
-, imageView.getCenter());
+_X, center.x);%0A            outState.putFloat(STATE_CENTER_Y, center.y);%0A        %7D
 %0A   

Change demo to store floats instead of point on save state