com.taobao.weex.dom.WXAttr Java Examples

The following examples show how to use com.taobao.weex.dom.WXAttr. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WXA.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
@Override
protected void onHostViewInitialized(WXFrameLayout host) {
  super.onHostViewInitialized(host);
  addClickListener(new OnClickListener() {
    @Override
    public void onHostViewClick() {
      String href;
      ImmutableDomObject domObject = getDomObject();
      if (domObject != null) {
        WXAttr attr = domObject.getAttrs();
        if (attr !=null && (href = (String)attr.get("href")) != null) {
          ATagUtil.onClick(null, getInstanceId(), href);
        }
      } else {
        WXLogUtils.d("WXA", "Property href is empty.");
      }
    }
  });
}
 
Example #2
Source File: WeexActivity.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
/**
 * 处理weex返回键
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    BasicComponentData basicComponentData = mWXSDKInstance.getRootComponent().getBasicComponentData();
    final WXAttr attrs = basicComponentData.getAttrs();
    boolean isHasInterceptBack = attrs.containsKey(WeexConstant.ATTR_INTERCEPT_BACK);
    if ((keyCode == KeyEvent.KEYCODE_BACK) && isHasInterceptBack) {
        Object interceptBackObj = attrs.get(WeexConstant.ATTR_INTERCEPT_BACK);
        try {
            boolean interceptBack = false;
            if (interceptBackObj != null) {
                interceptBack = Boolean.parseBoolean(interceptBackObj.toString());
            }
            if (interceptBack) {
                WXEvent events = basicComponentData.getEvents();
                boolean hasBack = events.contains(WeexConstant.EVENT_BACK);
                if (hasBack) {
                    mWXSDKInstance.fireEvent(basicComponentData.mRef, WeexConstant.EVENT_BACK);
                }
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
Example #3
Source File: BasicListComponent.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private boolean isDragExcluded(@Nullable ImmutableDomObject domObject) {
  if (domObject == null) {
    return DEFAULT_EXCLUDED;
  }
  WXAttr cellAttrs = domObject.getAttrs();
  return WXUtils.getBoolean(cellAttrs.get(EXCLUDED), DEFAULT_EXCLUDED);
}
 
Example #4
Source File: WXImageTest.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetSrc() throws Exception {
  TestDomObject.setAttribute((WXDomObject)mWXImage.getDomObject(),PowerMockito.mock(WXAttr.class));
  PowerMockito.when(mWXImage.getDomObject().getAttrs().getImageSharpen()).thenReturn(WXImageSharpen.SHARPEN);
  mWXImage.setSrc("");

}
 
Example #5
Source File: WXImageTest.java    From weex-uikit with MIT License 5 votes vote down vote up
@Test
public void testSetSrc() throws Exception {
  TestDomObject.setAttribute((WXDomObject)mWXImage.getDomObject(),PowerMockito.mock(WXAttr.class));
  PowerMockito.when(mWXImage.getDomObject().getAttrs().getImageSharpen()).thenReturn(WXImageSharpen.SHARPEN);
  mWXImage.setSrc("");

}