“This is the 13th day of my participation in the November Gwen Challenge. See details: The Last Gwen Challenge 2021”.

preface

The novel reader can now be modified to draw on the ListView instead of the original canvas.

But before we do that, maybe we can do some other optimizations, such as the simulation page flipping;

The status quo

On the novel reader that has been implemented so far, the simulation page turning looks like this:

The reference implementation is from this series of articles:

# Android Development from Scratch series summary

The solution I implemented is a simple optimization of this solution, and the performance is indeed shown in the figure, with no major problems;

But according to canto 3, the flip back is drawn in this way:

At this point, you can do some optimization;

plan

The original plan looked like this:

To be honest, my first reaction was to skip it; Very discouraging indeed;

To sum up, the operation of layers is quite complicated, including flipping, a rotation, two pans, and finally cropping.

After studying this part this time, I found that there is no need to be so complicated, in fact, a rotation plus a flip and finally a clipping is ok;

The above picture is an example, to be clear, it is based on this point to flip, and finally according to the page area clipping:

In terms of implementation, it’s pretty much the same, because you’re using matrices; But thinking about it, it’s a lot easier;

To put it plainly, it can be regarded as first translating to the position of the intersection, rotating the Angle of ehD in the figure above, then flipping, namely scale, and finally processing the effect of cropping down, which is the desired effect;

If you combine it with a matrix, it’s pretty much the same as the original solution, but in terms of understanding, it’s a lot easier;

Most importantly, there is no need to use a matrix, this method can be implemented directly using the API provided;

At the end

This article summarizes my review of an optimization point in the original project thinking, the next is to use a customized ListView, to reconstruct the current novel reader completely;