Search in sources :

Example 11 with WXRecyclerView

use of com.taobao.weex.ui.view.listview.WXRecyclerView in project incubator-weex by apache.

the class WXListComponent method setColumnCount.

@WXComponentProp(name = Constants.Name.COLUMN_COUNT)
public void setColumnCount(int columnCount) {
    if (mRecyclerDom != null && mRecyclerDom.getColumnCount() != mColumnCount) {
        markComponentUsable();
        updateRecyclerAttr();
        WXRecyclerView wxRecyclerView = getHostView().getInnerView();
        wxRecyclerView.initView(getContext(), mLayoutType, mColumnCount, mColumnGap, getOrientation());
    }
}
Also used : WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 12 with WXRecyclerView

use of com.taobao.weex.ui.view.listview.WXRecyclerView in project incubator-weex by apache.

the class WXListComponent method setLeftGap.

@WXComponentProp(name = Constants.Name.LEFT_GAP)
public void setLeftGap(float leftGap) {
    if (mRecyclerDom != null && mRecyclerDom.getLeftGap() != mLeftGap) {
        markComponentUsable();
        mRecyclerDom.preCalculateCellWidth();
        updateRecyclerAttr();
        WXRecyclerView wxRecyclerView = getHostView().getInnerView();
        wxRecyclerView.initView(getContext(), mLayoutType, mColumnCount, mColumnGap, getOrientation());
    }
}
Also used : WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 13 with WXRecyclerView

use of com.taobao.weex.ui.view.listview.WXRecyclerView in project weex-example by KalicyZhou.

the class BasicListComponent method scrollTo.

@Override
public void scrollTo(WXComponent component, Map<String, Object> options) {
    float offsetFloat = 0;
    boolean smooth = true;
    if (options != null) {
        String offsetStr = options.get(Constants.Name.OFFSET) == null ? "0" : options.get(Constants.Name.OFFSET).toString();
        smooth = WXUtils.getBoolean(options.get(Constants.Name.ANIMATED), true);
        if (offsetStr != null) {
            try {
                offsetFloat = WXViewUtils.getRealPxByWidth(Float.parseFloat(offsetStr), getInstance().getViewPortWidth());
            } catch (Exception e) {
                WXLogUtils.e("Float parseFloat error :" + e.getMessage());
            }
        }
    }
    final int offset = (int) offsetFloat;
    T bounceRecyclerView = getHostView();
    if (bounceRecyclerView == null) {
        return;
    }
    WXComponent parent = component;
    WXCell cell = null;
    while (parent != null) {
        if (parent instanceof WXCell) {
            cell = (WXCell) parent;
            break;
        }
        parent = parent.getParent();
    }
    if (cell != null) {
        final int pos = mChildren.indexOf(cell);
        final WXRecyclerView view = bounceRecyclerView.getInnerView();
        if (!smooth) {
            RecyclerView.LayoutManager layoutManager = view.getLayoutManager();
            if (layoutManager instanceof LinearLayoutManager) {
                //GridLayoutManager is also instance of LinearLayoutManager
                ((LinearLayoutManager) layoutManager).scrollToPositionWithOffset(pos, -offset);
            } else if (layoutManager instanceof StaggeredGridLayoutManager) {
                ((StaggeredGridLayoutManager) layoutManager).scrollToPositionWithOffset(pos, -offset);
            }
        //Any else?
        } else {
            view.smoothScrollToPosition(pos);
            if (offset != 0) {
                view.addOnScrollListener(new RecyclerView.OnScrollListener() {

                    @Override
                    public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                        if (newState == RecyclerView.SCROLL_STATE_IDLE) {
                            if (getOrientation() == Constants.Orientation.VERTICAL) {
                                recyclerView.smoothScrollBy(0, offset);
                            } else {
                                recyclerView.smoothScrollBy(offset, 0);
                            }
                            recyclerView.removeOnScrollListener(this);
                        }
                    }
                });
            }
        }
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) WXRuntimeException(com.taobao.weex.common.WXRuntimeException) Point(android.graphics.Point) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView)

Example 14 with WXRecyclerView

use of com.taobao.weex.ui.view.listview.WXRecyclerView in project weex-example by KalicyZhou.

the class BounceRecyclerView method setInnerView.

@Override
public WXRecyclerView setInnerView(Context context) {
    WXRecyclerView wxRecyclerView = new WXRecyclerView(context);
    wxRecyclerView.initView(context, WXRecyclerView.TYPE_LINEAR_LAYOUT, getOrientation());
    return wxRecyclerView;
}
Also used : WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView)

Example 15 with WXRecyclerView

use of com.taobao.weex.ui.view.listview.WXRecyclerView in project incubator-weex by apache.

the class BasicListComponent method setScrollable.

@WXComponentProp(name = Constants.Name.SCROLLABLE)
public void setScrollable(boolean scrollable) {
    this.isScrollable = scrollable;
    WXRecyclerView inner = getHostView().getInnerView();
    if (inner != null) {
        inner.setScrollable(scrollable);
    }
}
Also used : WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Aggregations

WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)26 WXComponentProp (com.taobao.weex.ui.component.WXComponentProp)13 Point (android.graphics.Point)7 RecyclerView (android.support.v7.widget.RecyclerView)4 BounceRecyclerView (com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView)4 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)3 StaggeredGridLayoutManager (android.support.v7.widget.StaggeredGridLayoutManager)3 ArrayMap (android.support.v4.util.ArrayMap)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 WXComponent (com.taobao.weex.ui.component.WXComponent)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 JSMethod (com.taobao.weex.annotation.JSMethod)1 WXRuntimeException (com.taobao.weex.common.WXRuntimeException)1 WXCell (com.taobao.weex.ui.component.list.WXCell)1