[Libreoffice-commits] core.git: android/sdremote
Artur Dryomov
artur.dryomov at gmail.com
Thu Aug 1 18:18:47 PDT 2013
android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java | 45 ++++++++--
1 file changed, 38 insertions(+), 7 deletions(-)
New commits:
commit 08157e4b63e41c1dbbc07584517fd4341cc5654c
Author: Artur Dryomov <artur.dryomov at gmail.com>
Date: Fri Aug 2 04:10:49 2013 +0300
Add saving state for ComputerConnectionFragment.
This change should provide more smooth rotation change.
Change-Id: I3d530485752069fb5f6d4683b68b83ef97f87808
diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/ComputerConnectionFragment.java
index c70599e..05172b5 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();
More information about the Libreoffice-commits
mailing list