private void setImage(final Bitmap bitmap) { if (!TiApplication.isUIThread()) { TiMessenger.sendBlockingMainMessage(handler.obtainMessage(SET_IMAGE), bitmap); } else { handleSetImage(bitmap); } }
@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; } } } }
@Kroll.getProperty @Kroll.method public KrollDict getCenter() { return (KrollDict) TiMessenger.sendBlockingMainMessage( getMainHandler().obtainMessage(MSG_GETCENTER), getActivity()); }
@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 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); } }
@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 KrollDict getItemAt(int index) { if (TiApplication.isUIThread()) { return handleGetItemAt(index); } else { return (KrollDict) TiMessenger.sendBlockingMainMessage( getMainHandler().obtainMessage(MSG_GET_ITEM_AT), index); } }
@Kroll.method public KrollDict toImage() { if (TiApplication.isUIThread()) { return handleToImage(); } else { return (KrollDict) TiMessenger.sendBlockingMainMessage( getMainHandler().obtainMessage(MSG_TOIMAGE), getActivity()); } }
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 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; }
@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 ""; }
@Kroll.method public void updateItemAt(int index, Object data) { if (!isIndexValid(index) || !(data instanceof HashMap)) { return; } if (TiApplication.isUIThread()) { handleUpdateItemAt(index, new Object[] {data}); } else { KrollDict d = new KrollDict(); d.put(TiC.EVENT_PROPERTY_INDEX, index); d.put(TiC.PROPERTY_DATA, new Object[] {data}); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_UPDATE_ITEM_AT), d); } }
@Kroll.method public void deleteItemsAt(int index, int count) { if (!isIndexValid(index)) { return; } if (TiApplication.isUIThread()) { handleDeleteItemsAt(index, count); } else { KrollDict d = new KrollDict(); d.put(TiC.EVENT_PROPERTY_INDEX, index); d.put(TiC.PROPERTY_COUNT, count); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_DELETE_ITEMS_AT), d); } }
@Kroll.method public void insertItemsAt(int index, Object data) { if (!isIndexValid(index)) { return; } if (TiApplication.isUIThread()) { handleInsertItemsAt(index, data); } else { KrollDict d = new KrollDict(); d.put(TiC.PROPERTY_DATA, data); d.put(TiC.EVENT_PROPERTY_INDEX, index); TiMessenger.sendBlockingMainMessage(getMainHandler().obtainMessage(MSG_INSERT_ITEMS_AT), d); } }
@Kroll.method public TiBlob getFilteredScreenshot(HashMap options) { if (options != null) { if (options.containsKey("callback")) { KrollFunction callback = (KrollFunction) options.get("callback"); if (callback != null) { (new FilterScreenShotTask()).execute(options); return null; } } } // View view = TiApplication.getAppCurrentActivity().getWindow() // .getDecorView(); View view = TiApplication.getAppCurrentActivity() .getWindow() .getDecorView() .findViewById(android.R.id.content); if (view == null) { return null; } Bitmap bitmap = null; try { if (TiApplication.isUIThread()) { bitmap = TiUIHelper.viewToBitmap(null, view); } else { bitmap = (Bitmap) TiMessenger.sendBlockingMainMessage( getMainHandler().obtainMessage(MSG_GETVIEWIMAGE), view); } // Rect statusBar = new Rect(); // view.getWindowVisibleDisplayFrame(statusBar); // bitmap = Bitmap.createBitmap(bitmap, 0, statusBar.top, // bitmap.getWidth(), bitmap.getHeight() - statusBar.top, // null, true); } catch (Exception e) { bitmap = null; } return getFilteredImage(bitmap, options); }