GestureListView is an experiment on how to achieve an effect like the one I described here on StackOverflow.
Those interactions/gestures (call them whatever you like) are simply amazing and one can see them more and more in iPhone and iPad apps such as Twitter or Clear.
My point is to gather ideas on this in order to achieve such a feature on an Android ListView.
So please gentlemen, let's help the community.
The main goal of this repository is to be highly collaborative but a lot of path may lead to the success of this enterprise.
For this reason, if you want to contribute to this repo and not only work on your own fork, please follow this simple rule: Code in a dedicated branch.
We'll all see later what's the best solution and put that one onto master.
Kept clean of development experiments. Is intended to contain the final working solution and the documentation on each branch via the README file.
This branch is a first experiment with a ScaleGestureDetector.
- The pinch gesture is somehow like a dragging gesture, we can get the X and Y coordinates of center of the two fingers on the screen
- Get the index position of the first visible item in the list
- Get the index position of the last visible item in the list
- Iterate from the first index to the last with the getChildAt function
- For each child, call the getLocationOnScreen method to get coordinates of the current iterated item
- After that, some comparison between the pinch gesture coordinates and each item coordinates might be done inside the loop to get the two items between which the new row must me inserted
- Use the scale factor to grow and shrink the newly added item
Result: Messy ListView scroll side effect but the item is added and its height can be manipulated.
- Get the position of each fingers 'pointers' on the screen in ACTION_POINTER_DOWN of MotionEvent and identify above from below finger
- Add a new item inside the list and notify the adapter
- When a finger is moved (inside ACTION_MOVE), adjust the height of the item according to the delta between the previous move and this one
- Take care of the scroll position when moving the above finger
Result: Still scroll side effects but interaction is much more close to the result we want to implement. When the user just puts his fingers on the screen, without moving (which is extremely difficult and not willing to happen often, but still), the new item is drawn with its full default size, and then redrawn to height close of 0 when fingers are moved. This is uggly is you succeed in noticing it.
Let's be awesome!