Do not think about animation so deep.
1. Create a thread for animation in which we can call invalidate.
2. And also, we can call paint method in main-thread itself when we call something like KEY_UP.
We can use aboves for animation.
My pleasure if you download the below for education.
Please reffer to the below for compilation.
https://waitrudweber.hatenablog.com/entry/2018/05/01/005938