use of com.taobao.weex.ui.component.AppearanceHelper 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.AppearanceHelper 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.AppearanceHelper in project incubator-weex by apache.
the class WXRecyclerTemplateList method setAppearanceWatch.
private void setAppearanceWatch(WXComponent component, int event, boolean enable) {
if (cellDataManager.listData == null || mAppearHelpers == null || TextUtils.isEmpty(component.getRef())) {
return;
}
WXCell cell = findCell(component);
int type = getCellTemplateItemType(cell);
if (type < 0) {
return;
}
List<AppearanceHelper> mAppearListeners = mAppearHelpers.get(type);
if (mAppearListeners == null) {
mAppearListeners = new ArrayList<>();
mAppearHelpers.put(type, mAppearListeners);
}
AppearanceHelper item = null;
for (AppearanceHelper mAppearListener : mAppearListeners) {
if (component.getRef().equals(mAppearListener.getAwareChild().getRef())) {
item = mAppearListener;
break;
}
}
if (item != null) {
item.setWatchEvent(event, enable);
} else {
item = new AppearanceHelper(component, type);
item.setWatchEvent(event, enable);
mAppearListeners.add(item);
}
}
use of com.taobao.weex.ui.component.AppearanceHelper in project incubator-weex by apache.
the class BasicListComponent method notifyAppearStateChange.
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
if (mAppearComponentsRunnable != null) {
getHostView().removeCallbacks(mAppearComponentsRunnable);
mAppearComponentsRunnable = null;
}
// 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;
}
View view = component.getHostView();
if (view == null) {
continue;
}
boolean outOfVisibleRange = !ViewCompat.isAttachedToWindow(view);
boolean visible = (!outOfVisibleRange) && item.isViewVisible(true);
int result = item.setAppearStatus(visible);
if (result == AppearanceHelper.RESULT_NO_CHANGE) {
continue;
}
if (WXEnvironment.isApkDebugable()) {
WXLogUtils.d("appear", "item " + item.getCellPositionINScollable() + " result " + result);
}
component.notifyAppearStateChange(result == AppearanceHelper.RESULT_APPEAR ? Constants.Event.APPEAR : Constants.Event.DISAPPEAR, direction);
}
}
use of com.taobao.weex.ui.component.AppearanceHelper in project incubator-weex by apache.
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);
}
}
Aggregations