At first I was having problems with the first challenge getting an exception on super.onRestoreInstanceState.
After reading the forums I noticed that it should have been obvious since the start. On the bundle for the state of the BoxDrawingView I need to save the state of its super implementation at onSaveInstanceState, and pass it back at onRestoreInstanceState
The second challenge is harder too
Here are my two main problems
At first, I didn’t (and still not fully) understand the differences between event.getAction() and event.getActionMasked(). I got them backwards.
Maybe its a problem of me not being a native english speakr that I got it wrong, but I realized it after seeing that I didn’t get ACTION_POINTER_DOWN events when using getAction() on the switch() .
The second (and harder) problem is that the challenge is not clear on the behavior of the app., and as a result I am trying to implement something rather ambitius.
First finger sets up the initial rectangle, after I put my second finger, I should get the following behaviour.
When I move the first finger, the corner I am moving is moved still, keeping the oposite corner static, keeping the figure a rectangle and resizing it.
When I move the second finger, the rectangle should rotate around the corner I am holding with the first finger.
Any other finger should be ignored.
The second finger can go up and down indefinitely and keep the behavior, but if the first finger goes up, it should be over…
Rather confusing. I have noticed I can’t do this with the current rectangle implementation, so now I wave switched over to having the explicit four points of the rectangle and using Path for drawing and a Matrix for rotating the individual corners.
This helped understand the events better though.