use of android.os.Handler 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));
}
use of android.os.Handler in project platform_frameworks_base by android.
the class ViewPropertyAnimatorTest method testPlayingDelayedCancelMidDelay.
/**
* Same as testPlayingDelayedCancel, but cancel during the startDelay period
*/
@MediumTest
public void testPlayingDelayedCancelMidDelay() throws Exception {
mAnimator.setStartDelay(ANIM_DELAY);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
// Set the listener to automatically timeout after an uncanceled animation
// would have finished. This tests to make sure that we're not calling
// the listeners with cancel/end callbacks since they won't be called
// with the start event.
mFutureListener = new FutureReleaseListener(mFuture, getTimeout());
Handler handler = new Handler();
mRunning = true;
mAnimator.start();
handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DELAY);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout() + 100, TimeUnit.MILLISECONDS);
}
use of android.os.Handler in project platform_frameworks_base by android.
the class ViewPropertyAnimatorTest method testPlayingCancel.
/**
* Verify that canceling an animator that is playing does the right thing.
*/
@MediumTest
public void testPlayingCancel() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Handler handler = new Handler();
mAnimator.setListener(mFutureListener);
mRunning = true;
mAnimator.start();
handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DURATION);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
use of android.os.Handler in project platform_frameworks_base by android.
the class ViewPropertyAnimatorTest method testPlayingDelayedCancel.
/**
* Same as testPlayingCancel, but with a startDelayed animator
*/
@MediumTest
public void testPlayingDelayedCancel() throws Exception {
mAnimator.setStartDelay(ANIM_DELAY);
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Handler handler = new Handler();
mAnimator.setListener(mFutureListener);
mRunning = true;
mAnimator.start();
handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DURATION);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
use of android.os.Handler in project platform_frameworks_base by android.
the class EventsTest method testPlayingCancel.
/**
* Verify that canceling an animator that is playing does the right thing.
*/
@MediumTest
public void testPlayingCancel() throws Exception {
mFutureListener = new FutureReleaseListener(mFuture);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Handler handler = new Handler();
mAnimator.addListener(mFutureListener);
mRunning = true;
mAnimator.start();
handler.postDelayed(new Canceler(mAnimator, mFuture), ANIM_MID_DURATION);
} catch (junit.framework.AssertionFailedError e) {
mFuture.setException(new RuntimeException(e));
}
}
});
mFuture.get(getTimeout(), TimeUnit.MILLISECONDS);
}
Aggregations