Skip to content

Commit

Permalink
* [android] fix slider initialization crash.
Browse files Browse the repository at this point in the history
  • Loading branch information
sospartan committed Jul 15, 2016
1 parent dfa71c4 commit 4c52d33
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public WXIndicator(WXSDKInstance instance, WXDomObject dom, WXVContainer parent,
protected WXCircleIndicator initComponentHostView(Context context) {
WXCircleIndicator view = new WXCircleIndicator(context);
if (mParent instanceof WXSlider) {
((WXSlider) mParent).addIndicator(this);
return view;
} else {
if (WXEnvironment.isApkDebugable()) {
throw new WXRuntimeException("WXIndicator initView error.");
Expand All @@ -247,6 +247,14 @@ protected WXCircleIndicator initComponentHostView(Context context) {
return null;
}

@Override
protected void onHostViewInitialized(WXCircleIndicator host) {
super.onHostViewInitialized(host);
if (mParent instanceof WXSlider) {
((WXSlider) mParent).addIndicator(this);
}
}

@WXComponentProp(name = "itemColor")
public void setItemColor(String itemColor) {
if (!TextUtils.isEmpty(itemColor)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,27 +347,19 @@ public void onActivityStop() {
}
}

// @Override
// protected void bindImpl(View view) {
// if(view==null){
// super.bindImpl(view);
// }
// else if(view instanceof ViewGroup){
// if(((ViewGroup) view).getChildAt(0) instanceof WXCircleViewPager){
// super.bindImpl(((ViewGroup) view).getChildAt(0));
// }
// }
// }

public void addIndicator(WXIndicator indicator) {
FrameLayout root = getView();
if (root == null) {
return;
}
mIndicator = indicator;
mIndicator.getView().setCircleViewPager(mViewPager);
mIndicator.getView().setOnPageChangeListener(this);
root.addView(mIndicator.getView());
WXCircleIndicator indicatorView = indicator.getView();
if(indicatorView != null){
indicatorView.setCircleViewPager(mViewPager);
indicatorView.setOnPageChangeListener(this);
root.addView(indicatorView);
}

}

@WXComponentProp(name = WXDomPropConstant.WX_ATTR_SLIDER_VALUE)
Expand Down

0 comments on commit 4c52d33

Please sign in to comment.