use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class BasicListComponent method bindViewType.
/**
* ViewType will be classified into {HashMap<Integer,ArrayList<Integer>> mViewTypes}
*
* @param component
*/
private void bindViewType(WXComponent component) {
int id = generateViewType(component);
if (mViewTypes == null) {
mViewTypes = new SparseArray<>();
}
ArrayList<WXComponent> mTypes = mViewTypes.get(id);
if (mTypes == null) {
mTypes = new ArrayList<>();
mViewTypes.put(id, mTypes);
}
mTypes.add(component);
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class BasicListComponent method onBeforeScroll.
@Override
public void onBeforeScroll(int dx, int dy) {
T bounceRecyclerView = getHostView();
if (mStickyMap == null || bounceRecyclerView == null) {
return;
}
HashMap<String, WXComponent> stickyMap = mStickyMap.get(getRef());
if (stickyMap == null) {
return;
}
Iterator<Map.Entry<String, WXComponent>> iterator = stickyMap.entrySet().iterator();
Map.Entry<String, WXComponent> entry;
WXComponent stickyComponent;
while (iterator.hasNext()) {
entry = iterator.next();
stickyComponent = entry.getValue();
if (stickyComponent != null && stickyComponent.getDomObject() != null && stickyComponent instanceof WXCell) {
WXCell cell = (WXCell) stickyComponent;
if (cell.getHostView() == null) {
return;
}
if (stickyComponent != null && stickyComponent.getDomObject() != null && stickyComponent instanceof WXCell) {
if (stickyComponent.getHostView() == null) {
return;
}
RecyclerView.LayoutManager layoutManager;
boolean beforeFirstVisibleItem = false;
if ((layoutManager = getHostView().getInnerView().getLayoutManager()) instanceof LinearLayoutManager) {
int fVisible = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
int pos = mChildren.indexOf(cell);
if (pos <= fVisible) {
beforeFirstVisibleItem = true;
}
}
int[] location = new int[2];
stickyComponent.getHostView().getLocationOnScreen(location);
int[] parentLocation = new int[2];
stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
int top = location[1] - parentLocation[1];
boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= 0 && dy >= 0;
boolean removeSticky = cell.getLocationFromStart() <= 0 && top > 0 && dy <= 0;
if (showSticky) {
bounceRecyclerView.notifyStickyShow(cell);
} else if (removeSticky) {
bounceRecyclerView.notifyStickyRemove(cell);
}
cell.setLocationFromStart(top);
}
}
}
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class BasicListComponent method relocateAppearanceHelper.
private void relocateAppearanceHelper() {
Iterator<Map.Entry<String, AppearanceHelper>> iterator = mAppearComponents.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, AppearanceHelper> item = iterator.next();
AppearanceHelper value = item.getValue();
WXComponent dChild = findDirectListChild(value.getAwareChild());
int index = mChildren.indexOf(dChild);
value.setCellPosition(index);
}
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class BasicListComponent method notifyAppearStateChange.
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
//notify appear state
Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
String direction = directionY > 0 ? Constants.Value.DIRECTION_UP : directionY < 0 ? Constants.Value.DIRECTION_DOWN : null;
if (getOrientation() == Constants.Orientation.HORIZONTAL && directionX != 0) {
direction = directionX > 0 ? Constants.Value.DIRECTION_LEFT : Constants.Value.DIRECTION_RIGHT;
}
while (it.hasNext()) {
AppearanceHelper item = it.next();
WXComponent component = item.getAwareChild();
if (!item.isWatch()) {
continue;
}
boolean outOfVisibleRange = item.getCellPositionINScollable() < firstVisible || item.getCellPositionINScollable() > lastVisible;
View view = component.getHostView();
if (view == null) {
continue;
}
boolean visible = (!outOfVisibleRange) && item.isViewVisible();
int result = item.setAppearStatus(visible);
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
}
if (result == AppearanceHelper.RESULT_NO_CHANGE) {
continue;
}
component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
}
}
use of com.taobao.weex.ui.component.WXComponent in project weex-example by KalicyZhou.
the class BasicListComponent method unBindViewType.
private void unBindViewType(WXComponent component) {
int id = generateViewType(component);
if (mViewTypes == null)
return;
ArrayList<WXComponent> mTypes = mViewTypes.get(id);
if (mTypes == null)
return;
mTypes.remove(component);
}
Aggregations