diff options
author | Artur Dryomov <artur.dryomov@gmail.com> | 2013-09-10 22:40:41 +0300 |
---|---|---|
committer | Artur Dryomov <artur.dryomov@gmail.com> | 2013-09-11 01:43:54 +0300 |
commit | 5dd70c5c9b3e8cc7313285c2eae31b8d4f7a8d60 (patch) | |
tree | c81298513f9e9a6ae882a257262da1c29dc02ae5 /android/sdremote | |
parent | ca5c6e9696048fca9cafba632b574ca4c351b4dd (diff) |
Add ability to change transactions via clicking a slide.
Change-Id: Ifc9344c53492a053b15bc0f005e881bc09077473
Diffstat (limited to 'android/sdremote')
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java | 10 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java | 22 |
2 files changed, 29 insertions, 3 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java b/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java index be6f84fcc974..328dc9773a39 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java +++ b/android/sdremote/src/org/libreoffice/impressremote/adapter/SlidesPagerAdapter.java @@ -25,11 +25,15 @@ public class SlidesPagerAdapter extends PagerAdapter { private final SlideShow mSlideShow; - public SlidesPagerAdapter(Context aContext, SlideShow aSlideShow) { + private final View.OnClickListener mSlideClickListener; + + public SlidesPagerAdapter(Context aContext, SlideShow aSlideShow, View.OnClickListener aSlideClickListener) { mLayoutInflater = LayoutInflater.from(aContext); mImageLoader = new ImageLoader(aContext.getResources(), R.drawable.slide_unknown); mSlideShow = aSlideShow; + + mSlideClickListener = aSlideClickListener; } @Override @@ -48,6 +52,10 @@ public class SlidesPagerAdapter extends PagerAdapter { setUpUnknownSlidePreview(aSlideView); } + // ViewPager itself cannot handle click events, + // so we need to use hacks. Android is good. + aSlideView.setOnClickListener(mSlideClickListener); + aViewGroup.addView(aSlideView); return aSlideView; diff --git a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java index f12b3d8ed048..aa86de07e5e4 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java +++ b/android/sdremote/src/org/libreoffice/impressremote/fragment/SlidesPagerFragment.java @@ -33,7 +33,7 @@ import org.libreoffice.impressremote.R; import org.libreoffice.impressremote.adapter.SlidesPagerAdapter; import org.libreoffice.impressremote.communication.CommunicationService; -public class SlidesPagerFragment extends SherlockFragment implements ServiceConnection, ViewPager.OnPageChangeListener { +public class SlidesPagerFragment extends SherlockFragment implements ServiceConnection, ViewPager.OnPageChangeListener, View.OnClickListener { private CommunicationService mCommunicationService; private BroadcastReceiver mIntentsReceiver; @@ -92,7 +92,25 @@ public class SlidesPagerFragment extends SherlockFragment implements ServiceConn private PagerAdapter buildSlidesAdapter() { SlideShow aSlideShow = mCommunicationService.getSlideShow(); - return new SlidesPagerAdapter(getActivity(), aSlideShow); + return new SlidesPagerAdapter(getActivity(), aSlideShow, this); + } + + @Override + public void onClick(View aView) { + if (!isLastSlideDisplayed()) { + showNextTransition(); + } + } + + private boolean isLastSlideDisplayed() { + int aCurrentSlideIndex = mCommunicationService.getSlideShow().getHumanCurrentSlideIndex(); + int aSlidesCount = mCommunicationService.getSlideShow().getSlidesCount(); + + return aCurrentSlideIndex == aSlidesCount; + } + + private void showNextTransition() { + mCommunicationService.getTransmitter().performNextTransition(); } private int getSlidesMargin() { |