Search in sources :

Example 6 with WXScrollView

use of com.taobao.weex.ui.view.WXScrollView in project WeexErosFramework by bmfe.

the class HookWxScroller method setScrollable.

@WXComponentProp(name = "scrollable")
public void setScrollable(boolean scrollable) {
    this.isScrollable = scrollable;
    View hostView = this.getInnerView();
    if (hostView instanceof WXHorizontalScrollView) {
        ((WXHorizontalScrollView) hostView).setScrollable(scrollable);
    } else if (hostView instanceof WXScrollView) {
        ((WXScrollView) hostView).setScrollable(scrollable);
    }
}
Also used : WXScrollView(com.taobao.weex.ui.view.WXScrollView) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) HookWXHorizontalScrollView(com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView) View(android.view.View) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) BaseBounceView(com.taobao.weex.ui.view.refresh.wrapper.BaseBounceView) BounceScrollerView(com.taobao.weex.ui.view.refresh.wrapper.BounceScrollerView) HookWXHorizontalScrollView(com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView) WXScrollView(com.taobao.weex.ui.view.WXScrollView) HookBounceScrollerView(com.eros.framework.extend.hook.ui.view.HookBounceScrollerView) WXComponentProp(com.taobao.weex.ui.component.WXComponentProp)

Example 7 with WXScrollView

use of com.taobao.weex.ui.view.WXScrollView in project WeexErosFramework by bmfe.

the class HookWxScroller method initComponentHostView.

protected ViewGroup initComponentHostView(@NonNull Context context) {
    String scroll;
    if (this.getDomObject() != null && !this.getDomObject().getAttrs().isEmpty()) {
        scroll = this.getDomObject().getAttrs().getScrollDirection();
    } else {
        scroll = "vertical";
    }
    Object host;
    if ("horizontal".equals(scroll)) {
        this.mOrientation = 0;
        HookWXHorizontalScrollView scrollView = new HookWXHorizontalScrollView(context);
        this.mRealView = new FrameLayout(context);
        scrollView.setScrollViewListener(new WXHorizontalScrollView.ScrollViewListener() {

            public void onScrollChanged(WXHorizontalScrollView scrollView, int x, int y, int oldx, int oldy) {
                procAppear(x, y, oldx, oldy);
            }
        });
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        scrollView.addView(this.mRealView, layoutParams);
        scrollView.setHorizontalScrollBarEnabled(false);
        host = scrollView;
    } else {
        this.mOrientation = 1;
        HookBounceScrollerView scrollerView = new HookBounceScrollerView(context, this.mOrientation, this);
        this.mRealView = new FrameLayout(context);
        WXScrollView innerView = (WXScrollView) scrollerView.getInnerView();
        innerView.addScrollViewListener(this);
        FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(-1, -1);
        innerView.addView(this.mRealView, layoutParams);
        innerView.setVerticalScrollBarEnabled(true);
        innerView.setNestedScrollingEnabled(WXUtils.getBoolean(this.getDomObject().getAttrs().get("nestedScrollingEnabled"), Boolean.valueOf(true)).booleanValue());
        innerView.addScrollViewListener(new WXScrollView.WXScrollViewListener() {

            public void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy) {
            }

            public void onScrollToBottom(WXScrollView scrollView, int x, int y) {
            }

            public void onScrollStopped(WXScrollView scrollView, int x, int y) {
                List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
                if (listeners != null && listeners.size() > 0) {
                    Iterator var5 = listeners.iterator();
                    while (var5.hasNext()) {
                        OnWXScrollListener listener = (OnWXScrollListener) var5.next();
                        if (listener != null) {
                            listener.onScrollStateChanged(scrollView, x, y, 0);
                        }
                    }
                }
            }

            public void onScroll(WXScrollView scrollView, int x, int y) {
                List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
                if (listeners != null && listeners.size() > 0) {
                    Iterator var5 = listeners.iterator();
                    while (var5.hasNext()) {
                        OnWXScrollListener listener = (OnWXScrollListener) var5.next();
                        if (listener != null) {
                            if (listener instanceof ICheckBindingScroller) {
                                if (((ICheckBindingScroller) listener).isNeedScroller(getRef(), (Object) null)) {
                                    listener.onScrolled(scrollView, x, y);
                                }
                            } else {
                                listener.onScrolled(scrollView, x, y);
                            }
                        }
                    }
                }
            }
        });
        host = scrollerView;
    }
    ((ViewGroup) host).getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

        @TargetApi(16)
        public void onGlobalLayout() {
            procAppear(0, 0, 0, 0);
            View view;
            if ((view = getHostView()) != null) {
                if (Build.VERSION.SDK_INT >= 16) {
                    view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                    view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
            }
        }
    });
    return (ViewGroup) host;
}
Also used : WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) HookWXHorizontalScrollView(com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView) ViewGroup(android.view.ViewGroup) ICheckBindingScroller(com.taobao.weex.common.ICheckBindingScroller) OnWXScrollListener(com.taobao.weex.common.OnWXScrollListener) View(android.view.View) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) BaseBounceView(com.taobao.weex.ui.view.refresh.wrapper.BaseBounceView) BounceScrollerView(com.taobao.weex.ui.view.refresh.wrapper.BounceScrollerView) HookWXHorizontalScrollView(com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView) WXScrollView(com.taobao.weex.ui.view.WXScrollView) HookBounceScrollerView(com.eros.framework.extend.hook.ui.view.HookBounceScrollerView) Point(android.graphics.Point) HookWXHorizontalScrollView(com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView) WXScrollView(com.taobao.weex.ui.view.WXScrollView) FrameLayout(android.widget.FrameLayout) Iterator(java.util.Iterator) WXDomObject(com.taobao.weex.dom.WXDomObject) HookBounceScrollerView(com.eros.framework.extend.hook.ui.view.HookBounceScrollerView) List(java.util.List) ArrayList(java.util.ArrayList) ViewTreeObserver(android.view.ViewTreeObserver) TargetApi(android.annotation.TargetApi)

Example 8 with WXScrollView

use of com.taobao.weex.ui.view.WXScrollView in project weex-example by KalicyZhou.

the class WXScrollerTest method testScroll.

@Test
public void testScroll() throws Exception {
    WXScroller comp = create();
    WXDiv div = WXDivTest.create(comp);
    ComponentTest.create(div);
    comp.addChild(div);
    ComponentTest.create(comp);
    WXScrollView view = (WXScrollView) comp.getInnerView();
    view.scrollTo(100, 100);
}
Also used : WXScrollView(com.taobao.weex.ui.view.WXScrollView) Test(org.junit.Test) WXSDKInstanceTest(com.taobao.weex.WXSDKInstanceTest)

Example 9 with WXScrollView

use of com.taobao.weex.ui.view.WXScrollView in project incubator-weex by apache.

the class WXScroller method setScrollable.

@WXComponentProp(name = Constants.Name.SCROLLABLE)
public void setScrollable(boolean scrollable) {
    this.isScrollable = scrollable;
    View hostView = getInnerView();
    if (hostView instanceof WXHorizontalScrollView) {
        ((WXHorizontalScrollView) hostView).setScrollable(scrollable);
    } else if (hostView instanceof WXScrollView) {
        ((WXScrollView) hostView).setScrollable(scrollable);
    }
}
Also used : WXScrollView(com.taobao.weex.ui.view.WXScrollView) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) BounceScrollerView(com.taobao.weex.ui.view.refresh.wrapper.BounceScrollerView) View(android.view.View) WXScrollView(com.taobao.weex.ui.view.WXScrollView) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) BaseBounceView(com.taobao.weex.ui.view.refresh.wrapper.BaseBounceView)

Example 10 with WXScrollView

use of com.taobao.weex.ui.view.WXScrollView in project incubator-weex by apache.

the class WXScroller method getScrollEvent.

public Map<String, Object> getScrollEvent(int x, int y) {
    Rect contentFrame = new Rect();
    if (getInnerView() instanceof WXScrollView) {
        contentFrame = ((WXScrollView) getInnerView()).getContentFrame();
    } else if (getInnerView() instanceof WXHorizontalScrollView) {
        contentFrame = ((WXHorizontalScrollView) getInnerView()).getContentFrame();
    }
    Map<String, Object> event = new HashMap<>(2);
    Map<String, Object> contentSize = new HashMap<>(2);
    Map<String, Object> contentOffset = new HashMap<>(2);
    int viewport = getInstance().getInstanceViewPortWidth();
    contentSize.put(Constants.Name.WIDTH, WXViewUtils.getWebPxByWidth(contentFrame.width(), viewport));
    contentSize.put(Constants.Name.HEIGHT, WXViewUtils.getWebPxByWidth(contentFrame.height(), viewport));
    contentOffset.put(Constants.Name.X, -WXViewUtils.getWebPxByWidth(x, viewport));
    contentOffset.put(Constants.Name.Y, -WXViewUtils.getWebPxByWidth(y, viewport));
    event.put(Constants.Name.CONTENT_SIZE, contentSize);
    event.put(Constants.Name.CONTENT_OFFSET, contentOffset);
    return event;
}
Also used : WXScrollView(com.taobao.weex.ui.view.WXScrollView) Rect(android.graphics.Rect) HashMap(java.util.HashMap) WXHorizontalScrollView(com.taobao.weex.ui.view.WXHorizontalScrollView) WXDomObject(com.taobao.weex.dom.WXDomObject) Point(android.graphics.Point)

Aggregations

WXScrollView (com.taobao.weex.ui.view.WXScrollView)10 WXHorizontalScrollView (com.taobao.weex.ui.view.WXHorizontalScrollView)8 View (android.view.View)6 BaseBounceView (com.taobao.weex.ui.view.refresh.wrapper.BaseBounceView)6 BounceScrollerView (com.taobao.weex.ui.view.refresh.wrapper.BounceScrollerView)6 Point (android.graphics.Point)5 TargetApi (android.annotation.TargetApi)3 ViewGroup (android.view.ViewGroup)3 ViewTreeObserver (android.view.ViewTreeObserver)3 FrameLayout (android.widget.FrameLayout)3 HookWXHorizontalScrollView (com.eros.framework.extend.hook.ui.view.HookWXHorizontalScrollView)3 OnWXScrollListener (com.taobao.weex.common.OnWXScrollListener)3 WXDomObject (com.taobao.weex.dom.WXDomObject)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Rect (android.graphics.Rect)2 LayoutParams (android.widget.FrameLayout.LayoutParams)2 HookBounceScrollerView (com.eros.framework.extend.hook.ui.view.HookBounceScrollerView)2 WXSDKInstanceTest (com.taobao.weex.WXSDKInstanceTest)2 ICheckBindingScroller (com.taobao.weex.common.ICheckBindingScroller)2