diff options
author | Jim Shuma <jshuma@google.com> | 2010-12-28 17:18:17 -0800 |
---|---|---|
committer | Jim Shuma <jshuma@google.com> | 2010-12-28 17:26:44 -0800 |
commit | d696cd4dc90b92e7653d5bcb0b14654c588e9d7d (patch) | |
tree | e70aab1f975ed689d407014f6d1f4fef92ce3bbd | |
parent | 819c18b25f5316429f34f975178999876c75b1de (diff) | |
download | android_frameworks_ex-d696cd4dc90b92e7653d5bcb0b14654c588e9d7d.tar.gz android_frameworks_ex-d696cd4dc90b92e7653d5bcb0b14654c588e9d7d.tar.bz2 android_frameworks_ex-d696cd4dc90b92e7653d5bcb0b14654c588e9d7d.zip |
Reset cards array on createCards(0)
createCards(0) is used to clear out an array. As such, it's
appropriate to entirely replace the array, rather than
resizing to size 1, which leaves stale data behind.
Bug: 3314456
Change-Id: Ifa1eb4a01ad9f5cc09c3cd6edce5de3f9602d9f0
-rw-r--r-- | carousel/java/com/android/ex/carousel/CarouselRS.java | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/carousel/java/com/android/ex/carousel/CarouselRS.java b/carousel/java/com/android/ex/carousel/CarouselRS.java index e60fcc7..3de1037 100644 --- a/carousel/java/com/android/ex/carousel/CarouselRS.java +++ b/carousel/java/com/android/ex/carousel/CarouselRS.java @@ -473,11 +473,10 @@ public class CarouselRS { // Because RenderScript can't have allocations with 0 dimensions, we always create // an allocation of at least one card. This relies on invoke_createCards() to keep // track of when the allocation is not valid. - if (mCards != null) { + if (mCards != null && count > 0) { // resize the array int oldSize = mCards.getAllocation().getType().getX(); - int newSize = count > 0 ? count : 1; - mCards.resize(newSize); + mCards.resize(count); mScript.invoke_createCards(oldSize, count); } else { // create array from scratch |