summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorArtur Dryomov <artur.dryomov@gmail.com>2013-08-02 04:10:49 +0300
committerArtur Dryomov <artur.dryomov@gmail.com>2013-08-02 04:10:49 +0300
commit08157e4b63e41c1dbbc07584517fd4341cc5654c (patch)
treeeb940eb2299febdd7abbe1e4f21702168eb2250f /android
parent429148c5f10828c50ae41309942f4946b12a7df9 (diff)
Add saving state for ComputerConnectionFragment.
This change should provide more smooth rotation change. Change-Id: I3d530485752069fb5f6d4683b68b83ef97f87808
Diffstat (limited to 'android')
-rw-r--r--android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java45
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();