I'm trying to implement cover flow using (Neil Davies implementation). In my application I have to use hardware acceleration, but when I set the hardware acceleration property to true this coverflow implementation is not working well (It renders the camera translations very unsmooth and stucks when scrolling).
I tried to disable hardware acceleration only on the view layer - this did not help me.
According to some solutions I found here ,or here (and some others), I have to call to View.invalidate()
after applying the camera translation. As you can see in the attached code snippet I've added this line, but after adding this invalidate()
call this transformImageBitmap()
function is being called in a never ending cycle. As I understand after the invalidation of the view the view is being "layouted" and the transformImageBitmap()
called again. This never ending cycle of the transformImageBitmap()
function causes some preformace issues in my application.
Here is my transformImageBitmap() function:
private void transformImageBitmap(View child, Transformation t, int rotationAngle)
{
mCamera.save();
final Matrix imageMatrix = t.getMatrix();
final int imageHeight = child.getLayoutParams().height;
final int imageWidth = child.getLayoutParams().width;
mCamera.translate(0.0f, 0.0f, 100.0f);
float zoomAmount = 0;
zoomAmount = Math.abs((float) (rotationAngle));
mCamera.translate(0.0f, 0.0f, zoomAmount - 300.0f);
mCamera.getMatrix(imageMatrix);
imageMatrix.preTranslate(-(imageWidth/2), -(imageHeight/2));
imageMatrix.postTranslate((imageWidth/2), (imageHeight/2));
mCamera.restore();
Log.e(LOG_TAG, "in transformImageBitmap");
child.invalidate();
}
How can I make this work properly?