diff options
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java index c70599e3957b..05172b56a8a3 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java @@ -75,6 +75,27 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } @Override + public void onViewStateRestored(Bundle aSavedInstanceState) { + super.onViewStateRestored(aSavedInstanceState); + + if (aSavedInstanceState == null) { + return; + } + + loadLayout(aSavedInstanceState); + } + + private void loadLayout(Bundle aSavedInstanceState) { + int aLayoutIndex = aSavedInstanceState.getInt("LAYOUT"); + + getViewAnimator().setDisplayedChild(aLayoutIndex); + } + + private ViewAnimator getViewAnimator() { + return (ViewAnimator) getView().findViewById(R.id.view_animator); + } + + @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); @@ -89,7 +110,6 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv @Override public void onServiceConnected(ComponentName aComponentName, IBinder aBinder) { CommunicationService.CBinder aServiceBinder = (CommunicationService.CBinder) aBinder; - mCommunicationService = aServiceBinder.getService(); connectToComputer(); @@ -181,7 +201,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } private void showPinValidationLayout() { - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); + ViewAnimator aViewAnimator = getViewAnimator(); LinearLayout aValidationLayout = (LinearLayout) getView().findViewById(R.id.layout_pin_validation); aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aValidationLayout)); @@ -215,7 +235,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } private void showErrorMessageLayout() { - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); + ViewAnimator aViewAnimator = getViewAnimator(); LinearLayout aMessageLayout = (LinearLayout) getView().findViewById(R.id.layout_error_message); aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aMessageLayout)); @@ -240,9 +260,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv return false; } - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); - - return aViewAnimator.getCurrentView().getId() == R.id.layout_error_message; + return getViewAnimator().getCurrentView().getId() == R.id.layout_error_message; } @Override @@ -260,7 +278,7 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } private void showProgressBar() { - ViewAnimator aViewAnimator = (ViewAnimator) getView().findViewById(R.id.view_animator); + ViewAnimator aViewAnimator = getViewAnimator(); ProgressBar aProgressBar = (ProgressBar) getView().findViewById(R.id.progress_bar); aViewAnimator.setDisplayedChild(aViewAnimator.indexOfChild(aProgressBar)); @@ -283,6 +301,19 @@ public class ComputerConnectionFragment extends SherlockFragment implements Serv } @Override + public void onSaveInstanceState(Bundle aOutState) { + super.onSaveInstanceState(aOutState); + + saveLayout(aOutState); + } + + private void saveLayout(Bundle aOutState) { + int aLayoutIndex = getViewAnimator().getDisplayedChild(); + + aOutState.putInt("LAYOUT", aLayoutIndex); + } + + @Override public void onDestroy() { super.onDestroy(); |