/** Scroll to the next photo. If we reach the end, let's start over */ public void actionNextPhoto() { CustomGallery gallery = (CustomGallery) findViewById(R.id.gallery); if (gallery == null) { Log.w( LOG_PREFIX, "Gallery view is not found in actionNextPhoto! Let's make sure this doesn't crash the app"); return; } if (userCreatedTouchEvent || gallery.hasUserCreatedTouchEvent()) { Log.i( LOG_PREFIX, "User created a touch even since time task started. Will not skip to next photo yet"); return; } // Log.i(LOG_PREFIX, "Selected position is " + gallery.getSelectedItemPosition()+ " out of "+ // gallery.getCount()); // TODO: Evaluate if we should add all queued photos if we are almost at the end if (gallery.getSelectedItemPosition() + 1 == gallery.getCount()) { Log.i(LOG_PREFIX, "At the end of the slideshow. Starting on the first photo again"); Analytics.trackEvent(getApplicationContext(), "actions", "slideshow", "cycles-free"); gallery.setSelection(0); } else { // skip to next photo gallery.onKeyDown(KeyEvent.KEYCODE_DPAD_RIGHT, new KeyEvent(0, 0)); } }