@Kroll.method
  public void remove(TiViewProxy child) {
    if (child == null) {
      Log.w(LCAT, "add called with null child");

      return;
    }

    if (peekView() != null) {
      if (TiApplication.isUIThread()) {
        handleRemove(child);
        return;
      }

      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_REMOVE_CHILD), child);

    } else {
      if (children != null) {
        children.remove(child);
        if (child.parent != null && child.parent.get() == this) {
          child.parent = null;
        }
      }
    }
  }
 private void setImage(final Bitmap bitmap) {
   if (!TiApplication.isUIThread()) {
     TiMessenger.sendBlockingMainMessage(handler.obtainMessage(SET_IMAGE), bitmap);
   } else {
     handleSetImage(bitmap);
   }
 }
  @Kroll.method
  public void add(TiViewProxy child) {
    if (child == null) {
      Log.w(LCAT, "add called with null child");
      return;
    }

    if (children == null) {
      children = new ArrayList<TiViewProxy>();
    }

    if (peekView() != null) {
      if (TiApplication.isUIThread()) {
        handleAdd(child);
        return;
      }

      TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_ADD_CHILD), child);

    } else {
      children.add(child);
      child.parent = new WeakReference<TiViewProxy>(this);
    }
    // TODO zOrder
  }
 @Kroll.method
 public void release() {
   if (TiApplication.isUIThread()) {
     super.releaseViews();
   } else {
     getMainHandler().sendEmptyMessage(MSG_RELEASE);
   }
 }
 public void stop() {
   if (!TiApplication.isUIThread()) {
     Message message = handler.obtainMessage(STOP);
     message.sendToTarget();
   } else {
     handleStop();
   }
 }
 @Kroll.method
 public void show() {
   if (TiApplication.isUIThread()) {
     handleShow();
   } else {
     getMainHandler().obtainMessage(MSG_SHOW).sendToTarget();
   }
 }
 @Kroll.method
 public void hide() {
   if (TiApplication.isUIThread()) {
     handleHide();
   } else {
     getMainHandler().obtainMessage(MSG_HIDE).sendToTarget();
   }
 }
 @Kroll.method
 public void focus() {
   if (TiApplication.isUIThread()) {
     handleFocus();
   } else {
     getMainHandler().sendEmptyMessage(MSG_FOCUS);
   }
 }
 @Kroll.method
 public void blur() {
   if (TiApplication.isUIThread()) {
     handleBlur();
   } else {
     getMainHandler().sendEmptyMessage(MSG_BLUR);
   }
 }
Beispiel #10
0
 @Kroll.method
 public void hide(@Kroll.argument(optional = true) KrollDict options) {
   if (TiApplication.isUIThread()) {
     handleHide(options);
   } else {
     getMainHandler().obtainMessage(MSG_HIDE, options).sendToTarget();
   }
 }
 @Kroll.method
 public void appendItems(Object data) {
   if (TiApplication.isUIThread()) {
     handleAppendItems(data);
   } else {
     TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_APPEND_ITEMS), data);
   }
 }
 @Kroll.method
 @Kroll.setProperty
 public void setItems(Object data) {
   if (TiApplication.isUIThread()) {
     handleSetItems(data);
   } else {
     TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_SET_ITEMS), data);
   }
 }
Beispiel #13
0
 public void handlePendingAnimation(boolean forceQueue) {
   if (pendingAnimation != null && peekView() != null) {
     if (forceQueue || !(TiApplication.isUIThread())) {
       getMainHandler().obtainMessage(MSG_ANIMATE).sendToTarget();
     } else {
       handleAnimate();
     }
   }
 }
  @Kroll.method
  public void removeRoute(KrollDict route) {
    // This needs to run on main thread.
    if (TiApplication.isUIThread()) {
      handleRemoveRoute(route);
      return;
    }

    getMainHandler().obtainMessage(MSG_REMOVE_ROUTE, route).sendToTarget();
  }
 @Kroll.method
 public void pause() {
   if (peekView() != null) {
     if (TiApplication.isUIThread()) {
       getWebView().pauseWebView();
     } else {
       getMainHandler().sendEmptyMessage(MSG_PAUSE);
     }
   }
 }
 @Kroll.method
 public void resume() {
   if (peekView() != null) {
     if (TiApplication.isUIThread()) {
       getWebView().resumeWebView();
     } else {
       getMainHandler().sendEmptyMessage(MSG_RESUME);
     }
   }
 }
 @Kroll.method
 public KrollDict getItemAt(int index) {
   if (TiApplication.isUIThread()) {
     return handleGetItemAt(index);
   } else {
     return (KrollDict)
         TiMessenger.sendBlockingMainMessage(
             getMainHandler().obtainMessage(MSG_GET_ITEM_AT), index);
   }
 }
 @Kroll.method
 @Kroll.getProperty
 public Object[] getItems() {
   if (TiApplication.isUIThread()) {
     return itemProperties.toArray();
   } else {
     return (Object[])
         TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_ITEMS));
   }
 }
  @Kroll.method
  public void addRoute(KrollDict routeMap) {
    // This needs to run on main thread.
    if (TiApplication.isUIThread()) {
      handleAddRoute(routeMap);
      return;
    }

    getMainHandler().obtainMessage(MSG_ADD_ROUTE, routeMap).sendToTarget();
  }
 @Kroll.method
 @Kroll.setProperty
 public void setBackgroundImage(String url) {
   if (TiApplication.isUIThread()) {
     handleSetBackgroundImage(url);
   } else {
     Message message = getMainHandler().obtainMessage(MSG_SET_BACKGROUND_IMAGE, url);
     message.getData().putString(BACKGROUND_IMAGE, url);
     message.sendToTarget();
   }
 }
 @Kroll.method
 @Kroll.setProperty
 public void setTitle(String title) {
   if (TiApplication.isUIThread()) {
     handleSetTitle(title);
   } else {
     Message message = getMainHandler().obtainMessage(MSG_SET_TITLE, title);
     message.getData().putString(TITLE, title);
     message.sendToTarget();
   }
 }
 @Kroll.method
 @Kroll.setProperty
 public void setDisplayHomeAsUp(boolean showHomeAsUp) {
   if (TiApplication.isUIThread()) {
     handlesetDisplayHomeAsUp(showHomeAsUp);
   } else {
     Message message = getMainHandler().obtainMessage(MSG_DISPLAY_HOME_AS_UP, showHomeAsUp);
     message.getData().putBoolean(SHOW_HOME_AS_UP, showHomeAsUp);
     message.sendToTarget();
   }
 }
 @Kroll.method
 @Kroll.setProperty
 public void setNavigationMode(int navigationMode) {
   if (TiApplication.isUIThread()) {
     handlesetNavigationMode(navigationMode);
   } else {
     Message message = getMainHandler().obtainMessage(MSG_SET_NAVIGATION_MODE, navigationMode);
     message.getData().putInt(NAVIGATION_MODE, navigationMode);
     message.sendToTarget();
   }
 }
Beispiel #24
0
  @Kroll.method
  public KrollDict toImage() {
    if (TiApplication.isUIThread()) {
      return handleToImage();

    } else {
      return (KrollDict)
          TiMessenger.sendBlockingMainMessage(
              getMainHandler().obtainMessage(MSG_TOIMAGE), getActivity());
    }
  }
 @Kroll.method
 public boolean canGoForward() {
   if (peekView() != null) {
     if (TiApplication.isUIThread()) {
       return getWebView().canGoForward();
     } else {
       return (Boolean)
           TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_CAN_GO_FORWARD));
     }
   }
   return false;
 }
Beispiel #26
0
  public TiUIView getOrCreateView() {
    if (activity == null || view != null) {
      return view;
    }

    if (TiApplication.isUIThread()) {
      return handleGetView();
    }

    return (TiUIView)
        TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GETVIEW), 0);
  }
 @Kroll.method
 @Kroll.setProperty
 public void setIcon(String url) {
   if (Build.VERSION.SDK_INT >= TiC.API_LEVEL_ICE_CREAM_SANDWICH) {
     if (TiApplication.isUIThread()) {
       handleSetIcon(url);
     } else {
       Message message = getMainHandler().obtainMessage(MSG_SET_ICON, url);
       message.getData().putString(ICON, url);
       message.sendToTarget();
     }
   }
 }
 @Kroll.method
 @Kroll.setProperty
 public void setUserAgent(String userAgent) {
   TiUIWebView currWebView = getWebView();
   if (currWebView != null) {
     if (TiApplication.isUIThread()) {
       currWebView.setUserAgentString(userAgent);
     } else {
       Message message = getMainHandler().obtainMessage(MSG_SET_USER_AGENT);
       message.obj = userAgent;
       message.sendToTarget();
     }
   }
 }
 @Kroll.method
 @Kroll.getProperty
 public String getUserAgent() {
   TiUIWebView currWebView = getWebView();
   if (currWebView != null) {
     if (TiApplication.isUIThread()) {
       return currWebView.getUserAgentString();
     } else {
       return (String)
           TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_GET_USER_AGENT));
     }
   }
   return "";
 }
 @Override
 public void onPropertyChanged(String name, Object value) {
   if (Build.VERSION.SDK_INT >= TiC.API_LEVEL_ICE_CREAM_SANDWICH
       && TiC.PROPERTY_ON_HOME_ICON_ITEM_SELECTED.equals(name)) {
     // If we have a listener on the home icon item, then enable the home button (we need to do
     // this for ICS and
     // above)
     if (TiApplication.isUIThread()) {
       actionBar.setHomeButtonEnabled(true);
     } else {
       getMainHandler().obtainMessage(MSG_SET_HOME_BUTTON_ENABLED).sendToTarget();
     }
   }
   super.onPropertyChanged(name, value);
 }