Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
littleseven committed Jan 16, 2017
2 parents 5c6597d + 42caacb commit de6536d
Show file tree
Hide file tree
Showing 61 changed files with 3,245 additions and 263 deletions.
3 changes: 2 additions & 1 deletion appframework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
provided 'com.android.support:support-v4:23.1.1'
provided 'com.android.support:appcompat-v7:23.1.1'
provided 'com.taobao.android:weex_sdk:0.9.4'
// compile project(':weex_sdk')
provided 'com.taobao.android:weex_sdk:0.9.5'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.facebook.fresco:fresco:0.10.0'
testCompile 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ protected TextView initComponentHostView(Context context) {
public void setTelLink(String tel){
SpannableString spannable=new SpannableString(tel);
spannable.setSpan(new URLSpan("tel:"+tel),0,tel.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
((TextView)mHost).setText(spannable);
((TextView)getHostView()).setText(spannable);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.alibaba.weex.extend.component;

import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.dom.WXDomObject;
import com.taobao.weex.ui.component.WXDiv;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.utils.WXLogUtils;

/**
* Created by zhengshihan on 2016/12/30.
*/

public class WXComponentSyncTest extends WXDiv {

public WXComponentSyncTest(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) {
super(instance, dom, parent);
}

@JSMethod (uiThread = false)
public void testSyncCall(){
WXLogUtils.d("11WXComponentSyncTest :"+ Thread.currentThread().getName());
}

@JSMethod (uiThread = true)
public void testAsyncCall(){
WXLogUtils.e("22WXComponentSynTest :"+ Thread.currentThread().getName() );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.alibaba.weex.extend.module;

import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
* Created by zhengshihan on 2016/12/28.
*/

public class SyncTestModule extends WXModule {

@JSMethod(uiThread = false)
public ArrayList getArray(){
ArrayList list = new ArrayList();
list.add("ArrayList test 1");
list.add("ArrayList test 2");
return list;
}
@JSMethod(uiThread = false)
public String getString(){

return "getString :i am string ";
}

@JSMethod(uiThread = false)
public int getNumber(){
return 1111;
}

/**
* JSON NOT allow KeyValue as non-string value
* @return
*/
@JSMethod(uiThread = false)
public Object getObject(){
ArrayList list = new ArrayList();
list.add("222");
list.add("test");
Map map = new HashMap();
map.put(11,"test11");
map.put("22","test22");
list.add(map);
return list;

}



}
7 changes: 4 additions & 3 deletions inspector/bintray-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ install {
dependencies {
// compile 'commons-cli:commons-cli:1.2'
provided 'com.google.code.findbugs:jsr305:2.0.1'
// compile 'com.squareup.okhttp:okhttp:2.3.0'
// compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
// provided 'com.squareup.okhttp:okhttp:2.3.0'
// provided 'com.squareup.okhttp:okhttp-ws:2.3.0'
// optional
testCompile 'junit:junit:4.12'
testCompile('org.robolectric:robolectric:2.4') {
Expand All @@ -115,8 +115,9 @@ dependencies {
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile 'org.powermock:powermock-module-junit4:1.6.1'
provided 'com.android.support:appcompat-v7:23.1.1'
provided 'com.taobao.android:weex_sdk:0.9.4'
provided 'com.taobao.android:weex_sdk:0.9.5'
provided 'com.alibaba:fastjson:1.1.45+'
provided 'com.taobao.android.weex_inspection:protocol:1.0.2'
}

task sourcesJar(type: Jar) {
Expand Down
6 changes: 4 additions & 2 deletions inspector/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ dependencies {
}
testCompile 'org.powermock:powermock-api-mockito:1.6.1'
testCompile 'org.powermock:powermock-module-junit4:1.6.1'
provided 'com.taobao.android:weex_sdk:0.9.4'
//compile project(':weex_sdk')
provided 'com.taobao.android:weex_sdk:0.9.5'
provided 'com.alibaba:fastjson:1.1.46.android'
// provided 'com.squareup.okio:okio:1.6.0'
// compile 'com.squareup.okhttp3:okhttp:3.4.1'
// compile 'com.squareup.okhttp3:okhttp-ws:3.4.1'
// compile 'com.squareup.okhttp:okhttp:2.3.0'
// compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
provided 'com.taobao.android.weex_inspection:protocol:1.0.2'
}

//apply from: rootProject.file('release.gradle')
Expand Down Expand Up @@ -87,4 +89,4 @@ android.libraryVariants.all { variant ->
from "build/commons-cli-tidy-${name}"
from "build/metainf-${name}"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.taobao.weex.devtools.debug;

import android.text.TextUtils;
import android.util.Log;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.bridge.WXJSObject;
import com.taobao.weex.bridge.WXParams;
Expand Down Expand Up @@ -60,12 +62,7 @@ public int initFramework(String framework, WXParams params) {
}
}

if (mSession != null && mSession.isOpen()) {
mSession.sendText(getInitFrameworkMessage(framework, params));
return 1;
}

return 0;
return sendMessage(getInitFrameworkMessage(framework, params));
}

private String getInitFrameworkMessage(String framework, WXParams params) {
Expand Down Expand Up @@ -104,11 +101,6 @@ private Map<String, Object> getEnvironmentMap(WXParams params) {

@Override
public int execJS(String instanceId, String namespace, String function, WXJSObject[] args) {
// if (!mInit || (TextUtils.isEmpty(instanceId) && !WXBridgeManager.METHOD_REGISTER_MODULES.equals(function))
// || TextUtils.isEmpty(function)) {
// return -1;
// }

ArrayList<Object> array = new ArrayList<>();
int argsCount = args == null ? 0 : args.length;
for (int i = 0; i < argsCount; i++) {
Expand All @@ -127,10 +119,20 @@ public int execJS(String instanceId, String namespace, String function, WXJSObje
Map<String, Object> map = new HashMap<>();
map.put(WXDebugConstants.METHOD, WXDebugConstants.METHOD_CALL_JS);
map.put(WXDebugConstants.PARAMS, func);
if (mSession != null && mSession.isOpen()) {
mSession.sendText(JSON.toJSONString(map));
}
return sendMessage(JSON.toJSONString(map));
}

@Override
public int execJSService(String javascript) {
if(!TextUtils.isEmpty(javascript)){
Map<String, Object> params = new HashMap<>();
params.put(WXDebugConstants.PARAM_JS_SOURCE, javascript);

Map<String, Object> map = new HashMap<>();
map.put(WXDebugConstants.METHOD, WXDebugConstants.METHOD_IMPORT_JS);
map.put(WXDebugConstants.PARAMS, params);
return sendMessage(JSON.toJSONString(map));
}
return 0;
}

Expand Down Expand Up @@ -159,6 +161,21 @@ public void reportJSException(String instanceId, String func, String exception)
}
}

@Override
public Object callNativeModule(String instanceId, String module, String method, byte[] arguments, byte[] options) {
if (mJsManager != null) {
JSONArray argArray = JSON.parseArray(new String(arguments));
return mJsManager.callNativeModule(instanceId, module, method, argArray, options);
}
return null;
}

@Override
public void callNativeComponent(String instanceId, String componentRef, String method, byte[] arguments, byte[] options) {
JSONArray argArray = JSON.parseArray(new String(arguments));
WXBridgeManager.getInstance().callNativeComponent(instanceId, componentRef, method, argArray, options);
}

public void onConnected() {
Log.v(TAG, "connect to debug server success");
synchronized (mLock) {
Expand All @@ -173,4 +190,15 @@ public void onDisConnected() {
mLock.notify();
}
}

private int sendMessage(String message) {
if (mSession != null && mSession.isOpen()) {
mSession.sendText(message);
return 1;
} else {
// session error, we need stop debug mode and switch to local runtime
WXBridgeManager.getInstance().stopRemoteDebug();
return 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.taobao.weex.devtools.debug;

import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.provider.Settings;
import android.text.TextUtils;
Expand All @@ -9,6 +10,7 @@

import com.alibaba.fastjson.JSON;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.common.IWXBridge;
Expand Down Expand Up @@ -84,6 +86,7 @@ private String getDeviceId(Context context) {

public void start() {
synchronized (DebugServerProxy.class) {
WXEnvironment.sDebugServerConnectable = true;
WeexInspector.initializeWithDefaults(mContext);
mBridge = DebugBridge.getInstance();
mBridge.setSession(mWebSocketClient);
Expand Down Expand Up @@ -153,15 +156,25 @@ public void onFailure(Throwable cause) {
}
}

@Override
public void stop() {
//@Override
public void stop(boolean reload) {
synchronized (DebugServerProxy.class) {
if (mWebSocketClient != null) {
mWebSocketClient.close(0, null);
mWebSocketClient = null;
}
mBridge = null;
if (reload) {
switchLocalRuntime();
}
}

}

private void switchLocalRuntime() {
WXEnvironment.sDebugServerConnectable = false;
WXSDKEngine.reload(WXEnvironment.getApplication(), false);
WXEnvironment.getApplication().sendBroadcast(new Intent(IWXDebugProxy.ACTION_DEBUG_INSTANCE_REFRESH));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class WXDebugConstants {

public static final String METHOD_INIT_RUNTIME = "WxDebug.initJSRuntime";
public static final String METHOD_CALL_JS = "WxDebug.callJS";
public static final String METHOD_IMPORT_JS = "WxDebug.importScript";

public static final String PARAM_INIT_ENV = "env";
public static final String PARAM_JS_SOURCE = "source";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,11 @@ public void store(Object element) {
// sub-tree is included automatically, so we don't need to send events for those.
if (newElementInfo.parentElement == null) {
ElementInfo oldElementInfo = mShadowDocument.getElementInfo(element);
int parentNodeId = mObjectIdMapper.getIdForObject(oldElementInfo.parentElement);
int nodeId = mObjectIdMapper.getIdForObject(element);
mUpdateListeners.onChildNodeRemoved(parentNodeId, nodeId);
Integer parentNodeId = mObjectIdMapper.getIdForObject(oldElementInfo.parentElement);
Integer nodeId = mObjectIdMapper.getIdForObject(element);
if (parentNodeId != null && nodeId != null) {
mUpdateListeners.onChildNodeRemoved(parentNodeId, nodeId);
}
}

// All garbage elements should be unhooked.
Expand Down Expand Up @@ -469,9 +471,11 @@ public void store(Object element) {
final ElementInfo newElementInfo = docUpdate.getElementInfo(element);

if (newElementInfo.parentElement != oldElementInfo.parentElement) {
int parentNodeId = mObjectIdMapper.getIdForObject(oldElementInfo.parentElement);
int nodeId = mObjectIdMapper.getIdForObject(element);
mUpdateListeners.onChildNodeRemoved(parentNodeId, nodeId);
Integer parentNodeId = mObjectIdMapper.getIdForObject(oldElementInfo.parentElement);
Integer nodeId = mObjectIdMapper.getIdForObject(element);
if (parentNodeId != null && nodeId != null) {
mUpdateListeners.onChildNodeRemoved(parentNodeId, nodeId);
}
}
}
});
Expand Down Expand Up @@ -639,8 +643,10 @@ public void addWithEvent(int index, Object element, Accumulator<Object> inserted

public void removeWithEvent(int index) {
Object element = remove(index);
int nodeId = mObjectIdMapper.getIdForObject(element);
mUpdateListeners.onChildNodeRemoved(mParentNodeId, nodeId);
Integer nodeId = mObjectIdMapper.getIdForObject(element);
if (nodeId != null) {
mUpdateListeners.onChildNodeRemoved(mParentNodeId, nodeId);
}
}
}

Expand Down
Loading

0 comments on commit de6536d

Please sign in to comment.