Posts

10 tips to speed up Android Gradle build

Image
A few months ago, in the year’s Google I/O, there is a wonderful tutorial to guild us how to speed up Android Gradle build. Grade always has a notorious reputation about the slow build for large modules dependency project, those upgrade will solve those problems. I copy a few of them here for the future reference. Although I still wait for the latest Android Studio 3.0 and grade plugin release which those tips dependence on.

Expand View's Touch area in Android

Image
There is an issue that I met a few days ago, my colleague wants me to improve the checkbox's clickable experience in Android. Following is the layout code and its visual effect. Then the xml layout file: < LinearLayout android : layout_width = " wrap_content " android : layout_height = " wrap_content " android : orientation = " vertical " > < LinearLayout android : id = " @+id/checkbox1_container " android : layout_width = " wrap_content " android : layout_height = " wrap_content " android : layout_marginEnd = " 50dp " android : layout_marginRight = " 50dp " android : gravity = " center " android : orientation = " horizontal " > < CheckBox android : id = &q

How to do Flip Animation in Android

Image
In the last  post , I list a category of Animations in Android platform, that’s my road map to learn android animation and this post will give a specific live example about the flip transformation which is really common in our apps. In the last post, I list the two kinds of animation strategies in Android, Animation and more powerful Animator. Both of them can implement the flip animation in our case, and my purpose is to compare those two ways. Animation We can’t use the predefined Animation subclass directly, there are scale, rotate, alpha and translate Animations, but we can’t use rotate animation to build the card flip effect. We should subclass Animation class to define the flip effect. package suzp1984.github.io.exapidemo.animation import android.graphics.Camera import android.view.animation.Animation import android.view.animation.Transformation class FlipAnimation(fromDegre: Float, toDegre: Float, centerX : Float, centerY : Float) : Ani

SQL tutorial - row column transform

Image
In this case, I intend to introduce a complicated SQL query problem: row column transform. In the last chapter, about the fundamental SQL syntax , I used a MySQL sample database named sakila . In this tutorial, I still use it. transform rows to columns Task #1: Take table actor inside sakila for example, How to query the most popular last_names? let limit the condition to the last_names repeat at least more than 3 times. USE sakila ; SELECT last_name , COUNT ( first_NAME ) as size FROM actor GROUP BY last_name having size > 3; We got the result: + -----------+------+ | last_name | size | + -----------+------+ | KILMER | 5 | | NOLTE | 4 | | TEMPLE | 4 | + -----------+------+ Task #2: Convert above result from row to column format. + --------+-------+--------+ | KILMER | NOLTE | TEMPLE | + --------+-------+--------+ | 5 | 4 | 4 | + --------+-------+--------+ Use CASE WHEN and co

SQL Tutorial - SQL Syntax

Image
This is my learning notes about the SQL (based on  MySql ). As far as I known, Mysql was acquired by Oracle , whose mainly product is also the enterprise highly professional database, and the founder of the Mysql worried the future of the MySQL, then he started another open sourced database named MariaDB . I consider the Mysql and MariaDB the same thing, they even have the same command line tool name. And with no hesitate, I use MariaDB as the alternative to Mysql in the tutorial. Database Creation The operation of Database include Change, Create, Alter, Drop database. USE db_name ; CREATE DATABASE IF NOT EXIST db_name CHARACTER SET = utf - 8 ; ALTER DATABASE db_name CHARACTER SET = utf - 8 ; DROP DATABASE IF EXIST db_name ; Table Creation The basic composition of a database is its tables, table schema definition is the beginning stage in the database design. There is two import aspect in define a table schema, the column data types and the constrictions.

Linking native Libraries in Android App

Image
ABI ABI , shorts for Application Binary Interface, is a concept combine the ARM architecture and Instructure set by some formal definition. According to the official document , android support 7 kinds of ABIs, if we want our app to support more android devices, we should package all 7 kinds of ABIs binaries to the package, in this case, it is a linking library. The advantage of this full package is that it can compatible with more devices, the disadvantage is that it enlarged the package size. Also in some situation, the linking library is provided by the third party, missing some ABI types. Then we should use the custom way to implement this app. How get current device's ABI? # ro . product . cpu . abi and ro . product . cpu . abi2 are obsolete , # use ro . product . cpu . abilist instead . ro . product . cpu . abi = armeabi - v7a ro . product . cpu . abi2 = armeabi ro . product . cpu . abilist = armeabi - v7a , armeabi ro . product . cpu . abilist32 = armeabi - v7

Memory Management in Android

Image
Memory in JVM One of the benefits of JVM is the isolation of memory from the host OS, so that if there are some errors in the JVM, the influence is only limited to current JVM process. Actually, the memory in a JVM can be separated to many functional parts, for the simplicity, Heap, and Stack. The Heap is this article's target, Out of Memory Error When the Heap size running to its limitation, the out of Memory Error throws, and the process will crash. It is really easy to repeat this Error, and just write codes to allocate memory repeatedly. while (true) { byte [ ] twn = new byte [ ( int ) ( 1024 L * 1024 L * 20 ) ] ; mLists . add ( twn ) ; } If you write some cache or Memory management app, then it is really the critic part to manage the memory. There are many reasons to trigger this error, serious memory leak or memory limitation, so how to enlarge the memory limitation. java -Xmx:1024m -Xms:512m This is the common way for  a general java command line p