You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by mi...@apache.org on 2017/07/19 03:48:56 UTC
incubator-weex git commit: * [android] fix invalid init index
Repository: incubator-weex
Updated Branches:
refs/heads/0.15-dev 3bf348d35 -> 10a074fd5
* [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/10a074fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/10a074fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/10a074fd
Branch: refs/heads/0.15-dev
Commit: 10a074fd5d9d0d173ae278671d864511df84de81
Parents: 3bf348d
Author: misakuo <mi...@apache.org>
Authored: Wed Jul 19 10:47:19 2017 +0800
Committer: misakuo <mi...@apache.org>
Committed: Wed Jul 19 10:47:19 2017 +0800
----------------------------------------------------------------------
.../com/taobao/weex/CreateFinishListener.java | 27 --------------
.../com/taobao/weex/UpdateFinishListener.java | 27 --------------
.../java/com/taobao/weex/WXSDKInstance.java | 39 --------------------
.../com/taobao/weex/ui/component/WXSlider.java | 34 +++--------------
4 files changed, 6 insertions(+), 121 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/10a074fd/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
deleted file mode 100644
index 37b4cfb..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/CreateFinishListener.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/13.
- */
-
-public interface CreateFinishListener {
- void onCreateFinish();
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/10a074fd/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
deleted file mode 100644
index c44cd8a..0000000
--- a/android/sdk/src/main/java/com/taobao/weex/UpdateFinishListener.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 UpdateFinishListener {
- void onUpdateFinish();
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/10a074fd/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 9339f67..a8d8a60 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,6 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View.
private boolean mNeedValidate = false;
private static volatile int mViewPortWidth = 750;
private int mInstanceViewPortWidth = 750;
- private List<CreateFinishListener> mCreateFinishListeners;
- private List<UpdateFinishListener> mUpdateFinishListeners;
/**
* Render strategy.
@@ -950,11 +948,6 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View.
*/
public void onUpdateFinish() {
WXLogUtils.d("Instance onUpdateSuccess");
- if (mUpdateFinishListeners != null && mUpdateFinishListeners.size() > 0) {
- for (UpdateFinishListener listener : mUpdateFinishListeners) {
- listener.onUpdateFinish();
- }
- }
}
@@ -1002,12 +995,6 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View.
WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, mWXPerformance.toString());
}
}
-
- if (mCreateFinishListeners != null) {
- for (CreateFinishListener listener : mCreateFinishListeners) {
- listener.onCreateFinish();
- }
- }
}
});
}
@@ -1603,30 +1590,4 @@ public class WXSDKInstance implements IWXActivityStateListener,DomContext, View.
public interface NestedInstanceInterceptor {
void onCreateNestInstance(WXSDKInstance instance, NestedContainer container);
}
-
- public void addCreateFinishListener(CreateFinishListener listener) {
- if (mCreateFinishListeners == null) {
- mCreateFinishListeners = new ArrayList<>();
- }
- mCreateFinishListeners.add(listener);
- }
-
- public void removeCreateFinishListener(CreateFinishListener listener) {
- if (mCreateFinishListeners != null && listener != null) {
- mCreateFinishListeners.remove(listener);
- }
- }
-
- public void addUpdateFinishListener(UpdateFinishListener listener) {
- if (mUpdateFinishListeners == null) {
- mUpdateFinishListeners = new ArrayList<>();
- }
- mUpdateFinishListeners.add(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/10a074fd/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 121b416..dd593f9 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,6 @@ import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
-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;
@@ -186,8 +184,12 @@ public class WXSlider extends WXVContainer<FrameLayout> {
}
mAdapter.addPageView(view);
hackTwoItemsInfiniteScroll();
-
- mViewPager.setCurrentItem(0);
+ if (initIndex != -1 && mAdapter.getRealCount() > initIndex) {
+ mViewPager.setCurrentItem(initIndex);
+ initIndex = -1;
+ } else {
+ mViewPager.setCurrentItem(0);
+ }
if (mIndicator != null) {
mIndicator.getHostView().forceLayout();
mIndicator.getHostView().requestLayout();
@@ -513,30 +515,6 @@ public class WXSlider extends WXVContainer<FrameLayout> {
}
}
- @Override
- protected void onHostViewInitialized(FrameLayout host) {
- super.onHostViewInitialized(host);
- getInstance().addCreateFinishListener(new CreateFinishListener() {
- @Override
- public void onCreateFinish() {
- if (mViewPager != null && initIndex != -1 && mAdapter != null && mAdapter.getRealCount() > initIndex) {
- mViewPager.setCurrentItem(initIndex);
- initIndex = -1;
- }
- }
- });
-
- getInstance().addUpdateFinishListener(new UpdateFinishListener() {
- @Override
- public void onUpdateFinish() {
- if (mViewPager != null && initIndex != -1 && mAdapter != null && mAdapter.getRealCount() > initIndex) {
- mViewPager.setCurrentItem(initIndex);
- initIndex = -1;
- }
- }
- });
- }
-
private static class FlingGestureListener extends GestureDetector.SimpleOnGestureListener {
private static final int SWIPE_MIN_DISTANCE = WXViewUtils.dip2px(50);
private static final int SWIPE_MAX_OFF_PATH = WXViewUtils.dip2px(250);