use of com.bourke.glimmr.fragments.viewer.PhotoViewerFragment.PhotoViewerVisibilityChangeEvent in project glimmr by brk3.
the class PhotoViewerActivity method startSlideshow.
private void startSlideshow() {
final Handler handler = new Handler();
SharedPreferences defaultSharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
final int delay_m = Integer.parseInt(defaultSharedPrefs.getString(Constants.KEY_SLIDESHOW_INTERVAL, "3")) * 1000;
if (BuildConfig.DEBUG)
Log.d(TAG, "slideshow delay: " + delay_m);
mTimer = new Timer();
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
mTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
handler.post(new Runnable() {
@Override
public void run() {
int currentPosition = mPager.getCurrentItem();
currentPosition++;
if (currentPosition >= mAdapter.getCount()) {
currentPosition = 0;
}
mPager.setCurrentItem(currentPosition);
}
});
}
}, delay_m, delay_m);
BusProvider.getInstance().post(new PhotoViewerVisibilityChangeEvent(!mActionBar.isShowing(), this));
}
Aggregations