Search in sources :

Example 16 with WXRecyclerView

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

the class BasicListComponent method addEvent.

@Override
public void addEvent(String type) {
    super.addEvent(type);
    if (ScrollStartEndHelper.isScrollEvent(type) && getHostView() != null && getHostView().getInnerView() != null && !mHasAddScrollEvent) {
        mHasAddScrollEvent = true;
        WXRecyclerView innerView = getHostView().getInnerView();
        innerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

            private int offsetXCorrection, offsetYCorrection;

            private boolean mFirstEvent = true;

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);
                // WXLogUtils.e("SCROLL", dx + ", " + dy + ", " + recyclerView.computeHorizontalScrollRange()
                // + ", " + recyclerView.computeVerticalScrollRange()
                // + ", " + recyclerView.computeHorizontalScrollOffset()
                // + ", " + recyclerView.computeVerticalScrollOffset());
                int offsetX = recyclerView.computeHorizontalScrollOffset();
                int offsetY = recyclerView.computeVerticalScrollOffset();
                if (dx == 0 && dy == 0) {
                    offsetXCorrection = offsetX;
                    offsetYCorrection = offsetY;
                    offsetX = 0;
                    offsetY = 0;
                } else {
                    offsetX = offsetX - offsetXCorrection;
                    offsetY = offsetY - offsetYCorrection;
                }
                getScrollStartEndHelper().onScrolled(offsetX, offsetY);
                if (!getDomObject().getEvents().contains(Constants.Event.SCROLL)) {
                    return;
                }
                if (mFirstEvent) {
                    // skip first event
                    mFirstEvent = false;
                    return;
                }
                RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
                if (!layoutManager.canScrollVertically()) {
                    return;
                }
                if (shouldReport(offsetX, offsetY)) {
                    fireScrollEvent(recyclerView, offsetX, offsetY);
                }
            }
        });
    }
}
Also used : GridLayoutManager(android.support.v7.widget.GridLayoutManager) StaggeredGridLayoutManager(android.support.v7.widget.StaggeredGridLayoutManager) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) BounceRecyclerView(com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) Point(android.graphics.Point)

Example 17 with WXRecyclerView

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

the class WXListComponent method setScrollable.

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

Example 18 with WXRecyclerView

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

the class WXListComponent method updateProperties.

@Override
public void updateProperties(Map<String, Object> props) {
    super.updateProperties(props);
    if (props.containsKey(Constants.Name.PADDING) || props.containsKey(Constants.Name.PADDING_LEFT) || props.containsKey(Constants.Name.PADDING_RIGHT)) {
        if (mRecyclerDom != null && (mPaddingLeft != mRecyclerDom.getPadding().get(Spacing.LEFT) || mPaddingRight != mRecyclerDom.getPadding().get(Spacing.RIGHT))) {
            markComponentUsable();
            updateRecyclerAttr();
            WXRecyclerView wxRecyclerView = getHostView().getInnerView();
            wxRecyclerView.initView(getContext(), mLayoutType, mColumnCount, mColumnGap, getOrientation());
        }
    }
}
Also used : WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView)

Example 19 with WXRecyclerView

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

the class WXListComponent method setColumnWidth.

@WXComponentProp(name = Constants.Name.COLUMN_WIDTH)
public void setColumnWidth(int columnCount) {
    if (mRecyclerDom != null && mRecyclerDom.getColumnWidth() != mColumnWidth) {
        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 20 with WXRecyclerView

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

the class WXListComponent method setColumnGap.

@WXComponentProp(name = Constants.Name.COLUMN_GAP)
public void setColumnGap(float columnGap) throws InterruptedException {
    if (mRecyclerDom != null && mRecyclerDom.getColumnGap() != mColumnGap) {
        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)

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