@Override
 public boolean handleMessage(Message msg) {
   switch (msg.what) {
     case MSG_ADD_TAB:
       {
         AsyncResult result = (AsyncResult) msg.obj;
         handleAddTab((TabProxy) result.getArg());
         result.setResult(null); // signal added
         return true;
       }
     case MSG_REMOVE_TAB:
       {
         AsyncResult result = (AsyncResult) msg.obj;
         handleRemoveTab((TabProxy) result.getArg());
         result.setResult(null); // signal added
         return true;
       }
     case MSG_FINISH_OPEN:
       {
         TiTabActivity activity = (TiTabActivity) msg.obj;
         view = new TiUITabGroup(this, activity);
         modelListener = view;
         handlePostOpen(activity);
         return true;
       }
     default:
       {
         return super.handleMessage(msg);
       }
   }
 }
  @Kroll.method
  public void addTab(TabProxy tab) {
    if (tabs == null) {
      tabs = new ArrayList<TabProxy>();
    }

    if (getTiContext().isUIThread()) {
      handleAddTab(tab);
      return;
    }
    sendBlockingUiMessage(MSG_ADD_TAB, tab);
  }