Search in sources :

Example 1 with WXBaseRefresh

use of com.taobao.weex.ui.component.WXBaseRefresh in project weex-example by KalicyZhou.

the class BasicListComponent method onCreateViewHolder.

/**
   * Create an instance of {@link ListBaseViewHolder} for the given viewType (not for the given
   * index). This method will look up for the first component that fits the viewType requirement and
   * doesn't be used. Then create the certain type of view, detach the view f[rom the component.
   *
   * @param parent   the ViewGroup into which the new view will be inserted
   * @param viewType the type of the new view
   * @return the created view holder.
   */
@Override
public ListBaseViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    if (mChildren != null) {
        if (mViewTypes == null)
            return createVHForFakeComponent(viewType);
        ArrayList<WXComponent> mTypes = mViewTypes.get(viewType);
        checkRecycledViewPool(viewType);
        if (mTypes == null)
            return createVHForFakeComponent(viewType);
        for (int i = 0; i < mTypes.size(); i++) {
            WXComponent component = mTypes.get(i);
            if (component == null || component.isUsing()) {
                continue;
            }
            if (component.getDomObject() != null && component.getDomObject().isFixed()) {
                return createVHForFakeComponent(viewType);
            } else {
                if (component instanceof WXCell) {
                    if (component.getRealView() != null) {
                        return new ListBaseViewHolder(component, viewType);
                    } else {
                        ((WXCell) component).lazy(false);
                        component.createView();
                        component.applyLayoutAndEvent(component);
                        return new ListBaseViewHolder(component, viewType);
                    }
                } else if (component instanceof WXBaseRefresh) {
                    return createVHForRefreshComponent(viewType);
                } else {
                    WXLogUtils.e(TAG, "List cannot include element except cell、header、fixed、refresh and loading");
                    return createVHForFakeComponent(viewType);
                }
            }
        }
    }
    if (WXEnvironment.isApkDebugable()) {
        WXLogUtils.e(TAG, "Cannot find request viewType: " + viewType);
    }
    return createVHForFakeComponent(viewType);
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXBaseRefresh(com.taobao.weex.ui.component.WXBaseRefresh) Point(android.graphics.Point) ListBaseViewHolder(com.taobao.weex.ui.view.listview.adapter.ListBaseViewHolder)

Example 2 with WXBaseRefresh

use of com.taobao.weex.ui.component.WXBaseRefresh in project weex-example by KalicyZhou.

the class WXListComponent method createChildViewAt.

@Override
public void createChildViewAt(int index) {
    int indexToCreate = index;
    if (indexToCreate < 0) {
        indexToCreate = childCount() - 1;
        if (indexToCreate < 0) {
            return;
        }
    }
    final WXComponent child = getChild(indexToCreate);
    if (child instanceof WXBaseRefresh) {
        child.createView();
        if (child instanceof WXRefresh) {
            getHostView().setOnRefreshListener((WXRefresh) child);
            getHostView().postDelayed(new Runnable() {

                @Override
                public void run() {
                    getHostView().setHeaderView(child);
                }
            }, 100);
        } else if (child instanceof WXLoading) {
            getHostView().setOnLoadingListener((WXLoading) child);
            getHostView().postDelayed(new Runnable() {

                @Override
                public void run() {
                    getHostView().setFooterView(child);
                }
            }, 100);
        }
    } else {
        super.createChildViewAt(indexToCreate);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXBaseRefresh(com.taobao.weex.ui.component.WXBaseRefresh) WXLoading(com.taobao.weex.ui.component.WXLoading) WXRefresh(com.taobao.weex.ui.component.WXRefresh)

Aggregations

WXBaseRefresh (com.taobao.weex.ui.component.WXBaseRefresh)2 WXComponent (com.taobao.weex.ui.component.WXComponent)2 Point (android.graphics.Point)1 WXLoading (com.taobao.weex.ui.component.WXLoading)1 WXRefresh (com.taobao.weex.ui.component.WXRefresh)1 ListBaseViewHolder (com.taobao.weex.ui.view.listview.adapter.ListBaseViewHolder)1