From f98687b22f4091083287ab7de7a0f3102bd9c1ba Mon Sep 17 00:00:00 2001 From: Chris Wren Date: Thu, 13 Sep 2012 13:52:27 -0400 Subject: deal out new images in batches Change-Id: I1637c4063a0f743efdde79e47c5f283ff5771f05 --- src/com/android/dreams/phototable/PhotoTable.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/dreams/phototable/PhotoTable.java b/src/com/android/dreams/phototable/PhotoTable.java index 076fe68..0c9c47f 100644 --- a/src/com/android/dreams/phototable/PhotoTable.java +++ b/src/com/android/dreams/phototable/PhotoTable.java @@ -76,6 +76,7 @@ public class PhotoTable extends FrameLayout { private final float mThrowSpeed; private final boolean mTapToExit; private final int mTableCapacity; + private final int mRedealCount; private final int mInset; private final PhotoSourcePlexor mPhotoSource; private final Resources mResources; @@ -107,6 +108,7 @@ public class PhotoTable extends FrameLayout { mThrowSpeed = mResources.getDimension(R.dimen.image_throw_speed); mThrowRotation = (float) mResources.getInteger(R.integer.image_throw_rotatioan); mTableCapacity = mResources.getInteger(R.integer.table_capacity); + mRedealCount = mResources.getInteger(R.integer.redeal_count); mTapToExit = mResources.getBoolean(R.bool.enable_tap_to_exit); mThrowInterpolator = new SoftLandingInterpolator( mResources.getInteger(R.integer.soft_landing_time) / 1000000f, @@ -394,8 +396,12 @@ public class PhotoTable extends FrameLayout { .withEndAction(new Runnable() { @Override public void run() { - while (mOnTable.size() > mTableCapacity) { - fadeAway(mOnTable.poll(), false); + if (mOnTable.size() > mTableCapacity) { + while (mOnTable.size() > (mTableCapacity - mRedealCount)) { + fadeAway(mOnTable.poll(), false); + } + // zero delay because we already waited duration ms + scheduleNext(0); } } }); -- cgit v1.2.3