Updates at 2012-12-12: Please checkout FlipView for an improved solution.
This short post explains how to handle touch events for the flip animation introduced in our previous post.
The full source codes of the demo application are available at Github:
A pre-built APK file is also present for your Android devices:
Updated at 2012-08-17: Fixed the broken links to the project and the APK file.
The new demo app adds two new features compared to the previous one:
Supports flipping over between two views. FlipCards.java takes screenshots of the front and back views, which are used to construct the textures for the translucent
GLSurfaceView. The flip animation is rendered by four instances of Card. Please refer to the draw(GL10 gl) method for more details.
Flip angle can be controlled by touch events. Angle is calculated according to the relative movement of touches. The logic can be found in the handleTouchEvent(MotionEvent event) method.
The demo app is just a prove of concept. It can be enhanced to be a component for general scenarios:
To support a
Adapteras its data source to load views dynamically and lazily.
To implement similar APIs like
To support other fancy effects that can be implemented in OpenGL ES.
But I’m sorry that I’ll be in a long trip with my family. Both
OpenAphid-Engine will not be updated until I come back. You can still reach me via email if you have any questions.