Evangelion Clock V2.0 released

Finally, after almost 2 years I remake the whole Evangelion Clock widget. This time is a total remake and I do all the codes and graphics from scratch, and if you are a lucky kid and have a HD screen, you would really notice the difference in details. In addition, due to some popular demand, I throw in some nice feature to it and soon will release more, including:

  1. Customize Color Theme (Currently not including background color, but will soon include it)
  2. Tap to Launch (It’s Still here! Don’t trust those comments in app store) Remember to touch the “clock” instead of buttons.. buttons is doing something else
  3. Config button REALLY brings you to config
  4. Time will be current time (anyone need another time zone? poll it!)
  5. Count (not working now) is supposed to be a simple count down timer, like 3 minutes (for making cup noodles)…
  6. Batt (not now) is the “guessed” run-time remaining in your phone
  7. Mini version (removed, consider to re-include it later)

I need some help. Since multiple state will be available in the widget (battery, countdown, time etc.) I need some good Japanese words to be replaced in “活動限界までActive Time Remaining”. 活動限界まで will be reserved to battery only, but countdown/time would need a different name. If you have good idea, please comment!

Oh! forgot to mention, the config screen is powered by Android-Binding: MVVM framework for Android!

When an attribute or widget is not yet supported by Android-Binding

There are so many default view widgets in Android, although we tried hard to keep up, some attributes or views are still not supported by Android-Binding. Of course, we open to any suggestion to include them, please report it in the issue tracker or post in the discussion group.

Wait, you want to DIY? We have two approaches:

  1. Extend that View that you need attributes, and treat it like Custom View (Easier)
  2. Create your own Binding Provider (Better reusability, and please submit it to me!)
Following I will discuss with adding a attribute to WebView, named “data”, and the usage is simple:
This reflects the method WebView.loadData();

Read more…

[Tutorial] Lazy Loading : List Views in Android Binding (4/4)

This is the  last post in this series, which is about lazy loading. Note this lazy loading is different from the lazy loading on the other infinite list post. Which, for infinite list, you don’t yet know how many items will be on your list, you just load them bit by bit whenever necessary; but for the lazy loading here, you know what and how many items here, but you don’t load “partial” of the content until it is necessary.

The most common scenario is a list of images, either coming from local disk or the Internet. Setting Image to Image View is a quite expensive operation, even you already cached the image in local drive. People love to fast scroll to skim a list, and this makes list very unresponsive if the image is loaded even in fast scrolling mode.

Kindly note this is the last post of this series, where the rest are:

  1. Introduction to List Views Binding
  2. Custom Row Model for List View
  3. Binding to Cursors
  4. Lazy Loading (this)

Read more…

Introducing Javascript support in Android Binding

It’s a productive weekend. Surfing around and found Mozilla Rhino as a Javascript interpreter, and took less than a day to integrate and test it with Android-Binding. Well, that ends up to be a plugin library for Android-Binding which is about 600Kb in size, where 590Kb goes to Rhino. It’s a little too big, so I decided that to be plugin, if anyone need this extra power can go for this one.

This plugin actually consists of one Converter only: JS, currently this converter is able to convert TO but not back. Following is the syntax:

JS(scope, js_statement, dynamic_object(optional))

For scope, it is the VM where the script will look for the observables, so in most cases, just passing “.” (self)  in it will be fine; js_statement is simply javascripts wrapped with string literal. the last statement, dynamic_object, is for putting additional arguments.

All the observables, which referenced in the js statements, will auto wired up and whenever changes happen in any observables, the js_statement will be re-evaluated too.


Assume the view model has a Hello observable with value “yes”

binding:text="JS(., 'Hello;')" => "yes"

The following “"” is not a mistake, it is the escape for xml’s double quote, so that we can use single-quote in javascript

  ")" => Same as above, wrapping with " gives more flexibility in writing js codes
binding:text="JS(., " 'Test from JS ' + Hello; ")" => "Test from JS yes"

If not using “"” the above will became…

binding:text="JS(.,' "Test from JS " + Hello; ')" => "Test from JS yes"

You can define function too!

    function add(a, b){ return a + b; }
    add('Test from JS ', Hello);
  ")" => "Test from JS yes"

Standard JS libraries can be use too:

    Hello.length + Math.sin(0);
  ")" => "6";

Eval (use) Android Binding Syntaxes in js

    $('CONCAT(Hello, Hello)');
  ")" => "yesyes"

Most binding syntaxes is fine, except referencing other View attributes

binding:text="JS(.," $(@string/hello); ")" => Value of the @string/hello res.

Placing Extra Arguments (probably referencing other view attributes)

    name + age;
  ", { name='adam', age='30' })" => "adam30";


Android-Binding v0.49 and up

[Tutorial] Infinite Scroll (Endless) List View with Android Binding

Infinite List tutorial on Phone

If you reach this page, you should know what’s infinite scroll. We just jump right to HOW we can do it in Android-Binding.

You can get the tutorial source code from the project home page.

To begin with, please read another blog post I have, which is about multiple lists in a list view. We’ll start from the following Layout XML:

<?xml version="1.0" encoding="utf-8"?>
    android:orientation="vertical" >
        	ADAPTER({source=LocationList, template=@layout/list_item}),
        	SECTION(., @layout/load_more_item)

This is very similar to what we have in the Multiple List in a list view, first, we use a STITCH to put two lists together in one list view:

  1. The Actual List (LocationList), loaded with ADAPTER();
  2. A SECTION() which is a single item list, I put “.” as the view model meaning the master view model itself

list_item.xml isn’t too interesting to put here, but here is the load_more_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    binding:text="IF(Loading, 'loading', 'Load More')"

Which is very similar to simple_list_item, except that I expect someone can click on it and to load more items to the list.

There are two versions to the infinite list I am going to demonstrate. First one, which is simpler, is when the user reach the end of list, he can click the last item (which is the last xml i shown) and the list will continue to populate.

The other version is whenever the user reached the last item, the list will load automatically. Such behavior is differentiated in how we implemented the View Model, and here we are:

Read more…

One Model, Different Views.

Finally, after a few months work, we have worked out a way to do fragment-less programming. As I discussed in previous article, fragments helps code-reusing, but in a way inter-fragments (& inter-fragment-activity) communication could be very dependent with each other.

In the coming release of Android Binding V30, which is a plugin to the base Android Binding that supports SDK version 14 and up (ICS), we have included a number of new features to achieve single view model, different views and layouts, without using the fragments, and most importantly, all layouts, view models and activity are independent.

New Markup Demo showing on Phone (800x480)

Showing on Tablet (1280x800)

Above screenshots taken from the new Markup Demo, which is already available in the market. Following discussions and code are all coming from this demo, you might get the source code from the project homepage.

Read more…

Dealing with Atomic operation on MongoDb with generic sub classes

Consider I have the following operation in a repository:

public T AddCountToTag(T tag, int count) where T: Tag {}

Where the base class for tag is a duple of Name and Count, but there maybe different sub-classes of tag which may consists of more fields. For instance, I try to make a sub class called “Folder” inherited from tag:

public class Tag{
public int ItemCount {get;set;}
public string Name {get;set;}
public class Folder : Tag {
public string ParentName {get;set;}

Read more…

%d bloggers like this: