当前位置: 首页>>代码示例>>Java>>正文


Java WXComponent类代码示例

本文整理汇总了Java中com.taobao.weex.ui.component.WXComponent的典型用法代码示例。如果您正苦于以下问题:Java WXComponent类的具体用法?Java WXComponent怎么用?Java WXComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


WXComponent类属于com.taobao.weex.ui.component包,在下文中一共展示了WXComponent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBindViewHolder

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
   * Bind the component of the position to the holder. Then flush the view.
   *
   * @param holder   viewHolder, which holds reference to the view
   * @param position position of component in WXListComponent
   */
  @Override
  public void onBindViewHolder(ListBaseViewHolder holder, int position) {
    if (holder == null) return;
    holder.setComponentUsing(true);
    WXComponent component = getChild(position);
    if (component == null
        || (component instanceof WXRefresh)
        || (component instanceof WXLoading)
        || (component.getDomObject() != null && component.getDomObject().isFixed())
        ) {
      if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.d(TAG, "Bind WXRefresh & WXLoading " + holder);
      }
      return;
    }

    if (holder.getComponent() != null && holder.getComponent() instanceof WXCell) {
      holder.getComponent().bindData(component);
//              holder.getComponent().refreshData(component);
    }

  }
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:29,代码来源:BasicListComponent.java

示例2: scrollTo

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 * @see com.taobao.weex.dom.WXDomStatement#scrollToDom(String, JSONObject)
 */
void scrollTo(String ref, Map<String, Object> options) {
  WXComponent component = mRegistry.get(ref);
  if (component == null) {
    return;
  }

  float offsetFloat = 0;
  if (options != null) {
    String offset = options.get("offset") == null ? "0" : options.get("offset").toString();
    if (offset != null) {
      try {
        offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offset),mWXSDKInstance.getViewPortWidth());
      }catch (Exception e ){
         WXLogUtils.e("Float parseFloat error :"+e.getMessage());
      }
    }
  }

  Scrollable scroller = component.getParentScroller();
  if (scroller == null) {
    return;
  }
  scroller.scrollTo(component,(int)offsetFloat);
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:28,代码来源:WXRenderStatement.java

示例3: loadConstructor

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
private void loadConstructor(){
  Class<? extends WXComponent> c = mCompClz;
  Constructor<? extends WXComponent> constructor;
  try {
    constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class);
  } catch (NoSuchMethodException e) {
    WXLogUtils.d("ClazzComponentCreator","Use deprecated component constructor");
    try {
      //compatible deprecated constructor with 4 args
      constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class, boolean.class);
    } catch (NoSuchMethodException e1) {
      try {
        //compatible deprecated constructor with 5 args
        constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class,String.class, boolean.class);
      } catch (NoSuchMethodException e2) {
        throw new WXRuntimeException("Can't find constructor of component.");
      }
    }
  }
  mConstructor = constructor;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:22,代码来源:SimpleComponentHolder.java

示例4: loadConstructor

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
private void loadConstructor(){
  Class<? extends WXComponent> c = mCompClz;
  Constructor<? extends WXComponent> constructor;
  try {
    constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class, boolean.class);
  } catch (NoSuchMethodException e) {
    WXLogUtils.d("ClazzComponentCreator","Use deprecated component constructor");
    try {
      //compatible deprecated constructor
      constructor = c.getConstructor(WXSDKInstance.class, WXDomObject.class, WXVContainer.class,String.class, boolean.class);
    } catch (NoSuchMethodException e1) {
      throw new WXRuntimeException("Can't find constructor of component.");
    }
  }
  mConstructor = constructor;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:17,代码来源:SimpleComponentHolder.java

示例5: setHeaderView

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 *
 * @param refresh should be {@link WXRefreshView}
 */
public void setHeaderView(WXComponent refresh) {
    setRefreshEnable(true);
    if (swipeLayout != null) {
        if (swipeLayout.getHeaderView() != null) {
            swipeLayout.setRefreshHeight((int) refresh.getDomObject().getLayoutHeight());

            String colorStr = (String) refresh.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR);
            String bgColor = WXUtils.getString(colorStr, null);

            if (bgColor != null) {
                if (!TextUtils.isEmpty(bgColor)) {
                    int colorInt = WXResourceUtils.getColor(bgColor);
                    if (!(colorInt == Color.TRANSPARENT)) {
                        swipeLayout.setRefreshBgColor(colorInt);
                    }
                }
            }
            swipeLayout.getHeaderView().setRefreshView(refresh.getHostView());
        }
    }
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:26,代码来源:BaseBounceView.java

示例6: addChild

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
@Override
public void addChild(WXComponent child, int index) {
  super.addChild(child, index);
  if (child == null || index < -1) {
    return;
  }
  setRefreshOrLoading(child);

  // Synchronize DomObject's attr to Component and Native View
  if(mDomObject != null && getHostView() != null && (mColumnWidth != mDomObject.getColumnWidth() ||
          mColumnCount != mDomObject.getColumnCount() ||
          mColumnGap != mDomObject.getColumnGap())) {
    updateRecyclerAttr();
    getHostView().getInnerView().initView(getContext(), mLayoutType,mColumnCount,mColumnGap,getOrientation());
  }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:17,代码来源:WXListComponent.java

示例7: createInstance

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
@Override
public WXComponent createInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) throws IllegalAccessException, InvocationTargetException, InstantiationException {
  if(mConstructor == null){
    loadConstructor();
  }
  int parameters = mConstructor.getParameterTypes().length;
  WXComponent component;

  if(parameters == 3){
    component =  mConstructor.newInstance(instance,node,parent);
  }else if(parameters == 4){
    component =  mConstructor.newInstance(instance,node,parent,false);
  }else{
    //compatible deprecated constructor
    component =  mConstructor.newInstance(instance,node,parent,instance.getInstanceId(),parent.isLazy());
  }
  return component;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:19,代码来源:SimpleComponentHolder.java

示例8: setFooterView

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 *
 * @param loading should be {@link WXRefreshView}
 */
public void setFooterView(WXComponent loading) {
    setLoadmoreEnable(true);
    if (swipeLayout != null) {
        if (swipeLayout.getFooterView() != null) {
            swipeLayout.setLoadingHeight((int) loading.getDomObject().getLayoutHeight());

            String colorStr = (String) loading.getDomObject().getStyles().get(Constants.Name.BACKGROUND_COLOR);
            String bgColor = WXUtils.getString(colorStr, null);

            if (bgColor != null) {
                if (!TextUtils.isEmpty(bgColor)) {
                    int colorInt = WXResourceUtils.getColor(bgColor);
                    if (!(colorInt == Color.TRANSPARENT)) {
                        swipeLayout.setLoadingBgColor(colorInt);
                    }
                }
            }
            swipeLayout.getFooterView().setRefreshView(loading.getHostView());
        }
    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:BaseBounceView.java

示例9: createBody

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 * create RootView ,every weex Instance View has a rootView;
 * @see com.taobao.weex.dom.WXDomStatement#createBody(JSONObject)
 */
void createBody(WXComponent component) {
  long start = System.currentTimeMillis();
  component.createView(mGodComponent, -1);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("createView", (System.currentTimeMillis() - start));
  }
  start = System.currentTimeMillis();
  component.applyLayoutAndEvent(component);
  component.bindData(component);

  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.renderPerformanceLog("bind", (System.currentTimeMillis() - start));
  }

  if (component instanceof WXScroller) {
    WXScroller scroller = (WXScroller) component;
    if (scroller.getInnerView() instanceof ScrollView) {
      mWXSDKInstance.setRootScrollView((ScrollView) scroller.getInnerView());
    }
  }
  mWXSDKInstance.setRootView(mGodComponent.getRealView());
  if (mWXSDKInstance.getRenderStrategy() != WXRenderStrategy.APPEND_ONCE) {
    mWXSDKInstance.onViewCreated(mGodComponent);
  }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:30,代码来源:WXRenderStatement.java

示例10: createBodyOnDomThread

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
WXComponent createBodyOnDomThread(WXDomObject dom) {
  if (mWXSDKInstance == null) {
    return null;
  }
  WXDomObject domObject = new WXDomObject();
  WXDomObject.prepareGod(domObject);
  mGodComponent = (WXVContainer) WXComponentFactory.newInstance(mWXSDKInstance, domObject, null);
  mGodComponent.createView(null, -1);
  if (mGodComponent == null) {
    if (WXEnvironment.isApkDebugable()) {
      WXLogUtils.e("rootView failed!");
    }
    //TODO error callback
    return null;
  }
  FrameLayout frameLayout = (FrameLayout) mGodComponent.getHostView();
  ViewGroup.LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
  frameLayout.setLayoutParams(layoutParams);
  frameLayout.setBackgroundColor(Color.TRANSPARENT);

  WXComponent component = generateComponentTree(dom, mGodComponent);
  mGodComponent.addChild(component);
  mRegistry.put(component.getRef(), component);
  return component;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:26,代码来源:WXRenderStatement.java

示例11: remove

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
@Override
public void remove(WXComponent child, boolean destroy) {
  int index = mChildren.indexOf(child);
  if (destroy) {
    child.detachViewAndClearPreInfo();
  }
  unBindViewType(child);

  BounceRecyclerView view = getHostView();
  if(view == null){
    return;
  }
  view.getAdapter().notifyItemRemoved(index);
  if (WXEnvironment.isApkDebugable()) {
    WXLogUtils.d(TAG, "removeChild child at " + index);
  }
  super.remove(child, destroy);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:19,代码来源:WXListComponent.java

示例12: generateViewType

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 * generate viewtype by component
 *
 * @param component
 * @return
 */
private int generateViewType(WXComponent component) {
  long id;
  try {
    id = Integer.parseInt(component.getDomObject().getRef());
    String type = component.getDomObject().getAttrs().getScope();

    if (!TextUtils.isEmpty(type)) {
      if (mRefToViewType == null) {
        mRefToViewType = new ArrayMap<>();
      }
      if (!mRefToViewType.containsKey(type)) {
        mRefToViewType.put(type, id);
      }
      id = mRefToViewType.get(type);

    }
  } catch (RuntimeException e) {
    WXLogUtils.eTag(TAG, e);
    id = RecyclerView.NO_ID;
    WXLogUtils.e(TAG, "getItemViewType: NO ID, this will crash the whole render system of WXListRecyclerView");
  }
  return (int) id;
}
 
开发者ID:erguotou520,项目名称:weex-uikit,代码行数:30,代码来源:BasicListComponent.java

示例13: bindViewType

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
/**
 * ViewType will be classified into {HashMap<Integer,ArrayList<Integer>> mViewTypes}
 * @param component
 */
private void bindViewType(WXComponent component) {
    int id = generateViewType(component);

    if (mViewTypes == null) {
        mViewTypes = new SparseArray<>();
    }

    ArrayList<WXComponent> mTypes = mViewTypes.get(id);

    if (mTypes == null) {
        mTypes = new ArrayList<>();
        mViewTypes.put(id,mTypes);
    }
    mTypes.add(component);
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:20,代码来源:WXListComponent.java

示例14: onNewIntent

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    setIntent(intent);
    if (intent == null) {
        return;
    }
    if (intent.getStringExtra("params") != null) {
        String params = intent.getStringExtra("params");
        String backTag = intent.getStringExtra("backTag");
        if (!TextUtils.isEmpty(params)) {
            WXComponent comp = mInstance.getRootComponent();
            if (comp != null) {
                WXEvent events = comp.getDomObject().getEvents();
                boolean hasActive = events.contains(UConstants.Event.ACTIVED);
                if (hasActive) {
                    Map<String, Object> data = new HashMap<>();
                    data.put("param", params);
                    data.put("tagCode", backTag);
                    WXBridgeManager.getInstance().fireEvent(mInstance.getInstanceId(), comp.getRef(), UConstants.Event.ACTIVED, data, null);
                }
            }
        }
    }
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:26,代码来源:UWXFrameBaseActivity.java

示例15: onViewCreated

import com.taobao.weex.ui.component.WXComponent; //导入依赖的package包/类
@Override
    public void onViewCreated(WXSDKInstance wxsdkInstance, View view) {
        super.onViewCreated(wxsdkInstance, view);
        WXComponent comp = mInstance.getRootComponent();
        if (comp != null) {
            WXEvent events = comp.getDomObject().getEvents();
            boolean hasReady = events.contains(UConstants.Event.READY);
            if (hasReady) {
                Map<String, Object> data = new HashMap<>();
                data.put("param", wxInfo.getParam());
                WXBridgeManager.getInstance().fireEvent(mInstance.getInstanceId(), comp.getRef(), UConstants.Event.READY, data, null);
            }
        }
//        if (!isHasNavBar) {
//            setTranslateAnimation(getContainer());
//        }
    }
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:18,代码来源:UWXFrameBaseActivity.java


注:本文中的com.taobao.weex.ui.component.WXComponent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。