fng 4 years ago
commit
52b2b69ec7
  1. 2
      .gitignore
  2. 148
      CHANGELOG.md
  3. 129
      README.md
  4. 89
      build.gradle
  5. BIN
      libs/GetuiSDK2.9.3.0.jar
  6. BIN
      libs/armeabi-v7a/libgetuiext2.so
  7. BIN
      libs/armeabi/libgetuiext2.so
  8. BIN
      libs/bm_imagepicker.aar
  9. BIN
      libs/umeng_social_api.jar
  10. BIN
      libs/umeng_social_net.jar
  11. BIN
      libs/umeng_social_tool.jar
  12. BIN
      libs/x86/libgetuiext2.so
  13. BIN
      libs/x86_64/libgetuiext2.so
  14. 31
      proguard-rules.pro
  15. 29
      src/androidTest/java/wxframework/benmu/com/wxframework/ExampleInstrumentedTest.java
  16. 12
      src/main/AndroidManifest.xml
  17. 49
      src/main/assets/bm-chart.html
  18. 38
      src/main/assets/echarts.min.js
  19. 55
      src/main/java/com/benmu/framework/BMInitConfig.java
  20. 127
      src/main/java/com/benmu/framework/BMWXApplication.java
  21. 210
      src/main/java/com/benmu/framework/BMWXEngine.java
  22. 39
      src/main/java/com/benmu/framework/PlugManager.java
  23. 930
      src/main/java/com/benmu/framework/activity/AbstractWeexActivity.java
  24. 151
      src/main/java/com/benmu/framework/activity/BrowseImgActivity.java
  25. 94
      src/main/java/com/benmu/framework/activity/DebugActivity.java
  26. 177
      src/main/java/com/benmu/framework/activity/GlobalWebViewActivity.java
  27. 47
      src/main/java/com/benmu/framework/activity/ResultActivity.java
  28. 66
      src/main/java/com/benmu/framework/adapter/BMDefaultUriAdapter.java
  29. 172
      src/main/java/com/benmu/framework/adapter/DefaultImageAdapter.java
  30. 183
      src/main/java/com/benmu/framework/adapter/DefaultNavigationAdapter.java
  31. 244
      src/main/java/com/benmu/framework/adapter/DefaultShareAdapter.java
  32. 210
      src/main/java/com/benmu/framework/adapter/router/DefaultRouterAdapter.java
  33. 305
      src/main/java/com/benmu/framework/adapter/router/RouterTracker.java
  34. 36
      src/main/java/com/benmu/framework/adapter/ws/BMWSCode.java
  35. 169
      src/main/java/com/benmu/framework/adapter/ws/DefaultWebSocketAdapter.java
  36. 31
      src/main/java/com/benmu/framework/adapter/ws/WSConfig.java
  37. 91
      src/main/java/com/benmu/framework/constant/WXConstant.java
  38. 173
      src/main/java/com/benmu/framework/debug/ws/DebuggerWebSocket.java
  39. 9
      src/main/java/com/benmu/framework/debug/ws/Instruction.java
  40. 277
      src/main/java/com/benmu/framework/event/DispatchEventCenter.java
  41. 48
      src/main/java/com/benmu/framework/event/EventCommunication.java
  42. 115
      src/main/java/com/benmu/framework/event/auth/EventAuth.java
  43. 28
      src/main/java/com/benmu/framework/event/browse/EventBrowse.java
  44. 111
      src/main/java/com/benmu/framework/event/camera/EventCamera.java
  45. 55
      src/main/java/com/benmu/framework/event/camera/EventImage.java
  46. 268
      src/main/java/com/benmu/framework/event/http/EventFetch.java
  47. 227
      src/main/java/com/benmu/framework/event/mediator/EventCenter.java
  48. 37
      src/main/java/com/benmu/framework/event/modal/EventAlert.java
  49. 38
      src/main/java/com/benmu/framework/event/modal/EventConfirm.java
  50. 19
      src/main/java/com/benmu/framework/event/modal/EventDismissLoading.java
  51. 26
      src/main/java/com/benmu/framework/event/modal/EventShowLoading.java
  52. 23
      src/main/java/com/benmu/framework/event/modal/EventToast.java
  53. 14
      src/main/java/com/benmu/framework/event/nav/EventCenterItem.java
  54. 15
      src/main/java/com/benmu/framework/event/nav/EventLeftItem.java
  55. 17
      src/main/java/com/benmu/framework/event/nav/EventNavigationInfo.java
  56. 15
      src/main/java/com/benmu/framework/event/nav/EventRightItem.java
  57. 60
      src/main/java/com/benmu/framework/event/pay/EventPay.java
  58. 22
      src/main/java/com/benmu/framework/event/router/EventBack.java
  59. 17
      src/main/java/com/benmu/framework/event/router/EventCall.java
  60. 31
      src/main/java/com/benmu/framework/event/router/EventFinish.java
  61. 22
      src/main/java/com/benmu/framework/event/router/EventGetBackParams.java
  62. 22
      src/main/java/com/benmu/framework/event/router/EventGetParams.java
  63. 85
      src/main/java/com/benmu/framework/event/router/EventNav.java
  64. 45
      src/main/java/com/benmu/framework/event/router/EventOpen.java
  65. 25
      src/main/java/com/benmu/framework/event/router/EventOpenBrowser.java
  66. 31
      src/main/java/com/benmu/framework/event/router/EventRefresh.java
  67. 54
      src/main/java/com/benmu/framework/event/router/EventSetHomePage.java
  68. 15
      src/main/java/com/benmu/framework/event/router/EventToMap.java
  69. 22
      src/main/java/com/benmu/framework/event/router/EventWebView.java
  70. 207
      src/main/java/com/benmu/framework/event/share/EventShare.java
  71. 36
      src/main/java/com/benmu/framework/event/shorage/EventDeleteData.java
  72. 35
      src/main/java/com/benmu/framework/event/shorage/EventGetData.java
  73. 33
      src/main/java/com/benmu/framework/event/shorage/EventRemoveData.java
  74. 37
      src/main/java/com/benmu/framework/event/shorage/EventSetData.java
  75. 53
      src/main/java/com/benmu/framework/event/tool/EventTool.java
  76. 39
      src/main/java/com/benmu/framework/extend/adapter/BMTypefaceAdapter.java
  77. 466
      src/main/java/com/benmu/framework/extend/adapter/DefaultWXHttpAdapter.java
  78. 367
      src/main/java/com/benmu/framework/extend/adapter/DefaultWXImageAdapter.java
  79. 113
      src/main/java/com/benmu/framework/extend/adapter/LightlyWebSocketAdapter.java
  80. 15
      src/main/java/com/benmu/framework/extend/adapter/LightlyWebSocketFactory.java
  81. 295
      src/main/java/com/benmu/framework/extend/adapter/WeexOkhttp3Interceptor.java
  82. 302
      src/main/java/com/benmu/framework/extend/comoponents/BMCalendar.java
  83. 143
      src/main/java/com/benmu/framework/extend/comoponents/BMChart.java
  84. 290
      src/main/java/com/benmu/framework/extend/comoponents/BMMask.java
  85. 402
      src/main/java/com/benmu/framework/extend/comoponents/BMPop.java
  86. 253
      src/main/java/com/benmu/framework/extend/comoponents/BMRich.java
  87. 80
      src/main/java/com/benmu/framework/extend/comoponents/BMSpan.java
  88. 47
      src/main/java/com/benmu/framework/extend/comoponents/BMView.java
  89. 263
      src/main/java/com/benmu/framework/extend/comoponents/BMWXText.java
  90. 86
      src/main/java/com/benmu/framework/extend/comoponents/view/BMMaskLayout.java
  91. 84
      src/main/java/com/benmu/framework/extend/comoponents/view/BMWXTextView.java
  92. 8
      src/main/java/com/benmu/framework/extend/comoponents/view/BMWebViewPool.java
  93. 8
      src/main/java/com/benmu/framework/extend/comoponents/view/BMWebViewWrapper.java
  94. 141
      src/main/java/com/benmu/framework/extend/mediator/MediatorDocker.java
  95. 45
      src/main/java/com/benmu/framework/extend/mediator/MediatorInstance.java
  96. 65
      src/main/java/com/benmu/framework/extend/module/AppConfigModule.java
  97. 40
      src/main/java/com/benmu/framework/extend/module/AxiosModule.java
  98. 25
      src/main/java/com/benmu/framework/extend/module/BrowserImgModule.java
  99. 64
      src/main/java/com/benmu/framework/extend/module/CameraModule.java
  100. 44
      src/main/java/com/benmu/framework/extend/module/CommunicationModule.java
  101. Some files were not shown because too many files have changed in this diff Show More

2
.gitignore vendored

@ -0,0 +1,2 @@
/build
*.iml

148
CHANGELOG.md

@ -0,0 +1,148 @@
# 0.0.1
1.Loading
1.1 完善loading样式
1.2 修复loading.hide的bug
2.拓展Axios
2.1 支持拓展Content-type
2.2 拓展head,put,delete,patch请求方式
2.3 返回http code
3.alert
3.1 修改alert样式
# 0.0.1
1.Loding
1.1 不设置message bug
2.shorage
2.1 shorage 修改setData()方法返回值
2.2 支持shorage set get delete remove方法的同步返回
# 0.0.3
1.image标签 border-radius的问题
2.中介者实例没有注入
3.请求没有域名崩溃
4.router.open backCallback没回调
# 0.0.4
1.修复bug
1.1 修复中介者失效问题
1.2 修复android weex debug 无法调试问题
1.3 修复下拉刷新
2.weex.config.env 调整
3.1 原weex.config.env自定义参数调整至weex.config.eros中
3.2 weex.config.eros增加状态栏高度参数
3.iconfont
4.1 支持bmLocal本地iconfont加载
4.Storage
5.1 增加同步存取方法
5.http
6.1 保留前端调用fetch时url的上的参数
6.2 支持添加端口号
# 2.0.0
1.目录调整
2.集成了个推推送
3.集成日历控件
5.iconfont加载逻辑优化
6.集成bmGeo模块
#2.0.1
1.更新编译gradle版本
2.打开jsbundle更新逻辑
3.修复上传问题 上传图片可附带参数
4.支持BMChart
5.集成weex-amap
6.增加bmAuth moudle 支持微信授权登陆
#2.0.2
1.修改 AbstractWeexActivity 基类,删除 基类里返回和销毁 时检查是否开启dialog代码。
2.修改 bmRouter callPhone方法,增加 int型 nowCall参数,如果传递并且 等于1时 不弹出dialog 直接跳转拨打电话页面
#2.0.3
1、增加第一个页面的 物理返回按钮监听抛出事件'homeBack'
2、增加 finish 方法 给前端调用。
3、eros.native.json 增加配置 isListentHomeBack 等于1时 监听HomeBack
# 2.0.4
1. 修改 EventFetch patch 方法
2. 修改 pages.zip 改成 bundle.zip
# 2.0.5
1. 图片上传增加传递head 参数 默认为null
2. 修改loading 实现,并做了微小修改
# 2.0.6
1. config.eros 中加入jsVersion deviceId navBarHeight 环境参数
2. bmRouter增加openBrowser方法以打开浏览器
3. 升级WeexSDK到0.17.0
4. eros.native.json加密
5. 上传图片module中传入url地址
6. axios 统一返回格式
7. bmStorage 去掉外面包装层
8. 打开通讯录选择联系人电话号码和打开短信发送信息
9. 所有除了崩溃的报错都弹窗提示
10. 双击调试按钮刷新
11. 解决手势冲突(sider 和 itemList)
# 2.0.7
1. 添加一键调试,不需要扫一扫即可调用调试,模拟器现在也可以调试了;需要在 eros.native.js 中添加 debugServer,添加方式请看eros.native.js 配置教程;
2. 新增bmImage Module,将图片相关方法统一放到此Module中,bmCamera及bmBrowserImg Module已经废弃,后续版本中移除;
3. bmAxios Module 新增 uploadImage 方法,用于上传本地图片;
4. 扫一扫功能移植到了bmTool Module 中;
5. 预览图片 preview 方法支持浏览本地图片及 jsbundle 中的图片;
6. 优化加载中介者机制,当拦截器变化时重新加载,刷新页面的时候检查是否已经加载成功;
7. 新增bmWebsocket Module;
8. bmRouter Module 新增 setHomePage方法: 作用:重新设置app启动加载的首页,js传path过来,native端会将传过来的path存储到本地,app启动的时候优先读取这个参数来显示首页,没有的话读取 native.js 中的配置;
9. navigatorModule支持RGB设置字体颜色
# 2.0.8
1. 修复axios bug
2. 修复setHomePage方法没有立即生效问题。
3. 修复sms 发短信崩溃问题。
4. 修复调试按钮点击崩溃问题。
5. 修复call方法总是110问题。
6. 修复预览本地图片问题。
7. 修改返回格式status问题
# 2.0.9
1. 动态修改activity category 无需在启动activity时进行选择
2. 修复debug invalidate instance报错
3. 集成weex性能分析(摇一摇开启)
4. 修改setHomePage 返回无效问题
5. 修改上传图片返回字符串改为对象
6. 修改storage储存逻辑
#2.1.0
1. 拓展weex.config.eros变量
2. 修复ToolsMoudle 是否安装微信方法
3. 修复iconfont不显示问题。
4. 修改富文本默认字体
5. 修复一些已知bug
6. 修复bmCalendar样式不生效问题
7. 修复滑动事件影响bmRefresh消失问题
#2.1.1
1. 修复未获得权限时多次点击图片可能出现返回多张图片问题。
2. 添加权限申请。
3. 将调试修改成扫一扫,并升级weex debug.
4. 修复一些已知bug
5. bmchart支持传递方法
#2.1.2
1. 修复增量更新可能失败问题。
2. 集成升级SDK 0.18版本.
3. 集成升级 weex-debugger 0.13.4版本.
4. 修改拦截器关闭时不拼接app borad.
5. 增加全局属性 deviceHeight、deviceWidth
6. 删除不需要的ndk 架构。
#2.1.3
1. 增加热刷新功能
2. 修改Input 默认字体为黑色
3. 修复扫码遇到Json串可能崩溃问题
4. 修改Image标签的 默认加载动画菊花 由 placeholder 属性控制,默认不展示
5. 修改Emit参数类型转化异常
6. 修改Modal组件为系统原生风格
7. 修复navigator.setRightItem()字体未靠右对齐问题

129
README.md

@ -0,0 +1,129 @@
### 安卓工程
Weex-eros Android框架工程
本部分主要面向android原生开发者,旨在介绍weex-eros-android框架的项目结构和设计思路,方便广大weex开发者进行weex原生拓展开发。
#### 一.功能介绍
weex-eros是在weex原生拓展的基础上,结合我团队具体项目业务场景,总结出来的一套易用性强,侵入性低,快速集成开发的框架,框架中集成内置module,包括路由,本地存储,网络请求,全局参数配置,事件发布订阅,调用摄像头等,基本涵盖大部分业务场景需求,且提供了自定义接口,方便开发者自定义实现。
#### 二.使用框架
目前提供了源码依赖的方式,这是我们比较推荐的方式。如果你使用Android Studio进行开发,你可将项目源码做为Moudle导入项目中,在app的build.gradle中添加如下依赖:
```
compile project(':wxframework')
```
关于gradle和maven的依赖方式,我们将以迅雷不及掩耳之势在后续更新放出。
三.项目目录结构
Eros项目的目录结构如下:
```
项目目录结构
·
|-- BMInitConfig initConfig
|-- BMWXApplication 封装的Application
|-- BMWXEngine 框架初始化引擎
|-- BMWXEnvironment 框架上下文
|-- activity 封装的activity,包括提供weex渲染和一些默认实现页面
|-- AbstractWeexActivity
|-- adapter 框架对功能模块具体实现类
|-- router
|-- DefaultImageAdapter
|-- DefaultStorageAdapter
|-- constant 常量类
|-- event 处理与js交互的自定义事件
|-- extend weex原生的拓展
|-- adapter
| -- DefaultWXHttpAdapter 拓展weex原生IWXHttpAdapter
|-- DefaultWXImageAdapter 拓展weex原生IWXImgLoaderAdapter
|-- components 自定义weex组件
|-- module 自定义weex module
|-- http http实现(默认使用okhttp)
|-- manager 业务处理管理类
|-- model java beans
|-- utils utils
```
四.关键类
总览Eros项目的工程目录,有些类是我们需要特别注意的:
BMWXApplication
此类为Applcation的子类,将你项目的Application继承它,便可以自动完成Eros框架的初始化和内置moudle,component的注册,方便开发者快速集成。
```
public class BMWXApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
}
private void initWeex() {
BMWXEngine.initialize(this, new BMInitConfig.Builder().isActiceInterceptor(Constant
.INTERCEPTOR_ACTIVE).build());
}
}
```
BMWXEngine
此类是Eros框架的初始化入口,请在你的项目入口调用initialize方法完成初始化。
```
public class App extends Application {
@Override
public void onCreate() {
super.onCreate();
BMWXEngine.initialize(this, new BMInitConfig.Builder().isActiceInterceptor(Constant
.INTERCEPTOR_ACTIVE).build());
}
}
```
BMWXEngine内部将完成weex框架的初始化和内置moudle,component的注册以Enviroment.config的参数配置。
```
public static void initialize(Application context, BMInitConfig initConfig) {
initPlatformConfig(context);
initConing(initConfig);
engineStart(context);
registerBMComponentsAndModules(context);
initHttpClient(context);
initInterceptor(context, initConfig);
initDispatchCenter();
}
```
此外,为了方便于js端的数据交互,你可以通过BMInitConfig将一些参数放入全局环境中:
```
HashMap<String,String> envs=new HashMap<>();
envs.put("test","test");
BMWXEngine.initialize(this, new BMInitConfig.Builder().setCustomerEnv(envs).build());
```
js端可以使用```weex.enviroment.config``` 获取。
AbstractWeexActivity
此类为Application的子类,将你项目的Application继承它,便可以自动完成Eros框架的初始化和内置moudle,component的注册,方便开发者快速集成。
```
public class BMWXApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
}
private void initWeex() {
BMWXEngine.initialize(this, new BMInitConfig.Builder().isActiceInterceptor(Constant
.INTERCEPTOR_ACTIVE).build());
}
}
```
#### 五.项目地址
目前Eros项目的框架部分已经完全开源,项目地址[https://github.com/aa453509345/WeexErosFramework],
另外WeexErosFramework项目所以来的WeexSDK是我们在Weex原生SDK的基础上,修复了原生SDK的部分bug所维护的SDK,项目地址:
[https://github.com/aa453509345/WeexSDK] ,目前Eros项目还在快速开发迭代中,对于功能复杂或自定义程度高度制定的场景支持可能还不够完善,我们会在后续版本中支持完善, 也希望广大weex开发者和开源爱好者提出建议,共同完善Eros。
有任何问题和建议的童鞋,请查看[Eros使用手册](https://karynsong.gitbooks.io/weex-eros/content/)

89
build.gradle

@ -0,0 +1,89 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName '2.1.3'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jniLibs.srcDirs = ['libs']
}
}
}
repositories {
mavenCentral()
maven {
url "http://repo.baichuan-android.taobao.com/content/groups/BaichuanRepositories"
}
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBVERSION}"
testCompile 'junit:junit:4.12'
/**
* debug调试要用到的
*/
compile 'com.taobao.android.weex_inspection:protocol:1.1.4.1'
compile 'com.taobao.android:weex_inspector:0.13.4'
compile 'com.taobao.android:weex_inspector:0.13.4'
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.alibaba:fastjson:1.1.68.android'
compile project(':sdk')
compile(name: 'bm_imagepicker', ext: 'aar')
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile project(':nexus')
//
compile 'com.umeng.analytics:analytics:latest.integration'
compile files('libs/umeng_social_net.jar')
compile files('libs/umeng_social_api.jar')
compile files('libs/umeng_social_tool.jar')
compile files('libs/GetuiSDK2.9.3.0.jar')
compile 'com.android.support:multidex:1.0.1'
//bs patch
compile 'me.ele:bspatch:1.0.6'
//weex analyzer
debugCompile 'com.taobao.android:weex_analyzer:0.1.0.5'
//Bindigx
implementation 'com.alibaba.android:bindingx-core:1.0.1'
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.2'
//plugin Moudle
compile project(':ErosPluginAmap')
}

BIN
libs/GetuiSDK2.9.3.0.jar

Binary file not shown.

BIN
libs/armeabi-v7a/libgetuiext2.so

Binary file not shown.

BIN
libs/armeabi/libgetuiext2.so

Binary file not shown.

BIN
libs/bm_imagepicker.aar

Binary file not shown.

BIN
libs/umeng_social_api.jar

Binary file not shown.

BIN
libs/umeng_social_net.jar

Binary file not shown.

BIN
libs/umeng_social_tool.jar

Binary file not shown.

BIN
libs/x86/libgetuiext2.so

Binary file not shown.

BIN
libs/x86_64/libgetuiext2.so

Binary file not shown.

31
proguard-rules.pro vendored

@ -0,0 +1,31 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/Carry/Documents/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
#umeng
-keepclassmembers class * {
public <init> (org.json.JSONObject);
}
-keep public class com.benmu.wx.R$*{
public static final int *;
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}

29
src/androidTest/java/wxframework/benmu/com/wxframework/ExampleInstrumentedTest.java

@ -0,0 +1,29 @@
package wxframework.benmu.com.wxframework;
import android.content.Context;
import android.net.Uri;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("wxframework.benmu.com.wxframework.test", appContext.getPackageName());
}
}

12
src/main/AndroidManifest.xml

@ -0,0 +1,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.benmu.framework">
<application
tools:replace="android:allowBackup"
android:allowBackup="true"
android:label="@string/app_name"
android:supportsRtl="true"></application>
</manifest>

49
src/main/assets/bm-chart.html

@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta name="format-detection" content="telephone=no,email=no" />
<title>ECharts</title>
</head>
<body style="margin:0; padding:0;">
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="height:260px;width: 100%;"></div>
<!-- ECharts单文件引入 -->
<script type="text/javascript">
var mainDom = document.querySelector('#main')
mainDom.style.height=window.innerHeight+'px';
function setHeight(height) {
mainDom.style.height = height + 'px';
}
/*
*/
function setOption(options) {
var formatOptions = JSON.parse(options,function(k,v){
if(v.indexOf&&v.indexOf('function')>-1){
return eval("(function(){return "+v+" })()")
}
return v;
});
var myChart = echarts.init(mainDom);
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(formatOptions);
}
</script>
<script type="text/javascript" src="echarts.min.js"></script>
</body>

38
src/main/assets/echarts.min.js vendored

File diff suppressed because one or more lines are too long

55
src/main/java/com/benmu/framework/BMInitConfig.java

@ -0,0 +1,55 @@
package com.benmu.framework;
import java.util.HashMap;
import java.util.Map;
/**
* Created by Carry on 2017/8/23.
*/
public class BMInitConfig {
private Map<String, String> mEnvs;
private String mActice;
private BMInitConfig() {
}
public Map<String, String> getmEnvs() {
return mEnvs;
}
public void setmEnvs(Map<String, String> mEnvs) {
this.mEnvs = mEnvs;
}
public String getmActice() {
return mActice;
}
public void setmActice(String mActice) {
this.mActice = mActice;
}
public static class Builder {
HashMap<String, String> mCustomerEnv;
private String mActiveInterceptor;
public Builder setCustomerEnv(HashMap<String, String> mCustomerEnv) {
this.mCustomerEnv = mCustomerEnv;
return this;
}
public Builder isActiceInterceptor(String active) {
this.mActiveInterceptor = active;
return this;
}
public BMInitConfig build() {
BMInitConfig initConfig = new BMInitConfig();
initConfig.mEnvs = this.mCustomerEnv;
initConfig.mActice = this.mActiveInterceptor;
return initConfig;
}
}
}

127
src/main/java/com/benmu/framework/BMWXApplication.java

@ -0,0 +1,127 @@
package com.benmu.framework;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.support.multidex.MultiDex;
import com.benmu.framework.activity.AbstractWeexActivity;
import com.benmu.framework.adapter.router.RouterTracker;
import com.benmu.framework.constant.Constant;
import com.benmu.framework.debug.ws.DebuggerWebSocket;
import com.benmu.framework.manager.ManagerFactory;
import com.benmu.framework.manager.impl.GlobalEventManager;
import com.benmu.framework.manager.impl.LifecycleManager;
import com.benmu.framework.model.PlatformConfigBean;
import com.benmu.framework.update.VersionChecker;
import com.benmu.framework.utils.DebugableUtil;
import com.taobao.weex.WXSDKInstance;
import com.umeng.socialize.Config;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import java.util.List;
/**
* Created by Carry on 2017/9/4.
*/
public class BMWXApplication extends Application {
private static BMWXApplication mInstance;
private WXSDKInstance mMediator;
private VersionChecker mVersionChecker;
private DebuggerWebSocket debugSocket;
@Override
public void onCreate() {
super.onCreate();
if (shouldInit()) {
mInstance = this;
initWeex();
mVersionChecker = new VersionChecker(this);
registerLifecycle();
initShare();
initDebugSocket();
}
}
private void initDebugSocket() {
debugSocket = new DebuggerWebSocket(this);
debugSocket.init();
}
private void initShare() {
PlatformConfigBean.Wechat wechat = BMWXEnvironment.mPlatformConfig.getWechat();
if (wechat != null && wechat.isEnabled()) {
PlatformConfig.setWeixin(wechat.getAppId(), wechat.getAppSecret());
}
Config.DEBUG = DebugableUtil.isDebug();
UMShareAPI.get(this);
}
private boolean shouldInit() {
ActivityManager am = ((ActivityManager) getSystemService(Context.ACTIVITY_SERVICE));
List<ActivityManager.RunningAppProcessInfo> processInfos = am.getRunningAppProcesses();
String mainProcessName = getPackageName();
int myPid = android.os.Process.myPid();
for (ActivityManager.RunningAppProcessInfo info : processInfos) {
if (info.pid == myPid && mainProcessName.equals(info.processName)) {
return true;
}
}
return false;
}
@Override
protected void attachBaseContext(Context base) {
MultiDex.install(base);
super.attachBaseContext(base);
}
private void registerLifecycle() {
LifecycleManager lifecycleManager = ManagerFactory.getManagerService(LifecycleManager
.class);
lifecycleManager.register(this).setOnTaskSwitchListenner(new LifecycleManager
.OnTaskSwitchListener() {
@Override
public void onTaskSwitchToForeground() {
Activity activity = RouterTracker.peekActivity();
if (activity != null) {
GlobalEventManager.appActive(((AbstractWeexActivity) activity)
.getWXSDkInstance());
}
//app resume try check verison
if (mVersionChecker != null) {
mVersionChecker.checkVersion();
}
}
@Override
public void onTaskSwitchToBackground() {
Activity activity = RouterTracker.peekActivity();
if (activity != null) {
GlobalEventManager.appDeactive(((AbstractWeexActivity) activity)
.getWXSDkInstance());
}
}
});
}
private void initWeex() {
BMWXEngine.initialize(this, new BMInitConfig.Builder().isActiceInterceptor(Constant
.INTERCEPTOR_ACTIVE).build());
}
public static BMWXApplication getWXApplication() {
return mInstance;
}
}

210
src/main/java/com/benmu/framework/BMWXEngine.java

@ -0,0 +1,210 @@
package com.benmu.framework;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import com.alibaba.android.bindingx.plugin.weex.BindingX;
import com.benmu.framework.adapter.BMDefaultUriAdapter;
import com.benmu.framework.constant.Constant;
import com.benmu.framework.event.DispatchEventCenter;
import com.benmu.framework.event.mediator.EventCenter;
import com.benmu.framework.extend.adapter.BMTypefaceAdapter;
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.mediator.MediatorDocker;
import com.benmu.framework.manager.ManagerFactory;
import com.benmu.framework.manager.impl.AxiosManager;
import com.benmu.framework.manager.impl.CustomerEnvOptionManager;
import com.benmu.framework.utils.AppUtils;
import com.benmu.framework.utils.BaseCommonUtil;
import com.benmu.framework.utils.DebugableUtil;
import com.benmu.framework.utils.SharePreferenceUtil;
import com.taobao.weex.InitConfig;
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.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.umeng.analytics.MobclickAgent;
import com.umeng.socialize.PlatformConfig;
import com.umeng.socialize.UMShareAPI;
import java.util.HashMap;
import java.util.Map;
import me.ele.patch.BsPatch;
/**
* Created by Carry on 2017/8/23.
*/
public class BMWXEngine {
public static void initialize(Application context, BMInitConfig initConfig) {
initPatch(context);
initPlatformConfig(context);
initConing(context, initConfig);
engineStart(context);
registerBMComponentsAndModules(context);
initHttpClient(context);
initInterceptor(context, initConfig);
initDispatchCenter();
DebugableUtil.syncIsDebug(context);
initWeChat(context);
initUmeng(context);
EventCenter.getInstance().init();
// initMap();
PlugManager.initPlug();
initBindingx();
}
private static void initBindingx() {
// register bindingx module manually
try {
BindingX.register();
} catch (WXException e) {
Log.e("BMWXEngine", "initBindingx error -> " + e.getMessage());
}
}
private static void initPatch(Application context) {
BsPatch.init(context);
}
private static void initUmeng(Application context) {
boolean enabled = BMWXEnvironment.mPlatformConfig.getUmeng().isEnabled();
String androidAppKey = BMWXEnvironment.mPlatformConfig.getUmeng().getAndroidAppKey();
if (enabled && !TextUtils.isEmpty(androidAppKey)) {
MobclickAgent.setDebugMode(DebugableUtil.isDebug());
MobclickAgent.openActivityDurationTrack(false);
MobclickAgent.setCatchUncaughtExceptions(!DebugableUtil.isDebug());
MobclickAgent.setScenarioType(context, MobclickAgent.EScenarioType.E_UM_NORMAL);
PlatformConfig.setWeixin(BMWXEnvironment.mPlatformConfig.getWechat().getAppId(),
BMWXEnvironment.mPlatformConfig.getWechat().getAppSecret());
UMShareAPI.get(context);
}
}
private static void initWeChat(Context context) {
boolean enabled = BMWXEnvironment.mPlatformConfig.getWechat().isEnabled();
String appId = BMWXEnvironment.mPlatformConfig.getWechat().getAppId();
if (enabled && !TextUtils.isEmpty(appId)) {
BMWXEnvironment.mWXApi = WXAPIFactory.createWXAPI(context, appId, true);
}
}
private static void initDispatchCenter() {
DispatchEventCenter.getInstance().register();
MediatorDocker.getInstance().registe();
}
private static void initPlatformConfig(Application context) {
BMWXEnvironment.mPlatformConfig = CustomerEnvOptionManager.initPlatformConfig
(context);
BMWXEnvironment.mApplicationContext = context;
}
private static void initInterceptor(Application context, BMInitConfig initConfig) {
String activeState = SharePreferenceUtil.getInterceptorActive(context);
if (!Constant.INTERCEPTOR_DEACTIVE.equals(activeState)) {
if (initConfig != null) {
SharePreferenceUtil.setInterceptorActive(context, initConfig.getmActice());
}
}
}
private static void initHttpClient(Application context) {
ManagerFactory.getManagerService(AxiosManager.class).initClient(context);
}
private static void registerBMComponentsAndModules(Application context) {
CustomerEnvOptionManager.init(context);
CustomerEnvOptionManager.registerComponents(CustomerEnvOptionManager.getComponents());
CustomerEnvOptionManager.registerModules(CustomerEnvOptionManager.getModules());
try {
registerCustomDomObject();
} catch (WXException e) {
e.printStackTrace();
}
}
private static void registerCustomDomObject() throws WXException {
WXSDKEngine.registerDomObject("bmtext", WXTextDomObject.class);
WXSDKEngine.registerDomObject("bmspan", WXTextDomObject.class);
WXSDKEngine.registerDomObject("bmrichtext", RichTextDomObject.class);
}
private static void engineStart(Application app) {
WXSDKEngine.initialize(app,
new InitConfig.Builder()
.setImgAdapter(new DefaultWXImageAdapter())
.setHttpAdapter(new DefaultWXHttpAdapter(app))
.setWebSocketAdapterFactory(new LightlyWebSocketFactory())
.setTypefaceAdapter(new BMTypefaceAdapter(app))
.setURIAdapter(new BMDefaultUriAdapter())
.build()
);
}
private static void initConing(Application context, BMInitConfig initConfig) {
if (initConfig == null) return;
initConfig.setmEnvs(WXEnvironment.getConfig());
initEnv(initConfig.getmEnvs(), context);
}
private static void initEnv(Map<String, String> Env, Context context) {
HashMap<String, String> insideEnv = new HashMap<>();
insideEnv.put(Constant.CustomOptions.CUSTOM_APPNAME, BMWXEnvironment.mPlatformConfig
.getAppName());
insideEnv.put(Constant.CustomOptions.CUSTOM_SERVERURL, BMWXEnvironment.mPlatformConfig
.getUrl()
.getJsServer());
insideEnv.put(Constant.CustomOptions.CUSTOM_REQUESTURL, BMWXEnvironment.mPlatformConfig
.getUrl().getRequest());
int statusBarHeight = BaseCommonUtil.getStatusBarHeight(context);
insideEnv.put(Constant.CustomOptions.CUSTOM_STATUSBARHEIGHT, BaseCommonUtil
.transferDimenToFE(context, statusBarHeight) + "");
insideEnv.put(Constant.CustomOptions.CUSTOM_REALDEVICEHEIGHT, "" + BaseCommonUtil
.transferDimenToFE(context, BaseCommonUtil.getRealDeviceHeight(context)));
insideEnv.put(Constant.CustomOptions.CUSTOM_NAVBARHEIGHT, BaseCommonUtil
.transferDimenToFE(context, BaseCommonUtil.dp2px(context, 44)) + "");
insideEnv.put(Constant.CustomOptions.CUSTOM_JSVERSION, AppUtils.getJsVersion(context));
insideEnv.put(Constant.CustomOptions.CUSTOM_DEVICEID, AppUtils.getDeviceId(context));
String fontSize = SharePreferenceUtil.getAppFontSizeOption(context);
insideEnv.put(Constant.CustomOptions.CUSTOM_FONTSIZE, fontSize);
insideEnv.put(Constant.CustomOptions.CUSTOM_FONTSCALE, BaseCommonUtil.getScaleByFontsize
(fontSize) + "");
Resources resources = context.getResources();
DisplayMetrics dm = resources.getDisplayMetrics();
insideEnv.put(Constant.CustomOptions.CUSTOM_DEVICEHEIGHT, String.valueOf(dm.heightPixels));
insideEnv.put(Constant.CustomOptions.CUSTOM_DEVICEWIDTH, String.valueOf(dm.widthPixels));
if (Env != null && !Env.isEmpty()) {
for (Map.Entry<String, String> entry : Env.entrySet()) {
if (!TextUtils.isEmpty(entry.getValue())) {
insideEnv.put(entry.getKey(), entry.getValue());
}
}
}
BMWXEnvironment.mCustomer = insideEnv;
CustomerEnvOptionManager.registerCustomConfig(insideEnv);
}
}

39
src/main/java/com/benmu/framework/PlugManager.java

@ -0,0 +1,39 @@
package com.benmu.framework;
import com.benmu.framework.constant.Constant;
import com.benmu.framework.manager.Manager;
import com.benmu.framework.manager.ManagerFactory;
import com.benmu.framework.manager.impl.CustomerEnvOptionManager;
import java.util.HashMap;
/**
* Created by liuyuanxiao on 17/12/5.
*/
public class PlugManager {
public static void initPlug() {
Manager geoManager = ManagerFactory.getManagerService("com.plugamap.manager.GeoManager");
if (geoManager != null) {
geoManager.init();
registerCompnentsAndModules(geoManager.getComponentsAndModules());
}
}
/**
* 注册 compent Modules
*
* @param compentAndModules compent Modules 集合
*/
private static void registerCompnentsAndModules(HashMap<String, HashMap<String, String>> compentAndModules) {
if (compentAndModules == null) return;
HashMap<String, String> compents = compentAndModules.get(Constant.CUSTOMER_COMPONETS);
if (compents != null) {
CustomerEnvOptionManager.registerComponents(compents);
}
HashMap<String, String> modules = compentAndModules.get(Constant.CUSTOMER_MODULES);
if (modules != null) {
CustomerEnvOptionManager.registerModules(compents);
}
}
}

930
src/main/java/com/benmu/framework/activity/AbstractWeexActivity.java

@ -0,0 +1,930 @@
package com.benmu.framework.activity;
import com.benmu.framework.BMWXEnvironment;
import com.benmu.framework.BuildConfig;
import com.benmu.framework.constant.Constant;
import com.benmu.framework.constant.WXConstant;
import com.benmu.framework.manager.ManagerFactory;
import com.benmu.framework.manager.impl.PermissionManager;
import com.benmu.framework.manager.impl.dispatcher.DispatchEventManager;
import com.benmu.framework.model.AxiosResultBean;
import com.benmu.framework.model.UploadResultBean;
import com.benmu.framework.utils.WXAnalyzerDelegate;
import com.benmu.widget.view.DebugErrorDialog;
import com.benmu.widget.view.loading.LoadingDialog;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.provider.ContactsContract;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import android.widget.Toast;
import com.benmu.framework.R;
import com.benmu.framework.adapter.router.RouterTracker;
import com.benmu.framework.manager.impl.GlobalEventManager;
import com.benmu.framework.manager.impl.ImageManager;
import com.benmu.framework.manager.impl.PersistentManager;
import com.benmu.framework.manager.impl.status.StatusBarManager;
import com.benmu.framework.model.CameraResultBean;
import com.benmu.framework.model.RouterModel;
import com.benmu.framework.model.UploadImageBean;
import com.benmu.framework.model.WeexEventBean;
import com.benmu.framework.utils.DebugableUtil;
import com.benmu.framework.utils.InsertEnvUtil;
import com.benmu.framework.utils.WXCommonUtil;
import com.benmu.widget.view.BMFloatingLayer;
import com.benmu.widget.view.BMLoding;
import com.benmu.widget.view.BaseToolBar;
import com.igexin.sdk.PushManager;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.util.BitmapUtil;
import com.taobao.weex.IWXRenderListener;
import com.taobao.weex.RenderContainer;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.common.WXRenderStrategy;
import com.umeng.analytics.MobclickAgent;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by Carry on 2017/8/16.
*/
public class AbstractWeexActivity extends AppCompatActivity implements IWXRenderListener, Handler
.Callback,
RouterTracker.RouterTrackerListener {
protected RouterModel mRouterParam;
private WXSDKInstance mWXInstance;
protected ViewGroup mContainer;
private String mPageUrl;
private static final String TAG = "AbstractWeexActivity";
private String mPageName;
private String mRouterType;
protected BMLoding mLoding;
private BaseToolBar mNavigationBar;
private BMFloatingLayer mDebugger;
protected Activity mAct;
public String[] mDebugOptions = new String[]{"调试页面", "刷新", "扫一扫"};
private RelativeLayout rl_error;
private ViewGroup mRootView;
private boolean isHomePage;
private ViewGroup decorView;//activity的根View
private ViewGroup rootView;// mSharedView 的 根View
private LoadingDialog loadingDialog;
private DebugErrorDialog errorDialog;
private final int EVENT_SINGLE_CILKE = 1;
private final int EVENT_DOUBLE_CILKE = 2;
private Handler mHandler = new Handler(this);
private long mLastTime, mCurTime; // 调试按钮点击时间
private ImagePicker imagePicker;
private BroadcastReceiver mReloadReceiver;
protected WXAnalyzerDelegate mWxAnalyzerDelegate;
@Override
public boolean handleMessage(Message msg) {
switch (msg.what) {
case EVENT_SINGLE_CILKE:
debugLayerClick();
break;
case EVENT_DOUBLE_CILKE:
refresh();
break;
}
return false;
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mAct = this;
mRouterType = GlobalEventManager.TYPE_OPEN;
Intent data = getIntent();
initRouterParams(data);
initUrl(data);
synRouterStack();
initDebug();
initPush();
imagePicker = ImagePicker.getInstance();
mReloadReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
renderPage();
}
};
LocalBroadcastManager.getInstance(this).registerReceiver(mReloadReceiver, new
IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
mWxAnalyzerDelegate = new WXAnalyzerDelegate(this);
mWxAnalyzerDelegate.onCreate();
}
private void initPush() {
PushManager.getInstance().initialize(this.getApplicationContext());
}
private void initDebug() {
if (!DebugableUtil.isDebug()) return;
mDebugger = new BMFloatingLayer(mAct);
mDebugger.setListener(new BMFloatingLayer.FloatingLayerListener() {
@Override
public void onClick() {
mLastTime = mCurTime;
mCurTime = System.currentTimeMillis();
if (mCurTime - mLastTime < 300) {//双击事件
mCurTime = 0;
mLastTime = 0;
mHandler.removeMessages(1);
mHandler.sendEmptyMessage(2);
} else {//单击事件
mHandler.sendEmptyMessageDelayed(1, 310);
}
}
@Override
public void onShow() {
}
@Override
public void onClose() {
}
});
mDebugger.show(mAct);
}
private void debugLayerClick() {
android.support.v7.app.AlertDialog.Builder builder = new android.support.v7
.app.AlertDialog.Builder(mAct);
builder.setItems(mDebugOptions, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
Intent intent = new Intent(mAct, DebugActivity.class);
startActivity(intent);
} else if (which == 1) {
refresh();
} else if (which == 2) {
DispatchEventManager dispatchEventManager = ManagerFactory
.getManagerService(DispatchEventManager.class);
WeexEventBean eventBean = new WeexEventBean();
eventBean.setContext(mAct);
eventBean.setKey(WXConstant.WXEventCenter.EVENT_CAMERA);
dispatchEventManager.getBus().post(eventBean);
// connectionDebugService(BMWXEnvironment.mPlatformConfig.getUrl()
// .getDebugServer());
}
}
});
builder.create().show();
}
private void connectionDebugService(String url) {
WXEnvironment.sDebugServerConnectable = BuildConfig.DEBUG;
WXEnvironment.sRemoteDebugProxyUrl = url;
WXSDKEngine.reload();
Toast.makeText(this, "devtool", Toast.LENGTH_SHORT).show();
}
@Override
public void setContentView(@LayoutRes int layoutResID) {
mRootView = (ViewGroup) View.inflate(this, R.layout.layout_root, null);
RelativeLayout rl_root = (RelativeLayout) mRootView.findViewById(R.id.rl_root);
rl_error = (RelativeLayout) mRootView.findViewById(R.id.rl_error);
mNavigationBar = (BaseToolBar) mRootView.findViewById(R.id.base_navBar);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams
.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
View child = View.inflate(this, layoutResID, null);
rl_root.addView(child, params);
StatusBarManager.setHeaderBg(mRouterParam, this);
StatusBarManager.setStatusBarFontStyle(this, mRouterParam);
setNavigationBar();
setContentView(mRootView);
}
public View getRootView() {
return mRootView;
}
public void setNavigationBar() {
if (mNavigationBar == null) return;
//setVisibility
if (null == mRouterParam) {
mNavigationBar.setNavigationVisible(false);
return;
}
if (!mRouterParam.navShow) {
mNavigationBar.setNavigationVisible(false);
return;
}
mNavigationBar.setNavigationVisible(true);
//set color
String navBarColor = BMWXEnvironment.mPlatformConfig.getPage().getNavBarColor();
if (!TextUtils.isEmpty(navBarColor)) {
mNavigationBar.setBackgroundColor(Color.parseColor(navBarColor));
}
//set title
String title = mRouterParam.navTitle;
mNavigationBar.setTitle(title);
//left icon
mNavigationBar.setOnLeftListenner(new BaseToolBar.OnLeftIconClick() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
//back
mNavigationBar.setLeftIconVisible(mRouterParam.canBack);
//nav item color
mNavigationBar.setNavigationItemColor(BMWXEnvironment.mPlatformConfig.getPage()
.getNavItemColor(), mNavigationBar);
}
public BaseToolBar getNavigationBar() {
return mNavigationBar;
}
protected void initRouterParams(Intent data) {
Serializable serializableExtra = data.getSerializableExtra(Constant.ROUTERPARAMS);
if (serializableExtra instanceof RouterModel) {
setRouterParam((RouterModel) serializableExtra);
}
}
public void showError() {
rl_error.setVisibility(View.VISIBLE);
}
public void hideError() {
rl_error.setVisibility(View.GONE);
}
protected void initUrl(Intent data) {
Uri pageUri = data.getData();
if (pageUri == null) return;
setPageUrl(pageUri.toString());
}
public void setRouterParam(RouterModel param) {
this.mRouterParam = param;
}
public RouterModel getRouterParam() {
return mRouterParam;
}
protected void synRouterStack() {
if (mRouterParam != null) {
if (!Constant.ACTIVITIES_ANIMATION.ANIMATION_PRESENT.equals(mRouterParam.type)) {
onAttach(this);
} else {
onAttach(this, getClass().getName());
}
} else {
onAttach(this);
}
}
public void refresh() {
runOnUiThread(new Runnable() {
@Override
public void run() {
DispatchEventManager dispatchEventManager = ManagerFactory.getManagerService
(DispatchEventManager.class);
Intent intent = new Intent(WXConstant.ACTION_WEEX_REFRESH);
intent.putExtra("instanceId", mWXInstance.getInstanceId());
dispatchEventManager.getBus().post(intent);
createWXInstance();
renderPage();
}
});
}
//改造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
.layout_svprogresshud, null, false);
rootView.setLayoutParams(new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
));
}
public ViewGroup getLoadingDecorView() {
if (decorView == null) {
createLoadingView();
}
return decorView;
}
public ViewGroup getLoadingRootView() {
if (rootView == null) {
createLoadingView();
}
return rootView;
}
public void showLoadingDialog(String msg) {
if (loadingDialog == null) {
loadingDialog = new LoadingDialog();
loadingDialog.createLoadingDialog(this, msg);
}
loadingDialog.setTipText(msg);
loadingDialog.show();
}
public void closeDialog() {
if (loadingDialog != null) {
loadingDialog.dismiss();
}
}
public void setPageUrl(String url) {
this.mPageUrl = url;
}
public String getPageUrl() {
return mPageUrl;
}
protected void renderPage() {
if (TextUtils.isEmpty(mPageUrl)) {
return;
}
createWXInstance();
preRender();
renderPageByURL();
postRender();
}
private void renderPageByURL() {
WXCommonUtil.throwIfNull(mContainer, new RuntimeException("Can't render page, container " +
"is" +
" null"));
Map<String, Object> options = new HashMap<>();
options.put(WXSDKInstance.BUNDLE_URL, mPageUrl);
InsertEnvUtil.customerRender(options);
mWXInstance.renderByUrl(
getPageName(),
mPageUrl,
options,
null,
WXRenderStrategy.APPEND_ASYNC);
}
public String getPageName() {
return mPageName == null ? TAG : mPageName;
}
public void setPageName(String pageName) {
this.mPageName = pageName;
}
protected void preRender() {
}
protected void postRender() {
}
public WXSDKInstance getWXSDkInstance() {
return mWXInstance;
}
protected void createWXInstance() {
if (mWXInstance != null) {