Change slide show operations related to its starting.

Do not start a slide show when it is already started.

Change-Id: I2cd1df48c07f60ddedb63f93973a0bda029bbd3f
This commit is contained in:
Artur Dryomov 2013-09-14 01:04:16 +03:00
parent 06806b93f1
commit f9bee0318c
4 changed files with 26 additions and 6 deletions

View File

@ -118,6 +118,11 @@ public class SlideShowActivity extends SherlockFragmentActivity implements Servi
}
private void startSlideShow() {
if (mCommunicationService.getSlideShow().isRunning()) {
setUpSlideShowInformation();
return;
}
mCommunicationService.getTransmitter().startPresentation();
}

View File

@ -186,6 +186,7 @@ public class CommunicationService extends Service implements Runnable, MessagesL
public void onSlideShowStart(int aSlidesCount, int aCurrentSlideIndex) {
mSlideShow = new SlideShow(mTimer);
mSlideShow.setSlidesCount(aSlidesCount);
mSlideShow.setRunning(true);
Intent aIntent = Intents.buildSlideShowRunningIntent();
LocalBroadcastManager.getInstance(this).sendBroadcast(aIntent);

View File

@ -12,6 +12,8 @@ import android.util.SparseArray;
public class SlideShow {
private boolean mRunning;
private int mSlidesCount;
private int mCurrentSlideIndex;
@ -21,13 +23,23 @@ public class SlideShow {
private final Timer mTimer;
public SlideShow(Timer aTimer) {
this.mSlidesCount = 0;
this.mCurrentSlideIndex = 0;
mRunning = false;
this.mSlidePreviewsBytes = new SparseArray<byte[]>();
this.mSlideNotes = new SparseArray<String>();
mSlidesCount = 0;
mCurrentSlideIndex = 0;
this.mTimer = aTimer;
mSlidePreviewsBytes = new SparseArray<byte[]>();
mSlideNotes = new SparseArray<String>();
mTimer = aTimer;
}
public void setRunning(boolean aRunning) {
mRunning = aRunning;
}
public boolean isRunning() {
return mRunning;
}
public void setSlidesCount(int aSlidesCount) {

View File

@ -132,7 +132,9 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn
@Override
public void onPageSelected(int aPosition) {
mCommunicationService.getTransmitter().setCurrentSlide(aPosition);
if (mCommunicationService.getSlideShow().getCurrentSlideIndex() != aPosition) {
mCommunicationService.getTransmitter().setCurrentSlide(aPosition);
}
setUpSlideNotes(aPosition);
}