Tuesday, December 27, 2016

[Movie Review] When a Peking family meets Au pair



*A movie (with Chinese name: 洋妞到我家) directed by Gang Chen, main actors include: Fan Xu,  Jianbing Chen and young actor from Columbia: Gianina Arana Terranova, the Chinese stars Honglei Sun and Liya Tong also shown up in the movie. 



A Chinese housewife (Fan Xu) was preparing for migrating to another country, mainly for her daughter (Pipi)'s education. She and her husband decided to hire an Au pair (Giannia) to teach Pipi English. Giannia is from Columbia, and she's an incurable optimist even though she had an unpleasant childhood since her mum died very early and she was raised up by her step mom who was really harsh to her. 

Overall speaking, the story is about the conflicts between Fan Xu and the au pair Giannia since they have totally different opinions on children's education, especially they were growing up in two different countries/cultures. Pipi's mom (Fan Xu) always over-protected her child: do not allow her child contact any "dirty" things, even prepared her own dishware when eating in restaurants. Do not allow her child get in touch with strangers, etc. While, Giannia wants Pipi to be independent, so she took Pipi outside, playing with her friends, took her to the subway where is full of strangers. After several rounds of conflicts, Fan Xu realized that Giannia is right, it's better to child to be independent. 

I thought about my daughter when I was watching the movie. Certainly I do not want my daughter to be over-protected, like the flower in a greenhouse, I want her to be independent as well. But how I can teach her to be independent, and what's the best way for her to grow up, this is for sure, as her father, I need to think more on this and to be prepared. 

  

Thursday, February 18, 2016

[Android UI]GridView and GridLayout

[Android UI]GridView and GridLayout

I was a bit confused about GridView and GridLayout at the very beginning when I was trying to use grid layout (not GridLayout, I had no idea what GridLayout is at that moment). What I want is the layout like this:


I want to know which one fits my need best. Here's what I have found:

1. GridView:
GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. The grid items are automatically inserted to the layout using a ListAdapter.

A typical grid view definition in XML is like this:
<?xml version="1.0" encoding="utf-8"?><GridView xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@+id/gridview"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:columnWidth="80dp"    android:numColumns="auto_fit"    android:verticalSpacing="16dp"    android:horizontalSpacing="16dp"    android:padding="16dp"    android:stretchMode="columnWidth"    android:gravity="center"/>
You can specify number of columns, rows, and also the column width etc. But seems the cells cannot be spanned which is actually what I wanted.

2. GridLayout:
Child views are aligned as cells in GridLayout, and you can scroll vertically or horizontally. 

A typical GridLayout definition in XML is like this:
<GridLayout    android:id="@+id/glfeature"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:rowCount="2"    android:columnCount="3"    android:alignmentMode="alignBounds"    android:layout_margin="6dp">
    <ImageView        android:id="@+id/button1"        android:layout_rowSpan="2"        android:layout_gravity="fill_vertical"
        android:layout_width="120dp"        android:layout_height="60dp"        android:layout_margin="10dp"        android:text="Button" />
    <ImageView        android:id="@+id/button1"        android:layout_gravity="fill_vertical"
        android:layout_margin="10dp"        android:text="Button" />
    <ImageView        android:id="@+id/button1"        android:layout_gravity="fill_vertical"
        android:layout_margin="10dp"        android:text="Button" />
    <ImageView        android:id="@+id/button1"        android:layout_gravity="fill_vertical"
        android:layout_margin="10dp"        android:text="Button" />
    <ImageView        android:id="@+id/button1"        android:layout_gravity="fill_vertical"
        android:layout_margin="10dp"        android:text="Button" />
</GridLayout>
You can specify column/row count for GridLayout, just like LinearLayout or RelativeLayout, you can specify the child views directly in XML file.

Okay, in a word. The major differences between these two can be summarized as below:
a). GridView is a ViewGroup, similar to ListView/RecyclerView. While GridLayout is a layout for holding views, similar to LinearLayout/RelativeLayout
b). You can set up adapter for GridView while you cannot do that for GridLayout
c). You cannot span cells in GridView, while GridLayout support spanning cells.

And I got my layout implemented with GridLayout finally.



Saturday, April 11, 2015

[Android Studio] How to add an external jar into project


How to Add an External Jar in Android Studio

Any beginners of Android Studio may encounter this problem: how to add an external jar into current project. It's pretty easy, just follow these steps:

-1. download the jar file and create sub dir "libs" in the "app"dir if there's no such subdir, then put the jar file into this dir

-2. Right click current project, and select "Open Module Settings"

-3. Click "+" at the left-top corner to "Import .JAR or .AAR package"

-4. Then find and select the jar file which is now located in the "libs" sub dir. You can choose to "Remove original file" to keep the project clean.

-5. After that, android studio will automatically start to sync the whole project.

That's it, you will find out the new jar was added in your project, and also a new "build.gradle" file was also created, the new jar was added into current project's "build.gradle" file as well.

Thursday, October 16, 2014

Psychological analysis of popularity of mobile apps


Now we are in the era of mobile networking, smartphones can be seen everywhere, almost user behind the smartphone is contributing to the global networking everyday, not just by posting contents or comments on the social medias, but also he/she is reading the online information.

One phenomenon is that some mobiles apps are becoming more and more popular, such as Snapchat, Whatsapp, Instagram, and even a very simple app such as Yo can get more than thousands of millions of users. But at the same time, for most of other apps, it's very hard for them to get event 1K users. What's the essential reasons which lead to this huge difference?

To understand the reason, from my point of view, besides the UI/UX design of the apps, the most important feature a successful and popular mobile app should have is to catch user's sweet point, psychologically. 

I wanna list some psychological principles I found in those popular mobile apps:

1. Desire to share private things in a risk-free way:  
     I would like to talk a bit about Snapchat firstly, the most funny and important feature I like in this app is that I can share a picture to my friend for just a certain period of time, and after that, it will be destroyed. I never tried this before, because of this feature, people can share more private pictures even including nude pictures to their close friends while no need to worry that somebody may leak these pictures online. The psychological principle behind this I think is people has a kind of desire to share private things with others in a limited range, cause no one wants to be judged by the public, but by a few close friends, it's okay. 
    This remind me about another app called "secret", I think the psychological principle behind this app is similar but with a bit difference. Everybody can share their personal awkward and ridiculous secret in a public platform, and others can comment on this, most of the users are interacting in anonymous way, possibly only the back end engineers of this app can tell who is who in the app.

2.  More personal, more sticking:
     People want to feel special and unique, a customized and personalized app will give user this kind of feeling. How to make it personal? Well, at least, I think there are two ways: put my personal friends in this app and allow me to share or post personal things in this app. All of the social network apps such as Facebook, Twitter, Google+ have this functionality. From users' point of view, if they put more personal things in an app, more likely, they will check this app. For example, I rarely posted on Facebook and Wechat, but I check these apps frequently, at least every two or three days, because, my friends are also in this app, and I want to check their status too.

3.  Have fun in a boring life (more interactive, more fun):
     Thanks to the internet and our powerful logistics system, we don't need to go outside and interact with other people, we can get what we want just by connecting to the internet and a few clicks on a web page or in an app.  That also means we are losing one of our major nature instincts: sociability. Life is becoming boring since individuals are more independent from each other than before. Apps which can make our daily life more fun and colorful definitely will get people's favor. For example, Yo is such kind of app, it's very simple, and the functionality looks "stupid", but it is fun, you have to admit this. I think it has the simplest way for you to interact with your friends, and that's why it's spreading quickly like virus. 

More apps I play around, the more I feel that a success of a mobile app is less related with the technology, but more related with the psychological issues. We did not see many fancy technologies in those popular apps, but we did see many unique functionality or feature in those apps. Hope those psychological principles I listed above may inspire us a bit when we're developing our own mobile apps. 

Android developer notes


To create a great product, you need to care about all aspects of it, usually we classify it into two categories: UX and UI.

UX is the most important, without this, user is not gonna use your app even your app got the most beautiful UI.

I'm listing some UX glitches here, so others who are reading this blog will benefit from this.

1 Network issues:
    We can guarantee that our app will always be used with high quality wifi connection, in case of slow/very slow network connection, we need to think about some scenarios in which user may get some problems:
     The principle here is: you can suppose the network is always reliable and even available, in this case, you need to make sure firstly the network task won't block the UI thread, and secondly, the app won't crash in case we cannot get data.

     a) You have a list view, and you also support search functionality for that. Before the whole list load, user may start to search using some keywords. Firstly, we need to make sure the app won't crash; Secondly, we need to show some hints to the user, cause in this case, definitely no result will be found for the search.

      b) You have an async task for one activity/fragment, and in this task, you're gonna use the activity instance, before the task finish, user switches to another activity / fragment, so what are you gonna do to prevent the potential app crash since the previous activity instance is already destroyed. Then in this case, don't use the instance of the activity, use the whole application instance instead.

      c) Sync up between menu items and network task: suppose you're using a global variable which will be assigned in an async task, and this value will be used when user click one of the menu buttons. But due to the unreliable network, before the global variable is assigned, user may click the menu button. Then your app should tolerate this case and make sure it won't crash.

To be continued.

Friday, April 11, 2014

Android Development Handbook


Chapter 1. Setting up Development Environment

1.1 Make sure you have installed Java Runtime  Environment (JRE) and Java Development Kit (JDK) on your machine.

1.2 Download android SDK from: http://developer.android.com/sdk/index.html, follow the instructions to set up the SDK runtime environment

1.3. For some reasons, it won't work in some OS. I was running ubuntu 12.04 LTS 64bits. I got the following error: 
"Unexpected exception 'Cannot run program "/home/.../Descargas/adt-bundle-linux-x86_64 20131030/sdk/platform-tools/adb": error=2, No existe el archivo o el directorio' while attempting to get adb version from '/home/.../Descargas/adt-bundle-linux-x86_64-20131030/sdk/platform-tools/adb'"
when I launched eclipse which already integrated android SDK. I checked the error information in eclipse console, seems I need to install ia32-libs. 

One way to solve the lib dependency issue is to install the following libs one-by-one:

sudo apt-get install libgl1-mesa-dri:i386
sudo apt-get install ia32-libs-multiarch:i386
sudo apt-get install ia32-libs-multiarch
sudo apt-get install ia32-libs

It works well after all libs are ready.

1.4 Follow instructions on the Android official website and enjoy android application development.

* Sometimes, we cannot start the emulator. As I am running android studio on Ubuntu 12.04, and is using Nvidia GPU, an error may triggered because of an OpenGL library cannot be found, such as:
emulator: ERROR: Could not load OpenGLES emulation library: libOpenglRender.so: cannot open shared object file: No such file or directory
emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
A possible way to avoid this problem is specify the option: [ -gpu off | -no-audio ] in command line before launching the emulator.
And also, to specify the missed library path, we should add "/home/.../android-studio/sdk/tools/lib" into "LD_LIBRARY_PATH"




Sunday, March 30, 2014

Federal Tax Return of J1 Scholar


There's a saying: "Nothing is certain but death and taxes". People in US start to get busy in March and April, cause this is so-called "tax-season" in US. Many documents and forms need to complete and submit.

2013 is my first year as a research scholar in US, holding  a J1 visa. As a J1 visa holder, I'm "non resident alien" in US for my first two years, but after that, I will be "resident alien" in US. Two different identities, mean two different ways to apply for federal tax return.

The steps to apply for federal tax return is pretty easy, suppose you're using Glacier for online tax process,which was specially designed for non-resident aliens.
1. Sign into this system, and choose to complete tax return, you will be redirected to the GTP system (which is short for Glacier Tax Prepare system)
2. Basically, before starting applying for federal tax return, you should already got your W-2, and 1042-S forms (or other forms, depends on your visa type and identify in US). Just copy the contents in above forms into the GTP system.
3. GTP will generate some forms for you, the only thing you need to do is print out these forms, sign and date them, and then mail them to IRS (Internal Revenue Service).
* Somethings need to be kept in mind are:
   - Copy those printed out forms before mailing them to IRS, since you need to keep those copies for certain period of time (usually, 3 calender years)
   - File separated forms in separated envelopes to IRS if you have spouse or dependents in US who's also need to submit forms.

That's all, enjoy life, enjoy tax!