Search in sources :

Example 1 with BasicListComponent

use of com.taobao.weex.ui.component.list.BasicListComponent in project incubator-weex by apache.

the class WXParallax method onScrolled.

@Override
public void onScrolled(View view, int dx, int dy) {
    if (ViewCompat.isInLayout(view)) {
        if (mBindingComponent == null && mBindingRef != null) {
            mBindingComponent = findComponent(mBindingRef);
        }
        if (mBindingComponent instanceof BasicListComponent && view instanceof RecyclerView) {
            BasicListComponent listComponent = (BasicListComponent) mBindingComponent;
            mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
        } else if (mBindingComponent instanceof WXRecyclerTemplateList && view instanceof RecyclerView) {
            WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent;
            mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
        }
    } else {
        mOffsetY = mOffsetY + dy;
    }
    AnimationSet animationSet = new AnimationSet(true);
    boolean hasAnimation = false;
    for (int i = 0; i < mTransformPropArrayList.size(); i++) {
        TransformCreator creator = mTransformPropArrayList.get(i);
        Animation animation = creator.getAnimation(dx, dy);
        if (animation != null) {
            animationSet.addAnimation(animation);
            hasAnimation = true;
        }
    }
    if (hasAnimation) {
        animationSet.setFillAfter(true);
        if (getHostView() != null) {
            getHostView().startAnimation(animationSet);
        }
    }
    if (mBackgroundColor != null) {
        int color = mBackgroundColor.getColor(dx, dy);
        if (mBackGroundColor != color) {
            getHostView().setBackgroundColor(color);
            mBackGroundColor = color;
        }
    }
}
Also used : WXRecyclerTemplateList(com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList) ScaleAnimation(android.view.animation.ScaleAnimation) TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) RotateAnimation(android.view.animation.RotateAnimation) BasicListComponent(com.taobao.weex.ui.component.list.BasicListComponent) WXRecyclerView(com.taobao.weex.ui.view.listview.WXRecyclerView) RecyclerView(android.support.v7.widget.RecyclerView) AnimationSet(android.view.animation.AnimationSet)

Aggregations

RecyclerView (android.support.v7.widget.RecyclerView)1 Animation (android.view.animation.Animation)1 AnimationSet (android.view.animation.AnimationSet)1 RotateAnimation (android.view.animation.RotateAnimation)1 ScaleAnimation (android.view.animation.ScaleAnimation)1 TranslateAnimation (android.view.animation.TranslateAnimation)1 BasicListComponent (com.taobao.weex.ui.component.list.BasicListComponent)1 WXRecyclerTemplateList (com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList)1 WXRecyclerView (com.taobao.weex.ui.view.listview.WXRecyclerView)1