Search in sources :

Example 1 with AppearanceHelper

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);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) HashMap(java.util.HashMap) Point(android.graphics.Point) AppearanceHelper(com.taobao.weex.ui.component.AppearanceHelper)

Example 2 with AppearanceHelper

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);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) ImageView(android.widget.ImageView) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) Point(android.graphics.Point) AppearanceHelper(com.taobao.weex.ui.component.AppearanceHelper)

Example 3 with AppearanceHelper

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);
    }
}
Also used : WXCell(com.taobao.weex.ui.component.list.WXCell) Point(android.graphics.Point) AppearanceHelper(com.taobao.weex.ui.component.AppearanceHelper)

Example 4 with AppearanceHelper

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);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) BounceRecyclerView(com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView) Point(android.graphics.Point) AppearanceHelper(com.taobao.weex.ui.component.AppearanceHelper)

Example 5 with AppearanceHelper

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);
    }
}
Also used : WXComponent(com.taobao.weex.ui.component.WXComponent) ArrayMap(android.support.v4.util.ArrayMap) Map(java.util.Map) HashMap(java.util.HashMap) Point(android.graphics.Point) AppearanceHelper(com.taobao.weex.ui.component.AppearanceHelper)

Aggregations

Point (android.graphics.Point)6 AppearanceHelper (com.taobao.weex.ui.component.AppearanceHelper)6 WXComponent (com.taobao.weex.ui.component.WXComponent)5 ArrayMap (android.support.v4.util.ArrayMap)3 RecyclerView (android.support.v7.widget.RecyclerView)3 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 View (android.view.View)2 WXCell (com.taobao.weex.ui.component.list.WXCell)2 BounceRecyclerView (com.taobao.weex.ui.view.refresh.wrapper.BounceRecyclerView)2 ImageView (android.widget.ImageView)1 JSONObject (com.alibaba.fastjson.JSONObject)1 WXCellDomObject (com.taobao.weex.dom.WXCellDomObject)1 WXDomObject (com.taobao.weex.dom.WXDomObject)1 WXEvent (com.taobao.weex.dom.WXEvent)1 WXRecyclerDomObject (com.taobao.weex.dom.WXRecyclerDomObject)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1