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);
}
}
});
}
}
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);
}
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());
}
}
}
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());
}
}
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());
}
}
Aggregations