Skip to content

Commit

Permalink
merge:merge master
Browse files Browse the repository at this point in the history
  • Loading branch information
limingyi committed May 30, 2018
2 parents 6936ce4 + d7c5352 commit 14cbf62
Show file tree
Hide file tree
Showing 41 changed files with 2,760 additions and 873 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,4 @@
/.idea/libraries
.DS_Store
/build
<<<<<<< HEAD
*.iml
=======
/captures
.externalNativeBuild

>>>>>>> 20171216-V2.0.6
7 changes: 5 additions & 2 deletions eros-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ dependencies {
compile 'com.alibaba.android:bindingx-core:1.0.1'
compile 'com.alibaba.android:bindingx_weex_plugin:1.0.2'
compile 'org.weex.plugin:plugin-loader:1.0.0'
compile 'com.github.bmfe.eros-nexus:nexus:1.0.1'
// compile project(':nexus')
compile ('com.github.niorgai:StatusBarCompat:2.1.4', {
exclude group: 'com.android.support'
})
compile 'com.github.bmfe:eros-nexus:1.0.2'

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;

import com.alibaba.android.bindingx.plugin.weex.BindingX;
import com.alibaba.weex.plugin.loader.WeexPluginContainer;
import com.benmu.framework.adapter.BMDefaultUriAdapter;
Expand All @@ -16,7 +17,6 @@
import com.benmu.framework.extend.adapter.DefaultWXHttpAdapter;
import com.benmu.framework.extend.adapter.DefaultWXImageAdapter;
import com.benmu.framework.extend.adapter.LightlyWebSocketFactory;
import com.benmu.framework.extend.dom.richtext.RichTextDomObject;
import com.benmu.framework.extend.hook.ui.components.HookWxScroller;
import com.benmu.framework.extend.mediator.MediatorDocker;
import com.benmu.framework.extend.hook.ui.components.HookImage;
Expand All @@ -35,6 +35,7 @@
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.common.WXException;
import com.taobao.weex.dom.RichTextDomObject;
import com.taobao.weex.dom.WXTextDomObject;
import com.taobao.weex.ui.SimpleComponentHolder;
import com.taobao.weex.ui.component.WXBasicComponentType;
Expand Down Expand Up @@ -99,6 +100,7 @@ private static void initHook() {
false,
WXBasicComponentType.SCROLLER
);

} catch (WXException e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.benmu.framework.model.WeexEventBean;
import com.benmu.framework.utils.DebugableUtil;
import com.benmu.framework.utils.WXAnalyzerDelegate;
import com.benmu.widget.utils.ColorUtils;
import com.benmu.widget.view.DebugErrorDialog;
import com.benmu.widget.view.loading.LoadingDialog;

Expand Down Expand Up @@ -72,6 +73,7 @@
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXRenderStrategy;

import org.json.JSONException;
Expand Down Expand Up @@ -144,7 +146,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
initUrl(data);
synRouterStack();
initDebug();
// initPush();
imagePicker = ImagePicker.getInstance();
mReloadReceiver = new BroadcastReceiver() {
@Override
Expand All @@ -158,9 +159,6 @@ public void onReceive(Context context, Intent intent) {
mWxAnalyzerDelegate.onCreate();
}

// private void initPush() {
// GetuiManager.pushInit(this.getApplication());
// }

private void initDebug() {
if (!DebugableUtil.isDebug()) return;
Expand Down Expand Up @@ -359,7 +357,6 @@ public void run() {
//改造SVProgressHUD loadingView
private void createLoadingView() {
LayoutInflater layoutInflater = LayoutInflater.from(this);
Log.d("SVProgressHUD", "context hasCode -> " + this.hashCode());
decorView = (ViewGroup) (this).getWindow().getDecorView().findViewById(android.R.id
.content);
rootView = (ViewGroup) layoutInflater.inflate(com.benmu.R.layout
Expand Down Expand Up @@ -463,6 +460,9 @@ protected void createWXInstance() {
destroyWXInstance();
}
RenderContainer renderContainer = new RenderContainer(this);
if (mRouterParam != null && !TextUtils.isEmpty(mRouterParam.backgroundColor)) {
renderContainer.setBackgroundColor(ColorUtils.getColor(mRouterParam.backgroundColor));
}
mContainer.addView(renderContainer);
mWXInstance = new WXSDKInstance(this);
mWXInstance.registerRenderListener(this);
Expand Down Expand Up @@ -871,8 +871,9 @@ private void handleDecodeInternally(String code) {
if (uri.getQueryParameterNames().contains("bundle")) {
WXEnvironment.sDynamicMode = uri.getBooleanQueryParameter("debug", false);
WXEnvironment.sDynamicUrl = uri.getQueryParameter("bundle");
String tip = WXEnvironment.sDynamicMode ? "Has switched to Dynamic Mode" : "Has " +
"switched to Normal Mode";
String tip = WXEnvironment.sDynamicMode ? "Has switched to Dynamic Mode" :
"Has " +
"switched to Normal Mode";
Toast.makeText(this, tip, Toast.LENGTH_SHORT).show();
finish();
return;
Expand Down Expand Up @@ -911,21 +912,17 @@ private void postBusScanCode(String code) {
}


@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
if (isHomePage() && BMWXEnvironment.mPlatformConfig.isAndroidIsListenHomeBack()) { //如果是首页
GlobalEventManager.homeBack(getWXSDkInstance());
return true;
}
}
return super.onKeyDown(keyCode, event);
}

private boolean isHomePage() {
protected boolean isHomePage() {
String homePage = BMWXEnvironment.mPlatformConfig.getPage().getHomePage(this);
homePage = BMWXEnvironment.mPlatformConfig.getUrl().getJsServer() +
"/dist/js" + homePage;
return homePage.equals(this.mPageUrl);
}

/**
* navigation 设置监听器,为了传递给下层 fragment
*/
public boolean navigationListenter(WeexEventBean weexEventBean) {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.benmu.framework.BMWXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.common.Constants;

import java.util.List;

Expand Down Expand Up @@ -33,10 +35,23 @@ public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
return resultBuilder.build();
}
}
if (uri.isAbsolute() && type.equals(URIAdapter.WEB)) {
String scheme = uri.getScheme();
if ("bmlocal".equals(scheme)) {
String path = BMWXEnvironment.loadBmLocal(instance.getContext(), uri);
Uri parse = Uri.parse(path);
if (TextUtils.isEmpty(parse.getScheme())) {
return parse.buildUpon().scheme(Constants.Scheme.FILE).build();
}
return parse;
}
}
return uri;
}

private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri, String type) {

private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri, String
type) {
if (uri.getAuthority() != null) {
return resultBuilder.scheme(base.getScheme());
} else {
Expand All @@ -63,4 +78,4 @@ private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri ur
return resultBuilder;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ public class WXConstant {

public static final String MEDIATOR_INIT = "MEDIATOR_INIT";

public static final String ACTION_NETWORK_CHANGED="ACTION_NETWORK_CHANGED";

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.alibaba.fastjson.JSONObject;
import com.benmu.framework.constant.Constant;
import com.benmu.framework.constant.WXEventCenter;
import com.benmu.framework.event.http.callback.AxiosResponseCallback;
import com.benmu.framework.http.okhttp.OkHttpUtils;
import com.benmu.framework.http.okhttp.callback.StringCallback;
import com.benmu.framework.http.okhttp.exception.CancelException;
Expand Down Expand Up @@ -99,63 +100,67 @@ public void fetch(String params, final Context context, final JSCallback jscallb

private void patch(final Context context, AxiosManager axiosManager, AxiosPost axiosPatch,
final JSCallback jscallback) {
axiosManager.patch(axiosPatch.url, axiosPatch.data, axiosPatch.header, new StringCallback
axiosManager.patch(axiosPatch.url, axiosPatch.data, axiosPatch.header, new
AxiosResponseCallback
() {
@Override
public void onError(Call call, Exception e, int id) {
parseError(context, e, jscallback);
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}
}, axiosPatch.url, axiosPatch.timeout);
}

private void put(final Context context, AxiosManager axiosManager, AxiosPost axiosPut, final
JSCallback jscallback) {
axiosManager.put(axiosPut.url, axiosPut.data, axiosPut.header, new StringCallback() {
axiosManager.put(axiosPut.url, axiosPut.data, axiosPut.header, new AxiosResponseCallback() {
@Override
public void onError(Call call, Exception e, int id) {
parseError(context, e, jscallback);
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}

}, axiosPut.url, axiosPut.timeout);
}

private void delete(final Context context, AxiosManager axiosManager, AxiosPost axiosDelete,
final JSCallback jscallback) {
axiosManager.delete(axiosDelete.url, axiosDelete.data, axiosDelete.header, new
StringCallback() {
AxiosResponseCallback() {
@Override
public void onError(Call call, Exception e, int id) {
parseError(context, e, jscallback);
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}

}, axiosDelete.url, axiosDelete.timeout);
}


private void head(final Context context, AxiosManager axiosManager, AxiosGet axiosHead, final
JSCallback jscallback) {
axiosManager.head(axiosHead.url, axiosHead.data, axiosHead.header, new StringCallback() {
axiosManager.head(axiosHead.url, axiosHead.data, axiosHead.header, new
AxiosResponseCallback() {
@Override
public void onError(Call call, Exception e, int id) {
parseError(context, e, jscallback);
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}
}, axiosHead.url, axiosHead.timeout);
}
Expand All @@ -164,7 +169,7 @@ private void post(final Context context, AxiosManager axiosManager, AxiosPost ax
final JSCallback
jscallback) {
axiosManager.post(axiosPost.url, axiosPost.data, axiosPost.header, new
StringCallback() {
AxiosResponseCallback() {


@Override
Expand All @@ -173,8 +178,8 @@ public void onError(Call call, Exception e, int id) {
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}
}, axiosPost.url, axiosPost.timeout);
}
Expand All @@ -183,17 +188,18 @@ public void onResponse(String response, int id) {
private void get(final Context context, AxiosManager axiosManager, AxiosGet axiosGet, final
JSCallback jscallback) {
axiosManager.get(axiosGet.url, axiosGet.data, axiosGet.header, new
StringCallback() {
AxiosResponseCallback() {

@Override
public void onError(Call call, Exception e, int id) {
parseError(context, e, jscallback);
}

@Override
public void onResponse(String response, int id) {
parseResponse(response, jscallback, code);
public void onResponse(AxiosResultBean response, int id) {
callback(response, jscallback);
}

}, axiosGet.url, axiosGet.timeout);
}

Expand All @@ -213,33 +219,19 @@ private void parseError(Context context, Exception e, JSCallback callback) {
IrregularUrlException irregularUrlException = (IrregularUrlException) e;
bean.status = 9;
bean.errorMsg = irregularUrlException.getmErrosMeeage();
} else {
bean.status = 9;
bean.errorMsg = e.getMessage();
}

if (callback != null) {
callback.invoke(bean);
}
}

private void parseResponse(String response, JSCallback callBack, int code) {
try {
AxiosResultBean bean = new AxiosResultBean();
if (callBack != null && !TextUtils.isEmpty(response)) {
bean.status = code;
bean.errorMsg = "";
bean.data = JSON.parse(response);
callBack.invoke(bean);
}
} catch (Exception e) {
e.printStackTrace();
L.e("json 解析错误");
AxiosResultBean bean = new AxiosResultBean();
bean.status = -1;
bean.errorMsg = "json 解析错误";
if (callBack != null) {
callBack.invoke(bean);
}
private void callback(Object object, JSCallback callback) {
if (callback != null) {
callback.invoke(object);
}

}

public void uploadImage(String json, Context context, JSCallback jsCallback) {
Expand Down
Loading

0 comments on commit 14cbf62

Please sign in to comment.