You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by gu...@apache.org on 2017/10/23 08:10:39 UTC
[11/18] incubator-weex git commit: Revert: * [android] modify
border-android.png
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
index 03f3057..782b16c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/WXDomObject.java
@@ -335,7 +335,9 @@ public class WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject
int index = mDomChildren.indexOf(child);
if (index == -1) {
+ if (WXEnvironment.isApkDebugable()) {
WXLogUtils.e("[WXDomObject] remove function error");
+ }
return;
}
mDomChildren.remove(index).parent = null;
@@ -683,7 +685,7 @@ public class WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject
type = TextUtils.isEmpty(result.replacedComponent) ? WXBasicComponentType.DIV
: result.replacedComponent;
json.put(TYPE, type);
- if (result.validateInfo != null) {
+ if (WXEnvironment.isApkDebugable() && result.validateInfo != null) {
String tag = "[WXDomObject]onComponentValidate failure. >>> " + result.validateInfo.toJSONString();
WXLogUtils.e(tag);
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
index 3fcedcb..9f35263 100644
--- a/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/AbstractAddElementAction.java
@@ -96,7 +96,9 @@ public abstract class AbstractAddElementAction extends TraceableAction implement
Stopwatch.split("parseDomObject");
if (domObject == null || context.getDomByRef(domObject.getRef()) != null) {
- WXLogUtils.e("[DOMActionContextImpl] " + getStatementName() + " error,DOM object is null or already registered!!");
+ if (WXEnvironment.isApkDebugable()) {
+ WXLogUtils.e("[DOMActionContextImpl] " + getStatementName() + " error,DOM object is null or already registered!!");
+ }
instance.commitUTStab(IWXUserTrackAdapter.DOM_MODULE, errCode);
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java b/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
index bbd093c..258da68 100644
--- a/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
+++ b/android/sdk/src/main/java/com/taobao/weex/dom/action/MoveElementAction.java
@@ -91,8 +91,5 @@ final class MoveElementAction implements DOMAction, RenderAction {
WXVContainer oldParent = component.getParent();
oldParent.remove(component,false);
((WXVContainer) newParent).addChild(component, mNewIndex);
- if(!component.isVirtualComponent()){
- ((WXVContainer) newParent).addSubView(component.getHostView(), mNewIndex);
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
index 4ca9d50..a8d1963 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/AbstractEditComponent.java
@@ -221,14 +221,6 @@ public abstract class AbstractEditComponent extends WXComponent<WXEditText> {
mBeforeText = s.toString();
- if (getDomObject() != null && getDomObject().getAttrs() != null) {
- Object val = getDomObject().getAttrs().get(Constants.Name.VALUE);
- String valString = WXUtils.getString(val, null);
- if (mBeforeText != null && mBeforeText.equals(valString)) {
- return;
- }
- }
-
if (!mIgnoreNextOnInputEvent) {
fireEvent(Constants.Event.INPUT, s.toString());
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 082c14e..bd6c2d7 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -999,9 +999,7 @@ public abstract class WXComponent<T extends View> implements IWXObject, IWXActi
* @param type
*/
public void addEvent(String type) {
- if (TextUtils.isEmpty(type)
- || mAppendEvents.contains(type)
- || getRealView() == null) {
+ if (TextUtils.isEmpty(type) || mAppendEvents.contains(type)) {
return;
}
mAppendEvents.add(type);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponentFactory.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponentFactory.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponentFactory.java
index 4f9712f..4323821 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponentFactory.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponentFactory.java
@@ -59,9 +59,11 @@ public class WXComponentFactory {
IFComponentHolder holder = WXComponentRegistry.getComponent(node.getType());
if (holder == null) {
+ if (WXEnvironment.isApkDebugable()) {
String tag = "WXComponentFactory error type:[" +
node.getType() + "]" + " class not found";
WXLogUtils.e(tag);
+ }
//For compatible reason of JS framework, unregistered type will be treated as container.
holder = WXComponentRegistry.getComponent(WXBasicComponentType.CONTAINER);
if(holder == null){
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
index 1c4d062..1cf5d02 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXImage.java
@@ -19,7 +19,6 @@
package com.taobao.weex.ui.component;
import android.Manifest;
-import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.graphics.RectF;
@@ -28,7 +27,6 @@ import android.net.Uri;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
-import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.widget.ImageView;
@@ -73,7 +71,6 @@ public class WXImage extends WXComponent<ImageView> {
public static final String SUCCEED = "success";
public static final String ERRORDESC = "errorDesc";
- private static final int WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE = 0x2;
private String mSrc;
private int mBlurRadius;
@@ -359,13 +356,6 @@ public class WXImage extends WXComponent<ImageView> {
public void save(final JSCallback saveStatuCallback) {
if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
- if (getContext() instanceof Activity) {
- ActivityCompat.requestPermissions((Activity) getContext(),
- new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, WRITE_EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE);
- }
- }
-
- if (ContextCompat.checkSelfPermission(getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
if (saveStatuCallback != null) {
Map<String, Object> result = new HashMap<>();
result.put(SUCCEED, false);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
index 9e56259..6cf784f 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
@@ -233,7 +233,7 @@ public class WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewL
* Intercept refresh view and loading view
*/
@Override
- public void addSubView(View child, int index) {
+ protected void addSubView(View child, int index) {
if (child == null || getRealView() == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/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 ec2d73f..1023e3e 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
@@ -173,7 +173,7 @@ public class WXSlider extends WXVContainer<FrameLayout> {
}
@Override
- public void addSubView(View view, int index) {
+ protected void addSubView(View view, int index) {
if (view == null || mAdapter == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSliderNeighbor.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSliderNeighbor.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSliderNeighbor.java
index 0899c8d..b1001b7 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSliderNeighbor.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXSliderNeighbor.java
@@ -113,7 +113,7 @@ public class WXSliderNeighbor extends WXSlider {
}
@Override
- public void addSubView(View view, final int index) {
+ protected void addSubView(View view, final int index) {
if (view == null || mAdapter == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
index 62b667b..e9263eb 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXVContainer.java
@@ -20,9 +20,6 @@ package com.taobao.weex.ui.component;
import android.content.Context;
import android.content.Intent;
-import android.support.annotation.RestrictTo;
-import android.support.annotation.RestrictTo.Scope;
-import android.util.Pair;
import android.support.annotation.Nullable;
import android.util.Pair;
import android.view.Menu;
@@ -312,8 +309,7 @@ public abstract class WXVContainer<T extends ViewGroup> extends WXComponent<T> {
}
}
- @RestrictTo(Scope.LIBRARY)
- public void addSubView(View child, int index) {
+ protected void addSubView(View child, int index) {
if (child == null || getRealView() == null) {
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
index c04ed0a..640a17e 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
@@ -150,15 +150,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
private WXStickyHelper stickyHelper;
-
- /**
- * keep positon
- * */
- private WXComponent keepPositionCell = null;
- private Runnable keepPositionCellRunnable = null;
- private long keepPositionLayoutDelay = 150;
-
-
public BasicListComponent(WXSDKInstance instance, WXDomObject node, WXVContainer parent) {
super(instance, node, parent);
stickyHelper = new WXStickyHelper(this);
@@ -245,9 +236,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
if (transforms != null) {
bounceRecyclerView.getInnerView().addItemDecoration(RecyclerTransform.parseTransforms(getOrientation(), transforms));
}
- if(getDomObject().getAttrs().get(Constants.Name.KEEP_POSITION_LAYOUT_DELAY) != null){
- keepPositionLayoutDelay = WXUtils.getNumberInt(getDomObject().getAttrs().get(Constants.Name.KEEP_POSITION_LAYOUT_DELAY), (int)keepPositionLayoutDelay);
- }
mItemAnimator=bounceRecyclerView.getInnerView().getItemAnimator();
@@ -257,10 +245,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
bounceRecyclerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
bounceRecyclerView.getInnerView().clearOnScrollListeners();
bounceRecyclerView.getInnerView().addOnScrollListener(mViewOnScrollListener);
- if(getDomObject().getAttrs().get(Constants.Name.HAS_FIXED_SIZE) != null){
- boolean hasFixedSize = WXUtils.getBoolean(getDomObject().getAttrs().get(Constants.Name.HAS_FIXED_SIZE), false);
- bounceRecyclerView.getInnerView().setHasFixedSize(hasFixedSize);
- }
bounceRecyclerView.getInnerView().addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
@@ -501,54 +485,53 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
if (stickyComponent != null && stickyComponent.getDomObject() != null
&& stickyComponent instanceof WXCell) {
- WXCell cell = (WXCell) stickyComponent;
- if (cell.getHostView() == null) {
- return;
- }
-
- int[] location = new int[2];
- stickyComponent.getHostView().getLocationOnScreen(location);
- int[] parentLocation = new int[2];
- stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
- int top = location[1] - parentLocation[1];
-
+ WXCell cell = (WXCell) stickyComponent;
+ if (cell.getHostView() == null) {
+ return;
+ }
RecyclerView.LayoutManager layoutManager;
boolean beforeFirstVisibleItem = false;
boolean removeOldSticky = false;
layoutManager = getHostView().getInnerView().getLayoutManager();
if (layoutManager instanceof LinearLayoutManager || layoutManager instanceof GridLayoutManager) {
- int firstVisiblePosition = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
- int lastVisiblePosition = ((LinearLayoutManager) layoutManager).findLastVisibleItemPosition();
+ int fVisible = ((LinearLayoutManager) layoutManager).findFirstVisibleItemPosition();
int pos = mChildren.indexOf(cell);
cell.setScrollPositon(pos);
- if (pos <= firstVisiblePosition
- || (cell.getStickyOffset() > 0 && firstVisiblePosition < pos && pos <= lastVisiblePosition &&
- top <= cell.getStickyOffset())) {
+
+ if (pos <= fVisible) {
beforeFirstVisibleItem = true;
if(pos > currentStickyPos) {
currentStickyPos = pos;
}
- }else{
+ }
+
+ if(pos > fVisible){
removeOldSticky = true;
}
} else if(layoutManager instanceof StaggeredGridLayoutManager){
int [] firstItems= new int[3];
- int firstVisiblePosition = ((StaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(firstItems)[0];
- int lastVisiblePosition = ((StaggeredGridLayoutManager) layoutManager).findLastVisibleItemPositions(firstItems)[0];
+ int fVisible = ((StaggeredGridLayoutManager) layoutManager).findFirstVisibleItemPositions(firstItems)[0];
int pos = mChildren.indexOf(cell);
- if (pos <= firstVisiblePosition || (cell.getStickyOffset() > 0 && firstVisiblePosition < pos && pos <= lastVisiblePosition &&
- top <= cell.getStickyOffset())) {
+ if (pos <= fVisible) {
beforeFirstVisibleItem = true;
- }else{
+ }
+
+ if(pos > fVisible){
removeOldSticky = true;
}
}
+ int[] location = new int[2];
+ stickyComponent.getHostView().getLocationOnScreen(location);
+ int[] parentLocation = new int[2];
+ stickyComponent.getParentScroller().getView().getLocationOnScreen(parentLocation);
+
+ int top = location[1] - parentLocation[1];
- boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= cell.getStickyOffset() && dy >= 0;
- boolean removeSticky = cell.getLocationFromStart() <= cell.getStickyOffset() && top > cell.getStickyOffset() && dy <= 0;
+ boolean showSticky = beforeFirstVisibleItem && cell.getLocationFromStart() >= 0 && top <= 0 && dy >= 0;
+ boolean removeSticky = cell.getLocationFromStart() <= 0 && top > 0 && dy <= 0;
if (showSticky) {
bounceRecyclerView.notifyStickyShow(cell);
} else if (removeSticky || removeOldSticky) {
@@ -601,6 +584,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
@Override
public void addChild(WXComponent child, int index) {
super.addChild(child, index);
+
if (child == null || index < -1) {
return;
}
@@ -609,7 +593,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
bindViewType(child);
int adapterPosition = index == -1 ? mChildren.size() - 1 : index;
- final T view = getHostView();
+ T view = getHostView();
if (view != null) {
boolean isAddAnimation = false;
ImmutableDomObject domObject = child.getDomObject();
@@ -632,52 +616,9 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
}
}
if (isKeepScrollPosition) {
- if(view.getInnerView().getLayoutManager() instanceof LinearLayoutManager){
- if(!view.getInnerView().isLayoutFrozen()){ //frozen, prevent layout when scroll
- view.getInnerView().setLayoutFrozen(true);
- }
- if(keepPositionCell == null){
- int last=((LinearLayoutManager)view.getInnerView().getLayoutManager()).findLastCompletelyVisibleItemPosition();
- ListBaseViewHolder holder = (ListBaseViewHolder) view.getInnerView().findViewHolderForAdapterPosition(last);
- if(holder != null){
- keepPositionCell = holder.getComponent();
- }
- if(keepPositionCell != null) {
- if(keepPositionCellRunnable != null){
- view.removeCallbacks(keepPositionCellRunnable);
- }
- keepPositionCellRunnable = new Runnable() {
- @Override
- public void run() {
- if(keepPositionCell != null){
- int keepPosition = indexOf(keepPositionCell);
- int offset = 0;
- if(keepPositionCell.getHostView() != null){
- offset = keepPositionCell.getHostView().getTop();
- }
- if(offset > 0) {
- ((LinearLayoutManager) view.getInnerView().getLayoutManager()).scrollToPositionWithOffset(keepPosition, offset);
- }else{
- view.getInnerView().getLayoutManager().scrollToPosition(keepPosition);
-
- }
- view.getInnerView().setLayoutFrozen(false);
- keepPositionCell = null;
- keepPositionCellRunnable = null;
- }
- }
- };
- }
- }
- if(keepPositionCellRunnable == null){
- view.getInnerView().scrollToPosition(((LinearLayoutManager)view.getInnerView().getLayoutManager()).findLastVisibleItemPosition());
- }
- }
+ int last=((LinearLayoutManager)view.getInnerView().getLayoutManager()).findLastVisibleItemPosition();
+ view.getInnerView().getLayoutManager().scrollToPosition(last);
view.getRecyclerViewBaseAdapter().notifyItemInserted(adapterPosition);
- if(keepPositionCellRunnable != null){
- view.removeCallbacks(keepPositionCellRunnable);
- view.postDelayed(keepPositionCellRunnable, keepPositionLayoutDelay);
- }
} else {
view.getRecyclerViewBaseAdapter().notifyItemChanged(adapterPosition);
}
@@ -687,7 +628,6 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
-
private void relocateAppearanceHelper() {
Iterator<Map.Entry<String, AppearanceHelper>> iterator = mAppearComponents.entrySet().iterator();
while (iterator.hasNext()) {
@@ -706,7 +646,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
* com.taobao.weex.ui.view.listview.WXRecyclerView}
*/
@Override
- public void addSubView(View child, int index) {
+ protected void addSubView(View child, int index) {
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/list/StickyHeaderHelper.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/StickyHeaderHelper.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/StickyHeaderHelper.java
index cedd86c..1534013 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/StickyHeaderHelper.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/StickyHeaderHelper.java
@@ -21,7 +21,6 @@ package com.taobao.weex.ui.component.list;
import android.view.View;
import android.view.ViewGroup;
-import com.taobao.weex.WXEnvironment;
import com.taobao.weex.common.WXThread;
import com.taobao.weex.utils.WXLogUtils;
@@ -88,20 +87,12 @@ public class StickyHeaderHelper {
if ((existedParent = (ViewGroup) headerView.getParent()) != null) {
existedParent.removeView(headerView);
}
- headerView.setTag(headComponent.getRef());
mParent.addView(headerView);
- headerView.setTag(this);
- if(headComponent.getStickyOffset() > 0) {
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) headerView.getLayoutParams();
- if(headComponent.getStickyOffset() != params.topMargin) {
- params.topMargin = headComponent.getStickyOffset();
- }
- }
//recover translation, sometimes it will be changed on fling
headerView.setTranslationX(translationX);
headerView.setTranslationY(translationY);
+
}
- changeFrontStickyVisible();
if (headComponent.getDomObject().getEvents().contains("sticky")) {
headComponent.fireEvent("sticky");
}
@@ -117,8 +108,7 @@ public class StickyHeaderHelper {
if(component == null || headerView == null){
- if(WXEnvironment.isApkDebugable()) {
- }
+ WXLogUtils.e(" sticky header to remove not found."+compToRemove.getRef());
return;
}
if(mCurrentStickyRef != null && mCurrentStickyRef.equals(compToRemove.getRef())){
@@ -128,12 +118,7 @@ public class StickyHeaderHelper {
@Override
public void run() {
mParent.removeView(headerView);
- if(headerView.getVisibility() != View.VISIBLE){
- headerView.setVisibility(View.VISIBLE);
- }
component.recoverySticky();
- changeFrontStickyVisible();
-
}
}));
if (component.getDomObject().getEvents().contains("unsticky")) {
@@ -156,7 +141,6 @@ public class StickyHeaderHelper {
View view = mHeaderViews.get(cell.getRef());
if(view != null){
view.bringToFront();
- changeFrontStickyVisible();
}
}
}
@@ -164,27 +148,4 @@ public class StickyHeaderHelper {
notifyStickyRemove(cell);
}
}
-
-
- private void changeFrontStickyVisible(){
- if(mHeaderViews.size() <= 0){
- return;
- }
- boolean fontVisible = false;
- for(int i=mParent.getChildCount()-1; i>=0; i--){
- View view = mParent.getChildAt(i);
- if(fontVisible && view.getTag() instanceof StickyHeaderHelper){
- if(view.getVisibility() != View.GONE){
- view.setVisibility(View.GONE);
- }
- }else{
- if(view.getTag() instanceof StickyHeaderHelper){
- fontVisible = true;
- if(view != null && view.getVisibility() != View.VISIBLE){
- view.setVisibility(View.VISIBLE);
- }
- }
- }
- }
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXCell.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXCell.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXCell.java
index 925da65..4fe4bc2 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXCell.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/WXCell.java
@@ -37,9 +37,6 @@ import com.taobao.weex.ui.flat.WidgetContainer;
import com.taobao.weex.ui.view.WXFrameLayout;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXUtils;
-import com.taobao.weex.utils.WXViewUtils;
-
-import static com.taobao.weex.common.Constants.Name.STICKY_OFFSET;
/**
* Root component for components in {@link WXListComponent}
@@ -58,14 +55,12 @@ public class WXCell extends WidgetContainer<WXFrameLayout> {
private int mScrollPositon = -1;
private boolean mFlatUIEnabled = false;
-
private Object renderData;
private boolean isSourceUsed = false;
private boolean hasLayout = false;
-
@Deprecated
public WXCell(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy) {
super(instance, dom, parent);
@@ -147,41 +142,28 @@ public class WXCell extends WidgetContainer<WXFrameLayout> {
}
public void removeSticky() {
- if(getHostView().getChildCount() > 0) {
- mHeadView = getHostView().getChildAt(0);
- int[] location = new int[2];
- int[] parentLocation = new int[2];
- getHostView().getLocationOnScreen(location);
- getParentScroller().getView().getLocationOnScreen(parentLocation);
- int headerViewOffsetX = location[0] - parentLocation[0];
- int headerViewOffsetY = getParent().getHostView().getTop();
- getHostView().removeView(mHeadView);
- mRealView = (ViewGroup) mHeadView;
- mTempStickyView = new FrameLayout(getContext());
- FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams((int) getDomObject().getLayoutWidth(),
- (int) getDomObject().getLayoutHeight());
- getHostView().addView(mTempStickyView, lp);
- mHeadView.setTranslationX(headerViewOffsetX);
- mHeadView.setTranslationY(headerViewOffsetY);
- }
+ mHeadView = getHostView().getChildAt(0);
+ int[] location = new int[2];
+ int[] parentLocation = new int[2];
+ getHostView().getLocationOnScreen(location);
+ getParentScroller().getView().getLocationOnScreen(parentLocation);
+ int headerViewOffsetX = location[0] - parentLocation[0];
+ int headerViewOffsetY = getParent().getHostView().getTop();
+ getHostView().removeView(mHeadView);
+ mRealView = (ViewGroup) mHeadView;
+ mTempStickyView = new FrameLayout(getContext());
+ FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams((int) getDomObject().getLayoutWidth(),
+ (int) getDomObject().getLayoutHeight());
+ getHostView().addView(mTempStickyView, lp);
+ mHeadView.setTranslationX(headerViewOffsetX);
+ mHeadView.setTranslationY(headerViewOffsetY);
}
public void recoverySticky() {
- if(mHeadView != null){
- if(mHeadView.getLayoutParams() != null){
- ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) mHeadView.getLayoutParams();
- if(params.topMargin > 0){
- params.topMargin = 0;
- }
- }
- if(mHeadView.getVisibility() != View.VISIBLE){
- mHeadView.setVisibility(View.VISIBLE);
- }
- getHostView().removeView(mTempStickyView);
- getHostView().addView(mHeadView);
- mHeadView.setTranslationX(0);
- mHeadView.setTranslationY(0);
- }
+ getHostView().removeView(mTempStickyView);
+ getHostView().addView(mHeadView);
+ mHeadView.setTranslationX(0);
+ mHeadView.setTranslationY(0);
}
@Override
@@ -203,18 +185,6 @@ public class WXCell extends WidgetContainer<WXFrameLayout> {
return getInstance().getFlatUIContext().isFlatUIEnabled(this) && WXCell.class.equals(getClass()) && !isSticky();
}
- public int getStickyOffset(){
- if(getDomObject() == null){
- return 0;
- }
- WXDomObject domObject = (WXDomObject) getDomObject();
- if(domObject.getAttrs().get(STICKY_OFFSET) == null){
- return 0;
- }
- float offset = WXUtils.getFloat(domObject.getAttrs().get(STICKY_OFFSET));
- return (int)(WXViewUtils.getRealPxByWidth(offset,domObject.getViewPortWidth()));
- }
-
public Object getRenderData() {
return renderData;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
index 76bcce0..7e0746b 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/WXRecyclerTemplateList.java
@@ -593,7 +593,7 @@ public class WXRecyclerTemplateList extends WXVContainer<BounceRecyclerView> imp
* com.taobao.weex.ui.view.listview.WXRecyclerView}
*/
@Override
- public void addSubView(View child, int index) {
+ protected void addSubView(View child, int index) {
}
@@ -1306,7 +1306,7 @@ public class WXRecyclerTemplateList extends WXVContainer<BounceRecyclerView> imp
continue;
}
TemplateViewHolder itemHolder = (TemplateViewHolder) recyclerView.findViewHolderForAdapterPosition(position);
- if(itemHolder == null || itemHolder.getComponent() == null){
+ if(itemHolder == null){
break;
}
List<WXComponent> childListeners = findChildListByRef(itemHolder.getComponent(), helper.getAwareChild().getRef());
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
index b2a1793..20be140 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/listview/WXRecyclerView.java
@@ -42,8 +42,6 @@ public class WXRecyclerView extends RecyclerView implements WXGestureObservable
public static final int TYPE_STAGGERED_GRID_LAYOUT = 3;
private WXGesture mGesture;
private boolean scrollable = true;
- private boolean hasTouch = false;
-
public WXRecyclerView(Context context) {
super(context);
@@ -93,7 +91,6 @@ public class WXRecyclerView extends RecyclerView implements WXGestureObservable
if(!scrollable) {
return true;
}
- hasTouch = true;
boolean result = super.onTouchEvent(event);
if (mGesture != null) {
result |= mGesture.onTouch(this, event);
@@ -113,31 +110,26 @@ public class WXRecyclerView extends RecyclerView implements WXGestureObservable
}
//Any else?
} else {
- smoothScrollToPosition(position);
if (offset != 0) {
setOnSmoothScrollEndListener(new ExtendedLinearLayoutManager.OnSmoothScrollEndListener() {
@Override
public void onStop() {
- post(new Runnable() {
- @Override
- public void run() {
- if (orientation == Constants.Orientation.VERTICAL) {
- smoothScrollBy(0, offset);
- } else {
- smoothScrollBy(offset, 0);
- }
- }
- });
+ if (orientation == Constants.Orientation.VERTICAL) {
+ smoothScrollBy(0, offset);
+ } else {
+ smoothScrollBy(offset, 0);
+ }
}
});
}
+ smoothScrollToPosition(position);
}
}
public void setOnSmoothScrollEndListener(final ExtendedLinearLayoutManager.OnSmoothScrollEndListener onSmoothScrollEndListener){
- if(getLayoutManager() instanceof ExtendedLinearLayoutManager && !hasTouch){
+ if(getLayoutManager() instanceof ExtendedLinearLayoutManager){
ExtendedLinearLayoutManager extendedLinearLayoutManager = (ExtendedLinearLayoutManager)getLayoutManager();
- extendedLinearLayoutManager.setOnScrollEndListener(onSmoothScrollEndListener);
+ extendedLinearLayoutManager.setOnScrollEndListener(onSmoothScrollEndListener);
}else{
addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java
index 1f5b4b2..1f2b4b1 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXLogUtils.java
@@ -71,18 +71,13 @@ public class WXLogUtils {
}
private static void log(String tag, String msg, LogLevel level){
- if (msg != null && WXEnvironment.sLogLevel.compare(level) >= 0) {
- if (sLogWatcher != null ) {
- sLogWatcher.onLog(level.getName(), tag, msg);
- }else{
- Log.println(level.getPriority(),tag, msg);
- }
-
- // if not debug level then print log
- if(WXEnvironment.isApkDebugable() && !level.getName().equals("debug")){
- writeConsoleLog(level.getName(), msg);
- sendLog(level, msg);
- }
+ if (WXEnvironment.isApkDebugable() && msg != null && WXEnvironment.sLogLevel.compare(level) >= 0) {
+ Log.println(level.getPriority(),tag, msg);
+ writeConsoleLog(level.getName(), msg);
+ sendLog(level, msg);
+ }
+ if (sLogWatcher != null) {
+ sLogWatcher.onLog(level.getName(), tag, msg);
}
}
@@ -119,8 +114,13 @@ public class WXLogUtils {
}
public static void d(String tag, String msg) {
+ if (!TextUtils.isEmpty(msg) && !TextUtils.isEmpty(tag)) {
+ log(tag, msg, LogLevel.DEBUG);
+ }
if (WXEnvironment.isApkDebugable() && !TextUtils.isEmpty(msg) && WXEnvironment.sLogLevel.compare(LogLevel.DEBUG) >= 0) {
+ Log.d(tag, msg);
+
if ("jsLog".equals(tag) && jsLogWatcher != null) {
if (msg.endsWith("__DEBUG")) {
jsLogWatcher.onJsLog(Log.DEBUG, msg.replace("__DEBUG", ""));
@@ -214,13 +214,15 @@ public class WXLogUtils {
}
public static void w(String prefix, Throwable e) {
+ if (WXEnvironment.isApkDebugable()) {
w(prefix + getStackTrace(e));
-
+ }
}
public static void e(String prefix, Throwable e) {
+ if (WXEnvironment.isApkDebugable()) {
e(prefix + getStackTrace(e));
-
+ }
}
public static void wtf(String prefix, Throwable e){
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
index 827cc94..a7fba8a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXSoInstallMgrSdk.java
@@ -32,7 +32,6 @@ import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.common.WXPerformance;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -69,8 +68,6 @@ public class WXSoInstallMgrSdk {
private final static String ARMEABI = "armeabi"; //default
private final static String X86 = "x86";
private final static String MIPS = "mips";
- private final static String STARTUPSO = "/libweexjsb.so";
- private final static String STARTUPSOANDROID15 = "/libweexjst.so";
private final static int ARMEABI_Size = 3583820;
private final static int X86_Size = 4340864;
@@ -114,9 +111,6 @@ public class WXSoInstallMgrSdk {
return false;
}
- // copy startup so
- copyStartUpSo();
-
boolean InitSuc = false;
if (checkSoIsValid(libName, BuildConfig.ARMEABI_Size) ||checkSoIsValid(libName, BuildConfig.X86_Size)) {
@@ -176,69 +170,6 @@ public class WXSoInstallMgrSdk {
return InitSuc;
}
- /**
- * copyStartUpSo
- */
- public static void copyStartUpSo() {
- try {
- boolean installOnSdcard = true;
- String pkgName = WXEnvironment.getApplication().getPackageName();
- // cp weexjsb any way
-// try {
-// PackageManager pm = WXEnvironment.getApplication().getApplicationContext().getPackageManager();
-// ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, 0);
-// if ((appInfo.flags & ApplicationInfo.FLAG_EXTERNAL_STORAGE) != 0) {
-// // App on sdcard
-// installOnSdcard = true;
-// }
-// } catch (Throwable e) {
-// }
-
- if (installOnSdcard) {
-
- String cacheFile = WXEnvironment.getApplication().getApplicationContext().getCacheDir().getPath();
- // if android api < 16 copy libweexjst.so else copy libweexjsb.so
- boolean pieSupport = true;
- File newfile;
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
- pieSupport = false;
- newfile = new File(cacheFile + STARTUPSOANDROID15);
- } else {
- newfile = new File(cacheFile + STARTUPSO);
- }
- if (newfile.exists()) {
- return;
- }
-
- String path = "/data/data/" + pkgName + "/lib";
- if (cacheFile != null && cacheFile.indexOf("/cache") > 0) {
- path = cacheFile.replace("/cache", "/lib");
- }
-
- String soName;
- if (pieSupport) {
- soName = path + STARTUPSO;
- } else {
- soName = path + STARTUPSOANDROID15;
- }
-
- File oldfile = new File(soName);
- if (oldfile.exists()) {
- FileInputStream inputStream = new FileInputStream(oldfile);
- byte[] data = new byte[1024];
- FileOutputStream outputStream =new FileOutputStream(newfile);
- while (inputStream.read(data) != -1) {
- outputStream.write(data);
- }
- inputStream.close();
- outputStream.close();
- }
- }
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
private static String _getFieldReflectively(Build build, String fieldName) {
try {
final Field field = Build.class.getField(fieldName);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java b/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
index 4a1b304..7d11d5a 100644
--- a/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
+++ b/android/sdk/src/main/java/com/taobao/weex/utils/WXViewUtils.java
@@ -378,7 +378,7 @@ public class WXViewUtils {
public static void clipCanvasWithinBorderBox(View targetView, Canvas canvas) {
Drawable drawable;
if (clipCanvasDueToAndroidVersion(canvas) &&
- clipCanvasIfAnimationExist(targetView) &&
+ clipCanvasIfAnimationExist() &&
((drawable = targetView.getBackground()) instanceof BorderDrawable)) {
BorderDrawable borderDrawable = (BorderDrawable) drawable;
if (borderDrawable.isRounded()) {
@@ -394,7 +394,7 @@ public class WXViewUtils {
public static void clipCanvasWithinBorderBox(Widget widget, Canvas canvas) {
BorderDrawable borderDrawable;
if (clipCanvasDueToAndroidVersion(canvas) &&
- clipCanvasIfAnimationExist(null) &&
+ clipCanvasIfAnimationExist() &&
(borderDrawable=widget.getBackgroundAndBorder())!=null ) {
if (borderDrawable.isRounded() && clipCanvasIfBackgroundImageExist(widget, borderDrawable)) {
Path path = borderDrawable.getContentPath(
@@ -424,25 +424,8 @@ public class WXViewUtils {
* As animation will not cause redraw if hardware-acceleration enabled, clipCanvas feature has
* to be disabled when API level is 24 without considering the animation property.
*/
- private static boolean clipCanvasIfAnimationExist(View targetView) {
- if (Build.VERSION.SDK_INT != VERSION_CODES.N) {
- return true;
- }
- if(targetView != null &&
- targetView.getScaleX() == 1 &&
- targetView.getScaleY() == 1 &&
- targetView.getTranslationX() == 0 &&
- targetView.getTranslationY() == 0 &&
- targetView.getRotation() == 0 &&
- targetView.getRotationX() == 0 &&
- targetView.getRotationY() == 0) {
- if(Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && targetView.getTranslationZ() != 0 ) {
- return false;
- } else {
- return true;
- }
- }
- return false;
+ private static boolean clipCanvasIfAnimationExist() {
+ return Build.VERSION.SDK_INT != VERSION_CODES.N;
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java
index e249c1c..3fde10a 100644
--- a/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java
@@ -20,7 +20,6 @@ package com.taobao.weex.utils;
import com.taobao.weappplus_sdk.BuildConfig;
import com.taobao.weex.WXEnvironment;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -92,17 +91,4 @@ public class WXLogUtilsTest {
Log.e("tag",new Throwable("test"));
}
- @Test
- public void testLogLevel() throws Exception {
- WXEnvironment.sLogLevel = LogLevel.DEBUG;
- Log.d("LogLevel.DEBUG", "test debug");
- Log.w("LogLevel.DEBUG", "test warning");
- Log.e("LogLevel.DEBUG", "test error");
-
- WXEnvironment.sLogLevel = LogLevel.WARN;
-
- Log.d("LogLevel.WARN", "test debug");
- Log.w("LogLevel.WARN", "test warning");
- Log.e("LogLevel.WARN", "test error");
- }
- }
+}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java
index 5b6d273..e981c69 100644
--- a/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java
+++ b/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java
@@ -19,7 +19,6 @@
package com.taobao.weex.utils;
import android.text.TextUtils;
-import android.util.Log;
import com.taobao.weappplus_sdk.BuildConfig;
import com.taobao.weex.WXEnvironment;
@@ -50,7 +49,7 @@ import static org.mockito.Matchers.any;
@RunWith(PowerMockRunner.class)
@Config(constants = BuildConfig.class, sdk = 19)
@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"})
-@PrepareForTest( {WXEnvironment.class, WXViewUtils.class, WXSDKInstance.class, TextUtils.class, Log.class, WXUtils.class, WXLogUtils.class})
+@PrepareForTest( {WXEnvironment.class, WXViewUtils.class, WXSDKInstance.class, TextUtils.class})
public class WXUtilsTest extends TestCase {
public static final float TEST_DENSITY = 3.0f;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/android/weex_debug/src/main/java/com/taobao/weex/bridge/WXWebsocketBridge.java
----------------------------------------------------------------------
diff --git a/android/weex_debug/src/main/java/com/taobao/weex/bridge/WXWebsocketBridge.java b/android/weex_debug/src/main/java/com/taobao/weex/bridge/WXWebsocketBridge.java
index 1343f60..b686f7c 100644
--- a/android/weex_debug/src/main/java/com/taobao/weex/bridge/WXWebsocketBridge.java
+++ b/android/weex_debug/src/main/java/com/taobao/weex/bridge/WXWebsocketBridge.java
@@ -204,21 +204,6 @@ public class WXWebsocketBridge implements IWXBridge,WXWebSocketManager.JSDebugge
}
@Override
- public int initFrameworkEnv(String scriptsFramework,WXParams params, String cacheDir, boolean pieSupport) {
- if (!mInit) {
- return -1;
- }
-
- Map<String, Object> map = new HashMap<>();
- map.put("method", "evalFramework");
- ArrayList<String> args = new ArrayList<>();
- args.add(scriptsFramework);
- map.put("arguments", args);
- WXWebSocketManager.getInstance().sendMessage(JSON.toJSONString(map));
- return 0;
- }
-
- @Override
public void takeHeapSnapshot(String filename) {}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/dangerfile.js
----------------------------------------------------------------------
diff --git a/dangerfile.js b/dangerfile.js
index 616f27a..97c4146 100644
--- a/dangerfile.js
+++ b/dangerfile.js
@@ -273,15 +273,6 @@ filesToVerifySrcHeader.forEach(filepath => {
return;
}
}
-
- // check cn for source code
- var reg = /[\u4e00-\u9FA5]+/;
- var res = reg.test(content);
- if(res){
- console.error("Code file "+ filepath +" has cn source code.");
- fail("Code file "+ filepath +" has cn source code.");
- return ;
- }
});
@@ -316,12 +307,11 @@ function findReviewer(resolve, reject) {
number: danger.github.pr.number,
headers: {Accept: 'application/vnd.github.diff',"user-agent": "node.js"}
}, function (err, result) {
+ console.log('parseDeleteAndNormalLines')
if ("undefined" === typeof result || "undefined" === typeof result.data || err) {
- console.log('result:'+result+', error:'+err);
resolve()
return
}
- console.log('result:'+result);
parseDeleteAndNormalLines(result.data, fileToDeletedLinesMap, fileToNormalLinesMap)
console.log('getContent')
var promises = danger.git.modified_files.map(function(file) {
@@ -376,29 +366,21 @@ function getContent(url) {
function parseDeleteAndNormalLines(diffData, fileToDeletedLinesMap, fileToNormalLinesMap) {
try {
- console.log('parseDeleteAndNormalLines')
var diffs = parseDiff(diffData)
- console.log('diffs:'+diffs)
- if(diffs&&diffs instanceof Array){
- diffs.forEach(diff => {
- fileToDeletedLinesMap[diff.from] = [];
- fileToNormalLinesMap[diff.from] = [];
- if(diff&&diff.chunks&&diff.chunks instanceof Array){
- diff.chunks.forEach(chunk => {
- if(chunk&&chunk.changes&&chunk.changes instanceof Array){
- chunk.changes.forEach(change => {
- if (change&&change.del) {
- fileToDeletedLinesMap[diff.from].push(change.ln)
- }
- if (change&&change.normal) {
- fileToNormalLinesMap[diff.from].push(change.ln1)
- }
- })
- }
- })
- }
+ diffs.forEach(diff => {
+ fileToDeletedLinesMap[diff.from] = [];
+ fileToNormalLinesMap[diff.from] = [];
+ diff.chunks.forEach(chunk => {
+ chunk.changes.forEach(change => {
+ if (change.del) {
+ fileToDeletedLinesMap[diff.from].push(change.ln)
+ }
+ if (change.normal) {
+ fileToNormalLinesMap[diff.from].push(change.ln1)
+ }
+ })
})
- }
+ })
} catch (error) {
console.log(error)
}
@@ -459,7 +441,6 @@ function findBlameReviewers(fileToDeletedLinesMap, fileToNormalLinesMap, fileToB
console.log('blame point:', reviewers)
var names = Object.keys(reviewers)
- if(!names||!names instanceof Array||names.length<=0)return;
names.sort((name1, name2) => {
return reviewers[name1] > reviewers[name2] ? -1 : 1
})
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/source/cn/guide/contributing.md
----------------------------------------------------------------------
diff --git a/doc/source/cn/guide/contributing.md b/doc/source/cn/guide/contributing.md
index fd3138d..36db1f9 100644
--- a/doc/source/cn/guide/contributing.md
+++ b/doc/source/cn/guide/contributing.md
@@ -25,24 +25,23 @@ version: 2.1
## 分支管理 (英)
```
-release
+master
↑
-{version}
- ↑
-master <--- PR(feature/hotfix/typo)
+dev <--- PR(hotfix/typo/3rd-PR)
+ ↑ PR
+{domain}-feature-{date}
```
0. `master` branch
- 0. `master` is the stable developing branch.
- 0. ***It's RECOMMENDED to commit hotfix (like typo) or feature PR to `master `***.
-0. `{version}` branch
- 0. `{version}` is used for every version which we consider for stable publish.
- 0. e.g. `v0.16`
-0. `release` branch
- 0. `release` is the latest release branch,we will make tag and publish version on this branch.
-
-### 用于PR的分支命名
-
+ 0. `master` is the latest (pre-)release branch.
+0. `dev` branch
+ 0. `dev` is the stable developing branch.
+ 0. ***It's RECOMMENDED to commit hotfix (like typo) or feature PR to `dev`***.
+0. `{domain}-feature-{date}` branch
+ 0. The branch for a developing iteration, e.g. `android-feature-20160607` is an android developing iteration which is done at 2016.06.07. `{domain}` consists of `android`, `ios`, `jsfm` and `html5`.
+ 0. **DO NOT commit any PR to such a branch**.
+
+### 分支命名
```
{module}-{action}-{shortName}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/source/guide/contributing.md
----------------------------------------------------------------------
diff --git a/doc/source/guide/contributing.md b/doc/source/guide/contributing.md
index 00cb979..ea824f4 100644
--- a/doc/source/guide/contributing.md
+++ b/doc/source/guide/contributing.md
@@ -25,23 +25,23 @@ Besides Weex dev mailing list, we also have some other mailing lists for you. Yo
## Branch Management
```
-release
+master
↑
-{version}
- ↑
-master <--- PR(feature/hotfix/typo)
+dev <--- PR(hotfix/typo/3rd-PR)
+ ↑ PR
+{domain}-feature-{date}
```
0. `master` branch
- 0. `master` is the stable developing branch.
- 0. ***It's RECOMMENDED to commit hotfix (like typo) or feature PR to `master `***.
-0. `{version}` branch
- 0. `{version}` is used for every version which we consider for stable publish.
- 0. e.g. `v0.16`
-0. `release` branch
- 0. `release` is the latest release branch,we will make tag and publish version on this branch.
-
-### Branch Name For PR
+ 0. `master` is the latest (pre-)release branch.
+0. `dev` branch
+ 0. `dev` is the stable developing branch.
+ 0. ***It's RECOMMENDED to commit hotfix (like typo) or feature PR to `dev`***.
+0. `{domain}-feature-{date}` branch
+ 0. The branch for a developing iteration, e.g. `android-feature-20160607` is an android developing iteration which is done at 2016.06.07. `{domain}` consists of `android`, `ios`, `jsfm` and `html5`.
+ 0. **DO NOT commit any PR to such a branch**.
+
+### Branch Name
```
{module}-{action}-{shortName}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/source/references/platform-difference.md
----------------------------------------------------------------------
diff --git a/doc/source/references/platform-difference.md b/doc/source/references/platform-difference.md
deleted file mode 100644
index 0aadfae..0000000
--- a/doc/source/references/platform-difference.md
+++ /dev/null
@@ -1,11 +0,0 @@
----
-title: Platform Differences Between Weex and Web
-type: references
-order: 12
-version: 2.1
-has_chapter_content: true
----
-
-# Platform Differences Between Weex and Web
-
-Work in progresss.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/source/references/platfrom-difference.md
----------------------------------------------------------------------
diff --git a/doc/source/references/platfrom-difference.md b/doc/source/references/platfrom-difference.md
new file mode 100644
index 0000000..0aadfae
--- /dev/null
+++ b/doc/source/references/platfrom-difference.md
@@ -0,0 +1,11 @@
+---
+title: Platform Differences Between Weex and Web
+type: references
+order: 12
+version: 2.1
+has_chapter_content: true
+---
+
+# Platform Differences Between Weex and Web
+
+Work in progresss.
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/source/references/vue/difference-with-web.md
----------------------------------------------------------------------
diff --git a/doc/source/references/vue/difference-with-web.md b/doc/source/references/vue/difference-with-web.md
index b750591..2af11f9 100644
--- a/doc/source/references/vue/difference-with-web.md
+++ b/doc/source/references/vue/difference-with-web.md
@@ -9,7 +9,7 @@ version: 2.1
## Platform Differences
-Vue.js was designed for the Web platform at the begining. Although it can be based on Weex to develop native applications, there are still many differences between web and native. See [Platform Differences Between Weex and Web](../platform-difference.html) for more details.
+Vue.js was designed for the Web platform at the begining. Although it can be based on Weex to develop native applications, there are still many differences between web and native. See [Platform Differences Between Weex and Web](../ platform-difference.html) for more details.
Due to those differences, Weex doesn't support those features in Vue.js (mostly are DOM-related):
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/layout/_partial/article.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/_partial/article.ejs b/doc/themes/weex/layout/_partial/article.ejs
index e7052b7..3ee5b2a 100644
--- a/doc/themes/weex/layout/_partial/article.ejs
+++ b/doc/themes/weex/layout/_partial/article.ejs
@@ -8,6 +8,4 @@
<% if (page_type === 'article') { %>
<%- partial('_partial/post/nav') %>
<% } %>
- <%- partial('footer') %>
- <%- partial('after-footer') %>
</article>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/layout/index.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/index.ejs b/doc/themes/weex/layout/index.ejs
index b713fd4..4a1ad87 100644
--- a/doc/themes/weex/layout/index.ejs
+++ b/doc/themes/weex/layout/index.ejs
@@ -250,9 +250,6 @@
</div>
</div>
<a href="javascript:;" id="back2top" class="back2top"><span class="iconfont icon-arrow-small"></span></a>
-<%- partial('_partial/footer') %>
-<%- partial('_partial/after-footer') %>
-
<%- js('js/swiper.min') %>
<%- js('js/velocity.js') %>
<script>
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/layout/layout.ejs
----------------------------------------------------------------------
diff --git a/doc/themes/weex/layout/layout.ejs b/doc/themes/weex/layout/layout.ejs
index ba6dee3..df3b12b 100644
--- a/doc/themes/weex/layout/layout.ejs
+++ b/doc/themes/weex/layout/layout.ejs
@@ -9,6 +9,8 @@
<%- partial('_partial/sidebar', {post: page, page_type: page_type}) %>
<%- body %>
+ <%- partial('_partial/footer') %>
+ <%- partial('_partial/after-footer') %>
<%- js('js/reqwest.js') %>
<%- js('js/common.js') %>
<% if (config.docsearch.enable){ %>
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/source/css/common.scss
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/css/common.scss b/doc/themes/weex/source/css/common.scss
index d03be9f..10c25cf 100644
--- a/doc/themes/weex/source/css/common.scss
+++ b/doc/themes/weex/source/css/common.scss
@@ -17,9 +17,9 @@ html, body {
}
body {
- background: $bg-white;
+ background: $bg-gray;
// font-family: Exo,'-apple-system','Open Sans',HelveticaNeue-Light,'Helvetica Neue Light','Helvetica Neue','Hiragino Sans GB','Microsoft YaHei',Helvetica,Arial,sans-serif;
- font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
+ font-family: Lato, "Microsoft Jhenghei", "Hiragino Sans GB", "Microsoft YaHei", sans-serif,'-apple-system','Open Sans',HelveticaNeue-Light,'Helvetica Neue Light';
// font-family: 'PingFang SC', 'Hiragino Sans GB', 'Microsoft Yahei', 'WenQuanYi Micro Hei',sans-serif;
// font-size:62.5%;max-height:100%;
font-size: 14px;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/source/css/partial/header.scss
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/css/partial/header.scss b/doc/themes/weex/source/css/partial/header.scss
index a45d8f7..ac02f1a 100644
--- a/doc/themes/weex/source/css/partial/header.scss
+++ b/doc/themes/weex/source/css/partial/header.scss
@@ -6,7 +6,7 @@
padding: 0 40px;
position: fixed;
background-color: rgba(255, 255, 255, .95);
- box-shadow: 0 0 1px rgba(0,0,0,0.25);
+ box-shadow: 3px 2px 4px 0 rgba(0,0,0,0.12);
top: 0;
left: 0;
right: 0;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/source/css/post.scss
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/css/post.scss b/doc/themes/weex/source/css/post.scss
index 370d90c..f3a6544 100644
--- a/doc/themes/weex/source/css/post.scss
+++ b/doc/themes/weex/source/css/post.scss
@@ -50,15 +50,14 @@
}
.doc-nav {
- position: fixed;
+ position: absolute;
top: 72px;
left: 0;
bottom: 0;
- width: 260px;
- padding: 40px 20px 60px 60px;
- background: $bg-white;
+ background: $bg-gray;
width: 300px;
z-index: 999;
+ padding: 43px 15px 15px;
overflow-x: hidden;
overflow-y: auto;
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/doc/themes/weex/source/css/variable.scss
----------------------------------------------------------------------
diff --git a/doc/themes/weex/source/css/variable.scss b/doc/themes/weex/source/css/variable.scss
index cbe4b12..50e35cd 100644
--- a/doc/themes/weex/source/css/variable.scss
+++ b/doc/themes/weex/source/css/variable.scss
@@ -6,7 +6,7 @@ $text-light-black: #333;
$text-black: #333;
$text-white: #fff;
$text-gray: #999;
-$text-blue: #088bc3;
+$text-blue: #00BDFF;
$bg-blue: $text-blue;
$bg-light-blue: #23CEFD;
$bg-white: #fff;
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/html5/runtime/api/WeexInstance.js
----------------------------------------------------------------------
diff --git a/html5/runtime/api/WeexInstance.js b/html5/runtime/api/WeexInstance.js
deleted file mode 100644
index 2093f17..0000000
--- a/html5/runtime/api/WeexInstance.js
+++ /dev/null
@@ -1,126 +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.
- */
-
-import Document from '../vdom/Document'
-import { isRegisteredModule, getModuleDescription } from './module'
-import { isRegisteredComponent } from './component'
-
-const moduleProxies = {}
-
-function setId (weex, id) {
- Object.defineProperty(weex, '[[CurrentInstanceId]]', { value: id })
-}
-
-function getId (weex) {
- return weex['[[CurrentInstanceId]]']
-}
-
-function moduleGetter (module, method, taskCenter) {
- return (...args) => taskCenter.send('module', { module, method }, args)
-}
-
-export default class WeexInstance {
- constructor (id, config) {
- setId(this, id)
- this.config = config || {}
- this.document = new Document(id, this.config.bundleUrl)
- this.requireModule = this.requireModule.bind(this)
- this.isRegisteredModule = isRegisteredModule
- this.isRegisteredComponent = isRegisteredComponent
- }
-
- requireModule (moduleName) {
- const id = getId(this)
- if (!(id && this.document && this.document.taskCenter)) {
- console.error(`[JS Framework] invalid instance id "${id}"`)
- return
- }
-
- // warn for unknown module
- if (!isRegisteredModule(moduleName)) {
- console.warn(`[JS Framework] using unregistered weex module "${moduleName}"`)
- return
- }
-
- // create new module proxy
- if (!moduleProxies[moduleName]) {
- const moduleDefine = getModuleDescription(moduleName)
- const taskCenter = this.document.taskCenter
-
- // create registered module apis
- const moduleApis = {}
- for (const methodName in moduleDefine) {
- Object.defineProperty(moduleApis, methodName, {
- enumerable: true,
- configurable: true,
- get: () => moduleGetter(moduleName, methodName, taskCenter),
- set (fn) {
- if (typeof fn === 'function') {
- return taskCenter.send('module', {
- module: moduleName,
- method: methodName
- }, [fn])
- }
- }
- })
- }
-
- // create module Proxy
- if (typeof Proxy === 'function') {
- moduleProxies[moduleName] = new Proxy(moduleApis, {
- get (target, methodName) {
- if (methodName in target) {
- return target[methodName]
- }
- console.warn(`[JS Framework] using unregistered method "${moduleName}.${methodName}"`)
- return moduleGetter(moduleName, methodName, taskCenter)
- }
- })
- }
- else {
- moduleProxies[moduleName] = moduleApis
- }
- }
-
- return moduleProxies[moduleName]
- }
-
- supports (condition) {
- if (typeof condition !== 'string') return null
-
- const res = condition.match(/^@(\w+)\/(\w+)(\.(\w+))?$/i)
- if (res) {
- const type = res[1]
- const name = res[2]
- const method = res[4]
- switch (type) {
- case 'module': return isRegisteredModule(name, method)
- case 'component': return isRegisteredComponent(name)
- }
- }
-
- return null
- }
-
- // registerStyleSheet (styles) {
- // if (this.document) {
- // this.document.registerStyleSheet(styles)
- // }
- // }
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/html5/runtime/api/component.js
----------------------------------------------------------------------
diff --git a/html5/runtime/api/component.js b/html5/runtime/api/component.js
deleted file mode 100644
index 8a56961..0000000
--- a/html5/runtime/api/component.js
+++ /dev/null
@@ -1,51 +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.
- */
-
-import { registerElement } from '../vdom/WeexElement'
-
-const weexComponents = {}
-
-/**
- * Register native components information.
- * @param {array} newComponents
- */
-export function registerComponents (newComponents) {
- if (Array.isArray(newComponents)) {
- newComponents.forEach(component => {
- if (!component) {
- return
- }
- if (typeof component === 'string') {
- weexComponents[component] = true
- }
- else if (typeof component === 'object' && typeof component.type === 'string') {
- weexComponents[component.type] = component
- registerElement(component.type, component.methods)
- }
- })
- }
-}
-
-/**
- * Check whether the component has been registered.
- * @param {String} component name
- */
-export function isRegisteredComponent (name) {
- return !!weexComponents[name]
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/html5/runtime/api/init.js
----------------------------------------------------------------------
diff --git a/html5/runtime/api/init.js b/html5/runtime/api/init.js
index cad0179..024afa7 100644
--- a/html5/runtime/api/init.js
+++ b/html5/runtime/api/init.js
@@ -18,10 +18,8 @@
*/
import { init as initTaskHandler } from '../bridge/TaskCenter'
-import { registerModules } from './module'
-import { registerComponents } from './component'
+import { registerElement } from '../vdom/WeexElement'
import { services, register, unregister } from './service'
-import WeexInstance from './WeexInstance'
let frameworks
let runtimeConfig
@@ -97,61 +95,58 @@ function createInstance (id, code, config, data) {
config = JSON.parse(JSON.stringify(config || {}))
config.env = JSON.parse(JSON.stringify(global.WXEnvironment || {}))
- const weex = new WeexInstance(id, config)
- Object.freeze(weex)
-
- const runtimeEnv = {
- weex,
- config, // TODO: deprecated
+ const context = {
+ config,
created: Date.now(),
framework: bundleType
}
- runtimeEnv.services = createServices(id, runtimeEnv, runtimeConfig)
- instanceMap[id] = runtimeEnv
+ context.services = createServices(id, context, runtimeConfig)
+ instanceMap[id] = context
- const runtimeContext = Object.create(null)
- Object.assign(runtimeContext, runtimeEnv.services, { weex })
+ if (process.env.NODE_ENV === 'development') {
+ console.debug(`[JS Framework] create an ${bundleType} instance`)
+ }
- const framework = runtimeConfig.frameworks[bundleType]
- if (!framework) {
+ const fm = frameworks[bundleType]
+ if (!fm) {
return new Error(`invalid bundle type "${bundleType}".`)
}
- // run create instance
- if (typeof framework.prepareInstanceContext === 'function') {
- const instanceContext = framework.prepareInstanceContext(runtimeContext)
- return runInContext(code, instanceContext)
- }
- return framework.createInstance(id, code, config, data, runtimeEnv)
+ return fm.createInstance(id, code, config, data, context)
+}
+
+const methods = {
+ createInstance,
+ registerService: register,
+ unregisterService: unregister
}
/**
- * Run js code in a specific context.
- * @param {string} code
- * @param {object} context
+ * Register methods which init each frameworks.
+ * @param {string} methodName
*/
-function runInContext (code, context) {
- const keys = []
- const args = []
- for (const key in context) {
- keys.push(key)
- args.push(context[key])
+function genInit (methodName) {
+ methods[methodName] = function (...args) {
+ if (methodName === 'registerComponents') {
+ checkComponentMethods(args[0])
+ }
+ for (const name in frameworks) {
+ const framework = frameworks[name]
+ if (framework && framework[methodName]) {
+ framework[methodName](...args)
+ }
+ }
}
-
- const bundle = `
- (function (global) {
- "use strict";
- ${code}
- })(Object.create(this))
- `
-
- return (new Function(...keys, bundle))(...args)
}
-const methods = {
- createInstance,
- registerService: register,
- unregisterService: unregister
+function checkComponentMethods (components) {
+ if (Array.isArray(components)) {
+ components.forEach((name) => {
+ if (name && name.type && name.methods) {
+ registerElement(name.type, name.methods)
+ }
+ })
+ }
}
/**
@@ -208,27 +203,6 @@ function adaptInstance (methodName, nativeMethodName) {
}
}
-/**
- * Register methods which init each frameworks.
- * @param {string} methodName
- * @param {function} sharedMethod
- */
-function adaptMethod (methodName, sharedMethod) {
- methods[methodName] = function (...args) {
- if (typeof sharedMethod === 'function') {
- sharedMethod(...args)
- }
-
- // TODO: deprecated
- for (const name in runtimeConfig.frameworks) {
- const framework = runtimeConfig.frameworks[name]
- if (framework && framework[methodName]) {
- framework[methodName](...args)
- }
- }
- }
-}
-
export default function init (config) {
runtimeConfig = config || {}
frameworks = runtimeConfig.frameworks || {}
@@ -242,9 +216,8 @@ export default function init (config) {
framework.init(config)
}
- adaptMethod('registerComponents', registerComponents)
- adaptMethod('registerModules', registerModules)
- adaptMethod('registerMethods')
+ // @todo: The method `registerMethods` will be re-designed or removed later.
+ ; ['registerComponents', 'registerModules', 'registerMethods'].forEach(genInit)
; ['destroyInstance', 'refreshInstance', 'receiveTasks', 'getRoot'].forEach(genInstance)
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/html5/runtime/api/module.js
----------------------------------------------------------------------
diff --git a/html5/runtime/api/module.js b/html5/runtime/api/module.js
deleted file mode 100644
index df26b92..0000000
--- a/html5/runtime/api/module.js
+++ /dev/null
@@ -1,56 +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.
- */
-
-const weexModules = {}
-
-/**
- * Register native modules information.
- * @param {object} newModules
- */
-export function registerModules (newModules) {
- for (const name in newModules) {
- if (!weexModules[name]) {
- weexModules[name] = {}
- }
- newModules[name].forEach(method => {
- if (typeof method === 'string') {
- weexModules[name][method] = true
- }
- else {
- weexModules[name][method.name] = method.args
- }
- })
- }
-}
-
-/**
- * Check whether the module or the method has been registered.
- * @param {String} module name
- * @param {String} method name (optional)
- */
-export function isRegisteredModule (name, method) {
- if (typeof method === 'string') {
- return !!(weexModules[name] && weexModules[name][method])
- }
- return !!weexModules[name]
-}
-
-export function getModuleDescription (name) {
- return weexModules[name]
-}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/html5/runtime/vdom/Element.js
----------------------------------------------------------------------
diff --git a/html5/runtime/vdom/Element.js b/html5/runtime/vdom/Element.js
index 15837f2..6663b51 100644
--- a/html5/runtime/vdom/Element.js
+++ b/html5/runtime/vdom/Element.js
@@ -409,7 +409,7 @@ export default class Element extends Node {
if (!isStopPropagation
&& isBubble
- && (BUBBLE_EVENTS.indexOf(type) !== -1)
+ && BUBBLE_EVENTS.includes(type)
&& this.parentNode
&& this.parentNode.fireEvent) {
event.currentTarget = this.parentNode
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
index 749cb8c..8addaca 100644
--- a/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
+++ b/ios/sdk/WeexSDK.xcodeproj/project.pbxproj
@@ -264,10 +264,6 @@
77E65A161C155EB5008B8775 /* WXTextComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E65A141C155EB5008B8775 /* WXTextComponent.m */; };
77E65A191C155F25008B8775 /* WXScrollerComponent.h in Headers */ = {isa = PBXBuildFile; fileRef = 77E65A171C155F25008B8775 /* WXScrollerComponent.h */; settings = {ATTRIBUTES = (Public, ); }; };
77E65A1A1C155F25008B8775 /* WXScrollerComponent.m in Sources */ = {isa = PBXBuildFile; fileRef = 77E65A181C155F25008B8775 /* WXScrollerComponent.m */; };
- 841CD1031F9739890081196D /* WXExceptionUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 841CD1021F9739890081196D /* WXExceptionUtils.m */; };
- 841CD1051F974DFA0081196D /* WXExceptionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 841CD1041F97399C0081196D /* WXExceptionUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 841CD1061F974DFA0081196D /* WXExceptionUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 841CD1041F97399C0081196D /* WXExceptionUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
- 841CD1071F974E000081196D /* WXExceptionUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 841CD1021F9739890081196D /* WXExceptionUtils.m */; };
C401945E1E344E8300D19C31 /* WXFloatCompareTests.m in Sources */ = {isa = PBXBuildFile; fileRef = C401945D1E344E8300D19C31 /* WXFloatCompareTests.m */; };
C41E1A971DC1FD15009C7F90 /* WXDatePickerManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C41E1A951DC1FD15009C7F90 /* WXDatePickerManager.h */; };
C41E1A981DC1FD15009C7F90 /* WXDatePickerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = C41E1A961DC1FD15009C7F90 /* WXDatePickerManager.m */; };
@@ -855,8 +851,6 @@
77E65A141C155EB5008B8775 /* WXTextComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXTextComponent.m; sourceTree = "<group>"; };
77E65A171C155F25008B8775 /* WXScrollerComponent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXScrollerComponent.h; sourceTree = "<group>"; };
77E65A181C155F25008B8775 /* WXScrollerComponent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXScrollerComponent.m; sourceTree = "<group>"; };
- 841CD1021F9739890081196D /* WXExceptionUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXExceptionUtils.m; sourceTree = "<group>"; };
- 841CD1041F97399C0081196D /* WXExceptionUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WXExceptionUtils.h; sourceTree = "<group>"; };
C401945D1E344E8300D19C31 /* WXFloatCompareTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXFloatCompareTests.m; sourceTree = "<group>"; };
C41E1A951DC1FD15009C7F90 /* WXDatePickerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WXDatePickerManager.h; sourceTree = "<group>"; };
C41E1A961DC1FD15009C7F90 /* WXDatePickerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WXDatePickerManager.m; sourceTree = "<group>"; };
@@ -1088,8 +1082,6 @@
2AAFC1B41C48DFF70026D2FE /* WXSDKError.h */,
749DC2791D40827B009E1C91 /* WXMonitor.h */,
749DC27A1D40827B009E1C91 /* WXMonitor.m */,
- 841CD1041F97399C0081196D /* WXExceptionUtils.h */,
- 841CD1021F9739890081196D /* WXExceptionUtils.m */,
);
name = Monitor;
path = WeexSDK/Sources/Monitor;
@@ -1610,7 +1602,6 @@
DCA0EF641D6EED6F00CB18B9 /* WXGlobalEventModule.h in Headers */,
2A837AB21CD9DE9200AEDF03 /* WXLoadingComponent.h in Headers */,
DCA446271EFA5DAF00D0CFA8 /* WeexSDK.h in Headers */,
- 841CD1051F974DFA0081196D /* WXExceptionUtils.h in Headers */,
C42E8F9B1F39DF07001EBE9D /* WXTracingProtocol.h in Headers */,
7423899F1C32733800D748CA /* WXType.h in Headers */,
59A582FC1CF5B17B0081FD3E /* WXBridgeContext.h in Headers */,
@@ -1802,7 +1793,6 @@
DCA445D51EFA598200D0CFA8 /* WXComponent+PseudoClassManagement.h in Headers */,
DCA4460E1EFA5A7E00D0CFA8 /* WXLength.h in Headers */,
DCA445FA1EFA5A3A00D0CFA8 /* WXNavigatorModule.h in Headers */,
- 841CD1061F974DFA0081196D /* WXExceptionUtils.h in Headers */,
DCA446081EFA5A6A00D0CFA8 /* NSArray+Weex.h in Headers */,
74B81AE51F73C3E900D3A61D /* WXRecycleListDataManager.h in Headers */,
DCA445F21EFA5A2300D0CFA8 /* WXHeaderComponent.h in Headers */,
@@ -2210,7 +2200,6 @@
7463192A1C71B92600EFEBD4 /* WXModalUIModule.m in Sources */,
77D161501C02E3880010B15B /* WXUtility.m in Sources */,
74A4BA9F1CB3C0A100195969 /* WXHandlerFactory.m in Sources */,
- 841CD1031F9739890081196D /* WXExceptionUtils.m in Sources */,
C4E97D341F1EF46D00ABC314 /* WXTracingManager.m in Sources */,
742AD72F1DF98C45007DC46C /* WXResourceRequest.m in Sources */,
7461F8931CFB373100F62D44 /* WXLayer.m in Sources */,
@@ -2289,7 +2278,6 @@
DCA4455E1EFA55B300D0CFA8 /* WXFooterComponent.m in Sources */,
DCA4455F1EFA55B300D0CFA8 /* WXNavigationDefaultImpl.m in Sources */,
74B81AF21F73C3E900D3A61D /* WXJSASTParser.mm in Sources */,
- 841CD1071F974E000081196D /* WXExceptionUtils.m in Sources */,
DCA445601EFA55B300D0CFA8 /* WXURLRewriteDefaultImpl.m in Sources */,
DCA445611EFA55B300D0CFA8 /* WXPrerenderManager.m in Sources */,
DCA445631EFA55B300D0CFA8 /* WXPickerModule.m in Sources */,
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
index 24801cc..7985fe5 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXBridgeContext.m
@@ -40,7 +40,6 @@
#import "WXSDKInstance_private.h"
#import "WXPrerenderManager.h"
#import "WXTracingManager.h"
-#import "WXExceptionUtils.h"
#define SuppressPerformSelectorLeakWarning(Stuff) \
do { \
@@ -507,10 +506,8 @@ _Pragma("clang diagnostic pop") \
WX_MONITOR_PERF_END(WXPTFrameworkExecute);
if ([self.jsBridge exception]) {
- NSString *exception = [[self.jsBridge exception] toString];
- NSMutableString *errMsg = [NSMutableString stringWithFormat:@"[WX_KEY_EXCEPTION_SDK_INIT_JSFM_INIT_FAILED] %@",exception];
- [WXExceptionUtils commitCriticalExceptionRT:@"WX_KEY_EXCEPTION_SDK_INIT" errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_SDK_INIT] function:@"" exception:errMsg extParams:nil];
- WX_MONITOR_FAIL(WXMTJSFramework, WX_ERR_JSFRAMEWORK_EXECUTE, errMsg);
+ NSString *message = [NSString stringWithFormat:@"JSFramework executes error: %@", [self.jsBridge exception]];
+ WX_MONITOR_FAIL(WXMTJSFramework, WX_ERR_JSFRAMEWORK_EXECUTE, message);
} else {
WX_MONITOR_SUCCESS(WXMTJSFramework);
//the JSFramework has been load successfully.
@@ -571,10 +568,8 @@ _Pragma("clang diagnostic pop") \
[self.jsBridge executeJavascript:script];
if ([self.jsBridge exception]) {
- NSString *exception = [[self.jsBridge exception] toString];
- NSMutableString *errMsg = [NSMutableString stringWithFormat:@"[WX_KEY_EXCEPTION_INVOKE_JSSERVICE_EXECUTE] %@",exception];
- [WXExceptionUtils commitCriticalExceptionRT:@"WX_KEY_EXCEPTION_INVOKE" errCode:[NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_INVOKE] function:@"" exception:errMsg extParams:nil];
- WX_MONITOR_FAIL(WXMTJSService, WX_ERR_JSFRAMEWORK_EXECUTE, errMsg);
+ NSString *message = [NSString stringWithFormat:@"JSService executes error: %@", [self.jsBridge exception]];
+ WX_MONITOR_FAIL(WXMTJSService, WX_ERR_JSFRAMEWORK_EXECUTE, message);
} else {
// success
}
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
index f076817..ec81b22 100644
--- a/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
+++ b/ios/sdk/WeexSDK/Sources/Bridge/WXJSCoreBridge.m
@@ -36,7 +36,6 @@
#import "WXSDKManager.h"
#import "WXExtendCallNativeManager.h"
#import "WXTracingManager.h"
-#import "WXExceptionUtils.h"
#import <dlfcn.h>
@@ -155,17 +154,14 @@
_jsContext.exceptionHandler = ^(JSContext *context, JSValue *exception){
context.exception = exception;
+ NSString *message = [NSString stringWithFormat:@"[%@:%@:%@] %@\n%@", exception[@"sourceURL"], exception[@"line"], exception[@"column"], exception, [exception[@"stack"] toObject]];
+ id<WXJSExceptionProtocol> jsExceptionHandler = [WXHandlerFactory handlerForProtocol:@protocol(WXJSExceptionProtocol)];
WXSDKInstance *instance = [WXSDKEngine topInstance];
- NSString *bundleUrl = [instance.scriptURL absoluteString]?:@"WX_KEY_EXCEPTION_WXBRIDGE";
- NSString *errorCode = [NSString stringWithFormat:@"%d", WX_KEY_EXCEPTION_WXBRIDGE];
- NSString *message = [NSString stringWithFormat:@"[WX_KEY_EXCEPTION_WXBRIDGE] [%@:%@:%@] %@\n%@", exception[@"sourceURL"], exception[@"line"], exception[@"column"], [exception toString], [exception[@"stack"] toObject]];
- NSMutableDictionary *userInfo = [NSMutableDictionary dictionaryWithObjectsAndKeys:
- instance.userInfo[@"jsMainBundleStringContentLength"]?:@"",@"jsMainBundleStringContentLength",
- instance.userInfo[@"jsMainBundleStringContentMd5"]?:@"",@"jsMainBundleStringContentMd5",nil];
- WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc] initWithInstanceId:instance.instanceId bundleUrl:bundleUrl errorCode:errorCode functionName:@"" exception:message userInfo:userInfo];
-
- [WXExceptionUtils commitCriticalExceptionRT:jsExceptionInfo];
+ WXJSExceptionInfo * jsExceptionInfo = [[WXJSExceptionInfo alloc] initWithInstanceId:instance.instanceId bundleUrl:[instance.scriptURL absoluteString] errorCode:[NSString stringWithFormat:@"%d", WX_ERR_JS_EXECUTE] functionName:@"" exception:[NSString stringWithFormat:@"[%@:%@] %@\n%@ \njsMainBundleStringContentLength:%@\njsMainBundleStringContentMd5:%@",exception[@"line"], exception[@"column"],[exception toString], exception[@"stack"], instance.userInfo[@"jsMainBundleStringContentLength"]?:@"",instance.userInfo[@"jsMainBundleStringContentMd5"]?:@""] userInfo:nil];
+ if ([jsExceptionHandler respondsToSelector:@selector(onJSException:)]) {
+ [jsExceptionHandler onJSException:jsExceptionInfo];
+ }
WX_MONITOR_FAIL(WXMTJSBridge, WX_ERR_JS_EXECUTE, message);
if (instance.onJSRuntimeException) {
instance.onJSRuntimeException(jsExceptionInfo);
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/bdcc5356/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
index 929dd1a..48eda1a 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXCycleSliderComponent.m
@@ -662,8 +662,8 @@ typedef NS_ENUM(NSInteger, Direction) {
if (_sliderChangeEvent) {
[self fireEvent:@"change" params:@{@"index":@(index)} domChanges:@{@"attrs": @{@"index": @(index)}}];
+ self.currentIndex = index;
}
- self.currentIndex = index;
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView