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