In Part I, we talked about how to create a simple custom view. But we don’t really implement the onMeasure(). In this post, we will analyze what problems we will have if we omit the onMeasure().
You can think of how the measurements are made as a conversation between the child and parent views.
The child tells its parent how it wants to be laid out by using LayoutParams. This can either be set in xml file or programatically.
Some time ago I read this article about Why Mit Stopped Teaching SICP. Gerry Sussman said that nowadays people do not often need to build something from scratch again, there exists massive and huge library code for nearly everything. So today’s programming work is more like poking around other people’s code until it works.
I’ve beening doing Android dev for some time now, and I have to say that I sadly agree with him.
Creating your own custom android views can be useful and daunting at the same time. For a long time there is nobody really talks about it in a approachable way, until this lady Huyen Tue Dao. Let’s try to follow her approach and create some custom view!
In this part, we will create a very simple timer view that takes up the whole screen and display the current time.
So let’s get started.
While reading Effective Java Item 21: Use function objects to represent strategies, something hit my mind and now I’m writing it down.
All these new lambda thing is really what is called the Strategy pattern in the OOP world, or would it be more appropriate to say that the Strategy Pattern in Design patterns is really what lambda is.
The essence of all these, can be boiled down to one simple idea, pass functionalities around.
We are going to write a program, a bit program, lots of stuff happening here and there, ok, big program. Now, lots of threads of course, loads and loads of them, we have to synchronize, yes we do, I think so, yeah, synchronize very important stuff, good idea, but, why?
Remember what we have been taught in school? That mutex thing? Mutual Exclusive? That 2 threads are trying to read and write some mutual value at the same time and create a big mess?