Commit 86c39069 authored by clotee's avatar clotee

Merge branch 'master' into release

# Conflicts:
#	platforms/android/GSST/app/build.gradle
#	platforms/android/LMWeex/settings.gradle
parents 48b939ed f84dab12
......@@ -19,7 +19,7 @@ module.exports = {
},
'zipFolder': {
'iOS': '/ios/LMWeex/LMWeex',
'android': '/android/LMWeex/app/src/main/assets'
'android': '/android/GSST/app/src/main/assets'
},
'getui': {
'enabled': 'false',
......
......@@ -18,24 +18,28 @@ android {
abiFilters "x86"
abiFilters "armeabi"
}
manifestPlaceholders = [
JPUSH_PKGNAME : applicationId,
JPUSH_APPKEY : "cfe349282988dfd8ca842350", //JPush 上注册的包名对应的 Appkey.
JPUSH_CHANNEL : "developer-default", //暂时填写默认值即可.
]
}
signingConfigs {
eros {
keyAlias 'LMWeexDemo'
keyPassword 'gsst2019'
storeFile file('../com.gsst.lm.keystore')
storePassword 'gsst2019'
ddlStaff {
keyAlias 'com.gsst.ddl.staff'
keyPassword '123qazwsx'
storeFile file('../com.gsst.ddl.staff.keystore')
storePassword '123qazwsx'
v2SigningEnabled false
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.eros
signingConfig signingConfigs.ddlStaff
manifestPlaceholders=[
GETUI_APP_ID:GETUI_APPID,
GETUI_APP_KEY:GETUI_APPKEY,
......@@ -47,7 +51,7 @@ android {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.eros
signingConfig signingConfigs.ddlStaff
manifestPlaceholders=[
GETUI_APP_ID:GETUI_APPID,
GETUI_APP_KEY:GETUI_APPKEY,
......@@ -94,6 +98,7 @@ repositories {
}
google()
maven { url 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/' }
}
......@@ -106,6 +111,11 @@ dependencies {
testCompile 'junit:junit:4.12'
//基础库
compile 'com.gsst.mobile:gsst-weex-base-plugin:0.0.03-SNAPSHOT'
compile 'com.gsst.mobile:gsst-weex-base-library:0.0.03-SNAPSHOT'
// compile 'com.gsst.mobile:gsst-weex-base-plugin:0.0.04-SNAPSHOT'
// compile 'com.gsst.mobile:gsst-weex-base-library:0.0.04-SNAPSHOT'
compile project(':nexus')
compile project(':weex-framework')
compile project(':gsstJPush')
compile project(':wechatplugin')
compile project(':pgyplugin')
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.gsst.lm">
package="com.gsst.clotee">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
......@@ -39,7 +39,7 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:name="com.gsst.lm.App"
android:name="com.gsst.App"
android:theme="@style/AppTheme.NoActionBar"
>
......@@ -68,7 +68,7 @@
android:theme="@android:style/Theme.Light.NoTitleBar"/>
<activity
android:name="com.gsst.lm.activity.SplashActivity"
android:name="com.gsst.activity.SplashActivity"
android:theme="@style/WelcomeStyle"
>
<intent-filter>
......@@ -98,7 +98,7 @@
<!--wxApi-->
<activity
android:name=".wxapi.WXEntryActivity"
android:name="com.gsst.wxapi.WXEntryActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen">
......@@ -112,7 +112,7 @@
</activity>
<activity
android:name=".wxapi.WXPayEntryActivity"
android:name="com.gsst.wxapi.WXPayEntryActivity"
android:exported="true"
android:launchMode="singleTop"/>
......
{"filesMd5":[{"page":"/mediator/index.js","md5":"42a934f1972863b8832409738a6b9ca5"},{"page":"/pages/user/security/index.js","md5":"88ca8c433f5b3c3c08f81710dc804363"},{"page":"/pages/user/wallet/bankcard.js","md5":"0f324ee77fe06d73732c620486e510a0"},{"page":"/pages/stats/performanceDetail.js","md5":"115abc9f53189e3238c5f4b8cd869831"},{"page":"/pages/stats/commissionDetail.js","md5":"32998dc70fb8748b9386594ee2d32b6f"},{"page":"/pages/user/wallet/withdrawBank.js","md5":"d4d22f7aa30aca18f5d7b66792b0519b"},{"page":"/pages/user/wallet/availableBank.js","md5":"b6b38993f8866a4b081714b376b929cd"},{"page":"/pages/home/tabbarItem1.js","md5":"76ede71f3d71c4e9df9fd583bef7c095"},{"page":"/pages/stats/commission.js","md5":"921b245c2457892e418684975885f6c7"},{"page":"/pages/stats/performance.js","md5":"0715401aaa55f976c2682663c58a0328"},{"page":"/pages/user/profile/index.js","md5":"50a92fb1d06a5a625ca4446dad5b7bec"},{"page":"/pages/user/statistics/billStatistics.js","md5":"3ffd3ff41289c5eb17f11c3e2d11a426"},{"page":"/pages/user/statistics/index.js","md5":"26e7e45c2e55d6ec317e34338463a638"},{"page":"/pages/user/statistics/orderStatistics.js","md5":"1ec3a3652836eec1947f793fc658d216"},{"page":"/pages/user/wallet/index.js","md5":"6897716a5d8b3711cd52b75c5dd844c9"},{"page":"/pages/booking/storeList.js","md5":"2be860b79f7ff771ecbc858cfbd50fb2"},{"page":"/pages/booking/siteList.js","md5":"337600b418da156fca8f2296375375a0"},{"page":"/pages/booking/serviceStaffList.js","md5":"26a5e7c67146489d7f3f1b62219fe0bf"},{"page":"/pages/message/list.js","md5":"a1936873ab13f17c936f00f784e601c4"},{"page":"/pages/stats/reservationOrder.js","md5":"0f6c6d83453eaa3de15025592b6c8f87"},{"page":"/pages/user/index/index.js","md5":"6bf04f2806b09f362541c6dea005b420"},{"page":"/pages/booking/remark.js","md5":"5f1542173a005f757ed6aa1144026c18"},{"page":"/pages/user/security/changePassword.js","md5":"043352c8aca1b04caf7000524121c1a5"},{"page":"/pages/user/setting/setting.js","md5":"85baff4ce33d2864c08fa021329f58f3"},{"page":"/pages/user/wallet/addBankcard.js","md5":"b6a0a618547b058f3452ff33a4dc1dea"},{"page":"/pages/user/wallet/withdraw.js","md5":"31384d2221ff0dcc80d9ba0589cd23e0"},{"page":"/pages/auth/login.js","md5":"971e5cfeb50066a081d0bf2c0b37e320"},{"page":"/pages/booking/memberServiceList.js","md5":"9cdf04da171d4c5a76a540a870962675"},{"page":"/pages/booking/serviceList.js","md5":"9422b86684b49db292270a417acf4a04"},{"page":"/pages/newTasks/list/index.js","md5":"b549a23d7ca93718aee1c923f8a1ebe1"},{"page":"/pages/schedule/list/index.js","md5":"e25d3c051917116a994bc318ba6abdc0"},{"page":"/pages/user/profile/userAlias.js","md5":"bb9613496cd9c4b7a24791ef08899911"},{"page":"/pages/booking/doConfirm.js","md5":"3cda00005a01e619be84f9b80960a5f2"},{"page":"/pages/booking/memberList.js","md5":"39b5d302de5d8b006ccd5a35c437df41"},{"page":"/pages/newTasks/detail/index.js","md5":"17828658af00db658b81b853e2c071eb"},{"page":"/pages/index.js","md5":"c86c9310bb6f536b3390670598f7c59c"},{"page":"/pages/booking/dateList.js","md5":"4a8c747581407c835fd1deb903f734b3"},{"page":"/config/index.js","md5":"4c815ee71f02a2f43ead729a3fa82fa1"},{"page":"/iconfont/font_1469606063_76593.ttf","md5":"7f64b407dbb118b2bf74aae8488f115e"},{"page":"/iconfont/font_1469606522_9417143.woff","md5":"8d34182774fbf5de6d7192ca76027faa"},{"page":"/iconfont/font_zn5b3jswpofuhaor.ttf","md5":"dc3b4b0978d180d7f122e74d2f3f2f51"},{"page":"/iconfont/iconfont-eros.ttf","md5":"68780fad0047dc5b02cb613ebb08cda1"},{"page":"/iconfont/iconfont.ttf","md5":"ec86bfe5bdb872bad2b2af4f11da14f4"},{"page":"/assets/NavBar_BackIcon@2x.png","md5":"3d9078f32a909f404bc416aad5d399c0"},{"page":"/assets/TabBar_Item1@2x.png","md5":"9f1edde3e3c493125aa1526aaf72e73d"},{"page":"/assets/TabBar_Item1_Selected@2x.png","md5":"d5e7609700d9a4f075e39b20fecbb9c3"},{"page":"/assets/TabBar_Item2@2x.png","md5":"6774d4074d376d716a5c9f447c6a3efd"},{"page":"/assets/TabBar_Item2_Selected@2x.png","md5":"e1ae4f456c18ccee39b3dd1fe7801994"},{"page":"/assets/TabBar_Item3@2x.png","md5":"c74d71c755710384145dc30922c21a3b"},{"page":"/assets/TabBar_Item3_Selected@2x.png","md5":"457d615a5c198b0148609f5eed84be70"},{"page":"/assets/avatar.png","md5":"397fc5c039636b3b54a60f9ff48848f7"},{"page":"/assets/bankcard-bg1.png","md5":"71da56e23c42337839124c63b25c45d2"},{"page":"/assets/bankcard-bg2.png","md5":"328004e752005fb405f04f47fc0be0ae"},{"page":"/assets/bill-statistics-bg.png","md5":"a32e6162fa3fff1fd1fece2c81ae02f1"},{"page":"/assets/ddl-user-bg.png","md5":"b81e617dd21bb969ec68905b858af0d4"},{"page":"/assets/demo.jpg","md5":"ad0a76ef138304056020d234c3217aeb"},{"page":"/assets/goods.png","md5":"dbfe11dc38b9bf440de2f3e1fd383c47"},{"page":"/assets/liebiao@2x.png","md5":"0f83bb33c094bdb5b76521b2a3fbb189"},{"page":"/assets/logo.png","md5":"39a9f8dcc1821372adff3db096fa9c0e"},{"page":"/assets/nothing-found.png","md5":"882a37b46155503134bb2ca8025ffde2"},{"page":"/assets/order-statistics-bg.png","md5":"566eb8e347be51fcb8c900726d7f7d33"},{"page":"/assets/qitaxiaoxi.png","md5":"ed6205871a877075886a5290057b4d07"},{"page":"/assets/renwutixing.png","md5":"f758598b186829ca5367a0e41211633b"},{"page":"/assets/rili@2x.png","md5":"015e5f46a59e286617fcf06648426d9d"},{"page":"/assets/search.png","md5":"b5621425996ce57e339111144021293d"},{"page":"/assets/selected.png","md5":"cfa73e1da76c43ccc7b48bb318abeff4"},{"page":"/assets/shanglajiantou.png","md5":"22d5619ec204368a766575ac7ddd42f2"},{"page":"/assets/shangyiyue.png","md5":"a3fdf51867da86cda918e5178e49728d"},{"page":"/assets/shangyiyue_weijihuo.png","md5":"7f7d5d15986c58deaab19d20481620e9"},{"page":"/assets/shouruxinxi.png","md5":"34b639ffa4fb3ae527965342e921c60e"},{"page":"/assets/tianjiayinhangka@2x.png","md5":"edd5c36f1dfb28c5615f492d488947bf"},{"page":"/assets/unselected.png","md5":"e5600086fb65d56281acac50efb69f0c"},{"page":"/assets/unselected1.png","md5":"98fb91d483b655c0d2cbd2ae90569512"},{"page":"/assets/user-bg.png","md5":"c64b4915d3e140ab7686b8b230581ead"},{"page":"/assets/wodeqianbao.png","md5":"fe2527d798fdd6f65605e3fc3e24caf1"},{"page":"/assets/wodericheng.png","md5":"4b97195bfd08293f96fcdd556c08095b"},{"page":"/assets/xialajiantou.png","md5":"12cd9bf013a246cee6f5f8eca09dd758"},{"page":"/assets/xiayiyue.png","md5":"7dd911542230f6b2cd4836e32d1e37cd"},{"page":"/assets/xiayiyue_weijihuo.png","md5":"450435434a668ea05c44526d73db0a78"},{"page":"/assets/xinrenwu.png","md5":"bb2a43564c9e8675b3fbe5ed28bdadab"},{"page":"/assets/yejitongji.png","md5":"b486307a196465a6a4e17fa618a75792"},{"page":"/assets/yinhangka@2x.png","md5":"23c6b395e6185a5a244d2974ae0bc6eb"},{"page":"/assets/yuyuexinxi.png","md5":"55c78a6dd73044c35ad8287a8b9220e0"},{"page":"/assets/holder/avatar.png","md5":"79e1c7b736bd964376434e58ab790509"},{"page":"/assets/holder/banner.png","md5":"55393f09bd227602ba1e4790cdddbbb6"},{"page":"/assets/holder/categories.png","md5":"507f0c95896b6045a16f2d8fcb826bb8"},{"page":"/assets/holder/goods.png","md5":"dbfe11dc38b9bf440de2f3e1fd383c47"},{"page":"/assets/holder/my-icon.png","md5":"5fe378f610806a47e6d50f8af5b9c78f"},{"page":"/assets/holder/product.png","md5":"e871bcdaf321b1a6c21d6c928b3bf2e4"},{"page":"/assets/holder/service.png","md5":"1a8fc338f4145ebdb8e39c83408e5250"},{"page":"/assets/holder/store.png","md5":"376f7c3b1a45c889101cebb76228ae32"},{"page":"/assets/holder/vip-card.png","md5":"ad89042a5c4c4a798cb6f0de79b9770d"},{"page":"/assets/iconfont/iconfont.ttf","md5":"b7c05dee37d8bc19501eac80b93e18bf"}],"android":"1.0.0","iOS":"1.0.0","appName":"城市会所服务","jsVersion":"68d3879b88deb024ba8e4b92195dbeab","timestamp":1570703881104,"jsPath":"https://app.weex-eros.com/source"}
"vsTZAbrVE4WzjaMh45cmyMTRpo8pnrFXjK/Fh13RfV2druWzknbKsiZndLNw+pea3518fVjh//yOub1lZcpqguUBMs8QvdtwumTxdDYw6Pd3VWtIOZlKyHC+U6NK/bbMwI13Dz/2aVc6tfLbowXcIGnajYuQ0AsygHM3J1/Vlg8heIbN/Ma1owhjEvucKSal8YjTv7qWpdB9Y88DFilmviC4qRaGyoZWKxz93tp4hwamV8tCQ3rCqIwX3KpibC0cZX2j1F0nXA3dU/NBJo3oTKW1MVpkhPTnhAX6AIyKRiBtOGru8kUAY/NAqOvKqvwptl9oJbVxxBMmxfkr5zHthdLQ84Vc8gYldwwD2AnaHGmGklYmT1ZoGsScAxpucECZekiVbYV1ouLVuD4wpcy5Dq7rDxEX6MDI1QjQzaZUclxa6k/68FX2vJ19ym4aokAdZhW4WkTuO2v1PdUROWkWDBWWeIAizEdv/xCfvG59y+AXNQSvs+A1/geV0wU57THjOtOjMJSh5d36BYlIz+7gLOgkiS11KdAvFdjbsPLIlRsTnr0CKZM6HPWMjXgF87mrNTOoWyINsHxYk6q2byzAyp+I2AOZ9GFW808kGUV5NR25g28wOuNKXKSKGOyYuQjBiDct6vtkI3mN5IVBdBiZVZIaS8neHnsUTKjZuLQ7+AI0OlSCH3eWBgl/fgY3BgBE7ebdoA5UxRSJFrYfIGMEZ6k+HVBmbj6hdMoYakv0C9AXcsQuybtpeIOREifxn0qTSTdpfbnhRtPaQvLMcUc1ZVpZFqMg4SGfg5J1vjsvyPjK1LpDpVJ/MnrDBZjFgjbJ3VpxoJSZLL7nHloZDiL1bfwLBPeTBIV8fcx8/Iki/goKLCDWv8jkzutZ8HHoXxYTHp7nWyb3tOrY7Mrq5EGr4BXZNE+vqnJBgUYoSA8Ekc9EH4hRpV6CQ/FT68HBohbXdvCg0+7uqbluP1ykmMGv+X8xSf6zXhgrt77eONGYZVnSYwMfr4HThrAhjstw99VdepVBhqXz2Vy7BRABXKpC2Q7s1TtWJqQIKmi3aCmelwkpFIxK1OLDSRXXUm9mWG7tAx72jpA+7+QxWDUzocxeYahvJwAHLktWx5dz4DEUhXg="
package com.gsst.lm.activity;
package com.gsst.activity;
import android.app.Activity;
import android.os.Bundle;
import com.eros.framework.proxy.SplashActivityProxy;
import com.gsst.lm.R;
import com.gsst.clotee.R;
/**
* Created by Carry on 2017/8/23.
......
<resources>
<string name="app_name">LMWeex</string>
<string name="app_name">店店联:服务人员</string>
<string name="umeng_socialize_female"></string>
<string name="umeng_socialize_male"></string>
</resources>
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-yingyongbao-release.apk","properties":{"packageId":"com.gsst.ddlstaff","split":"","minSdkVersion":"16"}}]
\ No newline at end of file
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.aa453509345'
android {
compileSdkVersion 25
buildToolsVersion "26.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
/**
* debug调试要用到的
*/
compile 'com.taobao.android.weex_inspection:protocol:1.1.4.1'
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.lzy.widget:imagepicker:0.6.1'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.android.support:multidex:1.0.1'
//bs patch
compile 'me.ele:bspatch:1.0.6'
//weex analyzer
compile 'com.taobao.android:weex_analyzer:0.1.0.5'
//Bindigx
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.niorgai:StatusBarCompat:2.1.4', {
exclude group: 'com.android.support'
})
// compile 'com.gsst.mobile:gsst-weex-base-plugin:0.0.03-SNAPSHOT'
compile project(':nexus')
// debugImplementation "com.squareup.leakcanary:leakcanary-android:1.5.4"
// releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:1.5.4"
}
repositories {
mavenCentral()
maven { url 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/' }
}
uploadArchives {
repositories {
mavenDeployer {
//maven address
repository(url: 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/') {
authentication(userName: "deployment", password: "deployment123")
}
pom.project {
groupId 'com.gsst.mobile'
artifactId 'gsst-weex-base-library'
version '0.0.03-SNAPSHOT'
packaging 'jar'
}
}
}
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# 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 *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
package com.benmu.framework;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented 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("com.benmu.framework.test", appContext.getPackageName());
}
}
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.eros.framework">
<application
tools:replace="android:allowBackup"
android:allowBackup="false"
android:label="@string/app_name"
android:supportsRtl="true"></application>
</manifest>
<!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>
package com.eros.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;
}
}
}
package com.eros.framework;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.support.multidex.MultiDex;
import android.util.DebugUtils;
import com.eros.framework.activity.AbstractWeexActivity;
import com.eros.framework.adapter.router.RouterTracker;
import com.eros.framework.constant.Constant;
import com.eros.framework.debug.ws.DebuggerWebSocket;
import com.eros.framework.extend.adapter.DefaultTypefaceAdapter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.GlobalEventManager;
import com.eros.framework.manager.impl.LifecycleManager;
import com.eros.framework.update.VersionChecker;
import com.eros.framework.utils.DebugableUtil;
import com.taobao.weex.WXSDKInstance;
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;
private DefaultTypefaceAdapter typefaceAdapter;
// private RefWatcher mWatcher;
/**
* 是否全屏显示
*/
public boolean IS_FULL_SCREEN = false;
@Override
public void onCreate() {
super.onCreate();
if (shouldInit()) {
mInstance = this;
initWeex();
mVersionChecker = new VersionChecker(this);
registerLifecycle();
initDebugSocket();
// mWatcher = DebugableUtil.isDebug() ? LeakCanary.install(this) : RefWatcher.DISABLED;
}
}
// public RefWatcher getWatcher() {
// return mWatcher;
// }
private void initDebugSocket() {
debugSocket = new DebuggerWebSocket(this);
debugSocket.init();
}
public DefaultTypefaceAdapter getTypefaceAdapter() {
return typefaceAdapter;
}
public void setTypefaceAdapter(DefaultTypefaceAdapter typefaceAdapter) {
this.typefaceAdapter = typefaceAdapter;
}
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 version
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;
}
public VersionChecker getVersionChecker() {
return mVersionChecker;
}
}
package com.eros.framework;
import com.eros.framework.constant.Constant;
import com.eros.framework.manager.Manager;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.CustomerEnvOptionManager;
import java.util.HashMap;
/**
* Created by liuyuanxiao on 17/12/5.
*/
public class PlugManager {
public static void initPlug() {
pluginInit("com.plugamap.manager.GeoManager");
pluginInit("com.eros.erosplugingt.manager.PushManager");
}
private static void pluginInit(String clazzName) {
Manager geoManager = ManagerFactory.getManagerService(clazzName);
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);
}
}
}
package com.eros.framework.activity;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* Created by sheatming on 2018/7/18.
*/
public class AndroidBug5497Workaround {
public static void assistActivity (Activity activity) {
new AndroidBug5497Workaround(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) {
// keyboard probably just became visible
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
// keyboard probably just became hidden
frameLayoutParams.height = usableHeightSansKeyboard;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}
}
package com.eros.framework.activity;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.eros.framework.R;
import com.eros.framework.model.BroeserImgModuleBean;
import com.eros.framework.view.ViewPagerFix;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import uk.co.senab.photoview.PhotoView;
import java.util.List;
/**
* 预览大图的默认实现
*/
public class BrowseImgActivity extends Activity implements ViewPager.OnPageChangeListener {
private ViewGroup mOvalViewGroup;
private ViewPagerFix mViewPager;
private ViewPagerAdapter mViewPagerAdapter;
public static final String BROWSE_IMG_BEAN = "browse_img_bean";
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_browse);
initData();
}
//数据初始化
private void initData() {
BroeserImgModuleBean imgModuleBean = (BroeserImgModuleBean) getIntent()
.getSerializableExtra(BROWSE_IMG_BEAN);
if (imgModuleBean == null || imgModuleBean.getImages() == null || imgModuleBean.getImages
().size() < 1)
return;
initView(imgModuleBean);
}
//View初始化
private void initView(BroeserImgModuleBean imgModuleBean) {
mViewPager = (ViewPagerFix) findViewById(R.id.viewpager_browse_img);
mOvalViewGroup = (ViewGroup) findViewById(R.id.rl_browse_prompt_oval);
mViewPagerAdapter = new ViewPagerAdapter(imgModuleBean.getImages());
mViewPager.setAdapter(mViewPagerAdapter);
mViewPager.setCurrentItem(imgModuleBean.getIndex());
mViewPager.setOnPageChangeListener(this);
initOval(imgModuleBean.getImages().size(), imgModuleBean.getIndex());
}
//添加ViewPager追踪点
private void initOval(int size, int index) {
for (int i = 0; i < size; i++) {
ImageView mOvalView = new ImageView(this);
if (i == index) {
mOvalView.setImageResource(R.drawable.browse_shape_on);
} else {
mOvalView.setImageResource(R.drawable.browse_shape_off);
}
mOvalViewGroup.addView(mOvalView);
}
}
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
@Override
public void onPageSelected(int position) {
changeIndicator(position);
}
@Override
public void onPageScrollStateChanged(int state) {
}
class ViewPagerAdapter extends PagerAdapter {
List<String> images;
public ViewPagerAdapter(List<String> images) {
this.images = images;
}
@Override
public int getCount() {
return images.size();
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
Glide.with(BrowseImgActivity.this).clear((View) object);
container.removeView((View) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
PhotoView imageView = new PhotoView(container.getContext());
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setBackgroundColor(Color.WHITE);
imageView.setZoomable(true);
Glide.with(BrowseImgActivity.this)
.load(images.get(position))
.apply(new RequestOptions().diskCacheStrategy(DiskCacheStrategy.ALL).fitCenter())
.into(imageView);
container.addView(imageView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout
.LayoutParams.MATCH_PARENT);
return imageView;
}
}
//重置追踪点颜色
private void changeIndicator(int position) {
for (int i = 0; i < mOvalViewGroup.getChildCount(); i++) {
ImageView iv = (ImageView) mOvalViewGroup.getChildAt(i);
if (position == i) {
iv.setImageResource(R.drawable.browse_shape_on);
} else {
iv.setImageResource(R.drawable.browse_shape_off);
}
}
}
}
package com.eros.framework.activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.eros.framework.R;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXConstant;
import com.eros.framework.debug.ws.DebuggerWebSocket;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.JsVersionInfoBean;
import com.eros.framework.utils.SharePreferenceUtil;
import com.eros.widget.utils.BaseCommonUtil;
/**
* Created by Carry on 2017/8/25.
*/
public class DebugActivity extends AbstractWeexActivity {
private TextView tv_appversion;
private TextView tv_jsverision;
private CheckBox cb_inter, cb_hotrefresh;
private DebuggerWebSocket debugSocket;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_debug);
initView();
}
private void initView() {
tv_appversion = (TextView) findViewById(R.id.tv_appversion);
tv_jsverision = (TextView) findViewById(R.id.tv_jsverision);
cb_inter = (CheckBox) findViewById(R.id.cb_inter);
cb_hotrefresh = (CheckBox) findViewById(R.id.cb_hotrefresh);
tv_appversion.setText(BaseCommonUtil.getVersionName(this));
String activeState = SharePreferenceUtil.getInterceptorActive(this);
if (Constant.INTERCEPTOR_ACTIVE.equals(activeState)) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
String jsVersion = parseManager.parseObject(SharePreferenceUtil.getVersion
(this), JsVersionInfoBean.class).getJsVersion();
tv_jsverision.setText(jsVersion);
}
cb_hotrefresh.setEnabled(!Constant.INTERCEPTOR_ACTIVE.equals(activeState));
cb_inter.setChecked(Constant.INTERCEPTOR_ACTIVE.equals(activeState));
cb_inter.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
SharePreferenceUtil.setInterceptorActive(mAct, isChecked ? Constant
.INTERCEPTOR_ACTIVE : Constant.INTERCEPTOR_DEACTIVE);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(new
Intent
(WXConstant.ACTION_INTERCEPTOR_SWTICH));
if (isChecked) {
cb_hotrefresh.setEnabled(false);
cb_hotrefresh.setChecked(false);
} else {
cb_hotrefresh.setEnabled(true);
}
}
});
cb_hotrefresh.setChecked(SharePreferenceUtil.getHotRefreshSwitch(this));
cb_hotrefresh.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Log.e("DebugActivity", "onCheckedChanged -> " + isChecked);
SharePreferenceUtil.setHotRefreshSwitch(mAct, isChecked);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(new
Intent
(WXConstant.ACTION_INTERCEPTOR_SWTICH));
}
});
}
public void refresh() {
}
}
package com.eros.framework.activity;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.ConsoleMessage;
import android.webkit.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import com.eros.framework.BMWXApplication;
import com.eros.framework.BMWXEnvironment;
import com.eros.framework.R;
import com.eros.framework.adapter.router.RouterTracker;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.event.mediator.EventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.FileManager;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.WebViewParamBean;
import com.eros.framework.utils.SharePreferenceUtil;
import com.eros.widget.utils.BaseCommonUtil;
import java.io.File;
import java.util.Map;
/**
* Created by Carry on 2017/8/25.
*/
public class GlobalWebViewActivity extends AbstractWeexActivity {
private final String LOCAL_SCHEME = "bmlocal";
private View rl_refresh;
private ProgressBar mProgressBar;
private WebView mWeb;
private String mFailUrl;
public static String WEBVIEW_URL = "WEBVIEW_URL";
private WebViewParamBean mWebViewParams;
private RelativeLayout mContainer;
private String mTitle;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_webview);
init();
statusBarHidden(BMWXApplication.getWXApplication().IS_FULL_SCREEN);
}
@Override
protected void onResume() {
super.onResume();
}
private void init() {
Intent data = getIntent();
mWebViewParams = (WebViewParamBean) data.getSerializableExtra(Constant.WEBVIEW_PARAMS);
String mUrl = mWebViewParams.getUrl();
Uri imageUri = Uri.parse(mUrl);
if (LOCAL_SCHEME.equalsIgnoreCase(imageUri.getScheme())) {
mUrl = "file://" + localPath(imageUri);
}
rl_refresh = findViewById(R.id.rl_refresh);
mProgressBar = (ProgressBar) findViewById(R.id.pb_progress);
mWeb = (WebView) findViewById(R.id.webView);
mContainer = (RelativeLayout) findViewById(R.id.rl_container);
WebSettings settings = mWeb.getSettings();
settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
addWebJavascriptInterface();
settings.setDomStorageEnabled(true);
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
}
mWeb.setWebViewClient(new MyWebViewClient(this));
mWeb.setWebChromeClient(new MyWebChromeClient());
if (!TextUtils.isEmpty(mUrl)) {
mWeb.loadUrl(mUrl);
}
ModalManager.BmLoading.showLoading(this, "", true);
}
@SuppressLint({"SetJavaScriptEnabled", "AddJavascriptInterface"})
private void addWebJavascriptInterface() {
WebSettings settings = mWeb.getSettings();
settings.setJavaScriptEnabled(true);
mWeb.addJavascriptInterface(new JSMethod(this), "bmnative");
}
private String localPath(Uri uri) {
String path = uri.getHost() + File.separator +
uri.getPath() + "?" + uri.getQuery();
return FileManager.getPathBundleDir(this, "bundle/" + path)
.getAbsolutePath();
}
//遇到ssl错误提示用户
private void handleSSLError(final SslErrorHandler handler) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.str_error_ssl_cert_invalid);
builder.setPositiveButton(getResources().getString(R.string.str_ensure), new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.proceed();
}
});
builder.setNegativeButton(getResources().getString(R.string.str_cancel), new
DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
handler.cancel();
}
});
final AlertDialog dialog = builder.create();
dialog.show();
}
private class MyWebViewClient extends WebViewClient {
GlobalWebViewActivity activity;
public MyWebViewClient(GlobalWebViewActivity activity) {
this.activity = activity;
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handleSSLError(handler);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageFinished(WebView view, String url) {
ModalManager.BmLoading.dismissLoading(activity);
super.onPageFinished(view, url);
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String
failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
//L.i("web failingUrl == " + failingUrl);
activity.mFailUrl = failingUrl;
activity.showRefreshView();
}
}
private class MyWebChromeClient extends WebChromeClient {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
@Override
public void onReceivedTitle(WebView view, String title) {
super.onReceivedTitle(view, title);
if (!TextUtils.isEmpty(title) && mTitle == null) {
getNavigationBar().setTitle(title);
}
}
@Override
public boolean onConsoleMessage(ConsoleMessage consoleMessage) {
Log.e("onConsoleMessage", "onConsoleMessage>>>>>" + consoleMessage.message());
return super.onConsoleMessage(consoleMessage);
}
}
private void showRefreshView() {
showWebCloseView();
}
@Override
public void onBackPressed() {
if (mWeb.canGoBack()) {
mWeb.goBack();
} else {
BaseCommonUtil.clearAllCookies(this);
super.onBackPressed();
}
}
private void showWebCloseView() {
}
public static class JSMethod {
private Context mContext;
public JSMethod(Context mContext) {
this.mContext = mContext;
}
@JavascriptInterface
public void closePage() {
//关闭当前页面
RouterTracker.popActivity();
}
@JavascriptInterface
public void fireEvent(String eventName, String param) {
if (!TextUtils.isEmpty(eventName)) {
Intent emit = new Intent(WXEventCenter.EVENT_JS_EMIT);
emit.putExtra("data", new EventCenter.Emit(eventName, param));
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(emit);
}
}
}
}
package com.eros.framework.activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.KeyEvent;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.WindowManager;
import android.widget.FrameLayout;
import com.eros.framework.BMWXApplication;
import com.eros.framework.BMWXEnvironment;
import com.eros.framework.R;
import com.eros.framework.constant.Constant;
import com.eros.framework.event.TabbarEvent;
import com.eros.framework.manager.impl.GlobalEventManager;
import com.eros.framework.model.RouterModel;
import com.eros.framework.model.TabbarBadgeModule;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.utils.SharePreferenceUtil;
import com.eros.framework.view.TableView;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
public class MainActivity extends AbstractWeexActivity {
private FrameLayout layout_container;
private ViewStub viewStub_tabView;
private TableView tableView;
private BroadcastReceiver mReloadReceiver;
private RouterModel routerModel;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// AndroidBug5497Workaround.assistActivity(this);
routerModel = (RouterModel) getIntent().getSerializableExtra(Constant.ROUTERPARAMS);
if (Constant.TABBAR.equals(routerModel.url)) {
initTabView();
} else {
layout_container = (FrameLayout) findViewById(R.id.layout_container);
initView();
renderPage();
}
initReloadReceiver();
statusBarHidden(BMWXApplication.getWXApplication().IS_FULL_SCREEN);
}
private void initReloadReceiver() {
mReloadReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (!Constant.TABBAR.equals(routerModel.url)) {
renderPage();
}
}
};
LocalBroadcastManager.getInstance(BMWXEnvironment.mApplicationContext).registerReceiver(mReloadReceiver, new
IntentFilter(WXSDKEngine.JS_FRAMEWORK_RELOAD));
}
private void initView() {
mContainer = (ViewGroup) findViewById(R.id.layout_container);
}
private void initTabView() {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
viewStub_tabView = (ViewStub) findViewById(R.id.vs_tabView);
viewStub_tabView.inflate();
tableView = (TableView) findViewById(R.id.tabView);
tableView.setData(BMWXEnvironment.mPlatformConfig.getTabBar());
}
@Override
public boolean navigationListenter(WeexEventBean weexEventBean) {
if (tableView != null) {
return tableView.setNaigation(weexEventBean);
}
return false;
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
if (isHomePage() && BMWXEnvironment.mPlatformConfig.isAndroidIsListenHomeBack()) {
WXSDKInstance wxsdkInstance = getWXSDkInstance();
if (wxsdkInstance != null) {
GlobalEventManager.homeBack(wxsdkInstance);
return true;
}
}
}
return super.onKeyDown(keyCode, event);
}
@Override
public WXSDKInstance getWXSDkInstance() {
return (tableView != null) ? tableView.getWXSDKInstance() : super.getWXSDkInstance();
}
@Override
public void refresh() {
if (tableView != null) {
tableView.refresh();
} else {
super.refresh();
}
}
public void setBadge(TabbarBadgeModule module) {
if (tableView != null) {
tableView.setBadge(module);
}
}
public void hideBadge(int index) {
if (tableView != null) {
tableView.hideBadge(index);
}
}
public void openPage(int index) {
if (tableView != null) {
tableView.openPage(index);
}
}
public int getPageIndex() {
if (tableView != null) {
return tableView.getCurrentIndex();
}
return -1;
}
@Override
protected void onDestroy() {
super.onDestroy();
LocalBroadcastManager.getInstance(BMWXEnvironment.mApplicationContext).unregisterReceiver(mReloadReceiver);
}
}
package com.eros.framework.adapter;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.eros.framework.BMWXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.common.Constants;
import java.util.List;
/**
* Created by liuyuanxiao on 18/1/11.
*/
public class BMDefaultUriAdapter implements URIAdapter {
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
if (TextUtils.isEmpty(instance.getBundleUrl())) {
return uri;
}
Uri base = Uri.parse(instance.getBundleUrl());
Uri.Builder resultBuilder = uri.buildUpon();
if (uri.isRelative() && !type.equals(URIAdapter.IMAGE)) {
//When uri is empty, means use the base url instead. Web broswer behave this way.
if (uri.getEncodedPath().length() == 0) {
return base;
} else {
resultBuilder = buildRelativeURI(resultBuilder, base, uri, type);
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) {
if (uri.getAuthority() != null) {
return resultBuilder.scheme(base.getScheme());
} else {
resultBuilder
.encodedAuthority(base.getEncodedAuthority())
.scheme(base.getScheme())
.path(null);
if (uri.getPath().startsWith("/")) {
//relative to root
resultBuilder.appendEncodedPath(uri.getEncodedPath().substring(1));
} else {
List<String> segments = base.getPathSegments();
//ignore last segment if not end with /
int ignoreLast = 1;
if (base.getPath().endsWith("/")) {
ignoreLast = 0;
}
for (int i = 0, len = segments.size() - ignoreLast; i < len; i++) {
resultBuilder.appendEncodedPath(segments.get(i));
}
resultBuilder.appendEncodedPath(uri.getEncodedPath());
}
return resultBuilder;
}
}
}
package com.eros.framework.adapter;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.SystemClock;
import android.text.TextUtils;
import android.widget.Toast;
import com.eros.framework.constant.Constant;
import com.eros.framework.http.Api;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.AxiosManager;
import com.eros.framework.manager.impl.FileManager;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.PermissionManager;
import com.eros.framework.manager.impl.PersistentManager;
import com.eros.framework.model.UploadImageBean;
import com.eros.framework.utils.BMHookGlide;
import com.eros.framework.utils.ImageUtil;
import com.lzy.imagepicker.ImagePicker;
import com.lzy.imagepicker.bean.ImageItem;
import com.lzy.imagepicker.ui.ImageGridActivity;
import com.lzy.imagepicker.view.CropImageView;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by Carry on 2017/8/21.
*/
public class DefaultImageAdapter {
private static DefaultImageAdapter mInstance = new DefaultImageAdapter();
private static ImagePicker imagePicker = ImagePicker.getInstance();
private DefaultImageAdapter() {
}
public static DefaultImageAdapter getInstance() {
return mInstance;
}
public void pickPhoto(final Context context, UploadImageBean bean, int requestCode) {
if (!checkPermission(context)) return;
imagePicker.setImageLoader(new BMHookGlide()); //设置图片加载器
imagePicker.setShowCamera(true); //
imagePicker.setCrop(false);//允许裁剪(单选才有效)
imagePicker.setMultiMode(true);//是否是多张
imagePicker.setSelectLimit(bean.maxCount); //选中数量限制
Intent intent = new Intent(context, ImageGridActivity.class);
PersistentManager persistentManager = ManagerFactory.getManagerService(PersistentManager
.class);
persistentManager.setCacheData(Constant.ImageConstants.UPLOAD_IMAGE_BEAN, bean);
((Activity) context).startActivityForResult(intent, requestCode);
}
public void pickAvatar(final Context context, UploadImageBean bean, int requestCode) {
if (!checkPermission(context)) return;
imagePicker.setImageLoader(new BMHookGlide()); //设置图片加载器
imagePicker.setShowCamera(true); //显示拍照按钮
imagePicker.setMultiMode(false);//是否是多张
imagePicker.setCrop(true);//允许裁剪
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setStyle(CropImageView.Style.RECTANGLE); //裁剪框的形状
imagePicker.setFocusWidth(Constant.ImageConstants.BIGGESTWIDTH); //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(Constant.ImageConstants.BIGGESTWIDTH); //裁剪框的高度。单位像素(圆形自动取宽高最小值)
Intent intent = new Intent(context, ImageGridActivity.class);
PersistentManager persistentManager = ManagerFactory.getManagerService(PersistentManager
.class);
persistentManager.setCacheData(Constant.ImageConstants.UPLOAD_IMAGE_BEAN, bean);
((Activity) context).startActivityForResult(intent, requestCode);
}
public void openCamera(final Context context, UploadImageBean bean) {
imagePicker.setImageLoader(new BMHookGlide()); //设置图片加载器
imagePicker.setCrop(bean.allowCrop);//允许裁剪
imagePicker.setSaveRectangle(true); //是否按矩形区域保存
imagePicker.setStyle(CropImageView.Style.RECTANGLE); //裁剪框的形状
imagePicker.setFocusWidth(Constant.ImageConstants.BIGGESTWIDTH); //裁剪框的宽度。单位像素(圆形自动取宽高最小值)
imagePicker.setFocusHeight(Constant.ImageConstants.BIGGESTWIDTH); //裁剪框的高度。单位像素(圆形自动取宽高最小值)
PersistentManager persistentManager = ManagerFactory.getManagerService(PersistentManager
.class);
persistentManager.setCacheData(Constant.ImageConstants.UPLOAD_IMAGE_BEAN, bean);
if (context instanceof Activity) {
// imagePicker.takePicture((Activity) context, 1001);
Intent intent = new Intent(context, ImageGridActivity.class);
intent.putExtra(ImageGridActivity.EXTRAS_TAKE_PICKERS, true); // 是否是直接打开相机
((Activity) context).startActivityForResult(intent, 101);
}
}
public void UpMultipleImageData(Context context, ArrayList<ImageItem> items, UploadImageBean
bean) {
ModalManager.BmLoading.showLoading(context, null, false);
ArrayList imagesFilrUrl = new ArrayList();
if (items != null && items.size() > 0) {
for (ImageItem item : items) {
Bitmap bitmap = ImageUtil.getBitmap(item.path, context);
//TODO 图片改为全路径
String path = new File(FileManager.getTempFilePath(context), String.valueOf
(SystemClock.currentThreadTimeMillis())).getAbsolutePath();
String imageFileUrl = ImageUtil.zoomImage(context, bitmap, bean == null ? 0 :
(int) bean.imageWidth, Constant
.ImageConstants.BIGGESTWIDTH, path);
imagesFilrUrl.add(imageFileUrl);
bitmap.recycle();
}
}
HashMap<String, String> uploadParams = null;
HashMap<String, String> heads = null;
if (bean != null) {
String params = bean.params;
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
uploadParams = parseManager.parseObject(params, HashMap.class);
heads = parseManager.parseObject(bean.header, HashMap.class);
}
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
String url = TextUtils.isEmpty(bean.url) ? Api.UPLOAD_URL : bean.url;
axiosManager.upload(url, imagesFilrUrl, uploadParams, heads);
}
/**
* 判断Sd卡是否挂载,是否有Sd卡权限
*/
private boolean checkPermission(Context context) {
PermissionManager permissionManager = ManagerFactory.getManagerService(PermissionManager
.class);
boolean hasPermisson = permissionManager.hasPermissions(context, Manifest.permission
.READ_EXTERNAL_STORAGE);
if (!hasPermisson) {
ModalManager.BmToast.toast(context, "读取sd卡存储权限未授予,请到应用设置页面开启权限!", Toast.LENGTH_SHORT);
}
return hasPermisson;
}
// public class GlideImageLoader implements ImageLoader {
//
// @Override
// public void displayImage(Activity activity, String path, ImageView imageView, int width,
// int height) {
//
// Glide.with(activity) //配置上下文
// .load(Uri.fromFile(new File(path))) //设置图片路径(fix #8,文件名包含%符号 无法识别和显示)
// .error(R.mipmap.default_image) //设置错误图片
// .placeholder(R.mipmap.default_image) //设置占位图片
// .diskCacheStrategy(DiskCacheStrategy.ALL)//缓存全尺寸
// .into(imageView);
// }
//
// @Override
// public void clearMemoryCache() {
//
// }
// }
}
package com.eros.framework.adapter.router;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;
import com.eros.framework.BMWXEnvironment;
import com.eros.framework.R;
import com.eros.framework.activity.AbstractWeexActivity;
import com.eros.framework.constant.Constant;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.CallPhoneBean;
import com.eros.framework.model.RouterModel;
import com.eros.framework.model.WebViewParamBean;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.bridge.SimpleJSCallback;
import java.util.Map;
/**
* Created by Carry on 2017/8/21.
*/
public class DefaultRouterAdapter {
private static DefaultRouterAdapter mInstance = new DefaultRouterAdapter();
private String mApplicationId;
private DefaultRouterAdapter() {
}
public String getPageCategory(Context context){
if(TextUtils.isEmpty(mApplicationId)){
mApplicationId=context.getApplicationInfo().packageName;
}
return mApplicationId + ".categoty.page";
}
public String getWebViewCategory(Context context){
if(TextUtils.isEmpty(mApplicationId)){
mApplicationId=context.getApplicationInfo().packageName;
}
return mApplicationId+".category.web";
}
public static DefaultRouterAdapter getInstance() {
return mInstance;
}
public boolean open(Context context, String params, JSCallback jsCallback) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
RouterModel routerModel = parseManager.parseObject(params, RouterModel.class);
if (jsCallback != null) {
routerModel.backCallback = (SimpleJSCallback) jsCallback;
}
return !(routerModel == null || !(context instanceof Activity)) && performStartActivity(
(Activity) context, routerModel, getPageCategory(context));
}
private boolean performStartActivity(Activity activity, RouterModel routerModel, String
bmpageCategory) {
String pathUrl = routerModel.url;
if (TextUtils.isEmpty(pathUrl)) return false;
Uri pathUri = Uri.parse(pathUrl);
if (!TextUtils.equals("http", pathUri.getScheme()) && !TextUtils.equals("https", pathUri
.getScheme())) {
pathUri = Uri.parse(BMWXEnvironment.mPlatformConfig.getUrl().getJsServer() +
"/dist/js" + pathUrl);
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.putExtra(Constant.ROUTERPARAMS, routerModel);
intent.setData(pathUri);
intent.addCategory(bmpageCategory);
activity.startActivity(intent);
if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PUSH.equals(routerModel.type)) {
activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
} else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PRESENT.equals(routerModel
.type)) {
activity.overridePendingTransition(R.anim.bottom_in, R.anim.view_stay);
} else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_TRANSLATION.equals(routerModel
.type)) {
activity.overridePendingTransition(R.anim.left_in, R.anim.view_stay);
} else {
activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
}
return true;
}
public boolean back(Context context, String params) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
RouterModel routerModel = parseManager.parseObject(params, RouterModel.class);
int backLength = routerModel.length;
if (backLength >= RouterTracker.length()) {
RouterTracker.clearActivitySurplus(1);
} else {
for (int i = 0; i < backLength; i++) {
RouterTracker.popActivity();
}
}
Object backParams = routerModel.params;
if (backParams instanceof Map) {
if (((Map) backParams).size() > 0) {
Activity activity = RouterTracker.peekActivity();
if (activity instanceof AbstractWeexActivity) {
//设置back参数
((AbstractWeexActivity) activity).setRouterParam(routerModel);
}
}
}
return true;
}
public RouterModel getParams(Context context) {
if (context == null) return null;
Activity activity = RouterTracker.peekActivity();
if (activity instanceof AbstractWeexActivity) {
return ((AbstractWeexActivity) activity).getRouterParam();
}
return null;
}
public static boolean refresh(Context context) {
if (context instanceof AbstractWeexActivity) {
((AbstractWeexActivity) context).refresh();
return true;
}
return false;
}
public static boolean finish(Context context) {
if (context instanceof AbstractWeexActivity) {
((AbstractWeexActivity) context).finish();
return true;
}
return false;
}
public static class Model {
public String to;
public boolean tip;
}
public void dialing(final Context context, String params) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
CallPhoneBean callPhone = null;
callPhone = parseManager.parseObject(params, CallPhoneBean.class);
if (callPhone == null) {
callPhone = new CallPhoneBean();
callPhone.to = "110";
}
if (TextUtils.isEmpty(callPhone.to) || context == null) return;
final String finalPhone = callPhone.to;
if (!callPhone.tip) {
callPhone(String.valueOf(finalPhone), context);
} else {
ModalManager.BmAlert.showAlert(context, null, String.valueOf(finalPhone), "呼叫", new
DialogInterface
.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
callPhone(String.valueOf(finalPhone), context);
dialog.dismiss();
}
}, "取消", null, null, null);
}
}
private void callPhone(String finalPhone, Context context) {
Intent dialIntent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +
finalPhone));
context.startActivity(dialIntent);
}
public void toWebView(Context context, String params) {
if (TextUtils.isEmpty(params)) return;
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
WebViewParamBean webViewParamBean = parseManager.parseObject(params, WebViewParamBean
.class);
String title = webViewParamBean.getTitle();
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addCategory(getWebViewCategory(context));
String type = webViewParamBean.getType() == null ? Constant.ACTIVITIES_ANIMATION
.ANIMATION_PUSH : webViewParamBean.getType();
RouterModel routerModel = new RouterModel(null, type, null, title, webViewParamBean
.isNavShow(),
null);
intent.putExtra(Constant.ROUTERPARAMS, routerModel);
intent.putExtra(Constant.WEBVIEW_PARAMS, webViewParamBean);
if (context instanceof Activity) {
Activity activity = (Activity) context;
activity.startActivity(intent);
if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PUSH.equals(routerModel.type)) {
activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
} else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_PRESENT.equals(routerModel
.type)) {
activity.overridePendingTransition(R.anim.bottom_in, R.anim.view_stay);
} else if (Constant.ACTIVITIES_ANIMATION.ANIMATION_TRANSLATION.equals(routerModel
.type)) {
activity.overridePendingTransition(R.anim.left_in, R.anim.view_stay);
} else {
activity.overridePendingTransition(R.anim.right_in, R.anim.view_stay);
}
}
}
public boolean openBrowser(Context context, String params) {
if (context == null || TextUtils.isEmpty(params)) return false;
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri parse = Uri.parse(params);
intent.setData(parse);
context.startActivity(intent);
return true;
}
}
package com.eros.framework.adapter.ws;
/**
* Created by Carry on 2018/1/5.
*/
public enum BMWSCode {
INVALID_INSTANCEID(4001, "无效的实例"), REPEAT_WEBSOCKET(4002, "重复的ws实例"), MODULE_DESTROY(4003,
"module销毁");
BMWSCode(int code, String reason) {
this.code = code;
this.reason = reason;
}
private int code;
private String reason;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
}
package com.eros.framework.adapter.ws;
import com.taobao.weex.appfram.websocket.IWebSocketAdapter;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.WebSocket;
import okhttp3.WebSocketListener;
import okio.ByteString;
/**
* Created by Carry on 2017/10/27.
*/
public class DefaultWebSocketAdapter {
private static final int INIT = 4;
private static final int DISCONNECTED = 0;
private static final int CONNECTING = 1;
private static final int CONNECTED = 2;
private static final int PINGINTERVAL = 1000;
private static final String TAG = "DefaultWebSocketAdapter";
private int CURRENT_STATUS;
private OkHttpClient mClient;
private Request mRequest;
private String mUrl;
private String mProtocol;
private Lock mLock;
private WebSocket mWebSocket;
private IWebSocketAdapter.EventListener mEventListener;
private WSConfig mConfig;
private boolean mConnected;
public DefaultWebSocketAdapter() {
CURRENT_STATUS = INIT;
mLock = new ReentrantLock();
}
public boolean isConnected() {
return mConnected;
}
public void setConnected(boolean mConnected) {
this.mConnected = mConnected;
}
private WebSocketListener mListener = new WebSocketListener() {
@Override
public void onOpen(WebSocket webSocket, Response response) {
mWebSocket = webSocket;
CURRENT_STATUS = CONNECTED;
if (mEventListener != null) {
mEventListener.onOpen();
}
}
@Override
public void onMessage(WebSocket webSocket, String text) {
if (mEventListener != null) {
mEventListener.onMessage(text);
}
}
@Override
public void onMessage(WebSocket webSocket, ByteString bytes) {
if (mEventListener != null) {
mEventListener.onMessage(bytes.toString());
}
}
@Override
public void onClosing(WebSocket webSocket, int code, String reason) {
super.onClosing(webSocket, code, reason);
}
@Override
public void onClosed(WebSocket webSocket, int code, String reason) {
CURRENT_STATUS = DISCONNECTED;
if (mEventListener != null) {
mEventListener.onClose(code, reason, true);
}
}
@Override
public void onFailure(WebSocket webSocket, Throwable t, Response response) {
CURRENT_STATUS = DISCONNECTED;
if (mEventListener != null) {
mEventListener.onError(response == null ? "" : response.message());
}
}
};
public void connect(String url, String protocol, IWebSocketAdapter.EventListener listener,
WSConfig config) {
this.mUrl = url;
this.mProtocol = protocol;
this.mEventListener = listener;
this.mConfig = config;
if (CURRENT_STATUS == INIT) {
initWebSocket();
}
}
public void reconnect() {
CURRENT_STATUS = INIT;
initWebSocket();
}
public void send(String message) {
boolean isSend = false;
if (mWebSocket != null && CURRENT_STATUS == CONNECTED) {
isSend = mWebSocket.send(message);
}
if (!isSend) {
//发送失败
}
}
public void close(int code, String reason) {
if (mWebSocket != null && CURRENT_STATUS == CONNECTED) {
mWebSocket.close(code, reason);
}
}
public void destroy(int code, String reason) {
if (mWebSocket != null) {
mWebSocket.close(code, reason);
}
mWebSocket = null;
}
private void initWebSocket() {
if (CURRENT_STATUS != INIT) return;
CURRENT_STATUS = CONNECTING;
if (mClient == null) {
if (mConfig != null) {
mClient = new OkHttpClient.Builder().retryOnConnectionFailure(mConfig
.isRetryOnConnectionFailure()).pingInterval(mConfig.getPingInterval(),
TimeUnit.SECONDS).build();
} else {
mClient = new OkHttpClient.Builder().retryOnConnectionFailure(false).build();
}
}
if (mRequest == null) {
mRequest = new Request.Builder().url(mUrl).build();
}
try {
mLock.lockInterruptibly();
try {
mClient.newWebSocket(mRequest, mListener);
} catch (Exception e) {
e.printStackTrace();
} finally {
mLock.unlock();
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
package com.eros.framework.adapter.ws;
/**
* Created by Carry on 2018/3/15.
*/
public class WSConfig {
private boolean retryOnConnectionFailure;
private long pingInterval;
public WSConfig(boolean retryOnConnectionFailure, long pingInterval) {
this.retryOnConnectionFailure = retryOnConnectionFailure;
this.pingInterval = pingInterval;
}
public boolean isRetryOnConnectionFailure() {
return retryOnConnectionFailure;
}
public void setRetryOnConnectionFailure(boolean retryOnConnectionFailure) {
this.retryOnConnectionFailure = retryOnConnectionFailure;
}
public long getPingInterval() {
return pingInterval;
}
public void setPingInterval(long pingInterval) {
this.pingInterval = pingInterval;
}
}
package com.eros.framework.constant;
/**
* Created by Carry on 2017/8/7.
*/
public class WXConstant {
/**
* -------------调试参数-----------------------
**/
public static final int HOT_REFRESH_CONNECT = 0x111;
public static final int HOT_REFRESH_DISCONNECT = HOT_REFRESH_CONNECT + 1;
public static final int HOT_REFRESH_REFRESH = HOT_REFRESH_DISCONNECT + 1;
public static final int HOT_REFRESH_CONNECT_ERROR = HOT_REFRESH_REFRESH + 1;
/**
* ----------router moudle回调js参数名--------
**/
public static final String OPEN_PAGE_SUCCESS = "打开页面成功";
public static final String OPNE_PAGE_FAILED = "打开页面失败";
public static final String BACK_PAGE_SUCCESS = "关闭页面成功";
public static final String BACK_PAGE_FAILED = "关闭页面失败";
public static final String ACTION_WEEX_REFRESH = "ACTION_WEEX_REFRESH";
//拦截器状态发生变化
public static final String ACTION_INTERCEPTOR_SWTICH = "ACTION_INTERCEPTOR_SWTICH";
//初始化激活中介者
public static final String MEDIATOR_INIT = "MEDIATOR_INIT";
//销毁中介者
public static final String MEDIATOR_DESTROY = "MEDIATOR_DESTROY";
//网络状态变化
public static final String ACTION_NETWORK_CHANGED = "ACTION_NETWORK_CHANGED";
//更新包下载完成
public static final String ACTION_BUNDLE_DOWNLOADED = "ACTION_BUNDLE_DOWNLOADED";
//activity入栈广播
public static final String ACTION_ACTIVITY_ATTACH = "ACTION_ACTIVITY_PUSH";
}
package com.eros.framework.debug.ws;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
import com.eros.framework.BMWXEnvironment;
import com.eros.framework.activity.AbstractWeexActivity;
import com.eros.framework.adapter.router.RouterTracker;
import com.eros.framework.adapter.ws.DefaultWebSocketAdapter;
import com.eros.framework.adapter.ws.WSConfig;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXConstant;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.utils.DebugableUtil;
import com.eros.framework.utils.SharePreferenceUtil;
import com.squareup.otto.Subscribe;
import com.taobao.weex.appfram.websocket.IWebSocketAdapter;
import com.taobao.weex.appfram.websocket.WebSocketCloseCodes;
/**
* 开发阶段 连接服务实时刷新页面
* Created by liuyuanxiao on 18/3/15.
*/
public class DebuggerWebSocket {
private DefaultWebSocketAdapter webSocketInstance;
private MyWebSocketListener eventListent;
private static final String TAG = "DebuggerWebSocket";
private Handler mHandler;
private boolean mActice;
private Context context;
public DebuggerWebSocket(Context context) {
webSocketInstance = new DefaultWebSocketAdapter();
eventListent = new MyWebSocketListener();
mHandler = new Handler(Looper.getMainLooper());
this.context = context;
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
}
public void init() {
if (!checkIsOpenHotRefresh()) return;
if (TextUtils.isEmpty(BMWXEnvironment.mPlatformConfig.getUrl().getSocketServer())) return;
connect(BMWXEnvironment.mPlatformConfig.getUrl().getSocketServer());
}
private void connect(String url) {
//connect when interceptor close
if (!Constant.INTERCEPTOR_ACTIVE.equals(SharePreferenceUtil.getInterceptorActive
(BMWXEnvironment.mApplicationContext)
)) {
Log.e(TAG, "connecting");
mActice = true;
//create new instance when webSocketInstance has connected
if (webSocketInstance.isConnected()) {
webSocketInstance = new DefaultWebSocketAdapter();
}
webSocketInstance.connect(url, "", eventListent, new WSConfig(true, 10));
webSocketInstance.setConnected(true);
} else {
close();
mActice = false;
}
}
private class MyWebSocketListener implements IWebSocketAdapter.EventListener {
@Override
public void onOpen() {
Log.e(TAG, "debug sockect has been connected!");
mHandler.post(new Runnable() {
@Override
public void run() {
Toast.makeText(BMWXEnvironment.mApplicationContext, "debug socket connected.",
Toast
.LENGTH_SHORT).show();
}
});
}
@Override
public void onMessage(String data) {
if (!checkIsOpenHotRefresh()) return;
if (Instruction.REFRESH.equals(data)) {
Activity peek = RouterTracker.peekActivity();
if (peek instanceof AbstractWeexActivity) {
((AbstractWeexActivity) peek).refresh();
}
}
}
@Override
public void onClose(int code, String reason, boolean wasClean) {
//重连
mActice = false;
Log.e(TAG, "debug socket disconnected.");
reconnect();
}
@Override
public void onError(String msg) {
//重连
mActice = false;
Log.e(TAG, "debug socket disconnected.");
reconnect();
}
}
private void reconnect() {
if (mActice) return;
if (!checkIsOpenHotRefresh()) {
close();
return;
}
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Toast.makeText(BMWXEnvironment.mApplicationContext, "debug socket try " +
"reconnecting", Toast
.LENGTH_SHORT).show();
webSocketInstance.reconnect();
}
}, 3000);
}
@Subscribe
public void onEvent(Intent intent) {
if (WXConstant.ACTION_INTERCEPTOR_SWTICH.equals(intent.getAction())) {
//interceptor swtich
if (!checkIsOpenHotRefresh()) {
close();
return;
}
if (TextUtils.isEmpty(BMWXEnvironment.mPlatformConfig.getUrl().getSocketServer()))
return;
connect(BMWXEnvironment.mPlatformConfig.getUrl().getSocketServer());
}
}
//检查是否满足开启socket条件
private boolean checkIsOpenHotRefresh() {
//拦截器是否关闭
if (Constant.INTERCEPTOR_ACTIVE.equals(SharePreferenceUtil.getInterceptorActive(context)))
return false;
//热刷新是否开启
if (!SharePreferenceUtil.getHotRefreshSwitch(context)) return false;
//是否是debug模式
if (!DebugableUtil.isDebug()) return false;
return true;
}
public void close() {
if (webSocketInstance != null) {
webSocketInstance.close(WebSocketCloseCodes.CLOSE_NORMAL.getCode(), "debug socket " +
"closed");
}
}
}
package com.eros.framework.debug.ws;
/**
* Created by Carry on 2018/3/15.
*/
public class Instruction {
public static final String REFRESH = "SERVER/JS_BUNDLE_CHANGED";
}
package com.eros.framework.event;
import android.Manifest;
import android.content.Context;
import com.alibaba.fastjson.JSON;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.CommunicationManager;
import com.eros.framework.manager.impl.PermissionManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.AxiosResultBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.utils.PermissionUtils;
import com.eros.wxbase.EventGate;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
import java.util.List;
/**
* Created by liuyuanxiao on 17/12/29.
*/
public class EventCommunication extends EventGate {
private JSCallback mContactsCallBack;
@Override
public void perform(Context context, WeexEventBean weexEventBean, String type) {
if (WXEventCenter.EVENT_COMMUNICATION_SMS.equals(type)) {
sms(weexEventBean.getExpand().toString(), weexEventBean.getJsParams(), context);
} else if (WXEventCenter.EVENT_COMMUNICATION_CONTACTS.equals(type)) {
contacts(context, weexEventBean.getJscallback());
}
}
public void sms(String recipients, String params, final Context context) {
List<String> rec = JSON.parseArray(recipients, String.class);
StringBuilder smsList = new StringBuilder();
for (int i = 0; i < rec.size(); i++) {
if (i > 0) {
smsList.append(",");
}
smsList.append(rec.get(i));
}
CommunicationManager routerManager = ManagerFactory.getManagerService(CommunicationManager.class);
routerManager.sms(smsList.toString(), params, context);
}
public void contacts(final Context context, JSCallback callback) {
if (!PermissionUtils.checkPermission(context, Manifest.permission.READ_CONTACTS)) {
return;
}
mContactsCallBack = callback;
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
CommunicationManager routerManager = ManagerFactory.getManagerService(CommunicationManager.class);
routerManager.contacts(context);
}
@Subscribe
public void contactsResult(AxiosResultBean uploadResultBean) {
if (uploadResultBean != null && mContactsCallBack != null) {
mContactsCallBack.invoke(uploadResultBean);
}
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
}
}
package com.eros.framework.event;
import android.app.Activity;
import android.content.Context;
import com.eros.framework.activity.AbstractWeexActivity;
import com.eros.framework.adapter.router.RouterTracker;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.GlobalEventManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.BaseEventBean;
import com.eros.wxbase.EventGate;
import com.taobao.weex.WXSDKInstance;
/**
* Created by liuyuanxiao on 18/4/9.
*/
public class GlobalEvent extends EventGate {
@Override
public void perform(Context context, BaseEventBean eventBean) {
if (WXEventCenter.EVENT_PUSHMANAGER.equals(eventBean.type)) {
eventPushMessage(context, eventBean);
}
}
private void eventPushMessage(Context context, BaseEventBean eventBean) {
Activity activity = RouterTracker.peekActivity();
if (activity instanceof AbstractWeexActivity) {
WXSDKInstance instance = ((AbstractWeexActivity) activity).getWXSDkInstance();
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
GlobalEventManager.pushMessage(instance, parseManager.parseObject(eventBean.param));
}
}
}
package com.eros.framework.event;
import android.app.Activity;
import android.content.Context;
import com.alibaba.fastjson.JSON;
import com.eros.framework.activity.MainActivity;
import com.eros.framework.adapter.router.RouterTracker;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.StorageManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.TabbarBadgeModule;
import com.eros.framework.model.TabbarWatchBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by liuyuanxiao on 2018/6/21.
*/
public class TabbarEvent extends EventGate {
private JSCallback watchCallback;
private int callBaclKey;
public void perform(Context context, WeexEventBean eventBean, String type) {
if (WXEventCenter.EVENT_TABBAR_SHOWBADGE.equals(type)) {
showBadge(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_HIDBADGE.equals(type)) {
hideBadge(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_OPENPAGE.equals(type)) {
openPage(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_SETTABBAR.equals(type)) {
setTabbar(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_WATCHINDEX.equals(type)) {
watchIndex(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_CLEARTABBARINFO.equals(type)) {
clearTabbarInfo(eventBean);
} else if (WXEventCenter.EVENT_TABBAR_CLEARWATCH.equals(type)) {
clearWatch(eventBean);
}
}
private void showBadge(WeexEventBean weexEventBean) {
Context context = weexEventBean.getContext();
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
TabbarBadgeModule module = parseManager.parseObject(weexEventBean.getJsParams(), TabbarBadgeModule.class);
if (context instanceof MainActivity) {
((MainActivity) context).setBadge(module);
}
}
private void hideBadge(WeexEventBean weexEventBean) {
Context context = weexEventBean.getContext();
String index = JSON.parseObject(weexEventBean.getJsParams()).get("index").toString();
if (context instanceof MainActivity) {
((MainActivity) context).hideBadge(Integer.parseInt(index));
}
}
private void openPage(WeexEventBean weexEventBean) {
Context context = weexEventBean.getContext();
String index = JSON.parseObject(weexEventBean.getJsParams()).get("index").toString();
RouterTracker.clearActivitySurplus(1);
Activity activity = RouterTracker.peekActivity();
if (activity instanceof MainActivity) {
((MainActivity) activity).openPage(Integer.parseInt(index));
}
}
private void setTabbar(WeexEventBean weexEventBean) {
Context context = weexEventBean.getContext();
StorageManager storageManager = ManagerFactory.getManagerService(StorageManager.class);
storageManager.setData(context, Constant.SP.SP_TABBAR_JSON, weexEventBean.getJsParams());
}
private void watchIndex(WeexEventBean weexEventBean) {
Context context = weexEventBean.getContext();
watchCallback = weexEventBean.getJscallback();
this.callBaclKey = Integer.parseInt(weexEventBean.getExpand().toString());
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
}
private void clearWatch(WeexEventBean weexEventBean) {
TabbarWatchBean bean = new TabbarWatchBean(-1);
bean.isClear = true;
bean.setHsCode(Integer.parseInt(weexEventBean.getExpand().toString()));
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(bean);
}
private void clearTabbarInfo(WeexEventBean weexEventBean) {
weexEventBean.setJsParams("");
setTabbar(weexEventBean);
}
@Subscribe
public void watchIndex(TabbarWatchBean bean) {
if (watchCallback != null) {
if (bean.index != -1 && !bean.isClear) {
watchCallback.invokeAndKeepAlive(bean.index);
} else {
if (bean.hsCode == callBaclKey) {
watchCallback = null;
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
}
}
}
}
}
package com.eros.framework.event;
import android.content.Context;
import android.content.Intent;
import com.eros.framework.BMWXApplication;
import com.eros.framework.constant.WXConstant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.UpdateOptionBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.update.VersionChecker;
import com.eros.framework.utils.JsPoster;
import com.eros.wxbase.EventGate;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
public class UpdateJsBundleEvent extends EventGate {
private JSCallback mCallback;
@Override
public void perform(Context context, WeexEventBean weexEventBean, String type) {
if (WXEventCenter.EVENT_DOWNLOAD_BUNDLE.equals(type)) {
downloadBundle(weexEventBean);
}
if (WXEventCenter.EVENT_UPDATE_BUNDLE.equals(type)) {
update();
}
}
private void update() {
VersionChecker versionChecker = BMWXApplication.getWXApplication().getVersionChecker();
if (versionChecker != null) {
versionChecker.restartApp();
}
}
private void downloadBundle(WeexEventBean weexEventBean) {
if (weexEventBean == null) return;
UpdateOptionBean updateOptionBean = ManagerFactory.getManagerService(ParseManager.class)
.parseObject(weexEventBean.getJsParams(), UpdateOptionBean.class);
if (updateOptionBean == null) return;
VersionChecker versionChecker = BMWXApplication.getWXApplication().getVersionChecker();
if (versionChecker != null) {
this.mCallback = weexEventBean.getJscallback();
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
versionChecker.checkVersion(updateOptionBean.getUrl(), updateOptionBean.isDiff());
}
}
@Subscribe
public void onUpdateResult(Intent intent) {
if (WXConstant.ACTION_BUNDLE_DOWNLOADED.equals(intent.getAction())) {
int code = intent.getIntExtra("code", -1);
String msg = intent.getStringExtra("msg");
if (code == 0) {
JsPoster.postSuccess(null, msg, mCallback);
} else {
JsPoster.postFailed(msg, mCallback);
}
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
}
}
}
package com.eros.framework.event.browse;
import android.content.Context;
import android.content.Intent;
import com.eros.framework.activity.BrowseImgActivity;
import com.eros.framework.constant.Constant;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.BroeserImgModuleBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
/**
* Created by Carry on 2017/8/21.
*/
public class EventBrowse extends EventGate{
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
open(weexEventBean.getJsParams(),context);
}
public void open(String params, Context context) {
BroeserImgModuleBean bean = ManagerFactory.getManagerService(ParseManager.class)
.parseObject(params, BroeserImgModuleBean.class);
if (bean == null || bean.getImages() == null || bean.getImages().size() == 0) return;
Intent intent = new Intent().putExtra(Constant.BROWSE_EVENT.BROWSE_IMG_BEAN, bean)
.setClass(context, BrowseImgActivity.class);
context.startActivity(intent);
}
}
package com.eros.framework.event.camera;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.utils.JsPoster;
import com.eros.framework.utils.PermissionUtils;
import com.eros.framework.utils.TextUtil;
import com.eros.wxbase.EventGate;
import com.google.zxing.integration.android.IntentIntegrator;
import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import com.eros.framework.R;
import com.eros.framework.manager.impl.CameraManager;
import com.eros.framework.manager.impl.ImageManager;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.PersistentManager;
import com.eros.framework.model.CameraResultBean;
import com.eros.framework.model.UploadImageBean;
import com.eros.framework.model.UploadResultBean;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by Carry on 2017/8/16.
*/
public class EventCamera extends EventGate {
private JSCallback mUploadAvatar, mScanCallback, mScreenShotCallback;
private Context mUploadContext;
@Override
public void perform(Context context, WeexEventBean weexEventBean, String type) {
String params = weexEventBean.getJsParams();
if (WXEventCenter.EVENT_CAMERA_UPLOADIMAGE.equals(type)) {
uploadImage(params, context, weexEventBean.getJscallback());
} else if (WXEventCenter.EVENT_CAMERA_PATH.equals(type)) {
openCamera(params, context, weexEventBean.getJscallback());
} else if (WXEventCenter.EVENT_CAMERA.equals(type)) {
scan(weexEventBean.getJscallback(), context);
}
}
public void scan(JSCallback jscallback, Context context) {
mScanCallback = jscallback;
CameraManager cameraManager = ManagerFactory.getManagerService(CameraManager.class);
CameraManager.ScanConfig.ConfigBuilder builder = new CameraManager.ScanConfig
.ConfigBuilder();
builder.setBeepEnable(true).setCodeFormat(IntentIntegrator.ALL_CODE_TYPES).setContext(
(Activity) context).setPrompt(context.getResources().getString(R.string
.capture_qrcode_prompt));
cameraManager.scanCode(builder.build());
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
}
@Subscribe
public void OnScanResult(CameraResultBean bean) {
if (this.mScanCallback == null || bean == null) return;
if (TextUtils.isEmpty(bean.text)) {
JsPoster.postFailed(mScanCallback);
} else {
JsPoster.postSuccess(bean.text, mScanCallback);
}
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
}
public void uploadImage(String json, Context context, JSCallback jsCallback) {
if (!PermissionUtils.checkPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
return;
}
mUploadAvatar = jsCallback;
mUploadContext = context;
UploadImageBean bean = ManagerFactory.getManagerService(ParseManager.class).parseObject
(json, UploadImageBean.class);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
ImageManager imageManager = ManagerFactory.getManagerService(ImageManager.class);
if (bean.allowCrop && bean.maxCount == 1) {
//上传头像
imageManager.pickAvatar(context, bean, Constant.ImageConstants.IMAGE_PICKER);
} else if (bean.maxCount > 0) {
imageManager.pickPhoto(context, bean, Constant.ImageConstants.IMAGE_PICKER);
}
}
public void openCamera(String json, Context context, JSCallback jsCallback) {
if (!PermissionUtils.checkPermission(context, Manifest.permission.CAMERA)) {
return;
}
mUploadAvatar = jsCallback;
mUploadContext = context;
UploadImageBean bean = ManagerFactory.getManagerService(ParseManager.class).parseObject
(json, UploadImageBean.class);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
ImageManager imageManager = ManagerFactory.getManagerService(ImageManager.class);
imageManager.openCamera(context, bean);
}
@Subscribe
public void OnUploadResult(UploadResultBean uploadResultBean) {
if (uploadResultBean != null && mUploadAvatar != null) {
JsPoster.postSuccess(TextUtil.conversionObject(uploadResultBean.data), mUploadAvatar);
}
if (uploadResultBean != null && mScreenShotCallback != null) {
JsPoster.postSuccess(uploadResultBean.data, mScreenShotCallback);
}
ModalManager.BmLoading.dismissLoading(mUploadContext);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
mScreenShotCallback = null;
mUploadAvatar = null;
ManagerFactory.getManagerService(PersistentManager.class).deleteCacheData(Constant
.ImageConstants.UPLOAD_IMAGE_BEAN);
}
}
package com.eros.framework.event.camera;
import android.Manifest;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import com.eros.framework.constant.Constant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ImageManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.manager.impl.PersistentManager;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.eros.framework.model.ScanImageBean;
import com.eros.framework.model.UploadImageBean;
import com.eros.framework.model.UploadResultBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.utils.JsPoster;
import com.eros.framework.utils.PermissionUtils;
import com.eros.wxbase.EventGate;
import com.google.zxing.BinaryBitmap;
import com.google.zxing.ChecksumException;
import com.google.zxing.FormatException;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.NotFoundException;
import com.google.zxing.RGBLuminanceSource;
import com.google.zxing.Reader;
import com.google.zxing.common.HybridBinarizer;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by liuyuanxiao on 18/1/4.
*/
public class EventImage extends EventGate {
private JSCallback mPickCallback;
@Override
public void perform(Context context, WeexEventBean weexEventBean, String type) {
String params = weexEventBean.getJsParams();
if (WXEventCenter.EVENT_IMAGE_PICK.equals(type)) {
pick(weexEventBean.getJsParams(), context, weexEventBean.getJscallback());
} else if (WXEventCenter.EVENT_IMAGE_SCAN.equals(type)) {
scan(params, context, weexEventBean.getJscallback());
}
}
public void pick(String json, Context context, JSCallback jsCallback) {
//Manifest.permission.READ_EXTERNAL_STORAGE 权限申请
if (!PermissionUtils.checkPermission(context, Manifest.permission.READ_EXTERNAL_STORAGE)) {
return;
}
mPickCallback = jsCallback;
UploadImageBean bean = ManagerFactory.getManagerService(ParseManager.class).parseObject
(json, UploadImageBean.class);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
ImageManager imageManager = ManagerFactory.getManagerService(ImageManager.class);
if (bean.allowCrop && bean.maxCount == 1) {
//上传头像
imageManager.pickAvatar(context, bean, Constant.ImageConstants.IMAGE_NOT_UPLOADER_PICKER);
} else if (bean.maxCount > 0) {
imageManager.pickPhoto(context, bean, Constant.ImageConstants.IMAGE_NOT_UPLOADER_PICKER);
}
}
public void scan(String json, Context context, JSCallback jsCallback) {
ScanImageBean bean = ManagerFactory.getManagerService(ParseManager.class).parseObject
(json, ScanImageBean.class);
Bitmap bitmap;
String path = bean.path;
bitmap = BitmapFactory.decodeFile(path);
// 获取bitmap的宽高,像素矩阵
int width = bitmap.getWidth();
int height = bitmap.getHeight();
int[] pixels = new int[width * height];
bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
Reader reader = new MultiFormatReader();
String result = "";
try {
result = reader.decode(binaryBitmap).getText();
JsPoster.postSuccess(result, jsCallback);
return;
} catch (NotFoundException e) {
e.printStackTrace();
} catch (ChecksumException e) {
e.printStackTrace();
} catch (FormatException e) {
e.printStackTrace();
}
JsPoster.postFailed(jsCallback);
}
@Subscribe
public void OnUploadResult(UploadResultBean uploadResultBean) {
if (uploadResultBean != null && mPickCallback != null) {
JsPoster.postSuccess(uploadResultBean.data, mPickCallback);
}
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().unregister(this);
mPickCallback = null;
ManagerFactory.getManagerService(PersistentManager.class).deleteCacheData(Constant
.ImageConstants.UPLOAD_IMAGE_BEAN);
}
}
package com.eros.framework.event.http.callback;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONException;
import com.eros.framework.http.okhttp.callback.Callback;
import com.eros.framework.model.AxiosResultBean;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Response;
/**
* Created by Carry on 2018/5/28.
*/
public abstract class AxiosResponseCallback extends Callback<AxiosResultBean> {
@Override
public AxiosResultBean parseNetworkResponse(Response response, int id) throws Exception {
Map<String, List<String>> responseHeader = new HashMap<>();
for (Map.Entry<String, List<String>> entry : response.headers().toMultimap()
.entrySet()) {
responseHeader.put(entry.getKey(), entry.getValue());
}
try {
return new AxiosResultBean(response.code(), "", JSON.parse(response.body().string()),
responseHeader);
} catch (JSONException e) {
e.printStackTrace();
return new AxiosResultBean(-1, "json解析错误", null, responseHeader);
}
}
}
package com.eros.framework.event.mediator;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import com.eros.framework.constant.WXConstant;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.squareup.otto.Subscribe;
import com.taobao.weex.bridge.JSCallback;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* Created by Carry on 2017/8/7. eventCenter between native and js
*/
public class EventCenter {
private static EventCenter mInstance = new EventCenter();
private Map<String, List<Event>> mEvents;
private HashSet<String> mWxInstances;
public static EventCenter getInstance() {
return mInstance;
}
private EventCenter() {
}
public void init() {
mEvents = new HashMap<String, List<Event>>();
mWxInstances = new HashSet<>();
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().register(this);
}
@Subscribe
public void on(Intent intent) {
if (WXEventCenter.EVENT_JS_ON.equals(intent.getAction())) {
Event event = (Event) intent.getSerializableExtra("data");
List<Event> list = mEvents.get(event.getType());
if (list == null) {
list = new ArrayList<>();
}
list.add(event);
mEvents.put(event.getType(), list);
if (!TextUtils.isEmpty(event.getInstanceId())) {
mWxInstances.add(event.getInstanceId());
}
}
}
@Subscribe
public void emit(Intent intent) {
if (WXEventCenter.EVENT_JS_EMIT.equals(intent.getAction())) {
Log.e("emit", "==========");
Emit emit = (Emit) intent.getSerializableExtra("data");
List<Event> list = mEvents.get(emit.getType());
if (list != null) {
Iterator<Event> iterator = list.iterator();
while (iterator.hasNext()) {
Event event = iterator.next();
if (event.getJsCallback() != null && mWxInstances.contains(event
.getInstanceId())) {
Log.e("test", "emit>>>>>>>" + emit.getParams());
event.getJsCallback().invokeAndKeepAlive(emit.getParams());
if (event.isOnce()) {
iterator.remove();
}
} else {
iterator.remove();
}
}
}
}
}
@Subscribe
public void off(Intent intent) {
if ( WXEventCenter.EVENT_JS_OFF.equals(intent.getAction())) {
Off off = (Off) intent.getSerializableExtra("data");
mEvents.remove(off.getType());
if (off.getCallback() != null) {
off.getCallback().invoke(null);
}
}
}
@Subscribe
public void offall(Intent intent) {
if ( WXEventCenter.EVENT_JS_OFFALL.equals(intent.getAction())) {
mEvents.clear();
}
}
@Subscribe
public void destoryInstance(Intent intent) {
if ( WXEventCenter.EVENT_INSTANCE_DESTORY.equals(intent.getAction())) {
String destoryInstanceId = intent.getStringExtra("data");
if (mWxInstances.contains(destoryInstanceId)) {
mWxInstances.remove(destoryInstanceId);
}
}
}
public static class Event implements Serializable {
private String instanceId;
private boolean once;
private JSCallback jsCallback;
private String bundle_url;
private String type;
public Event(String instanceId, boolean once, JSCallback jsCallback, String bundle_url,
String type) {
this.instanceId = instanceId;
this.once = once;
this.jsCallback = jsCallback;
this.bundle_url = bundle_url;
this.type = type;
}
public String getBundle_url() {
return bundle_url;
}
public void setBundle_url(String bundle_url) {
this.bundle_url = bundle_url;
}
public Event() {
}
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
public boolean isOnce() {
return once;
}
public void setOnce(boolean once) {
this.once = once;
}
public JSCallback getJsCallback() {
return jsCallback;
}
public void setJsCallback(JSCallback jsCallback) {
this.jsCallback = jsCallback;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
public static class Emit implements Serializable {
private String type;
private Object params;
public Emit(String type, Object params) {
this.type = type;
this.params = params;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object getParams() {
return params;
}
public void setParams(Object params) {
this.params = params;
}
}
public static class Off implements Serializable {
private String type;
private JSCallback callback;
public Off(String type, JSCallback callback) {
this.type = type;
this.callback = callback;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public JSCallback getCallback() {
return callback;
}
public void setCallback(JSCallback callback) {
this.callback = callback;
}
}
}
package com.eros.framework.event.modal;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import com.eros.framework.R;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.ModalBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by Carry on 2017/8/23.
*/
public class EventAlert extends EventGate {
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
String params = weexEventBean.getJsParams();
if (TextUtils.isEmpty(params)) return;
alert(params, weexEventBean.getJscallback(), context);
}
public void alert(String options, final JSCallback callback, Context Context) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
ModalBean bean = parseManager.parseObject(options, ModalBean.class);
String okTitle = bean.getOkTitle();
if (TextUtils.isEmpty(okTitle)) {
okTitle = Context.getResources().getString(R.string.str_ensure);
}
ModalManager.BmAlert.showAlert(Context, bean.getTitle(), bean
.getMessage(), okTitle, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (callback != null) {
callback.invoke(null);
}
}
}, null, null, bean.getTitleAlign(), bean.getMessageAlign());
}
}
package com.eros.framework.event.modal;
import android.content.Context;
import android.content.DialogInterface;
import android.text.TextUtils;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.ModalBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
import com.taobao.weex.bridge.JSCallback;
import java.util.ArrayList;
/**
* Created by Carry on 2017/8/23.
*/
public class EventConfirm extends EventGate {
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
String params = weexEventBean.getJsParams();
if (TextUtils.isEmpty(params)) return;
ArrayList<JSCallback> callbacks = weexEventBean.getCallbacks();
if (callbacks == null && callbacks.size() < 2) return;
confirm(params, callbacks.get(0), callbacks.get(1), context);
}
public void confirm(String options, final JSCallback cancel, final JSCallback ok, Context context) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
ModalBean bean = parseManager.parseObject(options, ModalBean.class);
ModalManager.BmAlert.showAlert(context, bean.getTitle(), bean
.getMessage(), bean.getOkTitle(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (ok != null) {
ok.invoke(null);
}
}
}, bean.getCancelTitle(), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (cancel != null) {
cancel.invoke(null);
}
}
}, bean.getTitleAlign(), bean.getMessageAlign());
}
}
package com.eros.framework.event.modal;
import android.content.Context;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by Carry on 2017/9/21.
*/
public class EventDismissLoading extends EventGate{
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
dismiss(context, weexEventBean.getJscallback());
}
public void dismiss(Context context, JSCallback jscallback) {
ModalManager.BmLoading.dismissLoading(context);
if (jscallback != null) {
jscallback.invoke(null);
}
}
}
package com.eros.framework.event.modal;
import android.content.Context;
import android.text.TextUtils;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.ModalBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by Carry on 2017/8/23.
*/
public class EventShowLoading extends EventGate {
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
String params = weexEventBean.getJsParams();
if (TextUtils.isEmpty(params)) return;
JSCallback modal_showloading_callback = weexEventBean.getJscallback();
showLoading(params, modal_showloading_callback, context);
}
public void showLoading(String options, JSCallback callback, Context Context) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
ModalBean bean = parseManager.parseObject(options, ModalBean.class);
ModalManager.BmLoading.showLoading(Context, bean.getMessage(), false);
if (callback != null) {
callback.invoke(null);
}
}
}
package com.eros.framework.event.modal;
import android.content.Context;
import android.text.TextUtils;
import android.widget.Toast;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.ModalManager;
import com.eros.framework.manager.impl.ParseManager;
import com.eros.framework.model.ModalBean;
import com.eros.framework.model.WeexEventBean;
import com.eros.wxbase.EventGate;
/**
* Created by Carry on 2017/8/23.
*/
public class EventToast extends EventGate {
@Override
public void perform(Context context, WeexEventBean weexEventBean) {
String params = weexEventBean.getJsParams();
if (TextUtils.isEmpty(params)) return;
toast(params, context);
}
public void toast(String options, Context Context) {
ParseManager parseManager = ManagerFactory.getManagerService(ParseManager.class);
ModalBean bean = parseManager.parseObject(options, ModalBean.class);
ModalManager.BmToast.toast(Context, bean.getMessage(), bean
.getDuration() == 0 ? Toast.LENGTH_SHORT : bean.getDuration());
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment