Posts

Showing posts from May, 2016

Custom 2D Drawing in Android and Html5 Canvas

Image
Recently, I attended an online MOOC course about  html5 canvas drawing . I was surprised how simple of its  drawing API , which has the power to create awesome UI effect. I summarize the 2D drawing API as two fields: regular shape drawing API and transformation API. As for 2D shape drawing in html5 Canvas there are following limited properties and functions: beginPath, endPath, fillStyle, strokeStyle, stroke, fill, fillRect, moveTo, lineTo, arc, font, fillText, strokeText, createLinearGradient, createRadialGradient, addColorStop, drawImage, bezierCurveTo, quadraticCurveTo. To sum up, the above 2D drawing API can do following jobs. moving a point; drawing a line; drawing an arc or circle; drawing a bezier curve; make a path; stroke along the path; fill the closed path with image, colors, gradient effect or patterns; Then, we count the transformation APIs: save, restore, translate, rotate, scale, transform. No need any more illustrations, is it? The transform one ma

Java Multi-Threading synchronization interview question

Image
The multi-threading synchronization questions always concentrate on a few keywords: wait, notify, notifyAll, synchronized, volatile. The following question is the hardest, I ever met. The thread t1 should print integer number from 1–52, the thread t2 should print character from A-Z, the question is how to let the final result to be 12A34B56C… by implement Printer class. (The Printer class is already finished by the way) public class Main { public static void main ( String [ ] args ) { System . out . println ( "Hello World!" ) ; Printer p = new Printer ( ) ; Thread t1 = new NumberPrinter ( p ) ; Thread t2 = new LetterPrinter ( p ) ; t1 . start ( ) ; t2 . start ( ) ; } } public class LetterPrinter extends Thread { private Printer p ; public LetterPrinter ( Printer p ) { this . p = p ; } public void run ( ) { for ( char c = 'A' ; c < = 

Light-BLE Release Note

Image
About two years ago, I published my debugging toolkit in Android for Bluetooth LE development, after that, I left that field, wearable-BLE equipment development just quit that job and join a new one. And now at this moment, I quit the job again, to summarize my collections during the past two years. There are two keynotes: my skills sharper a lot at Android App development, second,  Light-BLE  was still my most popular project. During the past one year, there are at least four people contact me for debugs and more stable demos. Finally, I am here to announce the release of the beta-2 version of Light-BLE, it is actually be rewritten. This is the first version release note two years ago. http://zpcat.blogspot.com/2014/03/lightble-practical-app-tool-to-develop.html So, what was changed compared with the two years ago? 1. New Architecture I rewrite this project to compatible with the legendary MVP architecture, which decoupled the View and logical data layer, make your cod

Android Job Interview Questions

Image
In this post, I tried to wrote some Job interview questions, that I met during my Job interview journey. Yeah, some of the them are still so fresh, because I mess up them a lot. However, A sketch notebook is always better than a good memory, especially in the situation of the lack practice exercise. finalize function The finalize method is used in JVM’s GC collection. But, it was said that it never guaranteed to be called during the collection, that’s means unpredictable, so I guess why I should put the resource release code into an unpredictable method, still be puzzled. How to write a singleton and thread-safe class? Following is an ordinary Singleton class without thread-safe features. public class Singular { private static Singular sInstance ; private Singular ( ) { } public static Singular getInstance ( ) { if ( sInstance = = null ) { sInstance = new Singular ( ) ; } return sInstance ;