Posts

Showing posts from September, 2015

Javascript Callback Hell

Image
Javascript Callback Hell Table of Contents callback hell Promise bluebird 1 callback hell Javascript callback hell looks like an inherent problem in js language, because of its asynchronous nature, writing callback functions and nesting them together looks the only way to coding for a newbie.    It then gave programmers some mess code, if he persists to writing nesting callback code, and this mess codes are named as callback hell . fs.readFile( "file.json" , function ( err , val ) { if ( err ) { console.error( "unable to read file" ); } else { try { val = JSON.parse(val); console.log(val.success); } catch ( e ) { console.error( "invalid json in file" ); } } }); 2 Promise Promise is a new ES6(ECMAScript 2015) feature, is used for deferred and asynchronous computations. Promise is also a proposal , which represents the eventual

JBIG Android library published

Image
JBIG Android library published Table of Contents Design details Where it come from? Include the dependency into your gradle script Start to use it Please jump to jbig-android 's home page . 1 Design details jbig-android is just a JNI level wrapper of jbig-kit , so it inherited its License as GPL v3. If you are a newbie of JNI programming, you can refer my JNI tutorial . Basically, JNI part is the key of porting jbig-kit to android platform. Beside the core implementation of this project, the sample code pleased me the most. I tried to wrote it in an MVC way, which took me the most time, and it succeeds, Maybe I will use another post to describe this MVC paradigm and its apply in Android App. Of course, I learned this way and copy it from Chris Banes's sensational work philm . 2 Where it come from? About years ago, I met this problem, the format of hand write a signature in bank related system, like a POS. The customer sign in the screen(LED)

How to publish and distribute your Android AAR package?

Image
How to publish and distribute your Android AAR package? Table of Contents JCenter vs Maven Central Add build script dependencies Configure the library module Sign up an account in bintray Sample 1 JCenter vs Maven Central I don't know since when Android Gradle's default repository started to use jcenter instead of the older maven central as the default archive repository. According to some talks, Jcenter can leverage the JFrog's technology, which is a superset of Maven central, so it improved and promoted the efficiency of Android project compilation. In a word, Jcenter is better than Maven Central. 2 Add build script dependencies dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.3.1' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // NOTE: Do not place your application dependencies here; the