Guowei Lv

5 minute read

In this post we talk about the drawing order in custom view. After super.onDraw() What we have done in the previous episodes is to override the onDraw() method of the View class. A lot of times we do not need to create our own custom view from scratch. We can simply extends an existing view, e.g. ImageView. If we want to draw something on top of the image, we can write that after the super.

Instance Initialization Block in Android

Use of IIB block in Android

Guowei Lv

2 minute read

This will be a short and sweet post. The usage of Instance Initialization Block of Java in custom android views. First of all, I have a confession to make. After almost 10 years of Java programming, I do not really know what is IIB and why it exists. Pretty obviously, the purpose of IIB is to initialize instance variables of a class. But you may ask isn’t that the job of constructors?

Android Custom View 102 (Part III)

Geometric Transformations

Guowei Lv

7 minute read

In this post, we will be focusing on what canvas can do. To demonstrate the effects, I simply created custom view that draws an image. The original verion is like this: Clip Clipping is easy to understand, it’s like cut the view in a certain way so that only part of it is shown. There are 2 methods: clipRect() and clipPath(). clipRect() This method will clip the view using a rectangle.

Guowei

2 minute read

Let’s take another look at the assembly line diagram now. If you pay close attention at each of the workers and observe how they work, you will probably find the 3 workers at the beginning of the assembly line to be a bit … not that smart. All of them only one type of part, either wheels or bodies. If the body worker takes a wheel, he will just abandon it and keep taking new parts until he gets a body.

Toy Factory Simulation Using core.async (5)

Closing Shop (Stopping Processes)

Guowei

3 minute read

We need a way to stop the whole assembly line after 10 toy cars have been put in the truck. But before that, we need to understand more about chan. Channels are created open Close a channel with close! You can call close! to close a channel. Once a channel is closed, it can never be reopened. Put (>!) on a closed channel returns false. Get (<!) from a closed channel returns nil.