* [android] fix invalid init index
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/faa70394 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/faa70394 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/faa70394 Branch: refs/heads/0.15-dev Commit: faa70394776ce7e99e4feb139ecbfdae08c76ce6 Parents: a3e8540 Author: misakuo <misa...@apache.org> Authored: Thu Jul 13 11:08:01 2017 +0800 Committer: misakuo <misa...@apache.org> Committed: Thu Jul 13 11:08:01 2017 +0800 ---------------------------------------------------------------------- .../com/taobao/weex/CreateFinishListener.java | 27 ++++++++++++++++++++ .../com/taobao/weex/ICreateFinishListener.java | 27 -------------------- .../com/taobao/weex/IUpdateFinishListener.java | 9 ------- .../com/taobao/weex/UpdateFinishListener.java | 27 ++++++++++++++++++++ .../java/com/taobao/weex/WXSDKInstance.java | 16 ++++++------ .../com/taobao/weex/ui/component/WXSlider.java | 12 ++++----- 6 files changed, 68 insertions(+), 50 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/CreateFinishListener.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/CreateFinishListener.java b/android/sdk/src/main/java/com/taobao/weex/CreateFinishListener.java new file mode 100644 index 0000000..37b4cfb --- /dev/null +++ b/android/sdk/src/main/java/com/taobao/weex/CreateFinishListener.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.taobao.weex; + +/** + * Created by moxun on 2017/7/13. + */ + +public interface CreateFinishListener { + void onCreateFinish(); +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/ICreateFinishListener.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ICreateFinishListener.java b/android/sdk/src/main/java/com/taobao/weex/ICreateFinishListener.java deleted file mode 100644 index b06fd86..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/ICreateFinishListener.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -/** - * Created by moxun on 2017/7/12. - */ - -public interface ICreateFinishListener { - void onCreateFinish(); -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/IUpdateFinishListener.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/IUpdateFinishListener.java b/android/sdk/src/main/java/com/taobao/weex/IUpdateFinishListener.java deleted file mode 100644 index 6824bf5..0000000 --- a/android/sdk/src/main/java/com/taobao/weex/IUpdateFinishListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.taobao.weex; - -/** - * Created by moxun on 2017/7/12. - */ - -public interface IUpdateFinishListener { - void onUpdateFinish(); -} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/UpdateFinishListener.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/UpdateFinishListener.java b/android/sdk/src/main/java/com/taobao/weex/UpdateFinishListener.java new file mode 100644 index 0000000..c44cd8a --- /dev/null +++ b/android/sdk/src/main/java/com/taobao/weex/UpdateFinishListener.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.taobao.weex; + +/** + * Created by moxun on 2017/7/12. + */ + +public interface UpdateFinishListener { + void onUpdateFinish(); +} http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java index c6b0553..9339f67 100644 --- a/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java +++ b/android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java @@ -115,8 +115,8 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View. private boolean mNeedValidate = false; private static volatile int mViewPortWidth = 750; private int mInstanceViewPortWidth = 750; - private List<ICreateFinishListener> mCreateFinishListeners; - private List<IUpdateFinishListener> mUpdateFinishListeners; + private List<CreateFinishListener> mCreateFinishListeners; + private List<UpdateFinishListener> mUpdateFinishListeners; /** * Render strategy. @@ -951,7 +951,7 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View. public void onUpdateFinish() { WXLogUtils.d("Instance onUpdateSuccess"); if (mUpdateFinishListeners != null && mUpdateFinishListeners.size() > 0) { - for (IUpdateFinishListener listener : mUpdateFinishListeners) { + for (UpdateFinishListener listener : mUpdateFinishListeners) { listener.onUpdateFinish(); } } @@ -1004,7 +1004,7 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View. } if (mCreateFinishListeners != null) { - for (ICreateFinishListener listener : mCreateFinishListeners) { + for (CreateFinishListener listener : mCreateFinishListeners) { listener.onCreateFinish(); } } @@ -1604,27 +1604,27 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View. void onCreateNestInstance(WXSDKInstance instance, NestedContainer container); } - public void addCreateFinishListener(ICreateFinishListener listener) { + public void addCreateFinishListener(CreateFinishListener listener) { if (mCreateFinishListeners == null) { mCreateFinishListeners = new ArrayList<>(); } mCreateFinishListeners.add(listener); } - public void removeCreateFinishListener(ICreateFinishListener listener) { + public void removeCreateFinishListener(CreateFinishListener listener) { if (mCreateFinishListeners != null && listener != null) { mCreateFinishListeners.remove(listener); } } - public void addUpdateFinishListener(IUpdateFinishListener listener) { + public void addUpdateFinishListener(UpdateFinishListener listener) { if (mUpdateFinishListeners == null) { mUpdateFinishListeners = new ArrayList<>(); } mUpdateFinishListeners.add(listener); } - public void removeUpdateFinishListener(IUpdateFinishListener listener) { + public void removeUpdateFinishListener(UpdateFinishListener listener) { if (mUpdateFinishListeners != null && listener != null) { mUpdateFinishListeners.remove(listener); } http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/faa70394/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java index b983f98..121b416 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSlider.java @@ -30,8 +30,8 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.widget.FrameLayout; -import com.taobao.weex.ICreateFinishListener; -import com.taobao.weex.IUpdateFinishListener; +import com.taobao.weex.CreateFinishListener; +import com.taobao.weex.UpdateFinishListener; import com.taobao.weex.WXEnvironment; import com.taobao.weex.WXSDKInstance; import com.taobao.weex.WXSDKManager; @@ -516,20 +516,20 @@ public class WXSlider extends WXVContainer<FrameLayout> { @Override protected void onHostViewInitialized(FrameLayout host) { super.onHostViewInitialized(host); - getInstance().addCreateFinishListener(new ICreateFinishListener() { + getInstance().addCreateFinishListener(new CreateFinishListener() { @Override public void onCreateFinish() { - if (mViewPager != null && initIndex != -1) { + if (mViewPager != null && initIndex != -1 && mAdapter != null && mAdapter.getRealCount() > initIndex) { mViewPager.setCurrentItem(initIndex); initIndex = -1; } } }); - getInstance().addUpdateFinishListener(new IUpdateFinishListener() { + getInstance().addUpdateFinishListener(new UpdateFinishListener() { @Override public void onUpdateFinish() { - if (mViewPager != null && initIndex != -1) { + if (mViewPager != null && initIndex != -1 && mAdapter != null && mAdapter.getRealCount() > initIndex) { mViewPager.setCurrentItem(initIndex); initIndex = -1; }