commonsguy/cwac-touchlist — Issue #9: DrawingCache not cleared properly
Author: cmelchior
Created: 2011-12-30 07:48:16+00:00
State: open

In some configurations of the TouchList, the DrawingCache is not cleared properly resulting in a wrong image being dragged around when a row is pressed.

Reproduced on Google Nexus S by doing the following:

1) Restrict the demo app to the first 5 elements.
2) Set tlv:expanded_height to the same value as tlv:normal_height
3) Start the demo app
4) Begin to repeatedly drag the second element in the list to the bottom (ipsum, dolor, sit, amet).
5) After doing this approx 5 times (can vary a bit), the image being dragged is another than the row pressed.

Fix:
Disable the drawingcache after writing the draggable bitmap.

item.setDrawingCacheEnabled(true);
// Create a copy of the drawing cache so that it does not get recycled
// by the framework when the list tries to clean up memory
Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
item.setDrawingCacheEnabled(false);