本文整理汇总了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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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());
}
}
}
示例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());
}
}
示例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;
}
示例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());
}
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
}
示例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());
// }
}