use of com.taobao.weex.ui.view.WXScrollView in project weex-example by KalicyZhou.
the class WXScroller method initComponentHostView.
@Override
protected ViewGroup initComponentHostView(@NonNull Context context) {
String scroll;
if (getDomObject() == null || getDomObject().getAttrs().isEmpty()) {
scroll = "vertical";
} else {
scroll = getDomObject().getAttrs().getScrollDirection();
}
ViewGroup host;
if (("horizontal").equals(scroll)) {
mOrientation = Constants.Orientation.HORIZONTAL;
WXHorizontalScrollView scrollView = new WXHorizontalScrollView(context);
mRealView = new FrameLayout(context);
scrollView.setScrollViewListener(new WXHorizontalScrollView.ScrollViewListener() {
@Override
public void onScrollChanged(WXHorizontalScrollView scrollView, int x, int y, int oldx, int oldy) {
procAppear(x, y, oldx, oldy);
}
});
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
scrollView.addView(mRealView, layoutParams);
scrollView.setHorizontalScrollBarEnabled(false);
host = scrollView;
} else {
mOrientation = Constants.Orientation.VERTICAL;
BounceScrollerView scrollerView = new BounceScrollerView(context, mOrientation, this);
mRealView = new FrameLayout(context);
WXScrollView innerView = scrollerView.getInnerView();
innerView.addScrollViewListener(this);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
innerView.addView(mRealView, layoutParams);
innerView.setVerticalScrollBarEnabled(true);
innerView.addScrollViewListener(new WXScrollViewListener() {
@Override
public void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy) {
}
@Override
public void onScrollToBottom(WXScrollView scrollView, int x, int y) {
}
@Override
public void onScrollStopped(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrollStateChanged(scrollView, x, y, OnWXScrollListener.IDLE);
}
}
}
}
@Override
public void onScroll(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrolled(scrollView, x, y);
}
}
}
}
});
host = scrollerView;
}
host.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
procAppear(0, 0, 0, 0);
View view;
if ((view = getHostView()) == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
return host;
}
use of com.taobao.weex.ui.view.WXScrollView in project weex-example by KalicyZhou.
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);
}
}
use of com.taobao.weex.ui.view.WXScrollView in project incubator-weex by apache.
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);
}
use of com.taobao.weex.ui.view.WXScrollView in project incubator-weex by apache.
the class WXScroller method initComponentHostView.
@Override
protected ViewGroup initComponentHostView(@NonNull Context context) {
String scroll;
if (getDomObject() == null || getDomObject().getAttrs().isEmpty()) {
scroll = "vertical";
} else {
scroll = getDomObject().getAttrs().getScrollDirection();
}
ViewGroup host;
if (("horizontal").equals(scroll)) {
mOrientation = Constants.Orientation.HORIZONTAL;
WXHorizontalScrollView scrollView = new WXHorizontalScrollView(context);
mRealView = new FrameLayout(context);
scrollView.setScrollViewListener(new WXHorizontalScrollView.ScrollViewListener() {
@Override
public void onScrollChanged(WXHorizontalScrollView scrollView, int x, int y, int oldx, int oldy) {
procAppear(x, y, oldx, oldy);
}
});
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
scrollView.addView(mRealView, layoutParams);
scrollView.setHorizontalScrollBarEnabled(false);
host = scrollView;
} else {
mOrientation = Constants.Orientation.VERTICAL;
BounceScrollerView scrollerView = new BounceScrollerView(context, mOrientation, this);
mRealView = new FrameLayout(context);
WXScrollView innerView = scrollerView.getInnerView();
innerView.addScrollViewListener(this);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
innerView.addView(mRealView, layoutParams);
innerView.setVerticalScrollBarEnabled(true);
innerView.setNestedScrollingEnabled(WXUtils.getBoolean(getDomObject().getAttrs().get(Constants.Name.NEST_SCROLLING_ENABLED), true));
innerView.addScrollViewListener(new WXScrollViewListener() {
@Override
public void onScrollChanged(WXScrollView scrollView, int x, int y, int oldx, int oldy) {
}
@Override
public void onScrollToBottom(WXScrollView scrollView, int x, int y) {
}
@Override
public void onScrollStopped(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
listener.onScrollStateChanged(scrollView, x, y, OnWXScrollListener.IDLE);
}
}
}
}
@Override
public void onScroll(WXScrollView scrollView, int x, int y) {
List<OnWXScrollListener> listeners = getInstance().getWXScrollListeners();
if (listeners != null && listeners.size() > 0) {
for (OnWXScrollListener listener : listeners) {
if (listener != null) {
if (listener instanceof ICheckBindingScroller) {
if (((ICheckBindingScroller) listener).isNeedScroller(getRef(), null)) {
listener.onScrolled(scrollView, x, y);
}
} else {
listener.onScrolled(scrollView, x, y);
}
}
}
}
}
});
host = scrollerView;
}
host.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void onGlobalLayout() {
procAppear(0, 0, 0, 0);
View view;
if ((view = getHostView()) == null) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
} else {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
}
});
return host;
}
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;
}
Aggregations