diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-08-02 17:42:19 +0300 |
---|---|---|
committer | Artur Dryomov <artur.dryomov@gmail.com> | 2013-08-03 19:01:57 +0300 |
commit | d4b4c94aa185093927866818b81816452310c5f3 (patch) | |
tree | 40b894473b03953537054a09ea95d06b03a8741a /android | |
parent | c76434ae061ecb07c61543cafcc9c9a14c6a2229 (diff) |
Add saving current mode when showing a slide show.
Should be helpful on orientation changes.
Change-Id: I0a00c980882decc3da3460f63b82c5d0bb308298
Diffstat (limited to 'android')
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java index f739394c3a32..fc0f7c623754 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java +++ b/android/sdremote/src/org/libreoffice/impressremote/activity/SlideShowActivity.java @@ -46,10 +46,10 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi private IntentsReceiver mIntentsReceiver; @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); + protected void onCreate(Bundle aSavedInstanceState) { + super.onCreate(aSavedInstanceState); - mMode = Mode.PAGER; + mMode = loadMode(aSavedInstanceState); setUpHomeButton(); setUpFragment(); @@ -57,6 +57,14 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi bindService(); } + private Mode loadMode(Bundle aSavedInstanceState) { + if (aSavedInstanceState == null) { + return Mode.PAGER; + } + + return (Mode) aSavedInstanceState.getSerializable("MODE"); + } + private void setUpHomeButton() { getSupportActionBar().setHomeButtonEnabled(true); } @@ -131,6 +139,7 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi if (Intents.Actions.TIMER_STARTED.equals(aIntent.getAction())) { int aMinutesLength = aIntent.getIntExtra(Intents.Extras.MINUTES, 0); mSlideShowActivity.startTimer(aMinutesLength); + mSlideShowActivity.setUpSlideShowInformation(); return; } @@ -208,8 +217,6 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi aTimer.setMinutesLength(aMinutesLength); aTimer.start(); - - setUpSlideShowInformation(); } private void resumeTimer() { @@ -358,9 +365,24 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi } @Override + protected void onSaveInstanceState(Bundle aOutState) { + super.onSaveInstanceState(aOutState); + + saveMode(aOutState); + } + + private void saveMode(Bundle aOutState) { + aOutState.putSerializable("MODE", mMode); + } + + @Override protected void onDestroy() { super.onDestroy(); + if (!isServiceBound()) { + return; + } + stopTimer(); disconnectComputer(); @@ -373,18 +395,10 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi } private void disconnectComputer() { - if (!isServiceBound()) { - return; - } - mCommunicationService.disconnect(); } private void unbindService() { - if (!isServiceBound()) { - return; - } - unbindService(this); } |