Author SHA1 Message Date
xiaoyan159 480ff37026 fix: 修改首次安装时,因为定位初始化问题程序崩溃的问题 2023-10-11 15:39:56 +08:00
xiaoyan159 f385fb8e6c fix: 修改bug 2023-09-27 09:28:27 +08:00
xiaoyan159 c40ccaece4 fix: POI录像和道路任务保存网络时增加geo参数上报 2023-09-26 14:51:46 +08:00
xiaoyan159 8a77853888 fix: 修改poi录像和道路任务保存数据时记录位置信息 2023-09-26 13:48:20 +08:00
xiaoyan159 e0618ee747 fix: 修改地址为开发环境-心榕自测 2023-09-25 15:16:20 +08:00
xiaoyan159 c80562f731 fix: 23Q4SP2功能开发完成 2023-09-21 14:56:59 +08:00
xiaoyan159 85f76408ea fix: POIEntity增加type类型注释 2023-08-14 17:48:46 +08:00
xiaoyan159 981ed24a27 feat: 修改交通枢纽、建筑物内部等数据类型为11/12/13 2023-08-14 17:47:34 +08:00
xiaoyan159 1c0e462ea9 fix: 修改退出登录后定位信息不显示的问题,修改自动捕捉结束逻辑 2023-08-14 16:57:28 +08:00
xiaoyan159 dc41a9bba8 fix: 修改bug 2023-07-28 17:34:00 +08:00
xiaoyan159 d6b917fb72 fix: 修改误删照片目录的问题 2023-07-21 15:52:48 +08:00
xiaoyan159 4ff0f5cd2a fix: 修改bug 2023-07-20 16:14:01 +08:00
xiaoyan159 a039b44271 fix: 修改gradle依赖 2023-07-18 16:01:50 +08:00
xiaoyan159 aff6dea97d fix: 修改数据库版本升级错误的问题 2023-07-18 12:37:46 +08:00
xiaoyan159 f4ce86f37b fix: 修改因过滤损坏照片导致附加txt和json文件被过滤的问题 2023-07-13 20:43:41 +08:00
xiaoyan159 b9bb75063b feat: SP7功能开发 2023-07-13 16:14:25 +08:00
xiaoyan159 b329f9dc54 fix: 修改了拍摄间隔选择失效的问题 2023-06-19 16:50:26 +08:00
xiaoyan159 b8719ccfaa fix: 自动捕捉不强制要求横向拍摄 2023-06-19 15:08:24 +08:00
xiaoyan159 5853e3f940 fix: 修改zip包中ocr文件后缀,修改竖向拍摄检查,修改速度检查原则(卫星) 2023-06-19 14:42:15 +08:00
xiaoyan159 82605b895e fix: 修改ocr识别结果的文件名 2023-06-19 11:14:11 +08:00
xiaoyan159 81ec86bb04 fix: 修改部分情况下分包数据与总数据大小不一致的情况 2023-06-05 13:56:40 +08:00
xiaoyan159 4ea20cb0cf fix: 修复分包上传时,分包太多,提示entity too large的问题 2023-05-22 15:21:56 +08:00
xiaoyan159 7c6ac78f53 fix: 增加辅助审查打分功能 2023-05-19 09:53:55 +08:00
xiaoyan159 edd91c8ad3 Merge branch 'dev_track' into dev_ocr 2023-05-17 17:25:25 +08:00
xiaoyan159 f28f9031a5 fix: 修改手动匹配轨迹时选择日期没有轨迹时,程序一直loading 的问题 2023-05-17 17:24:52 +08:00
xiaoyan159 53ce6e1c2e feat: POI录像增加辅助审核得分功能 2023-05-17 16:01:24 +08:00
xiaoyan159 8a3ccbd0f5 fix: 合并主线代码 2023-05-16 11:18:50 +08:00
xiaoyan159 038947fc42 fix: 更新忽略文件规则 2023-05-16 11:14:33 +08:00
xiaoyan159 5a1b0edd82 fix: 增加轨迹图片恢复、缓存删除等功能 2023-05-12 18:26:52 +08:00
xiaoyan159 9d8185a958 fix: 增加根据轨迹复制图片的功能 2023-05-10 14:40:04 +08:00
xiaoyan159 eb7adc487d fix: 修改特殊类型相关配置 2023-05-09 10:24:06 +08:00
xiaoyan159 f4685039e4 fix: 合并主线代码 2023-04-19 15:23:31 +08:00
xiaoyan159 ac2beb5370 fix: 修改停车检测根据卫星颗数导致隧道内不拍摄的问题,修改多线数据程序闪退的问题 2023-04-19 15:01:25 +08:00
xiaoyan159 6fcb464311 fix: 增加面状任务完成控制 2023-04-18 18:28:37 +08:00
xiaoyan159 26f6627be0 fix: 修改ocr申请权限错误的问题 2023-04-18 13:49:12 +08:00
xiaoyan159 6a5b6a5f19 feat: 线型手动拍摄增加照片检查功能 2023-04-06 17:08:26 +08:00
xiaoyan159 477f4981e8 fix: 修改版本号和请求地址 2023-04-03 10:27:45 +08:00
xiaoyan159 ae2f4705d9 fix: 修改版本号 2023-03-31 13:46:12 +08:00
xiaoyan159 34316889ce fix: 合并master分支修改内容 2023-03-28 14:06:00 +08:00
xiaoyan159 94c9253372 fix: 修改版本号 2023-03-28 13:52:58 +08:00
xiaoyan159 070d196f45 fix: 修改某些情况下照片不存在数据上传的问题 2023-03-28 11:15:34 +08:00
xiaoyan159 61c1c53696 fix: 修改某些情况下照片损坏的问题,修改线任务照片不存在时阻止用户上传 2023-03-28 10:57:38 +08:00
xiaoyan159 3b1624f49a fix: 修改辅助图片判断 2023-03-27 14:07:11 +08:00
xiaoyan159 8755b70705 fix: 解决冲突 2023-03-23 15:59:28 +08:00
xiaoyan159 ba57256471 fix: 解决和master的冲突 2023-03-23 15:55:51 +08:00
xiaoyan159 6399dc3abc fix: 修改XLog初始化问题 2023-03-23 15:49:18 +08:00
xiaoyan159 12b870ea79 feat: 增加ocr文字识别功能 2023-03-23 15:48:24 +08:00
xiaoyan159 a66647d735 fix: 修改版本号 2023-03-20 10:20:45 +08:00
xiaoyan159 4317bc87d8 fix: 修改版本号 2023-03-17 16:24:33 +08:00
xiaoyan159 37e4c59041 feat: 增加道路任务拍摄时的距离判定,当连续5个点距离小于2米时暂停拍摄 2023-03-17 16:14:10 +08:00
xiaoyan159 506299b3a3 feat: 增加绘制辅助线功能 2023-03-17 13:55:52 +08:00
xiaoyan159 c5e4a216bc feat: 增加道路和POI录像任务绘制辅助线的功能 2023-03-07 09:53:57 +08:00
xiaoyan159 baebb9e5cf feat: 增加批量上传及删除的打点记录 2023-03-02 18:07:23 +08:00
xiaoyan159 2b6163fe45 fix: 批量提交数据增加进度及错误原因展示 2023-03-02 16:45:17 +08:00
xiaoyan159 96bb6a35e6 feat: 增加POI录像自动捕捉功能 2023-02-22 14:26:58 +08:00
xiaoyan159 54358b2ef0 fix: 增加对话框依赖为DialogX 2023-02-21 15:11:12 +08:00
xiaoyan159 88dd96f572 fix: 修改了拍照界面出现的定位不存在导致的程序崩溃的问题 2023-02-21 11:11:18 +08:00
xiaoyan159 f7943db1c0 fix: 增加全局异常记录 2023-02-17 13:33:55 +08:00
xiaoyan159 11289fb08a fix: 修改记录频繁请求的问题 2023-02-17 11:41:20 +08:00
xiaoyan159 3e6f8997fb fix: 修改app频繁在已提交界面调用数据统计接口的问题 2023-02-16 10:37:55 +08:00
xiaoyan159 2126781230 交通枢纽增加上客、落客区 2023-02-14 18:29:05 +08:00
xiaoyan159 12b7d95982 fix: 合并代码 2023-02-14 16:49:28 +08:00
xiaoyan159 bee9fb9d59 fix: 修改面状任务无法结束采集的问题,修改部分机型下拍照方向错误的问题 2023-02-06 17:40:48 +08:00
xiaoyan159 b2e5d6dd87 fix: 修改拍照后loading的问题 2023-02-03 13:54:30 +08:00
xiaoyan159 3f8ee91230 fix: 修改点数据照片坐标错误问题,修改面数据点击完成采集功能 2023-02-03 13:44:11 +08:00
xiaoyan159 b6a6c85da7 fix: 修改版本号 2023-02-02 13:52:05 +08:00
xiaoyan159 8392b7ba7e fix: 修改版本号 2023-01-31 10:11:53 +08:00
xiaoyan159 43960c0740 fix: 合并冲突 2023-01-29 18:14:44 +08:00
xiaoyan159 c4d927d40b fix: 修改导航模式为普通模式 2023-01-29 15:14:36 +08:00
xiaoyan159 d5090bcd3d fix: 修改导航功能横竖屏切换 2023-01-29 15:07:05 +08:00
xiaoyan159 3c24038fd2 修改拍照界面 2023-01-12 10:27:50 +08:00
xiaoyan159 bd22ede488 fix: 修改拍摄和自动捕捉界面主定位模式切换 2023-01-10 17:35:29 +08:00
xiaoyan159 8b8866d3fb 修改导航界面为横向 2023-01-09 14:54:27 +08:00
xiaoyan159 f8ad72023f fix: 修改第一次使用时gps无信号程序崩溃的问题 2023-01-06 18:02:53 +08:00
xiaoyan159 7fb65d4a64 fix: 合并代码 2022-12-22 00:09:30 +08:00
xiaoyan159 9063a5a99e Merge branch 'dev_current_prod_20221207' 2022-12-19 16:38:16 +08:00
xiaoyan159 862e828c46 fix: 修改导航偏航提示 2022-12-19 10:20:23 +08:00
xiaoyan159 2ec9f49272 fix: 修改依赖项 2022-12-16 15:32:43 +08:00
xiaoyan159 390d3d435c fix: 修改定位方式 2022-12-14 10:50:55 +08:00
xiaoyan159 f04b2a5892 fix: 修改旧定位点获取不到的问题 2022-12-13 11:29:47 +08:00
xiaoyan159 7299e1e993 feat: 增加原生定位 2022-12-12 14:57:47 +08:00
xiaoyan159 c56322abb9 feat: 增加交通枢纽、区域设施和建筑物内部POI类型 2022-12-09 15:45:28 +08:00
147 changed files with 21831 additions and 2134 deletions
+3 -1
View File
@@ -13,4 +13,6 @@
/captures /captures
.externalNativeBuild .externalNativeBuild
.cxx .cxx
app/release/ app/release/
app/build/
ocr/build/
+30
View File
@@ -56,5 +56,35 @@
<option name="name" value="maven5" /> <option name="name" value="maven5" />
<option name="url" value="https://maven.google.com/" /> <option name="url" value="https://maven.google.com/" />
</remote-repository> </remote-repository>
<remote-repository>
<option name="id" value="maven4" />
<option name="name" value="maven4" />
<option name="url" value="https://maven.aliyun.com/repository/jcenter" />
</remote-repository>
<remote-repository>
<option name="id" value="maven3" />
<option name="name" value="maven3" />
<option name="url" value="https://maven.aliyun.com/repository/public" />
</remote-repository>
<remote-repository>
<option name="id" value="maven" />
<option name="name" value="maven" />
<option name="url" value="https://maven.aliyun.com/repository/google" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://maven.aliyun.com/repository/gradle-plugin" />
</remote-repository>
<remote-repository>
<option name="id" value="maven2" />
<option name="name" value="maven2" />
<option name="url" value="https://repo.spring.io/libs-release/" />
</remote-repository>
<remote-repository>
<option name="id" value="maven7" />
<option name="name" value="maven7" />
<option name="url" value="https://maven.aliyun.com/nexus/content/groups/public/" />
</remote-repository>
</component> </component>
</project> </project>
+56 -18
View File
@@ -1,20 +1,50 @@
apply plugin: 'com.android.application' plugins {
apply plugin: 'kotlin-android' id 'com.android.application'
apply plugin: 'kotlin-kapt' id 'kotlin-android'
apply plugin: 'kotlin-android-extensions' id 'kotlin-kapt'
id 'org.sonarqube'
}
sonarqube {
properties {
//Sonar服务器地址
property "sonar.host.url", "http://10.130.14.162:9000/"
//Token模式
// property "sonar.login","TRD2022"
//账号密码模式
property "sonar.login","TRD2022"
property "sonar.password","TRD2022"
property "sonar.sourceEncoding", "UTF-8"
property "sonar.projectKey", "Android_DuoApp"
property "sonar.projectName", project.name
//需要扫描的上传检测代码的模块,可以选择也可以配置哪一些需要或者不需要上传的模块(这里指APP模块下面的java包里面的全部)
property "sonar.sources", "src/main/java"
property "sonar.projectVersion", project.version
}
}
//apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
//apply plugin: 'kotlin-kapt'
//apply plugin: 'kotlin-android-extensions'
android { android {
compileSdkVersion 30 compileSdkVersion 31
buildToolsVersion '29.0.2' // buildToolsVersion '29.0.2'
//ndkVersion '23.0.7123448' //ndkVersion '23.0.7123448'
defaultConfig { defaultConfig {
applicationId "com.navinfo.outdoor" applicationId "com.navinfo.outdoor"
minSdkVersion 23 minSdkVersion 24
targetSdkVersion 30 targetSdkVersion 30
versionCode 43 versionCode 117
versionName "8.230130" versionName "8.231011-金山云测试版"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
// 设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
}
} }
lintOptions { lintOptions {
checkReleaseBuilds false checkReleaseBuilds false
@@ -36,8 +66,8 @@ android {
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
ndkVersion '21.3.6528147' ndkVersion '21.3.6528147'
packagingOptions { packagingOptions {
@@ -48,6 +78,9 @@ android {
pickFirst 'lib/x86_64/libc++_shared.so' pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so' pickFirst 'lib/armeabi-v7a/libc++_shared.so'
} }
buildFeatures {
viewBinding true
}
} }
//efs { //efs {
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启 // //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
@@ -66,17 +99,19 @@ android {
//} //}
dependencies { dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"]) implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0' implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.navigation:navigation-fragment:2.1.0' implementation 'androidx.navigation:navigation-fragment:2.1.0'
implementation 'androidx.navigation:navigation-ui:2.1.0' implementation 'androidx.navigation:navigation-ui:2.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation project(path: ':ocr')
testImplementation 'junit:junit:4.12' testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1' androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation "androidx.lifecycle:lifecycle-common:2.4.1" implementation "androidx.lifecycle:lifecycle-common:2.4.1"
implementation "androidx.lifecycle:lifecycle-process:2.4.1"
//友盟自动检测bug //友盟自动检测bug
implementation 'com.umeng.umsdk:apm:1.2.0' implementation 'com.umeng.umsdk:apm:1.2.0'
//友盟基础库依赖(必须) //友盟基础库依赖(必须)
@@ -90,7 +125,6 @@ dependencies {
implementation 'com.gyf.immersionbar:immersionbar:3.0.0' implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0' implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0'
//网络框架 //网络框架
implementation 'com.lzy.net:okgo:3.0.4' implementation 'com.lzy.net:okgo:3.0.4'
implementation 'com.lzy.net:okrx2:2.0.2' implementation 'com.lzy.net:okrx2:2.0.2'
@@ -117,6 +151,8 @@ dependencies {
implementation 'com.github.bumptech.glide:glide:4.8.0' implementation 'com.github.bumptech.glide:glide:4.8.0'
//弹窗 https://github.com/kongzue/DialogV3 //弹窗 https://github.com/kongzue/DialogV3
implementation 'com.kongzue.dialog_v3x:dialog:3.2.4' implementation 'com.kongzue.dialog_v3x:dialog:3.2.4'
implementation "com.kongzue.dialogx:DialogX:0.0.47"
implementation "com.kongzue.dialogx.style:DialogXMIUIStyle:0.0.47"
//xRecyclerview下拉刷新控件 //xRecyclerview下拉刷新控件
implementation project(':xrecyclerview') implementation project(':xrecyclerview')
//拍照功能 https://github.com/natario1/CameraView //拍照功能 https://github.com/natario1/CameraView
@@ -139,7 +175,7 @@ dependencies {
// implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9' // implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9'
// 权限请求框架:https://github.com/getActivity/XXPermissions // 权限请求框架:https://github.com/getActivity/XXPermissions
implementation 'com.github.getActivity:XXPermissions:11.6' implementation 'com.github.getActivity:XXPermissions:18.0'
//room 数据库 //room 数据库
def room_version = "2.2.0-alpha01" def room_version = "2.2.0-alpha01"
@@ -159,8 +195,8 @@ dependencies {
implementation 'cn.jzvd:jiaozivideoplayer:7.4.2' implementation 'cn.jzvd:jiaozivideoplayer:7.4.2'
//图片压缩 https://github.com/Hu12037102/ImageCompress //图片压缩 https://github.com/Hu12037102/ImageCompress
implementation 'com.github.Hu12037102:ImageCompress:2.3.0' implementation 'com.github.Hu12037102:ImageCompress:2.3.0'
//webp 转换 // //webp 转换
implementation 'com.wanghong.webpnative:webpnative:0.1.0' // implementation 'com.wanghong.webpnative:webpnative:0.1.0'
// 自动发送邮件 https://github.com/teprinciple/MailSender // 自动发送邮件 https://github.com/teprinciple/MailSender
implementation 'com.teprinciple:mailsender:1.2.0' implementation 'com.teprinciple:mailsender:1.2.0'
// // https://github.com/JiongBull/jlog/blob/master/README_ZH.md 日志记录 // // https://github.com/JiongBull/jlog/blob/master/README_ZH.md 日志记录
@@ -169,4 +205,6 @@ dependencies {
// implementation 'com.github.JiongBull:jlog-storage-qiniu:0.1.0' // implementation 'com.github.JiongBull:jlog-storage-qiniu:0.1.0'
// https://github.com/elvishew/xLog/blob/master/README_ZH.md 日志记录 // https://github.com/elvishew/xLog/blob/master/README_ZH.md 日志记录
implementation 'com.elvishew:xlog:1.10.1' implementation 'com.elvishew:xlog:1.10.1'
// // 百度定位
// implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.3.7'
} }
Binary file not shown.
+36 -11
View File
@@ -65,21 +65,26 @@
<!-- android:name="android.app.lib_name"--> <!-- android:name="android.app.lib_name"-->
<!-- android:value="" />--> <!-- android:value="" />-->
<!-- </activity>--> <!-- </activity>-->
<activity android:name=".activity.RegardMapActivity" /> <activity android:name=".activity.RegardMapActivity"
<activity android:name=".activity.StatementActivity" /> android:exported="true"/>
<activity android:name=".activity.StatementActivity"
android:exported="true"/>
<activity <activity
android:name=".activity.PicturesActivity" android:name=".activity.PicturesActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
android:launchMode="singleTop" /> android:launchMode="singleTop"
android:exported="true"/>
<activity <activity
android:name=".activity.PictureActivity" android:name=".activity.PictureActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
android:launchMode="singleTop" /> android:launchMode="singleTop"
android:exported="true"/>
<activity <activity
android:name=".activity.PhotographActivity" android:name=".activity.PhotographActivity"
android:screenOrientation="landscape" android:screenOrientation="landscape"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
android:launchMode="singleTop" /> android:launchMode="singleTop"
android:exported="true"/>
<meta-data <meta-data
android:name="android.webkit.WebView.EnableSafeBrowsing" android:name="android.webkit.WebView.EnableSafeBrowsing"
@@ -88,7 +93,8 @@
<!-- android:value="EWWBZ-2PB62-6JXUL-CEX7G-N7UE6-XRB4V" /> --> <!-- android:value="EWWBZ-2PB62-6JXUL-CEX7G-N7UE6-XRB4V" /> -->
<meta-data <meta-data
android:name="TencentMapSDK" android:name="TencentMapSDK"
android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" /> <!-- 今日头屏幕适配 --> android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" />
<!-- 今日头屏幕适配 -->
<meta-data <meta-data
android:name="design_width_in_dp" android:name="design_width_in_dp"
android:value="360" /> android:value="360" />
@@ -96,9 +102,15 @@
android:name="design_height_in_dp" android:name="design_height_in_dp"
android:value="640" /> android:value="640" />
<!-- <meta-data-->
<!-- android:name="com.baidu.lbsapi.API_KEY"-->
<!-- android:value="tqrlve3Njjz0GEu73BhSjxyyzIhTjCQz" >-->
<!-- </meta-data>-->
<activity <activity
android:name=".activity.MainActivity" android:name=".activity.MainActivity"
android:screenOrientation="portrait"> android:screenOrientation="portrait"
android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
@@ -133,9 +145,17 @@
<activity <activity
android:name=".activity.VideoActivity" android:name=".activity.VideoActivity"
android:screenOrientation="portrait" /> <!-- 自动拍照界面 --> android:screenOrientation="portrait" /> <!-- 自动拍照界面 -->
<!-- 自动捕捉道路任务 -->
<activity <activity
android:name=".activity.AutoTakePictureActivity" android:name=".activity.AutoTakePictureActivity"
android:screenOrientation="portrait" /> android:screenOrientation="landscape" />
<!-- 自动捕捉POI录像任务 -->
<activity
android:name=".activity.AutoTakePicture4PoiActivity"
android:screenOrientation="landscape" />
<activity
android:name=".activity.AutoTakePicture4PoiVideoActivity"
android:screenOrientation="landscape" />
<activity <activity
android:name=".activity.UserActivity" android:name=".activity.UserActivity"
android:configChanges="keyboardHidden|orientation" android:configChanges="keyboardHidden|orientation"
@@ -145,13 +165,13 @@
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity <activity
android:name=".activity.NaviCarActivity" android:name=".activity.NaviCarActivity"
android:screenOrientation="portrait" /> android:screenOrientation="sensor" />
<activity <activity
android:name=".activity.NaviRideActivity" android:name=".activity.NaviRideActivity"
android:screenOrientation="portrait" /> android:screenOrientation="sensor" />
<activity <activity
android:name=".activity.NaviWalkActivity" android:name=".activity.NaviWalkActivity"
android:screenOrientation="portrait" /> android:screenOrientation="sensor" />
<provider <provider
android:name="androidx.core.content.FileProvider" android:name="androidx.core.content.FileProvider"
@@ -202,6 +222,11 @@
android:name="com.umeng.message.UmengMessageIntentReceiverService" android:name="com.umeng.message.UmengMessageIntentReceiverService"
android:exported="false" android:exported="false"
tools:replace="android:exported" /> tools:replace="android:exported" />
<!-- 告知 XXPermissions 当前项目已经适配了分区存储特性 -->
<meta-data
android:name="ScopedStorage"
android:value="true" />
</application> </application>
</manifest> </manifest>
File diff suppressed because it is too large Load Diff
@@ -49,12 +49,11 @@ import com.github.lazylibrary.util.NetWorkUtils;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialogx.dialogs.CustomDialog;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialogx.dialogs.MessageDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialogx.interfaces.BaseDialog;
import com.kongzue.dialog.v3.CustomDialog; import com.kongzue.dialogx.interfaces.OnBindView;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialogx.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
@@ -81,13 +80,18 @@ import com.navinfo.outdoor.util.GPSUtils;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.Gps; import com.navinfo.outdoor.util.Gps;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.MyLocation;
import com.navinfo.outdoor.util.MyTecentLocationSource; import com.navinfo.outdoor.util.MyTecentLocationSource;
import com.navinfo.outdoor.util.NaviUtils; import com.navinfo.outdoor.util.NaviUtils;
import com.navinfo.outdoor.util.PicturesSpeedCheck;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.SystemTTS; import com.navinfo.outdoor.util.SystemTTS;
import com.navinfo.outdoor.util.TencentLocationObtain;
import com.navinfo.outdoor.util.TencentMarkerUtils; import com.navinfo.outdoor.util.TencentMarkerUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.navinfo.outdoor.util.XLogUtils;
import com.otaliastudios.cameraview.CameraListener; import com.otaliastudios.cameraview.CameraListener;
import com.otaliastudios.cameraview.CameraLogger; import com.otaliastudios.cameraview.CameraLogger;
import com.otaliastudios.cameraview.CameraOptions; import com.otaliastudios.cameraview.CameraOptions;
@@ -170,6 +174,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import io.reactivex.BackpressureStrategy; import io.reactivex.BackpressureStrategy;
import io.reactivex.Emitter;
import io.reactivex.Flowable; import io.reactivex.Flowable;
import io.reactivex.FlowableEmitter; import io.reactivex.FlowableEmitter;
import io.reactivex.FlowableOnSubscribe; import io.reactivex.FlowableOnSubscribe;
@@ -199,11 +204,10 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
private TextureMapView tvMapView; private TextureMapView tvMapView;
private SystemTTS systemTTS; private SystemTTS systemTTS;
private List<Removable> trackLocRemovables/*用户轨迹图标marker*/; private List<Removable> trackLocRemovables/*用户轨迹图标marker*/;
private GPSUtils gpsUtils;
private Location gpsLocation;
private boolean isMapSlide = false; // 地图是否为靠在侧边的小图模式 private boolean isMapSlide = false; // 地图是否为靠在侧边的小图模式
private ImageView ivZoomAdd/*zoom放大*/, ivZoomDel/*zoom缩小*/, ivLocation/*定位按钮*/, private ImageView ivZoomAdd/*zoom放大*/, ivZoomDel/*zoom缩小*/, ivLocation/*定位按钮*/,
ivPicRoadImage/*道路拍摄水平线*/, ivPicVideoImage/*视频拍摄水平线*/; ivPicRoadImage/*道路拍摄水平线*/, ivPicVideoImage/*视频拍摄水平线*/;
private View layerMapController;
private ImageView btnSwitch; // 切换地图大小的按钮 private ImageView btnSwitch; // 切换地图大小的按钮
private ViewGroup layerChange; // 切换地图和相机的父控件 private ViewGroup layerChange; // 切换地图和相机的父控件
private BitmapDescriptor pileDescriptor = BitmapDescriptorFactory private BitmapDescriptor pileDescriptor = BitmapDescriptorFactory
@@ -216,7 +220,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
private int satelliteCount; // 卫星颗数 private int satelliteCount; // 卫星颗数
private static double MATCH_START_BUFFER_DISTANCE=50e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断 private static double MATCH_START_BUFFER_DISTANCE=50e-5; // 匹配起点用到的buffer距离,此处5米使用简易判断
private static double MATCH_BUFFER_DISTANCE=30e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断 private static double MATCH_BUFFER_DISTANCE=30e-5; // 匹配途经点用到的buffer距离,此处5米使用简易判断
private static float /*UNMATCH_GIVE_UP_DISTANCE_BUFFER = 0.2f*//*放弃的距离匹配阈值*//*, */MATCH_CONFIRM_FINISH_BUFFER=0.75f/*完全匹配的距离阈值*/; private static float /*UNMATCH_GIVE_UP_DISTANCE_BUFFER = 0.2f*//*放弃的距离匹配阈值*//*, */MATCH_CONFIRM_FINISH_BUFFER=0.8f/*完全匹配的距离阈值*/;
private static int /*UNMATCH_BUFFER_START_BUFFER = 5*//*匹配开始后连续未匹配的个数*//*,*/ UNMATCH_BUFFER_MIDDLE_BUFFER = 20/*匹配过程中连续未匹配的个数*/; private static int /*UNMATCH_BUFFER_START_BUFFER = 5*//*匹配开始后连续未匹配的个数*//*,*/ UNMATCH_BUFFER_MIDDLE_BUFFER = 20/*匹配过程中连续未匹配的个数*/;
// private static float UNMATCH_COUNT_BUFFER = UNMATCH_GIVE_UP_DISTANCE_BUFFER/(1-UNMATCH_GIVE_UP_DISTANCE_BUFFER); // private static float UNMATCH_COUNT_BUFFER = UNMATCH_GIVE_UP_DISTANCE_BUFFER/(1-UNMATCH_GIVE_UP_DISTANCE_BUFFER);
private final String tmpPicFoldPath = Constant.PICTURE_FOLDER+"/tmp"; private final String tmpPicFoldPath = Constant.PICTURE_FOLDER+"/tmp";
@@ -235,10 +239,17 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
private ImageView imgNaviDistance/*自动规划到距离最近的数据开关*/, imgRoadDirection; // 道路方向匹配开关 private ImageView imgNaviDistance/*自动规划到距离最近的数据开关*/, imgRoadDirection; // 道路方向匹配开关
private Polyline currentNaviLine; // 当前界面上正显示的导航路径线,重绘路径时需要清除此前已绘制的路径 private Polyline currentNaviLine; // 当前界面上正显示的导航路径线,重绘路径时需要清除此前已绘制的路径
private boolean startMatchEnableDirection = true; // 是否启用方向匹配起点 private boolean startMatchEnableDirection = true; // 是否启用方向匹配起点
private Logger logger; private Logger logger = XLogUtils.Companion.getInstance().getAutoTakePictureLogWriter();
private ImageView imgLocationType;
private PicturesSpeedCheck speedCheck;
// 任务结束对应的控制对象
private Disposable finishDisposable;
private Emitter<RoadMatchEntity> finishEmitter;
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
speedCheck = new PicturesSpeedCheck();
SharedPreferences sharedPreferences = getSharedPreferences("pic", Context.MODE_PRIVATE); SharedPreferences sharedPreferences = getSharedPreferences("pic", Context.MODE_PRIVATE);
BRIGHTNESS = sharedPreferences.getInt("brightness", 40); BRIGHTNESS = sharedPreferences.getInt("brightness", 40);
FRAMENESS = sharedPreferences.getInt("framness", 30); FRAMENESS = sharedPreferences.getInt("framness", 30);
@@ -247,7 +258,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
setWindowBrightness(BRIGHTNESS); setWindowBrightness(BRIGHTNESS);
// 初始化提示音播放器 // 初始化提示音播放器
mediaPlayer=MediaPlayer.create(this, R.raw.ding); mediaPlayer=MediaPlayer.create(this, R.raw.ding);
super.onCreate(savedInstanceState); // 启动GPS定位
LocationLifeCycle.getInstance().startGPSLocation();
} }
@Override @Override
@@ -264,13 +276,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
} }
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
layerChange = findViewById(R.id.layer_change); layerChange = findViewById(R.id.layer_change);
systemTTS = SystemTTS.getInstance(AutoTakePictureActivity.this); systemTTS = SystemTTS.getInstance(AutoTakePictureActivity.this);
tvMapView = findViewById(R.id.text_map_view); tvMapView = findViewById(R.id.text_map_view);
tvMapView.setOnClickListener(this); tvMapView.setOnClickListener(this);
ivZoomAdd = findViewById(R.id.iv_zoom_add); ivZoomAdd = findViewById(R.id.iv_zoom_add);
ivZoomAdd.setOnClickListener(this); ivZoomAdd.setOnClickListener(this);
layerMapController = findViewById(R.id.layer_map_controller);
ivZoomDel = findViewById(R.id.iv_zoom_del); ivZoomDel = findViewById(R.id.iv_zoom_del);
ivZoomDel.setOnClickListener(this); ivZoomDel.setOnClickListener(this);
ivLocation = findViewById(R.id.iv_location); ivLocation = findViewById(R.id.iv_location);
@@ -288,6 +300,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
imgNaviDistance = findViewById(R.id.img_navi_distance); imgNaviDistance = findViewById(R.id.img_navi_distance);
imgRoadDirection = findViewById(R.id.img_road_direction); imgRoadDirection = findViewById(R.id.img_road_direction);
imgRoadDirection.setSelected(true); imgRoadDirection.setSelected(true);
imgLocationType = findViewById(R.id.img_location_type);
imgLocationType.setOnClickListener(this::onClick);
//获取地图 //获取地图
tencentMap = tvMapView.getMap(); tencentMap = tvMapView.getMap();
@@ -311,13 +325,6 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
ivPicVideoImage.setVisibility(View.GONE); ivPicVideoImage.setVisibility(View.GONE);
trackLocRemovables = new ArrayList<>(); trackLocRemovables = new ArrayList<>();
gpsUtils = new GPSUtils(AutoTakePictureActivity.this);
gpsUtils.setOnClickGPSStatus(new GPSUtils.OnClickGPSStatus() {
@Override
public void onGpsCount(int count) {
satelliteCount = count;
}
});
// 清空所有匹配的数据 // 清空所有匹配的数据
btnClearMatch.setOnClickListener(new View.OnClickListener() { btnClearMatch.setOnClickListener(new View.OnClickListener() {
@@ -360,7 +367,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
btnSetting.setOnClickListener(new View.OnClickListener() { btnSetting.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
CustomDialog.show(AutoTakePictureActivity.this, R.layout.camera_setting, new CustomDialog.OnBindView() { CustomDialog.show(new OnBindView<CustomDialog>(R.layout.camera_setting) {
@Override @Override
public void onBind(CustomDialog dialog, View v) { public void onBind(CustomDialog dialog, View v) {
EditText startDistance = v.findViewById(R.id.edt_camera_setting_start_distance); EditText startDistance = v.findViewById(R.id.edt_camera_setting_start_distance);
@@ -404,7 +411,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
MATCH_CONFIRM_FINISH_BUFFER = Float.parseFloat(matchPecent.getText().toString()); MATCH_CONFIRM_FINISH_BUFFER = Float.parseFloat(matchPecent.getText().toString());
} }
Toast.makeText(AutoTakePictureActivity.this, "设置完成", Toast.LENGTH_SHORT).show(); Toast.makeText(AutoTakePictureActivity.this, "设置完成", Toast.LENGTH_SHORT).show();
dialog.doDismiss(); dialog.dismiss();
} }
}); });
} }
@@ -505,7 +512,10 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
@Override @Override
public void onMapClick(LatLng latLng) { public void onMapClick(LatLng latLng) {
Message msg = handler.obtainMessage(0x105); Message msg = handler.obtainMessage(0x105);
msg.obj = obtainTecentLocation(latLng); Location location = new Location("GPS");
location.setLongitude(latLng.getLongitude());
location.setLatitude(latLng.getLatitude());
msg.obj = TencentLocationObtain.obtainTecentLocation(location);
handler.sendMessage(msg); handler.sendMessage(msg);
} }
}); });
@@ -571,6 +581,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
return; return;
} }
// 道路任务增加检查
// 检测到当前车辆未移动,则无需进行拍摄
if (!speedCheck.checkIsMove(LocationLifeCycle.getInstance().getMainLocation(), LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi())) {
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, "车辆静止中,暂停拍摄!");
return;
}
File tmpPicFolder = new File(tmpPicFoldPath); File tmpPicFolder = new File(tmpPicFoldPath);
if (!tmpPicFolder.exists()) { if (!tmpPicFolder.exists()) {
tmpPicFolder.mkdirs(); tmpPicFolder.mkdirs();
@@ -586,21 +603,19 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 在数据库中记录照片、轨迹位置以及卫星颗数 // 在数据库中记录照片、轨迹位置以及卫星颗数
LocationRecorder recorder = new LocationRecorder(); LocationRecorder recorder = new LocationRecorder();
recorder.setTime(Long.parseLong(file.getName())); recorder.setTime(Long.parseLong(file.getName()));
recorder.setTencentLocationX(Constant.currentLocation.getLongitude()); // 记录主定位方式
recorder.setTencentLocationY(Constant.currentLocation.getLatitude()); recorder.setTencentLocationX(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
gpsLocation = gpsUtils.getLocation(); recorder.setTencentLocationY(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
// 记录辅助定位方式
MyLocation gpsLocation = LocationLifeCycle.getInstance().getReferenceLocation();
if (gpsLocation!=null) { if (gpsLocation!=null) {
recorder.setGpsLocationX(gpsLocation.getLongitude()); recorder.setGpsLocationX(gpsLocation.getLongitude());
recorder.setGpsLocationY(gpsLocation.getLatitude()); recorder.setGpsLocationY(gpsLocation.getLatitude());
} }
if (Constant.currentLocation.getBearing() != 0) { recorder.setBearing(LocationLifeCycle.getInstance().getMainLocation().getBearing());
recorder.setBearing(Constant.currentLocation.getBearing());
} else {
recorder.setBearing(Constant.currentLocation.getDirection());
}
recorder.setImgFileName(file.getAbsolutePath()); recorder.setImgFileName(file.getAbsolutePath());
recorder.setRssi(Constant.currentLocation.getGPSRssi()); recorder.setRssi(GPSUtils.getInstance(AutoTakePictureActivity.this).getSateliteCount());
recorder.setSatelliteCount(satelliteCount); recorder.setSatelliteCount(GPSUtils.getInstance(AutoTakePictureActivity.this).getSateliteCount());
Observable.just(recorder).observeOn(Schedulers.io()) Observable.just(recorder).observeOn(Schedulers.io())
.filter(roadMatchEntity -> roadMatchEntity!=null) .filter(roadMatchEntity -> roadMatchEntity!=null)
.subscribe(new Consumer<LocationRecorder>() { .subscribe(new Consumer<LocationRecorder>() {
@@ -626,6 +641,82 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 清空缓存数据 // 清空缓存数据
spf.edit().remove("match-data"); spf.edit().remove("match-data");
spf.edit().commit(); spf.edit().commit();
// 启动数据完成的Rx流,当有数据需要完成时,会在捕捉流程中由上游发送数据
finishDisposable = Observable.create(new ObservableOnSubscribe<RoadMatchEntity>() {
@Override
public void subscribe(ObservableEmitter<RoadMatchEntity> emitter) throws Exception {
finishEmitter =emitter;
}
})
.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation())
.filter(roadMatchEntity -> roadMatchEntity!=null)
.map(roadMatchEntity -> {
// 判断是否已领取,未领取则调用领取数据接口
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
if (poiEntity == null) {
// 数据库中不存在,尝试再次领取
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
// 调用网络领取任务
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
}
List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime());
File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId());
if (!recorderFolder.exists()) {
recorderFolder.mkdirs();
}
// 编辑paper.txt
// 复制图片文件
File paperFile = new File(recorderFolder.getAbsolutePath(), "paper.txt");
for (int i = 0; i < recorderList.size(); i++) {
File originImg = new File(recorderList.get(i).getImgFileName());
File destFile = new File(recorderFolder.getAbsolutePath()+"/"+i+".jpg");
if (!destFile.exists()) {
FileUtils.copyFile(originImg.getAbsolutePath(), destFile.getAbsolutePath());
}
FileUtils.writeFile(paperFile.getAbsolutePath(), recorderList.get(i).toString(picFormatter ,i), true);
}
return poiEntity;
})
.doOnNext(poiEntity -> {
// 网络提交数据
if (poiEntity!=null) {
// 提交数据,更新状态
roadSaveWork(poiEntity);
}
})
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(Observable.empty())
.subscribe(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) {
// 重新绘制网络任务和本地任务
initRoadLine2Map();
finishTaskCount--;
if (finishTaskCount == 0&&wantBack) {
showExitDialog(false);
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
// 此处异常可能是服务返回的数据无法解析,但http正常返回了,因此可能为程序问题,不再重复尝试上报
systemTTS.playText("注意,领取任务失败!");
XLog.e("完成失败:"+throwable.getMessage());
ToastUtils.Message(AutoTakePictureActivity.this, throwable.getMessage());
finishTaskCount--;
if (finishTaskCount == 0&&wantBack) {
showExitDialog(true);
}
}
}, new Action() {
@Override
public void run() throws Exception {
}
});
} }
/** /**
@@ -641,9 +732,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
} }
}); });
} }
if (Constant.currentLocation != null) { //筛选从服务器获取到的数据 if (LocationLifeCycle.getInstance().getMainLocation() != null) { //筛选从服务器获取到的数据
// 注意,此处只获取道路数据 // 注意,此处只获取道路数据
tencentMarkerUtils.initNetMarkerList(AutoTakePictureActivity.this, Constant.currentLocation, tencentMap, removables, tencentMarkerUtils.initNetMarkerList(AutoTakePictureActivity.this, LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables,
"4"/*只获取道路数据*/,"0"/*只获取未领取的数据*/, removableHashMap, 50, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() { "4"/*只获取道路数据*/,"0"/*只获取未领取的数据*/, removableHashMap, 50, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
@Override @Override
@@ -656,13 +747,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
it -> { it -> {
String geometryStr = Geohash.getInstance().decode(it.getGeo()); String geometryStr = Geohash.getInstance().decode(it.getGeo());
Geometry geometry = GeometryTools.createGeometry(geometryStr); Geometry geometry = GeometryTools.createGeometry(geometryStr);
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
roadMatchEntity.setId(it.getId());
roadMatchEntity.setDataDetail(it);
roadMatchEntity.setGeometry((LineString) geometry);
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
// 实时设置当前任务的起始角度 // 实时设置当前任务的起始角度
if (geometry instanceof LineString) { if (geometry instanceof LineString) {
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
roadMatchEntity.setId(it.getId());
roadMatchEntity.setDataDetail(it);
roadMatchEntity.setGeometry((LineString) geometry);
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
LineString lineString = (LineString) geometry; LineString lineString = (LineString) geometry;
// 计算前两个点的坐标角度 // 计算前两个点的坐标角度
// 获取当前数据的前两个点的方向 // 获取当前数据的前两个点的方向
@@ -683,8 +774,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
} }
roadMatchEntity.setsPoint(lineString.getStartPoint().toString()); roadMatchEntity.setsPoint(lineString.getStartPoint().toString());
roadMatchEntity.setePoint(lineString.getEndPoint().toString()); roadMatchEntity.setePoint(lineString.getEndPoint().toString());
roadLinkEntityList.add(roadMatchEntity);
} else {
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, "当前界面存在多线任务,已自动过滤!");
systemTTS.playText("存在多线任务!");
XLog.e("存在多线任务:"+it.getId()+"-"+it.getName());
} }
roadLinkEntityList.add(roadMatchEntity);
} }
); );
// 如果当前自动规划打开且没有正在匹配的任务,自动规划下一条最近的任务 // 如果当前自动规划打开且没有正在匹配的任务,自动规划下一条最近的任务
@@ -707,14 +802,14 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
@Override @Override
public void onNext(PoiEntity poiEntity) { public void onNext(PoiEntity poiEntity) {
write2Log("领取任务成功:", poiEntity.getId()); logger.d(null, "领取任务成功:", poiEntity.getId());
} }
@Override @Override
public void onError(Throwable e) { public void onError(Throwable e) {
systemTTS.playText("注意,领取任务失败!"); systemTTS.playText("注意,领取任务失败!");
if (AutoTakePictureActivity.this!=null) { if (AutoTakePictureActivity.this!=null) {
write2Log("领取任务失败:", e.getMessage()+",网络状态-:"+ NetWorkUtils.getNetworkTypeName(AutoTakePictureActivity.this)); logger.d(null, "领取任务失败:", e.getMessage()+",网络状态-:"+ NetWorkUtils.getNetworkTypeName(AutoTakePictureActivity.this));
} }
} }
@@ -730,7 +825,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
private double minDistance = MATCH_START_BUFFER_DISTANCE; // 最小距离,需要在匹配过程点时判断哪个任务是距离最小的 private double minDistance = MATCH_START_BUFFER_DISTANCE; // 最小距离,需要在匹配过程点时判断哪个任务是距离最小的
private void startMatchRoadLink(Point currentPoint) { private void startMatchRoadLink(Point currentPoint) {
if (roadLinkEntityList == null/*没有需要匹配的道路数据*/ || currentPoint == null/*没有位置信息*/) { if (roadLinkEntityList == null/*没有需要匹配的道路数据*/ || currentPoint == null/*没有位置信息*/) {
write2Log("开始匹配:", "roadLinkEntityList == null:"+(roadLinkEntityList == null)+",currentPoint == null:"+(currentPoint == null)); logger.d(null, "开始匹配:", "roadLinkEntityList == null:"+(roadLinkEntityList == null)+",currentPoint == null:"+(currentPoint == null));
return; return;
} }
double[] speedAndBearing = getSpeedAndBearing(currentPoint); double[] speedAndBearing = getSpeedAndBearing(currentPoint);
@@ -742,7 +837,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
matchMiddleDistance = MATCH_BUFFER_DISTANCE*1.5; matchMiddleDistance = MATCH_BUFFER_DISTANCE*1.5;
} }
// 此处开始匹配起点 // 此处开始匹配起点
write2Log("开始匹配起点位置:", "currentLocation:"+currentPoint.toString()+",可匹配数据个数:"+roadLinkEntityList.size()); logger.d(null, "开始匹配起点位置:", "currentLocation:"+currentPoint.toString()+",可匹配数据个数:"+roadLinkEntityList.size());
List<RoadMatchEntity> matchStartList = roadLinkEntityList.stream() List<RoadMatchEntity> matchStartList = roadLinkEntityList.stream()
// 筛选当前任务与起点距离 // 筛选当前任务与起点距离
.filter(it-> { .filter(it-> {
@@ -760,7 +855,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
return true; return true;
} else { } else {
// 根据方向判定无法匹配 // 根据方向判定无法匹配
write2Log("方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getId()); logger.d(null, "方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getId());
return false; return false;
} }
} else { } else {
@@ -801,7 +896,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 将匹配到的数据加入到已匹配列表中 // 将匹配到的数据加入到已匹配列表中
roadMatchEntityList.addAll(matchStartList); roadMatchEntityList.addAll(matchStartList);
} else { } else {
write2Log("匹配起点数据为空:", "当前位置为:"+currentPoint.toString()+"当前角度:"+currentBearing); logger.d(null, "匹配起点数据为空:", "当前位置为:"+currentPoint.toString()+"当前角度:"+currentBearing);
} }
// 尝试用当前位置点匹配已经匹配到的roadLink,如果能匹配到,需要将该点记录,如果无法匹配,则需要评估已匹配的link是否需要被剔除 // 尝试用当前位置点匹配已经匹配到的roadLink,如果能匹配到,需要将该点记录,如果无法匹配,则需要评估已匹配的link是否需要被剔除
@@ -843,40 +938,50 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
} }
} else { // 在阈值内,但是并非最近的点 } else { // 在阈值内,但是并非最近的点
roadMatchEntity.setMatchCount(0); // 连续匹配个数置为0 roadMatchEntity.setMatchCount(0); // 连续匹配个数置为0
// 如果当前数据已经被标记为可完成状态,则直接结束当前任务
if (roadMatchEntity.getEndMathchTime()>0/*endMatchTime不为0,说明该数据已经匹配到终点*/) {
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
// 更新终点时间为距离终点逐渐变大时的时间
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
return;
}
} }
roadMatchEntity.setUnMatchCount(0); // 有匹配的数据,则连续未匹配个数归0(即使不是最近的数据,在阈值内即认为可匹配,未匹配点数也置为0) roadMatchEntity.setUnMatchCount(0); // 有匹配的数据,则连续未匹配个数归0(即使不是最近的数据,在阈值内即认为可匹配,未匹配点数也置为0)
double currentEndDistance = currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint())); // 当前距离终点的距离 double currentEndDistance = currentPoint.distance(GeometryTools.createGeometry(roadMatchEntity.getePoint())); // 当前位置距离终点的距离
// 记录本次的匹配距离,如果本次匹配距离大于上一次,且上一次匹配终点时间不为0(说明已经提前匹配到终点了),则结束匹配,否则继续等待匹配,设置过EndMathchTime的数据即为可以结束匹配的数据,下一次如果未匹配,也可以结束 // 匹配距离超过指定阈值,并且当前位置距离终点认为该条数据可完成,记录当前位置与终点的距离
if (roadMatchEntity.getEndMathchTime()>0/*endMatchTime不为0,说明该数据已经匹配到终点*/&&currentEndDistance>roadMatchEntity.getLastEndDistance()) { if (roadMatchEntity.getMatchPointList().size()>=2
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity); &&roadMatchEntity.getMatchedLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER /*匹配长度超过阈值*/
// 更新终点时间为距离终点逐渐变大时的时间 &&currentEndDistance<=MATCH_START_BUFFER_DISTANCE/*与终点距离在阈值范围内*/) {
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
}
// 匹配距离超过指定阈值,认为该条数据可完成,记录当前位置与终点的距离,当距离从小变大时,完成该任务
if (roadMatchEntity.getMatchPointList().size()>=2&&roadMatchEntity.getMatchedLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER) {
roadMatchEntity.setEndMathchTime(System.currentTimeMillis()); roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
// 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配 // 匹配到终点后,记录该条数据的最新一次匹配距离,当下一次匹配距离大于当前距离,则认为该数据完全匹配,结束匹配
roadMatchEntity.setLastEndDistance(currentEndDistance); roadMatchEntity.setLastEndDistance(currentEndDistance);
} }
//=============如果在匹配范围内,但是该数据并非最近的点,不需要记录匹配,也无需增加未匹配点的个数 //=============如果在匹配范围内,但是该数据并非最近的点,不需要记录匹配,也无需增加未匹配点的个数
} else { // 无法匹配 } else { // 无法匹配
// 更新连续无法匹配的点位个数 // 如果当前任务已经被标记为可完成,直接结束该任务
roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1); if (roadMatchEntity.getEndMathchTime()>0/*endMatchTime不为0,说明该数据已经匹配到终点*/) {
// 有未匹配的数据,连续匹配个数也归0 finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0 // 更新终点时间为距离终点逐渐变大时的时间
roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY())); roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
// 当连续未匹配个数大于等于20个时,该任务被认为可以结束(舍弃或完成-需根据匹配到的数据长度与任务长度做对比) } else {
if (roadMatchEntity.getUnMatchCount()>=UNMATCH_BUFFER_MIDDLE_BUFFER) { // 连续未匹配大于阈值时 // 更新连续无法匹配的点位个数
List<MyCoordinate> matchPointList = roadMatchEntity.getMatchPointList(); roadMatchEntity.setUnMatchCount(roadMatchEntity.getUnMatchCount()+1);
if (matchPointList == null || matchPointList.size()<2) { // 已匹配的点位不足2个,无法计算长度,直接放弃该任务 // 有未匹配的数据,连续匹配个数也归0
unMatchList.add(roadMatchEntity); roadMatchEntity.setMatchCount(0);// 设置连续匹配的数据个数为0
} else { roadMatchEntity.getUnMatchPointList().add(new MyCoordinate(currentPoint.getX(), currentPoint.getY()));
if (roadMatchEntity.getMatchedLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER) { // 已匹配距离与任务长度距离比例超过指定阈值,该任务可完成 // 当连续未匹配个数大于等于20个时,该任务被认为可以结束(舍弃或完成-需根据匹配到的数据长度与任务长度做对比)
roadMatchEntity.setEndMathchTime(System.currentTimeMillis()); if (roadMatchEntity.getUnMatchCount()>=UNMATCH_BUFFER_MIDDLE_BUFFER) { // 连续未匹配大于阈值时
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity); List<MyCoordinate> matchPointList = roadMatchEntity.getMatchPointList();
} else { if (matchPointList == null || matchPointList.size()<2) { // 已匹配的点位不足2个,无法计算长度,直接放弃该任务
unMatchList.add(roadMatchEntity); unMatchList.add(roadMatchEntity);
} else {
if (roadMatchEntity.getMatchedLength()/roadMatchEntity.getLength()>=MATCH_CONFIRM_FINISH_BUFFER) { // 已匹配距离与任务长度距离比例超过指定阈值,该任务可完成
roadMatchEntity.setEndMathchTime(System.currentTimeMillis());
finishEntityMap.put(roadMatchEntity.getId(), roadMatchEntity);
} else {
unMatchList.add(roadMatchEntity);
}
} }
} }
} }
@@ -946,7 +1051,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
return; return;
} }
// RxJava处理,子线程中做后台计算路径规划 // RxJava处理,子线程中做后台计算路径规划
Geometry currentGeometry = GeometryTools.createGeometry(new double[]{Constant.currentLocation.getLongitude(), Constant.currentLocation.getLatitude()}); Geometry currentGeometry = GeometryTools.createGeometry(new double[]{LocationLifeCycle.getInstance().getMainLocation().getLongitude(), LocationLifeCycle.getInstance().getMainLocation().getLatitude()});
Observable.create( Observable.create(
new ObservableOnSubscribe<RoadMatchEntity>() { new ObservableOnSubscribe<RoadMatchEntity>() {
@Override @Override
@@ -995,7 +1100,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 显示导航类型选择的对话框 // 显示导航类型选择的对话框
Constant.currentNaviType = nav_type; Constant.currentNaviType = nav_type;
try { try {
tencentNaviManager = NaviUtils.getInstance().searchRouteOnly(AutoTakePictureActivity.this, Constant.currentNaviType, new NaviPoi(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new NaviPoi(endPoint.getY(), endPoint.getX()), routeSearchCallback); tencentNaviManager = NaviUtils.getInstance().searchRouteOnly(AutoTakePictureActivity.this, Constant.currentNaviType, new NaviPoi(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new NaviPoi(endPoint.getY(), endPoint.getX()), routeSearchCallback);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, e.getMessage()); com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, e.getMessage());
@@ -1004,7 +1109,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
}); });
} else { } else {
// 已选择导航方式 // 已选择导航方式
tencentNaviManager = NaviUtils.getInstance().searchRouteOnly(AutoTakePictureActivity.this, Constant.currentNaviType, new NaviPoi(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new NaviPoi(endPoint.getY(), endPoint.getX()), routeSearchCallback); tencentNaviManager = NaviUtils.getInstance().searchRouteOnly(AutoTakePictureActivity.this, Constant.currentNaviType, new NaviPoi(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new NaviPoi(endPoint.getY(), endPoint.getX()), routeSearchCallback);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@@ -1157,7 +1262,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
* 初始化领取任务的管理栈 * 初始化领取任务的管理栈
* */ * */
private Observable<PoiEntity> receiverRoadTask(RoadMatchEntity entity) { private Observable<PoiEntity> receiverRoadTask(RoadMatchEntity entity) {
write2Log("开始领取任务:", entity.getId()+""); logger.d(null, "开始领取任务:", entity.getId()+"");
return Observable.just(entity).subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()) return Observable.just(entity).subscribeOn(Schedulers.io()).observeOn(Schedulers.computation())
.filter(roadMatchEntity -> roadMatchEntity!=null) .filter(roadMatchEntity -> roadMatchEntity!=null)
.map(new Function<RoadMatchEntity, PoiEntity>() { .map(new Function<RoadMatchEntity, PoiEntity>() {
@@ -1206,7 +1311,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
} }
} else if (taskByNetBean.getCode() == 230) { // Token过期 } else if (taskByNetBean.getCode() == 230) { // Token过期
systemTTS.playText("注意,Token过期,请重新登陆!"); systemTTS.playText("注意,Token过期,请重新登陆!");
write2Log("领取任务失败:", "Token过期:"+taskByNetBean.getMessage()); logger.d(null, "领取任务失败:", "Token过期:"+taskByNetBean.getMessage());
FlushTokenUtil.flushToken(AutoTakePictureActivity.this); FlushTokenUtil.flushToken(AutoTakePictureActivity.this);
Message msg = handler.obtainMessage(0x103); Message msg = handler.obtainMessage(0x103);
msg.obj = entity; msg.obj = entity;
@@ -1214,7 +1319,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
} else { } else {
systemTTS.playText("注意,领取任务失败!"); systemTTS.playText("注意,领取任务失败!");
ToastUtils.Message(AutoTakePictureActivity.this,taskByNetBean.getMessage()); ToastUtils.Message(AutoTakePictureActivity.this,taskByNetBean.getMessage());
write2Log("领取任务失败:", "领取失败:"+taskByNetBean.getMessage()); logger.d(null, "领取任务失败:", "领取失败:"+taskByNetBean.getMessage());
Message msg = handler.obtainMessage(0x103); Message msg = handler.obtainMessage(0x103);
msg.obj = entity; msg.obj = entity;
handler.sendMessageDelayed(msg, 10*1000); // 10秒后重试 handler.sendMessageDelayed(msg, 10*1000); // 10秒后重试
@@ -1321,84 +1426,12 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
private boolean wantBack = false; // 用户是否想要退出当前界面,如果当前有正在处理的图片转移任务,会阻挡用户退出,此时该值状态置为true,当照片处理完后,可以对话框提示用户退出 private boolean wantBack = false; // 用户是否想要退出当前界面,如果当前有正在处理的图片转移任务,会阻挡用户退出,此时该值状态置为true,当照片处理完后,可以对话框提示用户退出
private void finishRoadTask(Map<Integer, RoadMatchEntity> finishEntityMap) { private void finishRoadTask(Map<Integer, RoadMatchEntity> finishEntityMap) {
if (finishEntityMap!=null&&!finishEntityMap.isEmpty()) { if (finishEntityMap!=null&&!finishEntityMap.isEmpty()) {
finishTaskCount++; for (Map.Entry<Integer, RoadMatchEntity> entry: finishEntityMap.entrySet()) {
if (finishEmitter!=null) {
Observable.fromIterable(finishEntityMap.values()) finishTaskCount++;
.subscribeOn(Schedulers.io()).observeOn(Schedulers.computation()) finishEmitter.onNext(entry.getValue());
.filter(roadMatchEntity -> roadMatchEntity!=null) }
.map(roadMatchEntity -> { }
// 判断是否已领取,未领取则调用领取数据接口
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
if (poiEntity == null) {
// 数据库中不存在,尝试再次领取
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
// 调用网络领取任务
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
}
List<LocationRecorder> recorderList = recorderDao.getLocationRecorderByTime(roadMatchEntity.getStartMatchTime(), roadMatchEntity.getEndMathchTime());
File recorderFolder = new File(Constant.PICTURE_FOLDER+"/"+poiEntity.getId());
if (!recorderFolder.exists()) {
recorderFolder.mkdirs();
}
// 编辑paper.txt
// 复制图片文件
File paperFile = new File(recorderFolder.getAbsolutePath(), "paper.txt");
for (int i = 0; i < recorderList.size(); i++) {
File originImg = new File(recorderList.get(i).getImgFileName());
File destFile = new File(recorderFolder.getAbsolutePath()+"/"+i+".jpg");
if (!destFile.exists()) {
FileUtils.copyFile(originImg.getAbsolutePath(), destFile.getAbsolutePath());
}
FileUtils.writeFile(paperFile.getAbsolutePath(), recorderList.get(i).toString(picFormatter ,i), true);
}
return poiEntity;
})
.doOnNext(poiEntity -> {
// 网络提交数据
if (poiEntity!=null) {
// 提交数据,更新状态
roadSaveWork(poiEntity);
/*poiEntity.setTaskStatus(3);
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, poiEntity);*/
finishEntityMap.remove(poiEntity.getTaskId());
}
})
.observeOn(AndroidSchedulers.mainThread())
.onErrorResumeNext(Observable.empty())
.subscribe(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) {
// // 已经处理过该任务,将其从finish列表中移除
// if (poiEntity!=null) {
// finishEntityMap.remove(poiEntity.getTaskId());
// }
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) {
// 此处异常可能是服务返回的数据无法解析,但http正常返回了,因此可能为程序问题,不再重复尝试上报
systemTTS.playText("注意,领取任务失败!");
XLog.e("完成失败:"+throwable.getMessage());
ToastUtils.Message(AutoTakePictureActivity.this, throwable.getMessage());
finishTaskCount--;
if (finishTaskCount == 0) {
showExitDialog(true);
}
}
}, new Action() {
@Override
public void run() throws Exception {
// 重新绘制网络任务和本地任务
initRoadLine2Map();
finishTaskCount--;
if (finishTaskCount == 0) {
showExitDialog(false);
}
}
});
} }
} }
@@ -1407,18 +1440,19 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
if (hasError) { if (hasError) {
dialogMessage.append("(注意,其中有部分任务处理失败)"); dialogMessage.append("(注意,其中有部分任务处理失败)");
} }
MessageDialog.show(AutoTakePictureActivity.this, "退出当前界面", dialogMessage) MessageDialog.show("退出当前界面", dialogMessage)
.setOkButton("确定", new OnDialogButtonClickListener() { .setOkButton("确定", new OnDialogButtonClickListener<MessageDialog>() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(MessageDialog dialog, View v) {
dialog.dismiss();
AutoTakePictureActivity.this.finish(); AutoTakePictureActivity.this.finish();
return false; return false;
} }
}) })
.setCancelButton("取消", new OnDialogButtonClickListener() { .setCancelButton("取消", new OnDialogButtonClickListener<MessageDialog>() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(MessageDialog dialog, View v) {
baseDialog.doDismiss(); dialog.dismiss();
wantBack = false; wantBack = false;
return false; return false;
} }
@@ -1436,7 +1470,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 0); // httpParams.put("workType", 0);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
// 增加对应九天平台的参数 // 增加对应九天平台的参数
httpParams.put("existence", 0); httpParams.put("existence", 0);
@@ -1516,9 +1550,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
setLocMarkerStyle(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER); setLocMarkerStyle(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
break; break;
case R.id.iv_location://定位: case R.id.iv_location://定位:
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getMainLocation() != null) {
CameraUpdate cameraSigma = CameraUpdateFactory CameraUpdate cameraSigma = CameraUpdateFactory
.newCameraPosition(new CameraPosition(new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 .newCameraPosition(new CameraPosition(new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), //中心点坐标,地图目标经纬度
17, //目标缩放级别 17, //目标缩放级别
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
0)); //目标旋转角 0~360° (正北方为0) 0)); //目标旋转角 0~360° (正北方为0)
@@ -1527,6 +1561,14 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 设置当前地图的定位显示模式为跟随 // 设置当前地图的定位显示模式为跟随
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE); setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
break; break;
case R.id.img_location_type: // 切换定位方式
imgLocationType.setSelected(!imgLocationType.isSelected());
if (imgLocationType.isSelected()) { // 选中状态,切换为GPS为主定位
LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.ORIGIN);
} else {
LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT);
}
break;
} }
} }
@@ -1597,9 +1639,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
//小图 //小图
private void initMapBig() { private void initMapBig() {
isMapSlide = false; isMapSlide = false;
ivZoomAdd.setVisibility(View.GONE); layerMapController.setVisibility(View.GONE);
ivZoomDel.setVisibility(View.GONE);
ivLocation.setVisibility(View.GONE);
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE); setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
// 道路水平方向图标显示 // 道路水平方向图标显示
ivPicRoadImage.setVisibility(View.VISIBLE); ivPicRoadImage.setVisibility(View.VISIBLE);
@@ -1608,9 +1648,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
//大图 //大图
private void initMapShort() { private void initMapShort() {
isMapSlide = true; isMapSlide = true;
ivZoomAdd.setVisibility(View.VISIBLE); layerMapController.setVisibility(View.VISIBLE);
ivZoomDel.setVisibility(View.VISIBLE);
ivLocation.setVisibility(View.VISIBLE);
setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE); setLocMarkerStyle(LOCATION_TYPE_LOCATION_ROTATE);
// 道路水平方向图标不显示 // 道路水平方向图标不显示
ivPicRoadImage.setVisibility(View.GONE); ivPicRoadImage.setVisibility(View.GONE);
@@ -1719,23 +1757,26 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
editor.putString("match-data", gson.toJson(roadMatchEntityList)); editor.putString("match-data", gson.toJson(roadMatchEntityList));
editor.commit(); editor.commit();
} }
if (gpsUtils!=null) {
gpsUtils.unRegisterAllListener();
}
if (mediaPlayer!=null) { if (mediaPlayer!=null) {
mediaPlayer.release(); mediaPlayer.release();
} }
// 退出后切换主定位模式为腾讯定位
LocationLifeCycle.getInstance().setMainLocationFrom(LocationLifeCycle.LOCATION_FROM.TENCENT);
LocationLifeCycle.getInstance().stopGPSLocation();
if (finishDisposable!=null&&!finishDisposable.isDisposed()) {
finishDisposable.dispose();
}
} }
@Override @Override
public void onBackPressed() { public void onBackPressed() {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
if (finishTaskCount>0) { if (finishTaskCount>0) {
MessageDialog.show(this, "提示", "后台正在处理已拍摄完成的任务,请稍后再退出当前界面"); MessageDialog.show("提示", "后台正在处理已拍摄完成的任务,请稍后再退出当前界面");
wantBack = true; wantBack = true;
return; return;
} }
MessageDialog.show(this, "提示", "退出自动采集模式?", "是", "否").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show("提示", "退出自动采集模式?", "是", "否")
.setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
stopRecordLocation(); stopRecordLocation();
@@ -1773,8 +1814,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
.doOnComplete(new Action() { .doOnComplete(new Action() {
@Override @Override
public void run() throws Exception { public void run() throws Exception {
// 删除缓存目录 // 删除缓存目录-增加了删除缓存的功能,无需删除tmp照片
FileUtils.deleteFile(tmpPicFoldPath); // FileUtils.deleteFile(tmpPicFoldPath);
} }
}) })
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@@ -1827,16 +1868,17 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
*/ */
public void addTrackMarker() { public void addTrackMarker() {
LatLng latLng = null; LatLng latLng = null;
if (Constant.currentLocation.getGPSRssi() == 0) { latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); // if (GPSUtils.getInstance(AutoTakePictureActivity.this).getSateliteCount() != 0) {
} else { // latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
if (gpsLocation == null) { // } else {
latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); // if (gpsLocation == null) {
} else { // latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
double[] doubles = Gps.toGCJ02Point(gpsLocation.getLatitude(), gpsLocation.getLongitude()); // } else {
latLng = new LatLng(doubles[0],doubles[1]); // double[] doubles = Gps.toGCJ02Point(gpsLocation.getLatitude(), gpsLocation.getLongitude());
} // latLng = new LatLng(doubles[0],doubles[1]);
} // }
// }
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng) Marker marker = tencentMap.addMarker(new MarkerOptions(latLng)
.icon(pileDescriptor) .icon(pileDescriptor)
.alpha(0.9f) .alpha(0.9f)
@@ -1853,204 +1895,6 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// window.setAttributes(lp); // window.setAttributes(lp);
} }
private TencentLocation obtainTecentLocation(LatLng latLng) {
return new TencentLocation() {
@Override
public String getProvider() {
return "NetWork";
}
@Override
public String getFusionProvider() {
return null;
}
@Override
public String getSourceProvider() {
return null;
}
@Override
public double getLatitude() {
return latLng.getLatitude();
}
@Override
public double getLongitude() {
return latLng.getLongitude();
}
@Override
public double getAltitude() {
return latLng.getAltitude();
}
@Override
public float getAccuracy() {
return 100;
}
@Override
public String getName() {
return "null";
}
@Override
public String getAddress() {
return "null";
}
@Override
public String getNation() {
return "null";
}
@Override
public String getProvince() {
return "null";
}
@Override
public String getCity() {
return "null";
}
@Override
public String getDistrict() {
return "null";
}
@Override
public String getTown() {
return null;
}
@Override
public String getVillage() {
return null;
}
@Override
public String getStreet() {
return null;
}
@Override
public String getStreetNo() {
return null;
}
@Override
public Integer getAreaStat() {
return null;
}
@Override
public List<TencentPoi> getPoiList() {
return null;
}
@Override
public float getBearing() {
return 0;
}
@Override
public float getSpeed() {
return 0;
}
@Override
public long getTime() {
return 0;
}
@Override
public long getElapsedRealtime() {
return 0;
}
@Override
public int getGPSRssi() {
return 0;
}
@Override
public int getInOutStatus() {
return 0;
}
@Override
public String getIndoorBuildingId() {
return null;
}
@Override
public String getIndoorBuildingFloor() {
return null;
}
@Override
public int getIndoorLocationType() {
return 0;
}
@Override
public double getDirection() {
return 0;
}
@Override
public String getCityCode() {
return null;
}
@Override
public String getCityPhoneCode() {
return null;
}
@Override
public TencentMotion getMotion() {
return null;
}
@Override
public int getGpsQuality() {
return 0;
}
@Override
public float getDeltaAngle() {
return 0;
}
@Override
public float getDeltaSpeed() {
return 0;
}
@Override
public int getCoordinateType() {
return 0;
}
@Override
public int getFakeReason() {
return 0;
}
@Override
public int isMockGps() {
return 0;
}
@Override
public Bundle getExtra() {
return null;
}
};
}
private Handler handler = new Handler(new Handler.Callback() { private Handler handler = new Handler(new Handler.Callback() {
@Override @Override
@@ -2139,7 +1983,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
bearing = getBearing(oldCurrentLocation.getX(), currentPoint.getX(), oldCurrentLocation.getY(), currentPoint.getY()); bearing = getBearing(oldCurrentLocation.getX(), currentPoint.getX(), oldCurrentLocation.getY(), currentPoint.getY());
} }
float speed = Constant.currentLocation.getSpeed();//米/秒 float speed = LocationLifeCycle.getInstance().getMainLocation().getSpeed();//米/秒
if (speed != 0) { if (speed != 0) {
speed = (speed * 3600 / 1000);//km/h speed = (speed * 3600 / 1000);//km/h
} else { } else {
@@ -2172,7 +2016,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
public void onEventMessageMainThread(Message msg) { public void onEventMessageMainThread(Message msg) {
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新 if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
if (!locationEnable) { if (!locationEnable) {
write2Log("onEventMessageMainThread", "关闭了获取GPS定位开关"); logger.d(null, "onEventMessageMainThread", "关闭了获取GPS定位开关");
return; return;
} }
TencentLocation tencentLocation = (TencentLocation) msg.obj; TencentLocation tencentLocation = (TencentLocation) msg.obj;
@@ -2187,41 +2031,11 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
// 判断当前点位和上一个点位的距离,如果距离过近,忽略该点 // 判断当前点位和上一个点位的距离,如果距离过近,忽略该点
Point currentPoint = (Point) GeometryTools.createGeometry(new LatLng(tencentLocation.getLatitude(), tencentLocation.getLongitude())); Point currentPoint = (Point) GeometryTools.createGeometry(new LatLng(tencentLocation.getLatitude(), tencentLocation.getLongitude()));
if (lastPositionPoint!=null&&lastPositionPoint.distance(currentPoint)<5e-7) { // 如果当前点小于最小距离阈值,过滤该数据 if (lastPositionPoint!=null&&lastPositionPoint.distance(currentPoint)<5e-7) { // 如果当前点小于最小距离阈值,过滤该数据
write2Log("onEventMessageMainThread", "距离上一点位距离过近:currentPoint-"+currentPoint.toString()+"lastPositionPoint:"+lastPositionPoint.toString()); logger.d(null, "onEventMessageMainThread", "距离上一点位距离过近:currentPoint-"+currentPoint.toString()+"lastPositionPoint:"+lastPositionPoint.toString());
return; return;
} }
lastPositionPoint = currentPoint; lastPositionPoint = currentPoint;
startMatchRoadLink(currentPoint); startMatchRoadLink(currentPoint);
} }
} }
private void write2Log(String tag, String log) {
if (logger == null) {
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
.fileNameGenerator(new DateFileNameGenerator() {
ThreadLocal<SimpleDateFormat> mLocalDateFormat = new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd", Locale.US);
}
};
@Override
public boolean isFileNameChangeable() {
return true;
}
@Override
public String generateFileName(int logLevel, long timestamp) {
SimpleDateFormat sdf = mLocalDateFormat.get();
sdf.setTimeZone(TimeZone.getDefault());
return "AutoTakePicture-"+sdf.format(new Date(timestamp));
}
}) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.flattener(new ClassicFlattener())
.build();
logger = XLog.printers(filePrinter).build();
}
logger.v(null, tag, log);
}
} }
@@ -1,25 +1,13 @@
package com.navinfo.outdoor.activity; package com.navinfo.outdoor.activity;
import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.LogLevel;
import com.elvishew.xlog.XLog; import com.elvishew.xlog.XLog;
import com.elvishew.xlog.flattener.ClassicFlattener;
import com.elvishew.xlog.printer.AndroidPrinter;
import com.elvishew.xlog.printer.ConsolePrinter;
import com.elvishew.xlog.printer.Printer;
import com.elvishew.xlog.printer.file.FilePrinter;
import com.elvishew.xlog.printer.file.backup.BackupStrategy2;
import com.elvishew.xlog.printer.file.backup.FileSizeBackupStrategy2;
import com.elvishew.xlog.printer.file.backup.NeverBackupStrategy;
import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
import com.elvishew.xlog.printer.file.naming.LevelFileNameGenerator;
import com.github.lazylibrary.util.ShellUtils; import com.github.lazylibrary.util.ShellUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.navinfo.ocr.OCRManager;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.api.UserApplication; import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.base.BaseActivity; import com.navinfo.outdoor.base.BaseActivity;
@@ -31,6 +19,8 @@ import com.navinfo.outdoor.fragment.TreasureFragment;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.util.BackHandlerHelper; import com.navinfo.outdoor.util.BackHandlerHelper;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.MyTecentLocationSource;
import com.navinfo.outdoor.util.NaviUtils; import com.navinfo.outdoor.util.NaviUtils;
import com.navinfo.outdoor.util.NoSlideViewPager; import com.navinfo.outdoor.util.NoSlideViewPager;
@@ -38,6 +28,7 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.lifecycle.LifecycleOwner;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
import android.content.Context; import android.content.Context;
@@ -51,6 +42,7 @@ import android.os.Message;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
@@ -102,7 +94,6 @@ public class HomeActivity extends BaseActivity {
return false; return false;
} }
}); });
@Override @Override
protected int getLayout() { protected int getLayout() {
return R.layout.activity_home; return R.layout.activity_home;
@@ -111,34 +102,24 @@ public class HomeActivity extends BaseActivity {
@Override @Override
protected void onCreate(@Nullable Bundle savedInstanceState) { protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.init();
if (Constant.USHERED != null) { if (Constant.USHERED != null) {
Constant.initRootFolder(Constant.USHERED); Constant.initRootFolder(Constant.USHERED);
// 检测用户是否为虚拟定位 // 检测用户是否为虚拟定位
boolean result = handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random())); boolean result = handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random()));
Log.d("HomeActivity", "作弊检查:"+result); Log.d("HomeActivity", "作弊检查:"+result);
LogConfiguration logConfiguration = new LogConfiguration.Builder() // 注册位置更新的lifeCycle
// .enableStackTrace(5) getLifecycle().addObserver(LocationLifeCycle.getInstance());
.enableBorder() // 初始化图像识别组件
.tag("OutDoor").build(); OCRManager.Companion.getInstance().init(HomeActivity.this);
Printer androidPrinter = new AndroidPrinter(true); // 通过 android.util.Log 打印日志的打印器
Printer consolePrinter = new ConsolePrinter(); // 通过 System.out 打印日志到控制台的打印器
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
.fileNameGenerator(new LevelFileNameGenerator()) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.flattener(new ClassicFlattener())
.build();
// 初始化XLog
XLog.init( // 初始化 XLog
logConfiguration, // 指定日志配置,如果不指定,会默认使用 new LogConfiguration.Builder().build()
androidPrinter, // 添加任意多的打印器。如果没有添加任何打印器,会默认使用 AndroidPrinter(Android)/ConsolePrinter(java)
consolePrinter,
filePrinter);
} else { } else {
finish(); finish();
} }
} }
@Override @Override
public void onStart() { public void onStart() {
super.onStart(); super.onStart();
@@ -243,14 +224,14 @@ public class HomeActivity extends BaseActivity {
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
} else if (tab.getPosition() == 1) { } else if (tab.getPosition() == 1) {
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.STAY_SUBMIT_ITEM; obtain.what = Constant.SWITCH_RECORFER_ITEM; // 发送消息给Recorder界面,根据子tab的选项请求数据
obtain.obj = true;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
Message obtain1 = Message.obtain(); // 待提交页面暂时不需要获取,当用户在记录tab下点击已提交后,再去请求 #2023-0216
obtain1.what = Constant.HAS_SUBMIT_ITEM; // Message obtain1 = Message.obtain();
obtain1.obj = true; // obtain1.what = Constant.HAS_SUBMIT_ITEM;
EventBus.getDefault().post(obtain1); // obtain1.obj = true;
// EventBus.getDefault().post(obtain1);
} else if (tab.getPosition() == 3) { } else if (tab.getPosition() == 3) {
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.HOME_MINE; obtain.what = Constant.HOME_MINE;
@@ -383,6 +364,7 @@ public class HomeActivity extends BaseActivity {
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception { public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
Log.d("HomeActivity", "checkMockLocation结果:"+stringBooleanMap.isEmpty()); Log.d("HomeActivity", "checkMockLocation结果:"+stringBooleanMap.isEmpty());
if (!stringBooleanMap.isEmpty()) { if (!stringBooleanMap.isEmpty()) {
Constant.mockGPSMap = stringBooleanMap;
StringBuilder stringBuilder = new StringBuilder("检查到疑似存在以下违规行为:\n"); StringBuilder stringBuilder = new StringBuilder("检查到疑似存在以下违规行为:\n");
for (String key: stringBooleanMap.keySet() for (String key: stringBooleanMap.keySet()
) { ) {
@@ -405,6 +387,7 @@ public class HomeActivity extends BaseActivity {
ArrayList<String> toAddressList = new ArrayList<>(); ArrayList<String> toAddressList = new ArrayList<>();
toAddressList.add("xiaoyan159@qq.com"); toAddressList.add("xiaoyan159@qq.com");
toAddressList.add("huangjichao@navinfo.com"); toAddressList.add("huangjichao@navinfo.com");
toAddressList.add("HanFei1100@navinfo.com");
mail.setToAddress(toAddressList); mail.setToAddress(toAddressList);
mail.setSubject("疑似违规记录"); mail.setSubject("疑似违规记录");
mail.setContent(stringBuilder.append("用户名:").append(Constant.USER_NAME).append("\n") mail.setContent(stringBuilder.append("用户名:").append(Constant.USER_NAME).append("\n")
@@ -523,6 +506,14 @@ public class HomeActivity extends BaseActivity {
return false; return false;
} }
public int getCurrentTabSelected() {
if (mTab!=null) {
return mTab.getSelectedTabPosition();
}
return 0;
}
private String getUid(Context context) { private String getUid(Context context) {
String uid = ""; String uid = "";
try { try {
@@ -556,5 +547,6 @@ public class HomeActivity extends BaseActivity {
PoiDatabase.destroy(); PoiDatabase.destroy();
// 清空登录信息 // 清空登录信息
Constant.clearLoginInfo(); Constant.clearLoginInfo();
getLifecycle().removeObserver(LocationLifeCycle.getInstance());
} }
} }
@@ -37,7 +37,6 @@ import com.navinfo.outdoor.util.APKVersionCodeUtils;
import com.navinfo.outdoor.util.Base64; import com.navinfo.outdoor.util.Base64;
import com.navinfo.outdoor.util.Md5Util; import com.navinfo.outdoor.util.Md5Util;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.umeng.umcrash.UMCrash; import com.umeng.umcrash.UMCrash;
@@ -6,6 +6,10 @@ import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.CountDownTimer; import android.os.CountDownTimer;
@@ -19,7 +23,17 @@ import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.core.content.FileProvider; import androidx.core.content.FileProvider;
import androidx.lifecycle.LifecycleOwner;
import androidx.lifecycle.ProcessLifecycleOwner;
import com.elvishew.xlog.LogConfiguration;
import com.elvishew.xlog.XLog;
import com.elvishew.xlog.flattener.ClassicFlattener;
import com.elvishew.xlog.printer.AndroidPrinter;
import com.elvishew.xlog.printer.ConsolePrinter;
import com.elvishew.xlog.printer.Printer;
import com.elvishew.xlog.printer.file.FilePrinter;
import com.elvishew.xlog.printer.file.naming.LevelFileNameGenerator;
import com.github.lazylibrary.util.AppUtils; import com.github.lazylibrary.util.AppUtils;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
@@ -31,6 +45,7 @@ import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Progress; import com.lzy.okgo.model.Progress;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.base.BaseActivity; import com.navinfo.outdoor.base.BaseActivity;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.navinfo.outdoor.bean.ApkVersionBean; import com.navinfo.outdoor.bean.ApkVersionBean;
@@ -41,9 +56,7 @@ import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.http.UploadCallBack; import com.navinfo.outdoor.http.UploadCallBack;
import com.navinfo.outdoor.util.APKVersionCodeUtils; import com.navinfo.outdoor.util.APKVersionCodeUtils;
import com.navinfo.outdoor.util.Base64; import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.Md5Util;
import com.navinfo.outdoor.util.ToastUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
@@ -60,7 +73,6 @@ import java.util.List;
* 以及自启动 (获取token 获取用户信息) * 以及自启动 (获取token 获取用户信息)
*/ */
public class MainActivity extends BaseActivity { public class MainActivity extends BaseActivity {
private Handler handler = new Handler(new Handler.Callback() { private Handler handler = new Handler(new Handler.Callback() {
@Override @Override
public boolean handleMessage(@NonNull Message msg) { public boolean handleMessage(@NonNull Message msg) {
@@ -115,13 +127,13 @@ public class MainActivity extends BaseActivity {
// 申请多个权限 // 申请多个权限
//.permission(Permission.Group.CALENDAR) //.permission(Permission.Group.CALENDAR)
// 申请读写外部存储卡 // 申请读写外部存储卡
.permission(Permission.MANAGE_EXTERNAL_STORAGE /*, Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE*/) .permission(/*Permission.MANAGE_EXTERNAL_STORAGE,*/ Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE)
// 申请相机权限 // 申请相机权限
.permission(Permission.CAMERA) .permission(Permission.CAMERA)
.permission(Permission.REQUEST_INSTALL_PACKAGES) .permission(Permission.REQUEST_INSTALL_PACKAGES)
// 位置权限 // 位置权限
.permission(Permission.ACCESS_FINE_LOCATION) .permission(Permission.ACCESS_FINE_LOCATION)
.permission(Permission.ACCESS_MEDIA_LOCATION) // .permission(Permission.ACCESS_MEDIA_LOCATION)
//.permission(Permission.ACCESS_BACKGROUND_LOCATION) //.permission(Permission.ACCESS_BACKGROUND_LOCATION)
.permission(Permission.ACCESS_COARSE_LOCATION) .permission(Permission.ACCESS_COARSE_LOCATION)
//读写权限 //读写权限
@@ -130,11 +142,34 @@ public class MainActivity extends BaseActivity {
@Override @Override
public void onGranted(List<String> permissions, boolean all) { public void onGranted(List<String> permissions, boolean all) {
if (all) { if (all) {
LogConfiguration logConfiguration = new LogConfiguration.Builder()
// .enableStackTrace(5)
// .enableBorder()
.tag("XLog").build();
Printer androidPrinter = new AndroidPrinter(true); // 通过 android.util.Log 打印日志的打印器
Printer consolePrinter = new ConsolePrinter(); // 通过 System.out 打印日志到控制台的打印器
Printer filePrinter = new FilePrinter // 打印日志到文件的打印器
.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
.fileNameGenerator(new LevelFileNameGenerator()) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.flattener(new ClassicFlattener())
.build();
// 初始化XLog
XLog.init( // 初始化 XLog
logConfiguration, // 指定日志配置,如果不指定,会默认使用 new LogConfiguration.Builder().build()
androidPrinter, // 添加任意多的打印器。如果没有添加任何打印器,会默认使用 AndroidPrinter(Android)/ConsolePrinter(java)
consolePrinter,
filePrinter);
// 尝试定位
LocationLifeCycle.getInstance().init(getApplicationContext());
// 开始获取腾讯定位信息
LocationLifeCycle.getInstance().startTencentLocation();
if (Constant.USHERED != null) { if (Constant.USHERED != null) {
HttpInterface.initAppPath(Constant.USHERED); HttpInterface.initAppPath(Constant.USHERED);
Constant.initRootFolder(Constant.USHERED); Constant.initRootFolder(Constant.USHERED);
HttpInterface.initHttpInter(Constant.USHERED); HttpInterface.initHttpInter(Constant.USHERED);
// // 检查版本
initCheckVersion(); initCheckVersion();
} else { } else {
initTime(); initTime();
@@ -1,19 +1,30 @@
package com.navinfo.outdoor.activity; package com.navinfo.outdoor.activity;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;
import com.elvishew.xlog.XLog;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseActivity; import com.navinfo.outdoor.base.BaseActivity;
import com.navinfo.outdoor.base.NaviLifeCycle; import com.navinfo.outdoor.base.NaviLifeCycle;
import com.navinfo.outdoor.util.NaviUtils; import com.navinfo.outdoor.util.NaviUtils;
import com.navinfo.outdoor.util.TencentLocationObtain;
import com.tencent.map.fusionlocation.model.TencentGeoLocation;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.map.location.api.GeoLocationObserver;
import com.tencent.map.location.core.FusionGeoLocationAdapter;
import com.tencent.map.navi.TencentNaviManager; import com.tencent.map.navi.TencentNaviManager;
import com.tencent.map.navi.car.CarNaviView; import com.tencent.map.navi.car.CarNaviView;
import com.tencent.map.navi.data.NaviPoi; import com.tencent.map.navi.data.NaviPoi;
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
public class NaviCarActivity extends BaseActivity { public class NaviCarActivity extends BaseActivity {
private CarNaviView carNaviView; private CarNaviView carNaviView;
private LifecycleObserver lifecycleObserver; private LifecycleObserver lifecycleObserver;
private NaviCarViewModel naviCarViewModel;
@Override @Override
protected int getLayout() { protected int getLayout() {
return R.layout.activity_navi_car; return R.layout.activity_navi_car;
@@ -25,12 +36,20 @@ public class NaviCarActivity extends BaseActivity {
carNaviView = findViewById(R.id.carnaviview); carNaviView = findViewById(R.id.carnaviview);
lifecycleObserver = new NaviLifeCycle(carNaviView); lifecycleObserver = new NaviLifeCycle(carNaviView);
getLifecycle().addObserver(lifecycleObserver); getLifecycle().addObserver(lifecycleObserver);
if (naviCarViewModel == null) {
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
}
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, carNaviView); TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, carNaviView);
if (naviCarViewModel.getNaviManager() == null) {
naviCarViewModel.setNaviManager(naviManager);
} else {
naviCarViewModel.getNaviManager().addNaviView(carNaviView);
}
// 获取起终点 // 获取起终点
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start"); LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end"); LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
try { try {
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude)); NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -41,6 +60,6 @@ public class NaviCarActivity extends BaseActivity {
super.onDestroy(); super.onDestroy();
getLifecycle().removeObserver(lifecycleObserver); getLifecycle().removeObserver(lifecycleObserver);
// 如果当前正在导航,自动停止 // 如果当前正在导航,自动停止
NaviUtils.getInstance().stopNavi(); naviCarViewModel.getNaviManager().removeAllNaviViews();
} }
} }
@@ -0,0 +1,23 @@
package com.navinfo.outdoor.activity;
import androidx.lifecycle.ViewModel;
import com.navinfo.outdoor.util.NaviUtils;
import com.tencent.map.navi.TencentNaviManager;
public class NaviCarViewModel extends ViewModel {
private TencentNaviManager naviManager;
public void setNaviManager(TencentNaviManager naviManager) {
this.naviManager = naviManager;
}
public TencentNaviManager getNaviManager() {
return naviManager;
}
@Override
protected void onCleared() {
super.onCleared();
NaviUtils.getInstance().stopNavi();
}
}
@@ -1,6 +1,7 @@
package com.navinfo.outdoor.activity; package com.navinfo.outdoor.activity;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.ViewModelProvider;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
@@ -11,14 +12,17 @@ import com.tencent.map.navi.TencentNaviManager;
import com.tencent.map.navi.car.CarNaviView; import com.tencent.map.navi.car.CarNaviView;
import com.tencent.map.navi.data.NaviPoi; import com.tencent.map.navi.data.NaviPoi;
import com.tencent.map.navi.ride.RideNaviView; import com.tencent.map.navi.ride.RideNaviView;
import com.tencent.map.navi.ride.TencentRideNaviManager;
import com.tencent.map.navi.walk.TencentWalkNaviManager;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
public class NaviRideActivity extends BaseActivity { public class NaviRideActivity extends BaseActivity {
private RideNaviView rideNaviView; private RideNaviView rideNaviView;
private LifecycleObserver lifecycleObserver; private LifecycleObserver lifecycleObserver;
private NaviCarViewModel naviCarViewModel;
@Override @Override
protected int getLayout() { protected int getLayout() {
return R.layout.activity_navi_car; return R.layout.activity_navi_ride;
} }
@Override @Override
@@ -27,12 +31,21 @@ public class NaviRideActivity extends BaseActivity {
rideNaviView = findViewById(R.id.ridenaviview); rideNaviView = findViewById(R.id.ridenaviview);
lifecycleObserver = new NaviLifeCycle(rideNaviView); lifecycleObserver = new NaviLifeCycle(rideNaviView);
getLifecycle().addObserver(lifecycleObserver); getLifecycle().addObserver(lifecycleObserver);
if (naviCarViewModel == null) {
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
}
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, rideNaviView); TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, rideNaviView);
if (naviCarViewModel.getNaviManager() == null) {
naviCarViewModel.setNaviManager(naviManager);
} else {
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(rideNaviView);
}
// 获取起终点 // 获取起终点
LatLng startLatlng = (LatLng) getIntent().getSerializableExtra("start"); LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
LatLng endLatlng = (LatLng) getIntent().getSerializableExtra("end"); LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
try { try {
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude)); NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -43,6 +56,7 @@ public class NaviRideActivity extends BaseActivity {
super.onDestroy(); super.onDestroy();
getLifecycle().removeObserver(lifecycleObserver); getLifecycle().removeObserver(lifecycleObserver);
// 如果当前正在导航,自动停止 // 如果当前正在导航,自动停止
NaviUtils.getInstance().stopNavi(); naviCarViewModel.getNaviManager().removeAllNaviViews();
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(rideNaviView);
} }
} }
@@ -1,6 +1,7 @@
package com.navinfo.outdoor.activity; package com.navinfo.outdoor.activity;
import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.ViewModelProvider;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
@@ -10,15 +11,18 @@ import com.navinfo.outdoor.util.NaviUtils;
import com.tencent.map.navi.TencentNaviManager; import com.tencent.map.navi.TencentNaviManager;
import com.tencent.map.navi.data.NaviPoi; import com.tencent.map.navi.data.NaviPoi;
import com.tencent.map.navi.ride.RideNaviView; import com.tencent.map.navi.ride.RideNaviView;
import com.tencent.map.navi.walk.TencentWalkNaviManager;
import com.tencent.map.navi.walk.WalkNaviView; import com.tencent.map.navi.walk.WalkNaviView;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
public class NaviWalkActivity extends BaseActivity { public class NaviWalkActivity extends BaseActivity {
private WalkNaviView walkNaviView; private WalkNaviView walkNaviView;
private LifecycleObserver lifecycleObserver; private LifecycleObserver lifecycleObserver;
private NaviCarViewModel naviCarViewModel;
@Override @Override
protected int getLayout() { protected int getLayout() {
return R.layout.activity_navi_car; return R.layout.activity_navi_walk;
} }
@Override @Override
@@ -27,12 +31,20 @@ public class NaviWalkActivity extends BaseActivity {
walkNaviView = findViewById(R.id.walknaviview); walkNaviView = findViewById(R.id.walknaviview);
lifecycleObserver = new NaviLifeCycle(walkNaviView); lifecycleObserver = new NaviLifeCycle(walkNaviView);
getLifecycle().addObserver(lifecycleObserver); getLifecycle().addObserver(lifecycleObserver);
if (naviCarViewModel == null) {
naviCarViewModel = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory()).get(NaviCarViewModel.class);
}
TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, walkNaviView); TencentNaviManager naviManager = NaviUtils.getInstance().obitainnaviManager(this, Constant.currentNaviType, walkNaviView);
if (naviCarViewModel.getNaviManager() == null) {
naviCarViewModel.setNaviManager(naviManager);
} else {
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(walkNaviView);
}
// 获取起终点 // 获取起终点
LatLng startLatlng = (LatLng) getIntent().getSerializableExtra("start"); LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
LatLng endLatlng = (LatLng) getIntent().getSerializableExtra("end"); LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
try { try {
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude)); NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -43,6 +55,7 @@ public class NaviWalkActivity extends BaseActivity {
super.onDestroy(); super.onDestroy();
getLifecycle().removeObserver(lifecycleObserver); getLifecycle().removeObserver(lifecycleObserver);
// 如果当前正在导航,自动停止 // 如果当前正在导航,自动停止
NaviUtils.getInstance().stopNavi(); naviCarViewModel.getNaviManager().removeAllNaviViews();
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(walkNaviView);
} }
} }
@@ -33,6 +33,7 @@ import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper; import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.MyTecentLocationSource; import com.navinfo.outdoor.util.MyTecentLocationSource;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.otaliastudios.cameraview.CameraException; import com.otaliastudios.cameraview.CameraException;
@@ -476,10 +477,10 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
tencentMap.animateCamera(cameraUpdateOut); tencentMap.animateCamera(cameraUpdateOut);
break; break;
case R.id.iv_location://定位: case R.id.iv_location://定位:
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getMainLocation() != null) {
CameraUpdate cameraSigma = CameraUpdate cameraSigma =
CameraUpdateFactory.newCameraPosition(new CameraPosition( CameraUpdateFactory.newCameraPosition(new CameraPosition(
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), //中心点坐标,地图目标经纬度
tencentMap.getCameraPosition().zoom, //目标缩放级别 tencentMap.getCameraPosition().zoom, //目标缩放级别
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
0)); //目标旋转角 0~360° (正北方为0) 0)); //目标旋转角 0~360° (正北方为0)
@@ -680,21 +681,21 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
} }
} }
@Subscribe(threadMode = ThreadMode.MAIN) // @Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMessageMainThread(Message msg) { // public void onEventMessageMainThread(Message msg) {
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新 // if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
if (tencentMap != null && !isMapSlide) { // if (tencentMap != null && !isMapSlide) {
TencentLocation tencentLocation = (TencentLocation) msg.obj; // TencentLocation tencentLocation = (TencentLocation) msg.obj;
CameraUpdate cameraSigma = // CameraUpdate cameraSigma =
CameraUpdateFactory.newCameraPosition(new CameraPosition( // CameraUpdateFactory.newCameraPosition(new CameraPosition(
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 // new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
tencentMap.getCameraPosition().zoom, //目标缩放级别 // tencentMap.getCameraPosition().zoom, //目标缩放级别
0, //目标倾斜角 // 0, //目标倾斜角
0)); //目标旋转角 0~360° (正北方为0) // 0)); //目标旋转角 0~360° (正北方为0)
tencentMap.animateCamera(cameraSigma); // tencentMap.animateCamera(cameraSigma);
} // }
} // }
} // }
/** /**
* 记录视频拍摄的时间及经纬度 * 记录视频拍摄的时间及经纬度
@@ -722,17 +723,17 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
sb.append(","); sb.append(",");
sb.append(currentVideoTime);// 记录视频时间 sb.append(currentVideoTime);// 记录视频时间
sb.append(","); sb.append(",");
sb.append(Constant.currentLocation.getLatitude()); sb.append(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
sb.append(","); sb.append(",");
sb.append(Constant.currentLocation.getLongitude()); sb.append(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
sb.append(","); sb.append(",");
if (Constant.currentLocation.getBearing() != 0) { if (LocationLifeCycle.getInstance().getTencentLocation().getBearing() != 0) {
sb.append(Constant.currentLocation.getBearing()); sb.append(LocationLifeCycle.getInstance().getMainLocation().getBearing());
} else { } else {
sb.append(Constant.currentLocation.getDirection()); sb.append(LocationLifeCycle.getInstance().getTencentLocation().getDirection());
} }
sb.append("\r\n"); sb.append("\r\n");
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); LatLng latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.circle); BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.circle);
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng) Marker marker = tencentMap.addMarker(new MarkerOptions(latLng)
.icon(pileDescriptor) .icon(pileDescriptor)
File diff suppressed because it is too large Load Diff
@@ -8,6 +8,7 @@ import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@@ -22,6 +23,7 @@ import com.navinfo.outdoor.util.PoiEntityDeleteUtil;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
@@ -38,6 +40,18 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
return allRoad; return allRoad;
} }
public List<PoiEntity> getCheckedPoiEntity() {
List<PoiEntity> poiEntityList = new ArrayList<>();
if (allRoad!=null&&!allRoad.isEmpty()) {
for (PoiEntity poiEntity: allRoad) {
if (poiEntity.isChecked()) {
poiEntityList.add(poiEntity);
}
}
}
return poiEntityList;
}
public void setAllRoad(List<PoiEntity> allRoad) { public void setAllRoad(List<PoiEntity> allRoad) {
this.allRoad.clear(); this.allRoad.clear();
this.allRoad.addAll(allRoad); this.allRoad.addAll(allRoad);
@@ -65,6 +79,26 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
}).start(); }).start();
} }
/**
* 设置所有的勾选数据的当前状态
* */
public void setAllWorkType(int workType) {
new Thread(new Runnable() {
@Override
public void run() {
synchronized (allRoad) {
for (PoiEntity poiEntity : allRoad) {
if (poiEntity.isChecked()) {
poiEntity.setWork_type(workType);
}
PoiDatabase.getInstance(context).getPoiDao().updatePoiEntity(poiEntity);
}
handler.sendEmptyMessage(0x105);
}
}
}).start();
}
//全选 //全选
public void setAllDataChecked(boolean isChecked) { public void setAllDataChecked(boolean isChecked) {
for (PoiEntity entity : this.allRoad) { for (PoiEntity entity : this.allRoad) {
@@ -119,20 +153,15 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
poiEntity.setChecked(!poiEntity.isChecked()); poiEntity.setChecked(!poiEntity.isChecked());
} }
}); });
if (allRoad.get(position).isChecked()) { if (poiEntity.getWork_type() == 0) {
if (poiEntity.getWork_type() == 0) { holder.tvText.setText("待提交");
holder.tvText.setText("待提交"); } else if (poiEntity.getWork_type() == 1) {
} else if (poiEntity.getWork_type() == 1) { holder.tvText.setText("提交中");
holder.tvText.setText("提交中"); // poiEntity.setChecked(true);
allRoad.get(position).setChecked(true); } else if (poiEntity.getWork_type() == 2) {
} holder.tvText.setText("完成");
} else { } else if (poiEntity.getWork_type() == -1) {
if (poiEntity.getWork_type() == 1) { holder.tvText.setText("出错");
holder.tvText.setText("提交中");
allRoad.get(position).setChecked(true);
} else {
holder.tvText.setText("待提交");
}
} }
holder.itemView.setOnClickListener(new View.OnClickListener() { holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@@ -142,6 +171,23 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
} }
} }
}); });
// 显示进度
if (poiEntity.getWork_type()!=0&&poiEntity.getUploadMax()>0&&poiEntity.getUploadProgress()!=poiEntity.getUploadMax()) {
holder.layerProgress.setVisibility(View.VISIBLE);
holder.pbUpload.setMax(poiEntity.getUploadMax());
holder.pbUpload.setProgress(poiEntity.getUploadProgress());
holder.tvUploadProgress.setText(poiEntity.getUploadProgress()+"/"+poiEntity.getUploadMax());
} else {
holder.layerProgress.setVisibility(View.INVISIBLE);
}
// 显示上传状态
if (poiEntity.getUploadResult()!=null&&!poiEntity.getUploadResult().trim().equals("")) {
holder.tvUploadResult.setVisibility(View.VISIBLE);
holder.tvUploadResult.setText(poiEntity.getUploadResult());
holder.layerProgress.setVisibility(View.GONE); // 上传结果存在,不需要显示进度条
} else {
holder.tvUploadResult.setVisibility(View.INVISIBLE);
}
} }
@Override @Override
@@ -152,6 +198,9 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
public static class ViewHolder extends RecyclerView.ViewHolder { public static class ViewHolder extends RecyclerView.ViewHolder {
private TextView tvName, tvText, tvDay; private TextView tvName, tvText, tvDay;
private CheckBox cbUnSubmit; private CheckBox cbUnSubmit;
private ProgressBar pbUpload;
private TextView tvUploadProgress, tvUploadResult;
private View layerProgress;
public ViewHolder(@NonNull View itemView) { public ViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
@@ -159,6 +208,10 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
tvText = itemView.findViewById(R.id.tv_text); tvText = itemView.findViewById(R.id.tv_text);
tvDay = itemView.findViewById(R.id.tv_road_day); tvDay = itemView.findViewById(R.id.tv_road_day);
cbUnSubmit = itemView.findViewById(R.id.cb_unSubmit); cbUnSubmit = itemView.findViewById(R.id.cb_unSubmit);
pbUpload = itemView.findViewById(R.id.pb_stay_upload);
tvUploadProgress = itemView.findViewById(R.id.tv_pb_stay_upload);
layerProgress = itemView.findViewById(R.id.layer_pb);
tvUploadResult = itemView.findViewById(R.id.tv_upload_result);
} }
} }
@@ -14,6 +14,7 @@ import com.umeng.umcrash.UMCrash;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map;
import java.util.Set; import java.util.Set;
/** /**
@@ -43,6 +44,7 @@ public class Constant {
public static String LOG_FOLDER = ROOT_FOLDER + "/log"; public static String LOG_FOLDER = ROOT_FOLDER + "/log";
public static String GPS_LOG_FOLDER = ROOT_FOLDER + "/gps_log"; public static String GPS_LOG_FOLDER = ROOT_FOLDER + "/gps_log";
public static int TelLength = 0; public static int TelLength = 0;
public static Map<String, Boolean> mockGPSMap; // 是否模拟定位,如果模拟定位,该map不为空
public static void initRootFolder(String userId) { public static void initRootFolder(String userId) {
BASE_FOLDER = ROOT_FOLDER + "/" + userId; BASE_FOLDER = ROOT_FOLDER + "/" + userId;
@@ -149,6 +151,11 @@ public class Constant {
public static final int EVENT_MESSAGE = 55;//提示消息 public static final int EVENT_MESSAGE = 55;//提示消息
public static final int CAPACITY_EVALUATION=59;//能力测试的返回 public static final int CAPACITY_EVALUATION=59;//能力测试的返回
public static final int CHARGING_STATION_DISABLE=60;//能力测试的返回 public static final int CHARGING_STATION_DISABLE=60;//能力测试的返回
public static final int EVENT_WHAT_UPLOAD_PROGRESS=61;// 数据上传的进度progress
public static final int EVENT_WHAT_CHANGE_SLIDING_STATE=62;// 改变抽屉的状态
public static final int EVENT_WHAT_START_DRAW_LINE=63;// 开始绘制参考线
public static final int EVENT_WHAT_FINISH_DRAW_LINE=64;// 完成绘制参考线
public static final int SWITCH_RECORFER_ITEM=65;//记录界面请求数据提醒
public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type"; public static final String INTENT_POI_VIDEO_TYPE = "poi_video_type";
public static int NUMBER = 200; //任务个数 public static int NUMBER = 200; //任务个数
public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1 public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1
@@ -159,7 +166,6 @@ public class Constant {
/* /*
用户当前位置 用户当前位置
*/ */
public static TencentLocation currentLocation;
public static LatLng markerLacing; public static LatLng markerLacing;
public static JobSearchBean jobSearchBean;//数 public static JobSearchBean jobSearchBean;//数
public static MapView treasureMap; public static MapView treasureMap;
@@ -169,10 +175,12 @@ public class Constant {
public static final String INTENT_JPG_PATH = "INTENT_JPG_PATH"; // 拍照界面指定的图片保存位置 public static final String INTENT_JPG_PATH = "INTENT_JPG_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置 public static final String INTENT_PHOTO_PATH = "INTENT_PHOTO_PATH"; // 拍照界面指定的图片保存位置
public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置 public static final String INTENT_PICTURES_PATH = "INTENT_VIDEO_PATH"; // 拍照界面指定的视频文件保存位置
public static final String INTENT_PICTURES_CREDIBLE = "INTENT_PICTURES_CREDIBLE"; // 拍照界面获得的照片置信度
public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意 public static final String INTENT_VIDEO_OBLATION = "INTENT_VIDEO_OBLATION"; // 视频拍摄时屏幕方向 0-强制横屏 其他-任意
public static final String INTENT_TYPE = "type";//poiEntity 的type public static final String INTENT_TYPE = "type";//poiEntity 的type
public static final String INTENT_GEO_WKT = "geowkt";//poiEntity 的geowkt public static final String INTENT_GEO_WKT = "geowkt";//poiEntity 的geowkt
public static final String INTENT_DETAIL = "Detail";//poiEntity 的detail public static final String INTENT_DETAIL = "Detail";//poiEntity 的detail
public static final String MATCH_TRACK = "matchTrack";//poiEntity 的detail
public static SlidingUpPanelLayout SLIDING_LAYOUT = null;//設置 public static SlidingUpPanelLayout SLIDING_LAYOUT = null;//設置
public static TencentMap.OnMarkerClickListener markerClickListener = null; public static TencentMap.OnMarkerClickListener markerClickListener = null;
@@ -232,14 +240,13 @@ public class Constant {
public static String getRssiDesStr(int rssi) { public static String getRssiDesStr(int rssi) {
if (rssi == 0) { if (rssi == 0) {
return "无信号"; return "无信号";
} else if (rssi == 1) { } else if (rssi <= 3) {
return "弱"; return "弱";
} else if (rssi == 2) { } else if (rssi <= 8) {
return "中"; return "中";
} else if (rssi == 3) { } else {
return "强"; return "强";
} }
return "无信号"; // 默认为无信号
} }
public static Set<String> submitIdSet = new HashSet<>(); public static Set<String> submitIdSet = new HashSet<>();
@@ -7,13 +7,12 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.StrictMode; import android.os.StrictMode;
import android.util.Log; import android.util.Log;
import android.widget.RemoteViews;
import androidx.core.app.NotificationCompat; import androidx.lifecycle.ProcessLifecycleOwner;
import com.elvishew.xlog.LogLevel; import com.kongzue.dialogx.DialogX;
import com.elvishew.xlog.XLog; import com.kongzue.dialogx.style.MIUIStyle;
import com.google.gson.Gson; import com.kongzue.dialogx.style.MaterialStyle;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheEntity; import com.lzy.okgo.cache.CacheEntity;
import com.lzy.okgo.cache.CacheMode; import com.lzy.okgo.cache.CacheMode;
@@ -21,13 +20,7 @@ import com.lzy.okgo.cookie.CookieJarImpl;
import com.lzy.okgo.cookie.store.DBCookieStore; import com.lzy.okgo.cookie.store.DBCookieStore;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor; import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders; import com.lzy.okgo.model.HttpHeaders;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.util.CrashHandler;
import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.HomeActivity;
import com.navinfo.outdoor.activity.WebActivity;
import com.navinfo.outdoor.bean.NotificationBean;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.util.TalentLocationUtils;
import com.tencent.map.navi.TencentNavi; import com.tencent.map.navi.TencentNavi;
import com.tencent.navi.surport.utils.DeviceUtils; import com.tencent.navi.surport.utils.DeviceUtils;
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer; import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
@@ -61,7 +54,6 @@ public class UserApplication extends Application {
userApplication = this; userApplication = this;
initUMSDK(); initUMSDK();
initOkGo(); initOkGo();
TalentLocationUtils.getInstance(this).startLocation(this);
//创建一个线程池 //创建一个线程池
fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池 fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池
@@ -74,6 +66,10 @@ public class UserApplication extends Application {
config.setDeviceId(deviceID); config.setDeviceId(deviceID);
// 或者设置开发者自己的的设备号config.setDeviceId(xxxxxxxx); // 或者设置开发者自己的的设备号config.setDeviceId(xxxxxxxx);
TencentNavi.init(this, config); TencentNavi.init(this, config);
// 初始化对话框组件
DialogX.init(this);
DialogX.globalStyle = new MIUIStyle();
CrashHandler.getInstance().init();
} }
public static UserApplication getUserApplication() { public static UserApplication getUserApplication() {
@@ -1,12 +1,18 @@
package com.navinfo.outdoor.base; package com.navinfo.outdoor.base;
import android.Manifest;
import android.app.Activity; import android.app.Activity;
import android.app.Application; import android.app.Application;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@@ -17,10 +23,14 @@ import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.PermissionChecker;
import com.baidu.ai.edge.core.base.Consts;
import com.github.lazylibrary.util.StringUtils; import com.github.lazylibrary.util.StringUtils;
import com.jcodecraeer.xrecyclerview.XRecyclerView; import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
@@ -30,7 +40,11 @@ import com.gyf.immersionbar.ImmersionBar;
import com.navinfo.outdoor.util.NetWorkUtils; import com.navinfo.outdoor.util.NetWorkUtils;
import com.umeng.message.PushAgent; import com.umeng.message.PushAgent;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.Timer; import java.util.Timer;
import java.util.TimerTask; import java.util.TimerTask;
@@ -54,6 +68,10 @@ public abstract class BaseActivity extends AppCompatActivity {
initView(); initView();
initData(); initData();
initListener(); initListener();
requestPermission();
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
} }
private static void setCustomDensity(Application application, Activity activity) { private static void setCustomDensity(Application application, Activity activity) {
@@ -143,6 +161,9 @@ public abstract class BaseActivity extends AppCompatActivity {
super.onDestroy(); super.onDestroy();
dismissLoadingDialog(); dismissLoadingDialog();
Collector.removeActivity(this); Collector.removeActivity(this);
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
} }
/** /**
@@ -157,4 +178,92 @@ public abstract class BaseActivity extends AppCompatActivity {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
} }
} }
@Subscribe(sticky = true)
public void onEventMainThrean(Map<String, String> data) {
if (data.get("code") == "101") {
// 返回开启GPS导航设置界面
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent, 0);
}
}
private static final int REQUEST_PERMISSION = 1;
protected boolean allPermissionsGranted;
private void requestPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
String[] permissions = new String[]{
Manifest.permission.WRITE_EXTERNAL_STORAGE,
};
allPermissionsGranted = true;
for (String perm : permissions) {
if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) {
allPermissionsGranted = false;
break;
}
}
if (!allPermissionsGranted) {
ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION);
} else {
requestAllFilesAccess();
}
} else {
allPermissionsGranted = true;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
if (requestCode == REQUEST_PERMISSION) {
allPermissionsGranted = true;
for (int grantRes : grantResults) {
if (grantRes != PackageManager.PERMISSION_GRANTED) {
allPermissionsGranted = false;
break;
}
}
if (allPermissionsGranted) {
requestAllFilesAccess();
}
}
}
/**
* Android 11 跳转到设置获取SD卡根目录写入权限
*/
private void requestAllFilesAccess() {
if (!Consts.AUTH_REQUIRE_SDCARD) {
return;
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
allPermissionsGranted = false;
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this,
R.style.Theme_AppCompat_Light_Dialog_Alert);
alertBuilder.setMessage("需授权访问SD卡文件");
alertBuilder.setCancelable(false);
alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
});
alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
alertBuilder.show();
}
}
} }
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.MapManager; import com.navinfo.outdoor.util.MapManager;
import com.sothree.slidinguppanel.SlidingUpPanelLayout; import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate; import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
@@ -31,14 +32,15 @@ public abstract class BaseDrawerFragment extends BaseFragment {
protected PoiEntity showPoiEntity; protected PoiEntity showPoiEntity;
public SlidingUpPanelLayout slidingPaneLayout; public SlidingUpPanelLayout slidingPaneLayout;
public TencentMap tencentMap; public TencentMap tencentMap;
protected int matchTrack;
@Override @Override
protected void initData() { protected void initData() {
tencentMap = MapManager.getInstance().getTencentMap(); tencentMap = MapManager.getInstance().getTencentMap();
super.initData(); super.initData();
if (Constant.currentLocation!=null){ if (LocationLifeCycle.getInstance().getTencentLocation()!=null){
int mockGps = Constant.currentLocation.isMockGps(); int mockGps = LocationLifeCycle.getInstance().getTencentLocation().isMockGps();
int gpsRssi = Constant.currentLocation.getGPSRssi();//无信号,信号弱,信号中,信号强 int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();//无信号,信号弱,信号中,信号强
//1为是,0为否,-1为无法判断 //1为是,0为否,-1为无法判断
if (mockGps == 1) { if (mockGps == 1) {
onBackPressed(); onBackPressed();
@@ -138,6 +140,7 @@ public abstract class BaseDrawerFragment extends BaseFragment {
//以键值对的形式添加新值。 //以键值对的形式添加新值。
edit.putString("poiEntity", null); edit.putString("poiEntity", null);
edit.putString("chargingPileEntity", null); edit.putString("chargingPileEntity", null);
edit.putInt("roadVideoType", -1);
//提交新值。必须执行,否则前面的操作都无效。 //提交新值。必须执行,否则前面的操作都无效。
edit.commit(); edit.commit();
} }
@@ -173,4 +176,14 @@ public abstract class BaseDrawerFragment extends BaseFragment {
} }
} }
/**
* 隐藏抽屉界面
* */
public void changeSlidingLayout(int isVisible, SlidingUpPanelLayout.PanelState panelState) {
Message msg = Message.obtain();
msg.what = Constant.EVENT_WHAT_CHANGE_SLIDING_STATE;
msg.arg1 = isVisible;
msg.obj = panelState;
EventBus.getDefault().post(msg);
}
} }
@@ -23,15 +23,8 @@ import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentManager;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.kongzue.dialog.interfaces.OnBackClickListener;
import com.kongzue.dialog.v3.WaitDialog;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.HomeActivity;
import com.navinfo.outdoor.activity.WebActivity; import com.navinfo.outdoor.activity.WebActivity;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.util.BackHandlerHelper;
import com.navinfo.outdoor.util.FragmentBackHandler; import com.navinfo.outdoor.util.FragmentBackHandler;
import com.navinfo.outdoor.util.NetWorkUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@@ -82,7 +75,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
} }
protected <T extends View> T findViewById(@IdRes int id) { protected <T extends View> T findViewById(@IdRes int id) {
return Objects.requireNonNull(getView()).findViewById(id); return requireView().findViewById(id);
} }
protected void debounce(View view) { protected void debounce(View view) {
@@ -99,7 +92,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
if (alertDialog != null) { if (alertDialog != null) {
alertDialog.dismiss(); alertDialog.dismiss();
} }
alertDialog = new AlertDialog.Builder(Objects.requireNonNull(getActivity())).create(); alertDialog = new AlertDialog.Builder(requireActivity()).create();
Objects.requireNonNull(alertDialog.getWindow()).setBackgroundDrawable(new ColorDrawable()); Objects.requireNonNull(alertDialog.getWindow()).setBackgroundDrawable(new ColorDrawable());
alertDialog.setCancelable(false); alertDialog.setCancelable(false);
alertDialog.setOnKeyListener((dialog, keyCode, event) -> { alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
@@ -0,0 +1,84 @@
package com.navinfo.outdoor.base
import android.content.DialogInterface
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.provider.Settings
import android.view.KeyEvent
import android.view.LayoutInflater
import android.view.View
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.github.lazylibrary.util.StringUtils
import com.gyf.immersionbar.ImmersionBar
import com.navinfo.outdoor.R
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
open class BaseViewBindingActivity: AppCompatActivity() {
private var alertDialog: AlertDialog? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// setScreenRoate(true);
//初始化,默认透明状态栏和黑色导航栏
ImmersionBar.with(this).init()
Collector.addActivity(this)
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this)
}
}
fun showLoadingDialog() {
showLoadingDialog(null)
}
fun showLoadingDialog(msg: String?) {
alertDialog?.dismiss()
alertDialog = AlertDialog.Builder(this).create()
alertDialog!!.window?.setBackgroundDrawable(ColorDrawable())
alertDialog!!.setCancelable(false)
alertDialog!!.setOnKeyListener(DialogInterface.OnKeyListener { dialog: DialogInterface?, keyCode: Int, event: KeyEvent? -> keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK })
//loading样式
val view: View = LayoutInflater.from(this).inflate(R.layout.loading, null)
val tv = view.findViewById<TextView>(R.id.progressBar_tx)
if (!StringUtils.isBlank(msg)) {
tv.text = msg
}
alertDialog!!.setView(view)
alertDialog!!.setCanceledOnTouchOutside(false)
alertDialog!!.show()
}
fun setLoadingDialogText(s: String?) {
//给loading 添加文字
val view = alertDialog!!.findViewById<TextView>(R.id.progressBar_tx)
view!!.text = s
}
fun dismissLoadingDialog() {
if (null != alertDialog && alertDialog!!.isShowing()) {
alertDialog!!.dismiss()
}
}
override fun onDestroy() {
super.onDestroy()
dismissLoadingDialog()
Collector.removeActivity(this)
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this)
}
}
@Subscribe(sticky = true)
open fun onEventMainThrean(data: Map<String?, String>) {
if (data["code"] === "101") {
// 返回开启GPS导航设置界面
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
startActivityForResult(intent, 0)
}
}
}
@@ -3,16 +3,19 @@ package com.navinfo.outdoor.fragment;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import android.widget.EditText;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.Toast;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.github.lazylibrary.util.PreferencesUtils;
import com.kongzue.dialogx.dialogs.CustomDialog;
import com.kongzue.dialogx.interfaces.OnBindView;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.RegardMapActivity; import com.navinfo.outdoor.activity.RegardMapActivity;
import com.navinfo.outdoor.activity.WebActivity;
import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.http.HttpInterface;
import java.util.Objects; import java.util.Objects;
@@ -20,7 +23,9 @@ import java.util.Objects;
* 我的-关于页面的fragment * 我的-关于页面的fragment
*/ */
public class AboutFragment extends BaseFragment implements View.OnClickListener { public class AboutFragment extends BaseFragment implements View.OnClickListener {
private View layerSetting; // 设置对应的布局,默认隐藏,用户连击logo显示
private long lastClickTime = 0;
private int settingHookClickCount = 1;
public static AboutFragment newInstance(Bundle bundle) { public static AboutFragment newInstance(Bundle bundle) {
AboutFragment fragment = new AboutFragment(); AboutFragment fragment = new AboutFragment();
fragment.setArguments(bundle); fragment.setArguments(bundle);
@@ -46,13 +51,103 @@ public class AboutFragment extends BaseFragment implements View.OnClickListener
RelativeLayout rlPrivilege = findViewById(R.id.rl_privilege); RelativeLayout rlPrivilege = findViewById(R.id.rl_privilege);
ImageView ivAboutFinish = findViewById(R.id.iv_about_finish); ImageView ivAboutFinish = findViewById(R.id.iv_about_finish);
ivAboutFinish.setOnClickListener(this); ivAboutFinish.setOnClickListener(this);
ImageView imgLogo = findViewById(R.id.img_logo);
layerSetting = findViewById(R.id.layer_setting);
imgLogo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (layerSetting.isShown()) {
return;
}
settingHookClickCount++;
if(lastClickTime > 0){
long secondClickTime = System.currentTimeMillis();//距离上次开机时间
long dtime = secondClickTime - lastClickTime;
if(dtime <800){
if (settingHookClickCount>8) {
Toast.makeText(requireActivity(), "打开设置功能", Toast.LENGTH_SHORT).show();
layerSetting.setVisibility(View.VISIBLE);
} else {
if (settingHookClickCount>3) {
Toast.makeText(requireActivity(), "再点击"+(9-settingHookClickCount)+"下打开设置功能", Toast.LENGTH_SHORT).show();
}
}
} else{
lastClickTime = 0;
settingHookClickCount = 1;
}
}
lastClickTime = System.currentTimeMillis();
}
});
// 图像检查参数设置
findViewById(R.id.rl_picture_check_setting).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CustomDialog.build()
.setAlign(CustomDialog.ALIGN.CENTER)
.setMaskColor(getResources().getColor(R.color.black25))
.setCustomView(new OnBindView<CustomDialog>(R.layout.dialog_picture_check_setting) {
@Override
public void onBind(CustomDialog dialog, View v) {
EditText sensorDegree = v.findViewById(R.id.sensor_degree);
EditText poiMinSpeed = v.findViewById(R.id.poi_speed_min);
EditText poiMaxSpeed = v.findViewById(R.id.poi_speed_max);
EditText roadMinSpeed = v.findViewById(R.id.road_speed_min);
EditText roadMaxSpeed = v.findViewById(R.id.road_speed_max);
EditText satelliteCount = v.findViewById(R.id.satellite_count);
sensorDegree.setText(PreferencesUtils.getString(requireContext(), "sensorDegree", "45"));
poiMinSpeed.setText(PreferencesUtils.getString(requireContext(), "poiMinSpeed", "5"));
poiMaxSpeed.setText(PreferencesUtils.getString(requireContext(), "poiMaxSpeed", "30"));
roadMinSpeed.setText(PreferencesUtils.getString(requireContext(), "roadMinSpeed", "20"));
roadMaxSpeed.setText(PreferencesUtils.getString(requireContext(), "roadMaxSpeed", "120"));
satelliteCount.setText(PreferencesUtils.getString(requireContext(), "satelliteCount", "15"));
v.findViewById(R.id.tv_picture_setting_confirm).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Shared文件中记录对应参数
if (!"".equals(sensorDegree.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "sensorDegree", sensorDegree.getText().toString().trim());
}
if (!"".equals(poiMinSpeed.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "poiMinSpeed", poiMinSpeed.getText().toString().trim());
}
if (!"".equals(poiMaxSpeed.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "poiMaxSpeed", poiMaxSpeed.getText().toString().trim());
}
if (!"".equals(roadMinSpeed.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "roadMinSpeed", roadMinSpeed.getText().toString().trim());
}
if (!"".equals(roadMaxSpeed.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "roadMaxSpeed", roadMaxSpeed.getText().toString().trim());
}
if (!"".equals(satelliteCount.getText().toString().trim())) {
PreferencesUtils.putString(requireContext(), "satelliteCount", satelliteCount.getText().toString().trim());
}
}
});
v.findViewById(R.id.tv_picture_setting_cancel).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
}
})
.show();
}
});
} }
@Override @Override
public void onClick(View v) { public void onClick(View v) {
switch (v.getId()) { switch (v.getId()) {
case R.id.iv_about_finish: case R.id.iv_about_finish:
Objects.requireNonNull(getActivity()).finish(); requireActivity().finish();
break; break;
case R.id.rl_about: case R.id.rl_about:
Intent regardIntent = new Intent(getActivity(), RegardMapActivity.class); Intent regardIntent = new Intent(getActivity(), RegardMapActivity.class);
@@ -0,0 +1,954 @@
package com.navinfo.outdoor.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.StringUtils;
import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.ui.view.SpinnerUtils;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.locationtech.jts.geom.Geometry;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 寻宝-上报弹窗-区域设施
*/
public class AreaHubFragment extends BaseDrawerFragment implements View.OnClickListener {
private EditText etDesc;
private Spinner spnRoadName;
private ImageView ivPoiVideoPicture;
private Button btnRoadSave;
private File fileZip, logFile;
private FrameLayout fmPoiVideoPic;
private LatLng latLng;
private Marker markerPoiVideo;
private TextView tvCombo, tvShort;
private StringBuilder poiVideoBuilder;
private LatLng rearLatLng;
private boolean booleanExtra = true;
public static AreaHubFragment newInstance(Bundle bundle) {
AreaHubFragment fragment = new AreaHubFragment();
fragment.setArguments(bundle);
return fragment;
}
@Override
protected int getLayout() {
return R.layout.traffic_hub_fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
public void onResume() {
super.onResume();
View header = mView.findViewById(R.id.traffic_hub_header);
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBack();
}
});
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FragmentManagement.class);
intent.putExtra("tag", 8);
startActivity(intent);
}
});
moveLatlng(latLng, null);
}
@Override
public boolean onBackPressed() {
initBack();
return true;
}
private void initBack() {
if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
requireActivity().getSupportFragmentManager().popBackStack();
return false;
}
});
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
if (showPoiEntity != null) {
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
filePath.delete();
}
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
requireActivity().getSupportFragmentManager().popBackStack();
return false;
}
});
} else {
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
requireActivity().getSupportFragmentManager().popBackStack();
}
}
}
@Override
protected void initView() {
super.initView();
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
if (slidingPaneLayout != null) {
slidingPaneLayout.setScrollableView(nestedScrollView);
}
spnRoadName = findViewById(R.id.spn_poi_video_name);
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
etDesc = findViewById(R.id.et_desc);
//点击拍照
tvShort = findViewById(R.id.tv_short);
tvShort.setOnClickListener(this);
//自动连拍
tvCombo = findViewById(R.id.tv_combo);
tvCombo.setOnClickListener(this);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
fmPoiVideoPic.setOnClickListener(this);
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
return false;
}
});
return false;
}
});
btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this);
//添加数据
initShowPoi();
((TextView)findViewById(R.id.tv1)).setText("区域设施");
}
@Override
protected void initData() {
super.initData();
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
poiVideoBuilder = new StringBuilder();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
if (Constant.USHERED != null) {
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
}
}
private void initShowPoi() {
// 添加信息:
assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称
SpinnerUtils spinnerUtils = new SpinnerUtils();
String[] items = {"园区外围(含门)", "园区引导图", "园区底商"};
if (StringUtils.isEmpty(name)) {// 如果从数据获取的名称为空,则设置name显示为默认的第一个选项
name = items[0];
}
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spnRoadName.setTag(items[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}, name, items);
String geoWkt = showPoiEntity.getGeoWkt();
if (geoWkt != null) {
String geo = Geohash.getInstance().decode(geoWkt);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //点
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //面
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);//起點
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String detail = showPoiEntity.getDetail();
if (detail != null) {
String geo = Geohash.getInstance().decode(detail);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //点
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //面
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String x = showPoiEntity.getX();
String y = showPoiEntity.getY();
if (x != null && y != null) {
latLng = new LatLng();
latLng.setLongitude(Double.parseDouble(x));
latLng.setLatitude(Double.parseDouble(y));
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
}
}
}
String memo = showPoiEntity.getMemo();//任务描述
if (memo != null && !memo.equals("")) {
etDesc.setText(memo);
}
showPoiEntity.setType(12);
String photoList = showPoiEntity.getPhoto();
if (!StringUtils.isEmpty(photoList)) {
boolean isImageLoad = false;
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
if (showPoiEntity.getTaskStatus() == 3) {
disables();//禁用所有可操作的控件
}
// 如果是推送的POI录像,不允许修改名称
if (showPoiEntity.getTaskId()>0) {
spnRoadName.setEnabled(false);
}
}
}
private void disables() {
spnRoadName.setEnabled(false);
ivPoiVideoPicture.setEnabled(false);
tvShort.setEnabled(false);
tvCombo.setEnabled(false);
etDesc.setEnabled(false);
btnRoadSave.setEnabled(false);
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.PICTURE_VIDEO_WORD) {
if ((boolean) data.obj) {
initPoiVideoSharePre();
}
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() == 1) {
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
} else {
boolean isImageLoad = false;
for (int i = 0; i < fileListByUUID.size(); i++) {
File videoFile = fileListByUUID.get(i);
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
if (videoFile.exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
initPoiVideoSharePre();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fm_poi_video_picture:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() > 1) {
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
photoAlbumIntent.putExtra("tag", 36);
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
startActivity(photoAlbumIntent);
} else {
ToastUtils.Message(getActivity(), "请拍摄");
}
break;
case R.id.btn_poi_video_save:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
initPoiSaveLocal(false);
break;
case R.id.tv_short://点击拍摄
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
if (matchTrack == 0) {
if (geometry > rearGeometry) {//用戶在终点开始作业
if (rearGeometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
}
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRssi == 0) {
intents.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intents.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intents, 0x101);
break;
case R.id.tv_combo://自动连拍:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > rearGeom) {//用戶在终点开始作业
if (rearGeom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRss == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intent.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intent, 0x102);
break;
case R.id.btn_poi_video_upload:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(poiEntity);
}
break;
}
}
public void initPoiSaveLocal(boolean isLocal) {
if (spnRoadName.getTag() == null) {
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称,无法保存!");
return;
}
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
if (all) {
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
Toast.makeText(getActivity(), "POI录像任务必须拍照!", Toast.LENGTH_LONG).show();
return;
}
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
if (poiCheckResult.getCode() == 1) {
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
return;
}
poiEntity.setTaskStatus(2);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiVideoSave(poiEntity);
} else {
poiVideoSaveNet(poiEntity);
}
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(requireActivity(), permissions);
}
}
});
}
private void poiVideoSaveNet(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
if (getActivity() != null) {
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
WaitDialog.dismiss(1000);
}
}
private void poiVideoUpload(PoiEntity poiEntity) {
if (poiEntity.getBodyId() == 0) {
ToastUtils.Message(getActivity(), "请先保存本地在上传");
return;
}
if (Constant.isPresent) {
if (fmPoiVideoPic.getTag() != null) {
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
if (!existsPic) {
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
return;
}
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
@Override
public void onStart() {
dismissLoadingDialog();
Constant.isPresent = false;
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
WaitDialog.dismiss(3000);
}
@Override
public void onFinish() {
Constant.isPresent = true;
}
@Override
public void onError() {
}
});
} else {
dismissLoadingDialog();
ToastUtils.Message(getActivity(), "请录像拍照");
return;
}
} else {
ToastUtils.Message(getActivity(), "该任务正在提交中");
}
}
private void poiVideoSave(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
@Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
if (poiVideoBean.getCode() == 200) {
Integer poiVideoBody = poiVideoBean.getBody();
if (poiVideoBody != null && poiVideoBody != 0) {
poiEntity.setBodyId(poiVideoBody);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiEntity);
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
} else if (poiVideoBean.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101 && resultCode == 0x111) {
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
assert videoPath != null;
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(fileListByUUID);
}
// 更新当前POI的置信度
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
}
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
initPoiVideoSharePre();
}
/* 防止程序崩溃后数据丢失*/
public void initPoiVideoSharePre() {
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型,调用对应的put方法,
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
String newPoiEntity = new Gson().toJson(poiEntity);
//以键值对的形式添加新值。
edit.putString("poiEntity", newPoiEntity);
edit.putInt("roadVideoType", 3);
//提交新值。必须执行,否则前面的操作都无效。
edit.apply();
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
}
@Override
public void onPause() {
super.onPause();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
if (markerPoiVideo != null) {
markerPoiVideo.remove();
}
if (poiVideoBuilder != null) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
poiVideoBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
}
}
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity == null) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", poiEntity.getTaskId());
httpParams.put("auditIds", "");
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(url)
.params(httpParams)
.cls(UnPolygonTaskBean.class)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
new Thread(new Runnable() {
@Override
public void run() {
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
}
}).start();
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), response.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
String roadName = spnRoadName.getTag().toString();
poiEntity.setName(roadName);
// if (!roadName.equals("")) {
// poiEntity.setName(roadName);
// } else {
// @SuppressLint("SimpleDateFormat")
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// Calendar calendars = Calendar.getInstance();
// calendars.setTimeInMillis(System.currentTimeMillis());
// String formats = formatter.format(calendars.getTime());
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
// StringBuilder sb = new StringBuilder("poi录像上报");
// if (city != null && !"".equals(city)) {
// sb.append("-");
// sb.append(city);
// }
// if (district != null && !"".equals(district)) {
// sb.append(district);
// }
// sb.append("-").append(formats);
// poiEntity.setName(sb.toString());
// requireActivity().runOnUiThread(new Runnable() {
// @Override
// public void run() {
// etRoadName.setText(sb);
// }
// });
// }
String desc = etDesc.getText().toString().trim();
if (!desc.equals("")) {
poiEntity.setMemo(desc);
}
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
poiEntity.setCreateTime(format);
poiEntity.setChecked(false);
poiEntity.setType(12);
if (latLng != null) {
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
poiEntity.setGeoWkt(encode);
poiEntity.setX(String.valueOf(latLng.longitude));
poiEntity.setY(String.valueOf(latLng.latitude));
}
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
fmPoiVideoPic.setTag(fileListByUUID);
if (booleanExtra) {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
} else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
}
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
poiEntity.setPhoto(fileListByUUID.size()+"");
}
}
return poiEntity;
}
@Override
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
PoiCheckResult poiCheckResult = new PoiCheckResult();
if (entity.getPhoto() == null) {
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请拍摄");
return poiCheckResult;
}
return poiCheckResult;
}
@Override
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
return null;
}
@Override
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
return null;
}
}
File diff suppressed because it is too large Load Diff
@@ -50,9 +50,9 @@ import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PhotoUtils; import com.navinfo.outdoor.util.PhotoUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.tencentmap.mapsdk.maps.TencentMap; import com.tencent.tencentmap.mapsdk.maps.TencentMap;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
@@ -1047,70 +1047,70 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC
case R.id.rl_panorama: case R.id.rl_panorama:
chargingPileBuilder.append("点击了全景照片进行拍照,"); chargingPileBuilder.append("点击了全景照片进行拍照,");
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class); Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
File panoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File panoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, panoramaFile.getPath()); intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, panoramaFile.getPath());
startActivityForResult(intentPanorama, 101); startActivityForResult(intentPanorama, 101);
break; break;
case R.id.rl_coding: case R.id.rl_coding:
chargingPileBuilder.append("点击了充电桩编码进行拍照,"); chargingPileBuilder.append("点击了充电桩编码进行拍照,");
Intent intentCoding = new Intent(getActivity(), PhotographActivity.class); Intent intentCoding = new Intent(getActivity(), PhotographActivity.class);
File codingFile = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File codingFile = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentCoding.putExtra(Constant.INTENT_PHOTO_PATH, codingFile.getPath()); intentCoding.putExtra(Constant.INTENT_PHOTO_PATH, codingFile.getPath());
startActivityForResult(intentCoding, 102); startActivityForResult(intentCoding, 102);
break; break;
case R.id.rl_equipment: case R.id.rl_equipment:
chargingPileBuilder.append("点击了设备标牌进行拍照,"); chargingPileBuilder.append("点击了设备标牌进行拍照,");
Intent intentEquipment = new Intent(getActivity(), PhotographActivity.class); Intent intentEquipment = new Intent(getActivity(), PhotographActivity.class);
File equipmentFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File equipmentFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentEquipment.putExtra(Constant.INTENT_PHOTO_PATH, equipmentFile.getPath()); intentEquipment.putExtra(Constant.INTENT_PHOTO_PATH, equipmentFile.getPath());
startActivityForResult(intentEquipment, 103); startActivityForResult(intentEquipment, 103);
break; break;
case R.id.rl_facility: case R.id.rl_facility:
chargingPileBuilder.append("点击了设备标牌进行拍照,"); chargingPileBuilder.append("点击了设备标牌进行拍照,");
Intent intentFacility = new Intent(getActivity(), PhotographActivity.class); Intent intentFacility = new Intent(getActivity(), PhotographActivity.class);
File facilityFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File facilityFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentFacility.putExtra(Constant.INTENT_PHOTO_PATH, facilityFile.getPath()); intentFacility.putExtra(Constant.INTENT_PHOTO_PATH, facilityFile.getPath());
startActivityForResult(intentFacility, 104); startActivityForResult(intentFacility, 104);
break; break;
case R.id.rl_scutcheon: case R.id.rl_scutcheon:
chargingPileBuilder.append("点击了设备标牌进行拍照,"); chargingPileBuilder.append("点击了设备标牌进行拍照,");
Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class); Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class);
File scutcheonFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File scutcheonFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath()); intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
startActivityForResult(intentScutcheon, 105); startActivityForResult(intentScutcheon, 105);
break; break;
case R.id.rl_device: case R.id.rl_device:
chargingPileBuilder.append("点击了设备标牌进行拍照,"); chargingPileBuilder.append("点击了设备标牌进行拍照,");
Intent intentDevice = new Intent(getActivity(), PhotographActivity.class); Intent intentDevice = new Intent(getActivity(), PhotographActivity.class);
File deviceFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File deviceFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentDevice.putExtra(Constant.INTENT_PHOTO_PATH, deviceFile.getPath()); intentDevice.putExtra(Constant.INTENT_PHOTO_PATH, deviceFile.getPath());
startActivityForResult(intentDevice, 106); startActivityForResult(intentDevice, 106);
break; break;
case R.id.rl_usable: case R.id.rl_usable:
chargingPileBuilder.append("点击了可用状态进行拍照,"); chargingPileBuilder.append("点击了可用状态进行拍照,");
Intent intentUsable = new Intent(getActivity(), PhotographActivity.class); Intent intentUsable = new Intent(getActivity(), PhotographActivity.class);
File usableFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File usableFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentUsable.putExtra(Constant.INTENT_PHOTO_PATH, usableFile.getPath()); intentUsable.putExtra(Constant.INTENT_PHOTO_PATH, usableFile.getPath());
startActivityForResult(intentUsable, 107); startActivityForResult(intentUsable, 107);
break; break;
case R.id.rl_available: case R.id.rl_available:
chargingPileBuilder.append("点击了可用专题进行拍照,"); chargingPileBuilder.append("点击了可用专题进行拍照,");
Intent intentAvailable = new Intent(getActivity(), PhotographActivity.class); Intent intentAvailable = new Intent(getActivity(), PhotographActivity.class);
File availableFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File availableFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentAvailable.putExtra(Constant.INTENT_PHOTO_PATH, availableFile.getPath()); intentAvailable.putExtra(Constant.INTENT_PHOTO_PATH, availableFile.getPath());
startActivityForResult(intentAvailable, 108); startActivityForResult(intentAvailable, 108);
break; break;
case R.id.rl_parking: case R.id.rl_parking:
chargingPileBuilder.append("点击了停车位编号进行拍照,"); chargingPileBuilder.append("点击了停车位编号进行拍照,");
Intent intentParking = new Intent(getActivity(), PhotographActivity.class); Intent intentParking = new Intent(getActivity(), PhotographActivity.class);
File parkingFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File parkingFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentParking.putExtra(Constant.INTENT_PHOTO_PATH, parkingFile.getPath()); intentParking.putExtra(Constant.INTENT_PHOTO_PATH, parkingFile.getPath());
startActivityForResult(intentParking, 109); startActivityForResult(intentParking, 109);
break; break;
case R.id.rl_number: case R.id.rl_number:
chargingPileBuilder.append("点击了停车位编号进行拍照,"); chargingPileBuilder.append("点击了停车位编号进行拍照,");
Intent intentNumber = new Intent(getActivity(), PhotographActivity.class); Intent intentNumber = new Intent(getActivity(), PhotographActivity.class);
File numberFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File numberFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentNumber.putExtra(Constant.INTENT_PHOTO_PATH, numberFile.getPath()); intentNumber.putExtra(Constant.INTENT_PHOTO_PATH, numberFile.getPath());
startActivityForResult(intentNumber, 110); startActivityForResult(intentNumber, 110);
break; break;
@@ -52,6 +52,7 @@ import com.navinfo.outdoor.adapter.ChargingPileAdapter;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
@@ -1052,35 +1053,35 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
case R.id.rl_panorama: case R.id.rl_panorama:
chargingStationBuilder.append(TimestampUtil.time()).append("点击了全景照片进行拍照 ,"); chargingStationBuilder.append(TimestampUtil.time()).append("点击了全景照片进行拍照 ,");
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class); Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
File PanoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File PanoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, PanoramaFile.getPath()); intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, PanoramaFile.getPath());
startActivityForResult(intentPanorama, 101); startActivityForResult(intentPanorama, 101);
break; break;
case R.id.rl_name: case R.id.rl_name:
chargingStationBuilder.append(TimestampUtil.time()).append("点击了名称照片进行拍照 ,"); chargingStationBuilder.append(TimestampUtil.time()).append("点击了名称照片进行拍照 ,");
Intent intentName = new Intent(getActivity(), PhotographActivity.class); Intent intentName = new Intent(getActivity(), PhotographActivity.class);
File nameFile = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File nameFile = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentName.putExtra(Constant.INTENT_PHOTO_PATH, nameFile.getPath()); intentName.putExtra(Constant.INTENT_PHOTO_PATH, nameFile.getPath());
startActivityForResult(intentName, 102); startActivityForResult(intentName, 102);
break; break;
case R.id.rl_internal_photos: case R.id.rl_internal_photos:
chargingStationBuilder.append(TimestampUtil.time()).append("点击了服务说明进行拍照 ,"); chargingStationBuilder.append(TimestampUtil.time()).append("点击了服务说明进行拍照 ,");
Intent intentInternal = new Intent(getActivity(), PhotographActivity.class); Intent intentInternal = new Intent(getActivity(), PhotographActivity.class);
File internalFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File internalFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, internalFile.getPath()); intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, internalFile.getPath());
startActivityForResult(intentInternal, 103); startActivityForResult(intentInternal, 103);
break; break;
case R.id.rl_else: case R.id.rl_else:
chargingStationBuilder.append(TimestampUtil.time()).append("点击了充电站指引牌进行拍照 ,"); chargingStationBuilder.append(TimestampUtil.time()).append("点击了充电站指引牌进行拍照 ,");
Intent intentElse = new Intent(getActivity(), PhotographActivity.class); Intent intentElse = new Intent(getActivity(), PhotographActivity.class);
File elseFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File elseFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, elseFile.getPath()); intentElse.putExtra(Constant.INTENT_PHOTO_PATH, elseFile.getPath());
startActivityForResult(intentElse, 104); startActivityForResult(intentElse, 104);
break; break;
case R.id.rl_scutcheon: case R.id.rl_scutcheon:
chargingStationBuilder.append(TimestampUtil.time()).append("点击了停车收费标牌进行拍照 ,"); chargingStationBuilder.append(TimestampUtil.time()).append("点击了停车收费标牌进行拍照 ,");
Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class); Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class);
File scutcheonFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File scutcheonFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath()); intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
startActivityForResult(intentScutcheon, 105); startActivityForResult(intentScutcheon, 105);
break; break;
@@ -5,6 +5,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.os.HandlerThread;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
@@ -16,12 +17,14 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.ToastUtils;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.AutoTakePictureActivity;
import com.navinfo.outdoor.activity.NaviCarActivity; import com.navinfo.outdoor.activity.NaviCarActivity;
import com.navinfo.outdoor.activity.NaviRideActivity; import com.navinfo.outdoor.activity.NaviRideActivity;
import com.navinfo.outdoor.activity.NaviWalkActivity; import com.navinfo.outdoor.activity.NaviWalkActivity;
@@ -44,12 +47,9 @@ import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.NaviUtils; import com.navinfo.outdoor.util.NaviUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.lbssearch.httpresponse.Poi;
import com.tencent.map.navi.car.TencentCarNaviManager;
import com.tencent.map.navi.data.NaviPoi;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
@@ -60,6 +60,7 @@ import java.math.RoundingMode;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@@ -73,6 +74,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
private File logFile; private File logFile;
private StringBuilder gatherGetBuilder; private StringBuilder gatherGetBuilder;
private TextView tvStartNav; private TextView tvStartNav;
private TextView tvMatchTrack; // 手动匹配轨迹照片
public static GatherGetFragment newInstance(Bundle bundle) { public static GatherGetFragment newInstance(Bundle bundle) {
GatherGetFragment fragment = new GatherGetFragment(); GatherGetFragment fragment = new GatherGetFragment();
@@ -83,7 +85,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -115,7 +117,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
//主界面获取焦点 //主界面获取焦点
private void getFocus() { private void getFocus() {
Objects.requireNonNull(getView()).setFocusableInTouchMode(true); requireView().setFocusableInTouchMode(true);
getView().requestFocus(); getView().requestFocus();
getView().setOnKeyListener(new View.OnKeyListener() { getView().setOnKeyListener(new View.OnKeyListener() {
@Override @Override
@@ -153,6 +155,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
TextView tvDistance = findViewById(R.id.tv_distance); TextView tvDistance = findViewById(R.id.tv_distance);
TextView tvDescribe = findViewById(R.id.tv_describe); TextView tvDescribe = findViewById(R.id.tv_describe);
tvStartNav = findViewById(R.id.tv_gather_start_navi); tvStartNav = findViewById(R.id.tv_gather_start_navi);
tvMatchTrack = findViewById(R.id.tv_gather_match_track);
Button btnDelete = findViewById(R.id.btn_delete); Button btnDelete = findViewById(R.id.btn_delete);
btnDelete.setOnClickListener(this); btnDelete.setOnClickListener(this);
btnCancelGet = findViewById(R.id.btn_cancel_get);//取消领取 btnCancelGet = findViewById(R.id.btn_cancel_get);//取消领取
@@ -204,18 +207,59 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
public void selectNaviType(Constant.NAV_TYPE nav_type) { public void selectNaviType(Constant.NAV_TYPE nav_type) {
// 显示导航类型选择的对话框 // 显示导航类型选择的对话框
Constant.currentNaviType = nav_type; Constant.currentNaviType = nav_type;
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX()))); NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
} }
}); });
} else { } else {
// 已选择导航方式 // 已选择导航方式
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX()))); NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
} }
} }
}); });
// 连续点击tvTitle显示匹配轨迹的按钮
tvTitle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (tvMatchTrack.isShown()) {
return;
}
if (poiEntity.getType() != 3 && poiEntity.getType() != 4) {
return;
}
settingHookClickCount++;
if(lastClickTime > 0){
long secondClickTime = System.currentTimeMillis();//距离上次开机时间
long dtime = secondClickTime - lastClickTime;
if(dtime <800){
if (settingHookClickCount>8) {
Toast.makeText(requireActivity(), "打开轨迹自动匹配功能", Toast.LENGTH_SHORT).show();
tvMatchTrack.setVisibility(View.VISIBLE);
} else {
if (settingHookClickCount>5) {
Toast.makeText(requireActivity(), "再点击"+(9-settingHookClickCount)+"下打开设置功能", Toast.LENGTH_SHORT).show();
}
}
} else{
lastClickTime = 0;
settingHookClickCount = 1;
}
}
lastClickTime = System.currentTimeMillis();
}
});
tvMatchTrack.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 与领取任务功能类似,不再检查当前位置与任务之间的距离
initGather(1);
}
});
} }
} }
private long lastClickTime = 0;
private int settingHookClickCount = 1;
/** /**
* *
@@ -300,9 +344,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (type == 2) {//充电站的领取类型 } else if (type == 2) {//充电站的领取类型
chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, false, 1); chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, false, 1);
} else if (type == 3) {//poi录像的领取类型 } else if (type == 3) {//poi录像的领取类型
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, false, 1); taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, false, 1, 0);
} else if (type == 4) {//道路的领取类型 } else if (type == 4) {//道路的领取类型
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1); taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1, 0);
} else if (type == 5) {//其他的领取类型 } else if (type == 5) {//其他的领取类型
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, false, 1); receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, false, 1);
} }
@@ -311,28 +355,28 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
case R.id.btn_gather://立即采集 case R.id.btn_gather://立即采集
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了立即采集的按钮 ,"); gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了立即采集的按钮 ,");
if (poiEntity.getTaskStatus() < 2) { if (poiEntity.getTaskStatus() < 2) {
double latitude = Constant.currentLocation.getLatitude(); double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
double longitude = Constant.currentLocation.getLongitude(); double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置 LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置
LatLng endLatLng = new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())); LatLng endLatLng = new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX()));
double geometry = GeometryTools.distanceToDouble(startLatLng, endLatLng); double geometry = GeometryTools.distanceToDouble(startLatLng, endLatLng);
if (geometry > 5000) { if (geometry > 5000) {
ToastUtils.Message(getActivity(),"作业不在领取范围内,无法采集"); ToastUtils.showToast(getActivity(),"作业不在领取范围内,无法采集");
return; return;
} else { } else {
if (geometry > 50) { if (geometry > 50) {
//Voice.sprat("注意在附近50米范围内进行采集",0); //Voice.sprat("注意在附近50米范围内进行采集",0);
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
initGather(); initGather(0);
//Voice.sprat("注意在附近50米范围内进行采集",1); //Voice.sprat("注意在附近50米范围内进行采集",1);
return false; return false;
} }
}); });
} else { } else {
initGather(); initGather(0);
} }
} }
} }
@@ -342,13 +386,13 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
if (poiEntity != null) { if (poiEntity != null) {
int type = poiEntity.getType(); int type = poiEntity.getType();
if (type == 6) { if (type == 6) {
initSubmitPolygonTask(HttpInterface.COMPLETE, poiEntity); initSubmitPolygonTask(HttpInterface.COMPLETE+"/"+poiEntity.getTaskId(), poiEntity);
} else { } else {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity); PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() { requireActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
poiEntity.setTaskStatus(0); poiEntity.setTaskStatus(0);
@@ -363,7 +407,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} }
} }
private void initGather() { private void initGather(int matchTrack/*是否为根据轨迹手动匹配*/) {
if (poiEntity != null) { if (poiEntity != null) {
int type = poiEntity.getType(); int type = poiEntity.getType();
if (type == 6) { if (type == 6) {
@@ -378,9 +422,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (type == 2) {//充电站的领取类型 } else if (type == 2) {//充电站的领取类型
chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, true, 5); chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, true, 5);
} else if (type == 3) {//poi录像的领取类型 } else if (type == 3) {//poi录像的领取类型
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, true, 5); taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, true, 5, matchTrack);
} else if (type == 4) {//道路的领取类型 } else if (type == 4) {//道路的领取类型
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5); taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5, matchTrack);
} else if (type == 5) {//其他的领取类型 } else if (type == 5) {//其他的领取类型
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, true, 5); receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, true, 5);
} }
@@ -495,7 +539,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
} }
@@ -505,9 +549,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
Log.d("TAG", "onError: " + e.getMessage()); Log.d("TAG", "onError: " + e.getMessage());
} }
@@ -519,78 +563,100 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
*/ */
private void initPolygonTask(String url, PoiEntity poiEntity, boolean aBoolean) { private void initPolygonTask(String url, PoiEntity poiEntity, boolean aBoolean) {
if (poiEntity.getTaskId() == 0) { if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(),"无此任务"); ToastUtils.showToast(getActivity(),"无此任务");
return; return;
} }
showLoadingDialog(); // 如果当前存在未关闭的面状任务,提示用户无法领取,先关闭已领取的面状任务
OkGoBuilder.getInstance() new Thread(new Runnable() {
.time(30) @Override
.Builder(getActivity()) public void run() {
.url(url + "/" + poiEntity.getTaskId()) List<PoiEntity> recivePolygonPoi = new ArrayList<>();
.cls(PolygonTaskBean.class) // 如果点击立即采集,则面状任务taskstatus可能是2,如果点击领取任务,则可能是1,所以需要查询两个状态的数据
.token(Constant.ACCESS_TOKEN) List<PoiEntity> recivePolygonPoi1 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(1, 6);
.params(new HttpParams()) List<PoiEntity> recivePolygonPoi2 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(2, 6);
.getRequest(new Callback<PolygonTaskBean>() { recivePolygonPoi.addAll(recivePolygonPoi1);
recivePolygonPoi.addAll(recivePolygonPoi2);
requireActivity().runOnUiThread(new Runnable() {
@Override @Override
public void onSuccess(PolygonTaskBean response, int id) { public void run() {
dismissLoadingDialog(); if (recivePolygonPoi!=null&&!recivePolygonPoi.isEmpty()) {
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集), ToastUtils.showToast(requireActivity(),"您当前存在已领取的其他面状任务,请先关闭该任务后再领取!");
PolygonTaskBean.BodyBean listBean = response.getBody(); return;
PoiEntity polygonEntity = new PoiEntity();
if (listBean != null) {
polygonEntity.setTaskId(listBean.getId());
polygonEntity.setName(listBean.getName());
polygonEntity.setType(listBean.getType());
polygonEntity.setGeoWkt(listBean.getGeo());
String encodeStr = listBean.getGeo();
String geo = Geohash.getInstance().decode(encodeStr);
// 生成对应的x和y poiEntity.setX
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
polygonEntity.setTaskStatus(1);
}
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), polygonEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
initViewByTaskStatus(1);
ToastUtils.Message(getActivity(),"领取成功");
if (aBoolean) {
initCompleteTask(HttpInterface.SUBMIT_POLYGON_TASK, polygonEntity);
} else {
Message obtains = Message.obtain();
obtains.what = Constant.JOB_WORD_MONITOR;
obtains.obj = true;
EventBus.getDefault().post(obtains);
}
}
});
}
}
}).start();
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(),response.getMessage());
} }
}
@Override showLoadingDialog();
public void onError(Throwable e, int id) { OkGoBuilder.getInstance()
dismissLoadingDialog(); .time(30)
String message = e.getMessage(); .Builder(getActivity())
assert message != null; .url(url + "/" + poiEntity.getTaskId())
if (message.equals("timeout") || message.equals("Read time out")) { .cls(PolygonTaskBean.class)
ToastUtils.Message(getActivity(),"请求超时"); .token(Constant.ACCESS_TOKEN)
} else { .params(new HttpParams())
ToastUtils.Message(getActivity(),message); .getRequest(new Callback<PolygonTaskBean>() {
} @Override
Log.d("TAG", "onError: " + e.getMessage()); public void onSuccess(PolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集),
PolygonTaskBean.BodyBean listBean = response.getBody();
PoiEntity polygonEntity = new PoiEntity();
if (listBean != null) {
polygonEntity.setTaskId(listBean.getId());
polygonEntity.setName(listBean.getName());
polygonEntity.setType(listBean.getType());
polygonEntity.setGeoWkt(listBean.getGeo());
String encodeStr = listBean.getGeo();
String geo = Geohash.getInstance().decode(encodeStr);
// 生成对应的x和y poiEntity.setX
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
polygonEntity.setTaskStatus(1);
}
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), polygonEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
initViewByTaskStatus(1);
ToastUtils.showToast(getActivity(),"领取成功");
if (aBoolean) {
initCompleteTask(HttpInterface.SUBMIT_POLYGON_TASK, polygonEntity);
} else {
Message obtains = Message.obtain();
obtains.what = Constant.JOB_WORD_MONITOR;
obtains.obj = true;
EventBus.getDefault().post(obtains);
}
}
});
}
}
}).start();
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.showToast(getActivity(),response.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.showToast(getActivity(),"请求超时");
} else {
ToastUtils.showToast(getActivity(),message);
}
Log.d("TAG", "onError: " + e.getMessage());
}
});
} }
}); });
}
}).start();
} }
/* /*
@@ -599,7 +665,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
*/ */
private void initEndReceiveTask(String url, PoiEntity poiEntity) { private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity.getTaskId() == 0) { if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(),"无此任务"); ToastUtils.showToast(getActivity(),"无此任务");
return; return;
} }
showLoadingDialog(); showLoadingDialog();
@@ -643,7 +709,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
} }
@@ -653,9 +719,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
} }
}); });
@@ -666,7 +732,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
*/ */
private void initCompleteTask(String url, PoiEntity poiEntity) { private void initCompleteTask(String url, PoiEntity poiEntity) {
if (poiEntity.getTaskId() == 0) { if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(),"无此任务"); ToastUtils.showToast(getActivity(),"无此任务");
return; return;
} }
showLoadingDialog(); showLoadingDialog();
@@ -710,7 +776,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
} }
@@ -720,9 +786,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
} }
}); });
@@ -733,12 +799,23 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
*/ */
private void initSubmitPolygonTask(String url, PoiEntity poiEntity) { private void initSubmitPolygonTask(String url, PoiEntity poiEntity) {
if (poiEntity.getTaskId() == 0) { if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(),"无此任务"); ToastUtils.showToast(getActivity(),"无此任务");
return; return;
} }
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
httpParams.put("id", poiEntity.getTaskId()); httpParams.put("id", poiEntity.getTaskId());
showLoadingDialog(); showLoadingDialog();
// // 隐藏半框弹出界面
// Message obtain = Message.obtain();
// obtain.what = Constant.GATHER_GET_RETURN;
// obtain.obj = false;
// EventBus.getDefault().post(obtain);
// // 刷新地图
// Message obtains = Message.obtain();
// obtains.what = Constant.JOB_WORD_MONITOR;
// obtains.obj = true;
// EventBus.getDefault().post(obtains);
// onBackPressed();
OkGoBuilder.getInstance() OkGoBuilder.getInstance()
.time(30) .time(30)
.Builder(getActivity()) .Builder(getActivity())
@@ -749,18 +826,36 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
.getRequest(new Callback<UnPolygonTaskBean>() { .getRequest(new Callback<UnPolygonTaskBean>() {
@Override @Override
public void onSuccess(UnPolygonTaskBean response, int id) { public void onSuccess(UnPolygonTaskBean response, int id) {
// 隐藏半框弹出界面
Message obtain = Message.obtain();
obtain.what = Constant.GATHER_GET_RETURN;
obtain.obj = false;
EventBus.getDefault().post(obtain);
dismissLoadingDialog(); dismissLoadingDialog();
if (response.getCode() == 200) { if (response.getCode() == 200) {
ToastUtils.showToast(getActivity(), "结束采集成功!");
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity); PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// 刷新地图
Message obtains = Message.obtain();
obtains.what = Constant.JOB_WORD_MONITOR;
obtains.obj = true;
EventBus.getDefault().post(obtains);
}
});
} }
}).start(); }).start();
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
} }
@@ -770,9 +865,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
} }
}); });
@@ -783,7 +878,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
*/ */
private void receivedTaskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) { private void receivedTaskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) {
if (poiEntity.getTaskId() == 0) { if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(),"无此任务"); ToastUtils.showToast(getActivity(),"无此任务");
return; return;
} }
showLoadingDialog(); showLoadingDialog();
@@ -878,7 +973,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
} }
@@ -888,9 +983,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
} }
}); });
@@ -908,7 +1003,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
/** /**
* @param url 不同任务类型对应的url * @param url 不同任务类型对应的url
*/ */
private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) { private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId, int matchTrack) {
showLoadingDialog(); showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder OkGoBuilder okGoBuilder = OkGoBuilder
.getInstance() .getInstance()
@@ -921,7 +1016,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
okGoBuilder.getRequest(new Callback<TaskByNetBean>() { okGoBuilder.getRequest(new Callback<TaskByNetBean>() {
@Override @Override
public void onSuccess(TaskByNetBean response, int id) { public void onSuccess(TaskByNetBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) { if (response.getCode() == 200) {
TaskByNetBean.BodyBean listBean = response.getBody(); TaskByNetBean.BodyBean listBean = response.getBody();
if (listBean != null) { if (listBean != null) {
@@ -957,6 +1051,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.GATHER_GET_MAP; obtain.what = Constant.GATHER_GET_MAP;
obtain.obj = poiListEntity; obtain.obj = poiListEntity;
obtain.arg1 = matchTrack;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
} else { } else {
Message obtain = Message.obtain(); Message obtain = Message.obtain();
@@ -977,6 +1072,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
Message obtain = Message.obtain(); Message obtain = Message.obtain();
obtain.what = Constant.GATHER_GET_MAP; obtain.what = Constant.GATHER_GET_MAP;
obtain.obj = taskIdPoiEntity; obtain.obj = taskIdPoiEntity;
obtain.arg1 = matchTrack;
EventBus.getDefault().post(obtain); EventBus.getDefault().post(obtain);
} else { } else {
Message obtain = Message.obtain(); Message obtain = Message.obtain();
@@ -995,8 +1091,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
ToastUtils.Message(getActivity(),response.getMessage()); ToastUtils.showToast(getActivity(),response.getMessage());
} }
dismissLoadingDialog();
} }
@Override @Override
@@ -1005,9 +1102,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
String message = e.getMessage(); String message = e.getMessage();
assert message != null; assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) { if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(),"请求超时"); ToastUtils.showToast(getActivity(),"请求超时");
} else { } else {
ToastUtils.Message(getActivity(),message); ToastUtils.showToast(getActivity(),message);
} }
} }
}); });
@@ -23,10 +23,14 @@ import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.lzy.okrx2.adapter.FlowableBody;
import com.lzy.okrx2.adapter.FlowableResponse;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.HomeActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.bean.CommonResponse;
import com.navinfo.outdoor.bean.HasSubmitBean; import com.navinfo.outdoor.bean.HasSubmitBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
@@ -34,7 +38,6 @@ import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@@ -46,6 +49,8 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
/** /**
* 记录-已提交 * 记录-已提交
*/ */
@@ -106,7 +111,9 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
initRequest(); // if (((HomeActivity)getActivity()).getCurrentTabSelected() == 1) {
// initRequest();
// }
} }
@Subscribe @Subscribe
@@ -131,6 +138,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
} }
} }
private void initOtherSubMitWork() { private void initOtherSubMitWork() {
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
httpParams.put("type", 5); httpParams.put("type", 5);
@@ -14,14 +14,20 @@ import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop; import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.RequestOptions;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.v3.MessageDialog;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.LoginActivity; import com.navinfo.outdoor.activity.LoginActivity;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.activity.UserActivity; import com.navinfo.outdoor.activity.UserActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.base.BaseFragment;
@@ -29,6 +35,8 @@ import com.navinfo.outdoor.bean.GetPriceBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.DoubleUtil; import com.navinfo.outdoor.util.DoubleUtil;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
@@ -43,8 +51,19 @@ import java.text.DateFormat;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects; import java.util.Objects;
import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/** /**
* 我的Fragment * 我的Fragment
*/ */
@@ -105,6 +124,8 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
rlContact.setOnClickListener(this); rlContact.setOnClickListener(this);
RelativeLayout rlSet = findViewById(R.id.rl_set); RelativeLayout rlSet = findViewById(R.id.rl_set);
rlSet.setOnClickListener(this); rlSet.setOnClickListener(this);
RelativeLayout rlClearCache = findViewById(R.id.rl_clear_cache);
rlClearCache.setOnClickListener(this);
RelativeLayout rlAbout = findViewById(R.id.rl_about); RelativeLayout rlAbout = findViewById(R.id.rl_about);
rlAbout.setOnClickListener(this); rlAbout.setOnClickListener(this);
Button btnQuit = findViewById(R.id.btn_quit); Button btnQuit = findViewById(R.id.btn_quit);
@@ -253,6 +274,85 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
intentContact.putExtra("tag", 21); intentContact.putExtra("tag", 21);
startActivity(intentContact); startActivity(intentContact);
break; break;
case R.id.rl_clear_cache: //清除缓存
mainBuilder.append(TimestampUtil.time()).append(",").append("点击了item 清除缓存操作 ,");
MessageDialog.show((AppCompatActivity) requireActivity(), "注意", "注意,清除缓存操作会删除自动采集保存的照片素材,请确认自动采集任务已完全上传再清除!",
"确认", "取消")
.setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
// 开始清除缓存
Observable.create(new ObservableOnSubscribe<PoiEntity>() {
@Override
public void subscribe(ObservableEmitter<PoiEntity> emitter) throws Exception {
// 查询所有已上传数据,删除对应的文件夹
List<PoiEntity> poiEntityList = PoiDatabase.getInstance(requireActivity()).getPoiDao().getAllPoi();
for (PoiEntity poiEntity:poiEntityList) {
if (poiEntity.getTaskStatus() == 100) { // 只删除已上传完成的数据
emitter.onNext(poiEntity);
}
}
emitter.onComplete();
}
}).subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) throws Exception {
// 删除指定文件夹
File folder = new File(Constant.PICTURE_FOLDER, poiEntity.getId());
if (folder.exists()) {
FileUtils.deleteFile(folder.getAbsolutePath());
}
}
}).doOnComplete(new Action() {
@Override
public void run() throws Exception {
File tmpFolder = new File(Constant.PICTURE_FOLDER, "tmp");
if (tmpFolder.exists()) {
FileUtils.deleteFile(tmpFolder.getAbsolutePath());
}
}
}).observeOn(AndroidSchedulers.mainThread())
.doOnComplete(new Action() {
@Override
public void run() throws Exception {
setLoadingDialogText("正在清理自动采集的照片");
}
})
.subscribe(new Observer<PoiEntity>() {
@Override
public void onSubscribe(Disposable d) {
showLoadingDialog();
}
@Override
public void onNext(PoiEntity poiEntity) {
setLoadingDialogText("正在清理:"+poiEntity.getName());
}
@Override
public void onError(Throwable e) {
dismissLoadingDialog();
}
@Override
public void onComplete() {
dismissLoadingDialog();
ToastUtils.Message(requireActivity(), "缓存清理完成");
}
});
return false;
}
})
.setOnCancelButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
return false;
}
})
.show();
break;
case R.id.rl_about: //关于 case R.id.rl_about: //关于
mainBuilder.append(TimestampUtil.time()).append(",").append("点击了item 跳转到关于页面 ,"); mainBuilder.append(TimestampUtil.time()).append(",").append("点击了item 跳转到关于页面 ,");
Intent intentAbout = new Intent(getActivity(), FragmentManagement.class); Intent intentAbout = new Intent(getActivity(), FragmentManagement.class);
@@ -263,7 +363,7 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
mainBuilder.append(TimestampUtil.time()).append(",").append("点击了退出登录的按钮 ,"); mainBuilder.append(TimestampUtil.time()).append(",").append("点击了退出登录的按钮 ,");
Intent intent = new Intent(getContext(), LoginActivity.class); Intent intent = new Intent(getContext(), LoginActivity.class);
startActivity(intent); startActivity(intent);
Objects.requireNonNull(getActivity()).finish(); requireActivity().finish();
break; break;
} }
} }
@@ -44,6 +44,7 @@ import com.navinfo.outdoor.activity.PhotographActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
@@ -512,14 +513,14 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
case R.id.rl_picture: case R.id.rl_picture:
otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第一个照片进行拍照 ,"); otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第一个照片进行拍照 ,");
Intent intentPicture = new Intent(getActivity(), PhotographActivity.class); Intent intentPicture = new Intent(getActivity(), PhotographActivity.class);
File file = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File file = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentPicture.putExtra(Constant.INTENT_PHOTO_PATH, file.getPath()); intentPicture.putExtra(Constant.INTENT_PHOTO_PATH, file.getPath());
startActivityForResult(intentPicture, 101); startActivityForResult(intentPicture, 101);
break; break;
case R.id.rl_pictures: case R.id.rl_pictures:
otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第二个照片进行拍照 ,"); otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第二个照片进行拍照 ,");
Intent intentPictures = new Intent(getActivity(), PhotographActivity.class); Intent intentPictures = new Intent(getActivity(), PhotographActivity.class);
File files = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File files = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath()); intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath());
startActivityForResult(intentPictures, 102); startActivityForResult(intentPictures, 102);
break; break;
@@ -48,6 +48,7 @@ import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.util.AWMp4ParserHelper; import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
@@ -816,35 +817,35 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
case R.id.rl_panorama: case R.id.rl_panorama:
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了全景图的进行拍照,"); poiBuilder.append(TimestampUtil.time()).append(",").append("点击了全景图的进行拍照,");
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class); Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
File filePanorama = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File filePanorama = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, filePanorama.getPath()); intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, filePanorama.getPath());
startActivityForResult(intentPanorama, 101); startActivityForResult(intentPanorama, 101);
break; break;
case R.id.rl_name: case R.id.rl_name:
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名称的进行拍照,"); poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名称的进行拍照,");
Intent intentName = new Intent(getActivity(), PhotographActivity.class); Intent intentName = new Intent(getActivity(), PhotographActivity.class);
File fileName = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File fileName = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentName.putExtra(Constant.INTENT_PHOTO_PATH, fileName.getPath()); intentName.putExtra(Constant.INTENT_PHOTO_PATH, fileName.getPath());
startActivityForResult(intentName, 102); startActivityForResult(intentName, 102);
break; break;
case R.id.rl_internal_photos: case R.id.rl_internal_photos:
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了内部照片的进行拍照,"); poiBuilder.append(TimestampUtil.time()).append(",").append("点击了内部照片的进行拍照,");
Intent intentInternal = new Intent(getActivity(), PhotographActivity.class); Intent intentInternal = new Intent(getActivity(), PhotographActivity.class);
File fileInternal = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File fileInternal = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, fileInternal.getPath()); intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, fileInternal.getPath());
startActivityForResult(intentInternal, 103); startActivityForResult(intentInternal, 103);
break; break;
case R.id.rl_card: case R.id.rl_card:
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名片的进行拍照,"); poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名片的进行拍照,");
Intent intentCard = new Intent(getActivity(), PhotographActivity.class); Intent intentCard = new Intent(getActivity(), PhotographActivity.class);
File fileCard = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File fileCard = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentCard.putExtra(Constant.INTENT_PHOTO_PATH, fileCard.getPath()); intentCard.putExtra(Constant.INTENT_PHOTO_PATH, fileCard.getPath());
startActivityForResult(intentCard, 104); startActivityForResult(intentCard, 104);
break; break;
case R.id.rl_else: case R.id.rl_else:
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了其他的进行拍照,"); poiBuilder.append(TimestampUtil.time()).append(",").append("点击了其他的进行拍照,");
Intent intentElse = new Intent(getActivity(), PhotographActivity.class); Intent intentElse = new Intent(getActivity(), PhotographActivity.class);
File fileElse = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude())); File fileElse = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, fileElse.getPath()); intentElse.putExtra(Constant.INTENT_PHOTO_PATH, fileElse.getPath());
startActivityForResult(intentElse, 105); startActivityForResult(intentElse, 105);
break; break;
@@ -31,6 +31,7 @@ import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.umeng.commonsdk.debug.D; import com.umeng.commonsdk.debug.D;
@@ -139,7 +140,7 @@ public class PoiTaskFragment extends BaseFragment implements View.OnClickListene
assert getArguments() != null; assert getArguments() != null;
type = getArguments().getInt("type", 0); type = getArguments().getInt("type", 0);
listBeans = new ArrayList<>(); listBeans = new ArrayList<>();
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getMainLocation() != null) {
if (Constant.USHERED != null) { if (Constant.USHERED != null) {
initWork(type, true); initWork(type, true);
} }
@@ -24,7 +24,6 @@ import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.StringUtils; import com.github.lazylibrary.util.StringUtils;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
@@ -40,7 +39,6 @@ import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.OtherUploadPicBean;
import com.navinfo.outdoor.bean.PoiVideoBean; import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean; import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
@@ -48,7 +46,6 @@ import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper; import com.navinfo.outdoor.util.AWMp4ParserHelper;
@@ -56,12 +53,12 @@ import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PoiSaveUtils; import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.navinfo.outdoor.util.UploadUtils; import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.navinfo.outdoor.util.ZipUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
@@ -78,7 +75,6 @@ import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 寻宝-上报弹窗-poi录像 * 寻宝-上报弹窗-poi录像
@@ -95,6 +91,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
private StringBuilder poiVideoBuilder; private StringBuilder poiVideoBuilder;
private LatLng rearLatLng; private LatLng rearLatLng;
private boolean booleanExtra = true; private boolean booleanExtra = true;
private TextView tvDrawLine; // 绘制辅助线
public static PoiVideoFragment newInstance(Bundle bundle) { public static PoiVideoFragment newInstance(Bundle bundle) {
PoiVideoFragment fragment = new PoiVideoFragment(); PoiVideoFragment fragment = new PoiVideoFragment();
@@ -146,18 +143,18 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (showPoiEntity != null) { if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) { if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,"); poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
return false; return false;
} }
}); });
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,"); poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
@@ -185,7 +182,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
obtain1.obj = isSliding; obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1); EventBus.getDefault().post(obtain1);
} }
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
return false; return false;
} }
}); });
@@ -204,7 +201,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
obtain1.obj = isSliding; obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1); EventBus.getDefault().post(obtain1);
} }
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
} }
} }
} }
@@ -232,7 +229,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,"); poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
@@ -250,6 +247,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
}); });
btnRoadSave = findViewById(R.id.btn_poi_video_save); btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this); btnRoadSave.setOnClickListener(this);
tvDrawLine = findViewById(R.id.tv_draw_line_poi_video);
tvDrawLine.setOnClickListener(this::onClick);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload); Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this); btnPoiVideoUpload.setOnClickListener(this);
//添加数据 //添加数据
@@ -259,7 +258,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -287,6 +286,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
// 添加信息: // 添加信息:
assert getArguments() != null; assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity"); showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
matchTrack = getArguments().getInt("matchTrack", 0);
if (showPoiEntity != null) { if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称 String name = showPoiEntity.getName();//名称
if (name != null && !name.equals("")) { if (name != null && !name.equals("")) {
@@ -359,7 +359,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) { if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) { if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧 // 使用glide加载视频的第一帧
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivPoiVideoPicture); Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
isImageLoad = true; isImageLoad = true;
} }
} }
@@ -399,7 +399,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
ivPoiVideoPicture.setImageDrawable(null); ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null); fmPoiVideoPic.setTag(null);
} else { } else {
boolean isImageLoad = false; boolean isImageLoad = false;
for (int i = 0; i < fileListByUUID.size(); i++) { for (int i = 0; i < fileListByUUID.size(); i++) {
File videoFile = fileListByUUID.get(i); File videoFile = fileListByUUID.get(i);
@@ -414,6 +414,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
fmPoiVideoPic.setTag(fileListByUUID); fmPoiVideoPic.setTag(fileListByUUID);
} }
initPoiVideoSharePre(); initPoiVideoSharePre();
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
// 显示原有抽屉画面
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
if (data.arg1 == 1) {
List<LatLng> drawPoints = (List<LatLng>) data.obj;
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
}
} }
} }
@@ -438,20 +445,22 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
break; break;
case R.id.tv_short://点击拍摄 case R.id.tv_short://点击拍摄
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,"); poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
double latitude = Constant.currentLocation.getLatitude(); double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
double longitude = Constant.currentLocation.getLongitude(); double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置 LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離 double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離 double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
if (geometry > rearGeometry) {//用戶在终点开始作业 if (matchTrack == 0) {
if (rearGeometry > 5000) { if (geometry > rearGeometry) {//用戶在终点开始作业
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄"); if (rearGeometry > 5000) {
return; ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
} return;
} else {//用户在起点开始作业 }
if (geometry > 5000) { } else {//用户在起点开始作业
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄"); if (geometry > 5000) {
return; ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} }
} }
Intent intents = new Intent(getActivity(), PicturesActivity.class); Intent intents = new Intent(getActivity(), PicturesActivity.class);
@@ -460,7 +469,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()); intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = Constant.currentLocation.getGPSRssi(); intents.putExtra(Constant.MATCH_TRACK, matchTrack);
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRssi == 0) { if (gpsRssi == 0) {
intents.putExtra(Constant.INTENT_BOOLEAN, false); intents.putExtra(Constant.INTENT_BOOLEAN, false);
} else { } else {
@@ -470,7 +480,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
break; break;
case R.id.tv_combo://自动连拍: case R.id.tv_combo://自动连拍:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,"); poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); //用户当前位置 LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng); double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng); double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > rearGeom) {//用戶在终点开始作业 if (geom > rearGeom) {//用戶在终点开始作业
@@ -490,7 +500,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()); intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRss = Constant.currentLocation.getGPSRssi(); int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRss == 0) { if (gpsRss == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false); intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else { } else {
@@ -505,12 +515,25 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
initPoiSaveLocal(true); initPoiSaveLocal(true);
} else { } else {
poiVideoUpload(poiEntity); poiVideoUpload(poiEntity);
Constant.isPresent = false;
} }
break; break;
case R.id.tv_draw_line_poi_video:
// 开始绘制辅助线,隐藏当前界面,展示地图,用户点击绘制线
changeSlidingLayout(View.GONE, SlidingUpPanelLayout.PanelState.HIDDEN);
startDrawLine();
break;
} }
} }
/**
* 开始绘制参考线
* */
private void startDrawLine() {
Message drawMsg = Message.obtain();
drawMsg.what = Constant.EVENT_WHAT_START_DRAW_LINE;
EventBus.getDefault().post(drawMsg);
}
public void initPoiSaveLocal(boolean isLocal) { public void initPoiSaveLocal(boolean isLocal) {
XXPermissions.with(getContext()) XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE) .permission(Permission.MANAGE_EXTERNAL_STORAGE)
@@ -558,7 +581,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
if (never) { if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限"); ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面 // 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions); XXPermissions.startPermissionActivity(requireActivity(), permissions);
} }
} }
}); });
@@ -569,8 +592,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1); httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30) .time(30)
.Builder(getActivity()) .Builder(getActivity())
@@ -635,8 +660,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1); httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
showLoadingDialog(); showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30) .time(30)
@@ -663,7 +690,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
@Override @Override
public void run() { public void run() {
poiVideoUpload(poiEntity); poiVideoUpload(poiEntity);
Constant.isPresent = false;
} }
}); });
} }
@@ -707,6 +733,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(fileListByUUID); fmPoiVideoPic.setTag(fileListByUUID);
} }
// 更新当前POI的置信度
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
} }
} }
} }
@@ -723,7 +752,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。 //方法注释得知,建议以0或者MODE_PRIVATE为默认值。
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象 //获取Editor对象
SharedPreferences.Editor edit = poi.edit(); SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型,调用对应的put方法, //根据要保存的数据的类型,调用对应的put方法,
@@ -837,8 +866,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
Calendar calendars = Calendar.getInstance(); Calendar calendars = Calendar.getInstance();
calendars.setTimeInMillis(System.currentTimeMillis()); calendars.setTimeInMillis(System.currentTimeMillis());
String formats = formatter.format(calendars.getTime()); String formats = formatter.format(calendars.getTime());
String city = Constant.currentLocation.getCity();//返回当前位置的城市. String city = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县. String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
StringBuilder sb = new StringBuilder("poi录像上报"); StringBuilder sb = new StringBuilder("poi录像上报");
if (city != null && !"".equals(city)) { if (city != null && !"".equals(city)) {
sb.append("-"); sb.append("-");
@@ -849,7 +878,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
sb.append("-").append(formats); sb.append("-").append(formats);
poiEntity.setName(sb.toString()); poiEntity.setName(sb.toString());
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() { requireActivity().runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
etRoadName.setText(sb); etRoadName.setText(sb);
@@ -868,13 +897,19 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
poiEntity.setCreateTime(format); poiEntity.setCreateTime(format);
poiEntity.setChecked(false); poiEntity.setChecked(false);
poiEntity.setType(3); poiEntity.setType(3);
if (latLng != null) {
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
poiEntity.setGeoWkt(encode);
poiEntity.setX(String.valueOf(latLng.longitude));
poiEntity.setY(String.valueOf(latLng.latitude));
}
if (showPoiEntity.getId() != null) { if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null) { if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
fmPoiVideoPic.setTag(fileListByUUID); fmPoiVideoPic.setTag(fileListByUUID);
if (booleanExtra) { if (booleanExtra) {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID); List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null) { if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList); String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) { if (lineString != null) {
poiEntity.setDetail(lineString); poiEntity.setDetail(lineString);
@@ -882,7 +917,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
} }
} else { } else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID); List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null) { if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList); String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) { if (lineString != null) {
poiEntity.setDetail(lineString); poiEntity.setDetail(lineString);
@@ -7,6 +7,7 @@ import android.os.Message;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager; import androidx.viewpager.widget.ViewPager;
@@ -18,6 +19,7 @@ import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.util.NoSlideViewPager; import com.navinfo.outdoor.util.NoSlideViewPager;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
@@ -29,6 +31,7 @@ import java.util.Objects;
public class RecordFragment extends BaseFragment { public class RecordFragment extends BaseFragment {
private final String[] names = {"待提交", "已提交"}; private final String[] names = {"待提交", "已提交"};
private TabLayout tabRecord;
public static RecordFragment newInstance(Bundle bundle) { public static RecordFragment newInstance(Bundle bundle) {
RecordFragment fragment = new RecordFragment(); RecordFragment fragment = new RecordFragment();
@@ -44,7 +47,7 @@ public class RecordFragment extends BaseFragment {
@Override @Override
protected void initView() { protected void initView() {
super.initView(); super.initView();
TabLayout tabRecord = findViewById(R.id.tab_record); tabRecord = findViewById(R.id.tab_record);
NoSlideViewPager vpRecord = findViewById(R.id.vp_record); NoSlideViewPager vpRecord = findViewById(R.id.vp_record);
ArrayList<Fragment> fragments = new ArrayList<>(); ArrayList<Fragment> fragments = new ArrayList<>();
// 待提交 // 待提交
@@ -105,9 +108,37 @@ public class RecordFragment extends BaseFragment {
super.onPause(); super.onPause();
} }
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
}
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy(); super.onDestroy();
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.SWITCH_RECORFER_ITEM) {
if (tabRecord.getSelectedTabPosition() == 0) {
Message obtain = Message.obtain();
obtain.what = Constant.STAY_SUBMIT_ITEM;
obtain.obj = true;
EventBus.getDefault().post(obtain);
} else {
Message obtain1 = Message.obtain();
obtain1.what = Constant.HAS_SUBMIT_ITEM;
obtain1.obj = true;
EventBus.getDefault().post(obtain1);
}
}
} }
} }
@@ -26,7 +26,6 @@ import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide; import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.StringUtils; import com.github.lazylibrary.util.StringUtils;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback; import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission; import com.hjq.permissions.Permission;
@@ -34,24 +33,21 @@ import com.hjq.permissions.XXPermissions;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.CustomDialog;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.WaitDialog; import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.AutoTakePictureActivity;
import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity; import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.util.DataSaveUtils; import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PoiSaveUtils; import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils; import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.navinfo.outdoor.util.UploadUtils;
import com.navinfo.outdoor.bean.OtherUploadPicBean;
import com.navinfo.outdoor.bean.RoadSaveBean; import com.navinfo.outdoor.bean.RoadSaveBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean; import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
@@ -59,13 +55,12 @@ import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.AWMp4ParserHelper; import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.ZipUtils; import com.sothree.slidinguppanel.SlidingUpPanelLayout;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
@@ -83,7 +78,6 @@ import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
/* /*
* 寻宝-点击上传弹窗-道路 * 寻宝-点击上传弹窗-道路
@@ -104,6 +98,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
private RadioGroup rgRoadStatus; // 道路状态的radioGroup private RadioGroup rgRoadStatus; // 道路状态的radioGroup
private EditText edtCheckedOther; private EditText edtCheckedOther;
private int existence = 0; // 是否存在 private int existence = 0; // 是否存在
private TextView tvDrawLine; // 绘制辅助线
public static RoadFragment newInstance(Bundle bundle) { public static RoadFragment newInstance(Bundle bundle) {
RoadFragment fragment = new RoadFragment(); RoadFragment fragment = new RoadFragment();
@@ -149,18 +144,18 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (showPoiEntity != null) { if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) { if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,"); roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity); initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
return false; return false;
} }
}); });
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) { } else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,"); roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
@@ -186,7 +181,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
obtain1.obj = isSliding; obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1); EventBus.getDefault().post(obtain1);
} }
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
return false; return false;
} }
}); });
@@ -205,7 +200,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
obtain1.obj = isSliding; obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1); EventBus.getDefault().post(obtain1);
} }
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack(); requireActivity().getSupportFragmentManager().popBackStack();
} }
} }
} }
@@ -263,7 +258,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
public boolean onLongClick(View v) { public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
roadBuilder.append(TimestampUtil.time()).append(",").append("点击长按删除 确定按钮,"); roadBuilder.append(TimestampUtil.time()).append(",").append("点击长按删除 确定按钮,");
@@ -281,6 +276,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
}); });
btnRoadSave = findViewById(R.id.btn_road_save); btnRoadSave = findViewById(R.id.btn_road_save);
btnRoadSave.setOnClickListener(this); btnRoadSave.setOnClickListener(this);
tvDrawLine = findViewById(R.id.tv_draw_line_road);
tvDrawLine.setOnClickListener(this::onClick);
Button roadUpload = findViewById(R.id.road_upload); Button roadUpload = findViewById(R.id.road_upload);
roadUpload.setOnClickListener(this); roadUpload.setOnClickListener(this);
//数据展示 //数据展示
@@ -290,7 +287,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -318,6 +315,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
// 添加信息: // 添加信息:
assert getArguments() != null; assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity"); showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
matchTrack = getArguments().getInt("matchTrack", 0);
if (showPoiEntity != null) { if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称 String name = showPoiEntity.getName();//名称
if (name != null && !name.equals("")) { if (name != null && !name.equals("")) {
@@ -391,7 +389,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|| fileListByUUID.get(i).getPath().endsWith(".jpg")|| fileListByUUID.get(i).getPath().endsWith(".jpeg")) { || fileListByUUID.get(i).getPath().endsWith(".jpg")|| fileListByUUID.get(i).getPath().endsWith(".jpeg")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) { if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧 // 使用glide加载视频的第一帧
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivRoadPicture); Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivRoadPicture);
isImageLoad = true; isImageLoad = true;
} }
} }
@@ -408,7 +406,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (rgRoadStatus!=null) { if (rgRoadStatus!=null) {
for (int i = 0; i < rgRoadStatus.getChildCount(); i++) { for (int i = 0; i < rgRoadStatus.getChildCount(); i++) {
RadioButton childAt = (RadioButton) rgRoadStatus.getChildAt(i); RadioButton childAt = (RadioButton) rgRoadStatus.getChildAt(i);
if (childAt.getTag().equals(showPoiEntity.getExistence())) { if (Integer.parseInt(childAt.getTag().toString())==showPoiEntity.getExistence()) {
childAt.setChecked(true); childAt.setChecked(true);
break; break;
} }
@@ -487,6 +485,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
fmRoadPic.setTag(fileListByUUID); fmRoadPic.setTag(fileListByUUID);
} }
initRoadSharePre(); initRoadSharePre();
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
// 显示原有抽屉画面
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
if (data.arg1 == 1) {
List<LatLng> drawPoints = (List<LatLng>) data.obj;
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
}
} }
} }
@@ -511,20 +516,22 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
break; break;
case R.id.tv_pictures: case R.id.tv_pictures:
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了自动拍照的按钮 ,"); roadBuilder.append(TimestampUtil.time()).append(",").append("点击了自动拍照的按钮 ,");
double latitude = Constant.currentLocation.getLatitude(); double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
double longitude = Constant.currentLocation.getLongitude(); double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);//用户当前位置 LatLng startLatLng = new LatLng(latitude, longitude);//用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng); double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng); double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);
if (geometry > rearGeometry) {//用戶在终点开始作业 if (matchTrack == 0) { // 普通拍照模式
if (rearGeometry > 5000) { if (geometry > rearGeometry) {//用戶在终点开始作业
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄"); if (rearGeometry > 5000) {
return; ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
} return;
} else {//用户在起点开始作业 }
if (geometry > 5000) { } else {//用户在起点开始作业
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄"); if (geometry > 5000) {
return; ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} }
} }
@@ -563,7 +570,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
// intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()); // intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
// intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); // intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
// intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); // intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
// int gpsRssi = Constant.currentLocation.getGPSRssi(); // int gpsRssi = LocationLifeCycle.getInstance().getMainLocation().getGPSRssi();
// if (gpsRssi == 0) { // if (gpsRssi == 0) {
// intent.putExtra(Constant.INTENT_BOOLEAN, false); // intent.putExtra(Constant.INTENT_BOOLEAN, false);
// } else { // } else {
@@ -581,7 +588,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType()); intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt()); intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail()); intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = Constant.currentLocation.getGPSRssi(); intent.putExtra(Constant.MATCH_TRACK, matchTrack);
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRssi == 0) { if (gpsRssi == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false); intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else { } else {
@@ -597,13 +605,26 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
initPoiSaveLocal(true); initPoiSaveLocal(true);
} else { } else {
poiVideoUpload(poiEntity); poiVideoUpload(poiEntity);
Constant.isPresent = false;
} }
break;
case R.id.tv_draw_line_road:
// 开始绘制辅助线,隐藏当前界面,展示地图,用户点击绘制线
changeSlidingLayout(View.GONE, SlidingUpPanelLayout.PanelState.HIDDEN);
startDrawLine();
break; break;
} }
} }
/**
* 开始绘制参考线
* */
private void startDrawLine() {
Message drawMsg = Message.obtain();
drawMsg.what = Constant.EVENT_WHAT_START_DRAW_LINE;
EventBus.getDefault().post(drawMsg);
}
public void initPoiSaveLocal(boolean isLocal) { public void initPoiSaveLocal(boolean isLocal) {
XXPermissions.with(getContext()) XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE) .permission(Permission.MANAGE_EXTERNAL_STORAGE)
@@ -621,23 +642,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
ToastUtils.Message(getActivity(), poiCheckResult.getMsg()); ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
return; return;
} }
poiEntity.setTaskStatus(2); if (existence == 0&&showPoiEntity.getGeoWkt()!=null) {
new Thread(new Runnable() { DataSaveUtils.checkRoadPoiPicture(showPoiEntity, (List<File>) fmRoadPic.getTag(), new DataSaveUtils.RoadPercentCheckCallback() {
@Override @Override
public void run() { public void callback(double percent) {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity); if (percent<=0.1) {
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() { ToastUtils.Message(getActivity(), "手动拍摄的道路任务覆盖度小于10%时,不能选择‘道路正常开通’");
@Override return;
public void run() {
if (isLocal) {
roadSaveBetWork(poiEntity);
} else {
roadSaveWork(poiEntity);
}
} }
}); doSaveRoadData(poiEntity, isLocal);
} }
}).start(); });
} else {
doSaveRoadData(poiEntity, isLocal);
}
} else { } else {
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请"); ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
} }
@@ -648,18 +666,39 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
if (never) { if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限"); ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面 // 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions); XXPermissions.startPermissionActivity(requireActivity(), permissions);
} }
} }
}); });
} }
private void doSaveRoadData(PoiEntity poiEntity, boolean isLocal) {
poiEntity.setTaskStatus(2);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
roadSaveBetWork(poiEntity);
} else {
roadSaveWork(poiEntity);
}
}
});
}
}).start();
}
private void roadSaveWork(PoiEntity poiEntity) { private void roadSaveWork(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 0); httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 0);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
// 增加对应九天平台的参数 // 增加对应九天平台的参数
httpParams.put("existence", existence); httpParams.put("existence", existence);
@@ -710,7 +749,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
public void onError() { public void onError() {
Constant.isPresent = true;
} }
}); });
} else { } else {
@@ -730,7 +769,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 0); httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 0);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
// 增加对应九天平台的参数 // 增加对应九天平台的参数
httpParams.put("existence", existence); httpParams.put("existence", existence);
@@ -760,7 +800,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
@Override @Override
public void run() { public void run() {
poiVideoUpload(poiEntity); poiVideoUpload(poiEntity);
Constant.isPresent = false;
} }
}); });
} }
@@ -825,7 +864,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。 //方法注释得知,建议以0或者MODE_PRIVATE为默认值。
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象 //获取Editor对象
SharedPreferences.Editor edit = poi.edit(); SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型,调用对应的put方法, //根据要保存的数据的类型,调用对应的put方法,
@@ -935,8 +974,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
Calendar calendars = Calendar.getInstance(); Calendar calendars = Calendar.getInstance();
calendars.setTimeInMillis(System.currentTimeMillis()); calendars.setTimeInMillis(System.currentTimeMillis());
String formats = formatter.format(calendars.getTime()); String formats = formatter.format(calendars.getTime());
String city = Constant.currentLocation.getCity();//返回当前位置的城市. String city = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县. String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
StringBuffer sb = new StringBuffer("道路录像上报"); StringBuffer sb = new StringBuffer("道路录像上报");
if (city != null && !"".equals(city)) { if (city != null && !"".equals(city)) {
sb.append("-"); sb.append("-");
@@ -968,13 +1007,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
poiEntity.setCreateTime(format); poiEntity.setCreateTime(format);
poiEntity.setType(4); poiEntity.setType(4);
poiEntity.setChecked(false); poiEntity.setChecked(false);
poiEntity.setExistence(existence);
if (latLng != null) {
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
poiEntity.setGeoWkt(encode);
poiEntity.setX(String.valueOf(latLng.longitude));
poiEntity.setY(String.valueOf(latLng.latitude));
}
if (showPoiEntity.getId() != null) { if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId()); List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null) { if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
fmRoadPic.setTag(fileListByUUID); fmRoadPic.setTag(fileListByUUID);
if (booleanExtra) {//true if (booleanExtra) {//true
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID); List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null) { if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String encodeList = Geohash.getInstance().encodeList(lineStringByFileList); String encodeList = Geohash.getInstance().encodeList(lineStringByFileList);
if (encodeList != null) { if (encodeList != null) {
poiEntity.setDetail(encodeList); poiEntity.setDetail(encodeList);
@@ -982,7 +1028,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
} }
} else { } else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID); List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null) { if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList); String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) { if (lineString != null) {
poiEntity.setDetail(lineString); poiEntity.setDetail(lineString);
@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.elvishew.xlog.Logger;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.interfaces.OnMenuItemClickListener; import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
@@ -40,14 +41,17 @@ import com.navinfo.outdoor.room.PoiDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PoiEntityDeleteUtil; import com.navinfo.outdoor.util.PoiEntityDeleteUtil;
import com.navinfo.outdoor.util.PoiSaveUtils; import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.TimestampUtil; import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils; import com.navinfo.outdoor.util.ToastUtils;
import com.navinfo.outdoor.util.XLogUtils;
import com.umeng.umcrash.UMCrash; import com.umeng.umcrash.UMCrash;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.io.File; import java.io.File;
import java.text.DateFormat; import java.text.DateFormat;
@@ -56,6 +60,13 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.function.Predicate;
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.schedulers.Schedulers;
/** /**
* 记录-待提交的fragment * 记录-待提交的fragment
@@ -68,6 +79,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
private CheckBox cbSelect; private CheckBox cbSelect;
private File logFile; private File logFile;
private StringBuilder staySubmitBuilder; private StringBuilder staySubmitBuilder;
private Logger logger;
public static StaySubmitFragment newInstance(Bundle bundle) { public static StaySubmitFragment newInstance(Bundle bundle) {
StaySubmitFragment fragment = new StaySubmitFragment(); StaySubmitFragment fragment = new StaySubmitFragment();
@@ -81,6 +93,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
if (!EventBus.getDefault().isRegistered(this)) {//加上判断 if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
} }
logger=XLogUtils.Companion.getInstance().getUploadLogWriter();
} }
@Override @Override
@@ -102,9 +115,11 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
Button btnStaySubmit = findViewById(R.id.btn_stay_submit); Button btnStaySubmit = findViewById(R.id.btn_stay_submit);
tvNumber = findViewById(R.id.tv_number); tvNumber = findViewById(R.id.tv_number);
btnStaySubmit.setOnClickListener(this); btnStaySubmit.setOnClickListener(this);
Button btnStayCancel = findViewById(R.id.btn_stay_cancel);
btnStayCancel.setOnClickListener(this);
RecyclerView stayXrv = findViewById(R.id.stay_xrv); RecyclerView stayXrv = findViewById(R.id.stay_xrv);
stayXrv.setLayoutManager(new LinearLayoutManager(getActivity())); stayXrv.setLayoutManager(new LinearLayoutManager(getActivity()));
stayXrv.addItemDecoration(new DividerItemDecoration(Objects.requireNonNull(getContext()), DividerItemDecoration.VERTICAL)); stayXrv.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));
staySubmitAdapter = new StaySubmitAdapter(getContext()); staySubmitAdapter = new StaySubmitAdapter(getContext());
stayXrv.setAdapter(staySubmitAdapter); stayXrv.setAdapter(staySubmitAdapter);
//点击条目跳转 //点击条目跳转
@@ -141,7 +156,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getMainLocation() != null) {
if (Constant.USHERED != null) { if (Constant.USHERED != null) {
cbSelect.setChecked(false); cbSelect.setChecked(false);
refreshData(); refreshData();
@@ -152,7 +167,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -176,11 +191,11 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
} }
} }
@Subscribe @Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
public void onEvent(Message data) { public void onEvent(Message data) {
if (data.what == Constant.STAY_SUBMIT_ITEM) { if (data.what == Constant.STAY_SUBMIT_ITEM) {
if ((boolean) data.obj) { if ((boolean) data.obj) {
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getMainLocation() != null) {
if (Constant.USHERED != null) { if (Constant.USHERED != null) {
if (cbSelect != null) { if (cbSelect != null) {
cbSelect.setChecked(false); cbSelect.setChecked(false);
@@ -189,6 +204,14 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
} }
} }
} }
} else if (data.what == Constant.EVENT_WHAT_UPLOAD_PROGRESS) {
if (data.obj!=null&&staySubmitAdapter!=null&&staySubmitAdapter.getAllRoad()!=null) {
for (int i = 0; i < staySubmitAdapter.getAllRoad().size(); i++) {
if (data.obj == staySubmitAdapter.getAllRoad().get(i)) {
staySubmitAdapter.notifyItemChanged(i);
}
}
}
} }
} }
@@ -265,7 +288,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
case R.id.cl_stay_type://1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" case R.id.cl_stay_type://1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了待提交的类型 ,"); staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了待提交的类型 ,");
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
BottomMenu.show((AppCompatActivity) Objects.requireNonNull(getContext()), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() { BottomMenu.show((AppCompatActivity) requireActivity(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@Override @Override
public void onClick(String text, int index) { public void onClick(String text, int index) {
@@ -294,14 +317,21 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
}); });
break; break;
case R.id.tv_delete: case R.id.tv_delete:
List<PoiEntity> checkedPoiEntityList = staySubmitAdapter.getCheckedPoiEntity();
if (checkedPoiEntityList == null || checkedPoiEntityList.isEmpty()) {
ToastUtils.Message(getActivity(), "没有勾选任何数据!");
return;
}
logger.d("用户点击批量删除按钮+++++++++++++++++++++++");
staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了删除按钮 ,"); staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了删除按钮 ,");
if (Constant.isPresent) { if (Constant.isPresent) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@SuppressLint("SetTextI18n") @SuppressLint("SetTextI18n")
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
initRequest(staySubmitAdapter.getAllRoad()); logger.d("用户点击确认批量删除按钮+++++++++++++++++++++++");
initRequest(staySubmitAdapter.getCheckedPoiEntity());
return false; return false;
} }
}); });
@@ -311,6 +341,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
break; break;
case R.id.btn_stay_submit://提交 case R.id.btn_stay_submit://提交
staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了提交的按钮 ,"); staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了提交的按钮 ,");
logger.d("用户点击批量上传提交按钮+++++++++++++++++++++++");
if (Constant.isPresent) { if (Constant.isPresent) {
if (poiEntities == null) { if (poiEntities == null) {
poiEntities = new ArrayList<>(); poiEntities = new ArrayList<>();
@@ -334,23 +365,22 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作"); ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作");
} }
break; break;
case R.id.btn_stay_cancel:
// 用户点击取消上传
PoiSaveUtils.getInstance(requireActivity()).cancelUploadPoiEntityBatch();
// 数据上传取消后重置上传状态
staySubmitAdapter.setAllWorkType(0);
// 设置当前没有正在上传的数据
Constant.isPresent = true;
break;
} }
} }
private void initRequest(List<PoiEntity> allRoad) { private void initRequest(List<PoiEntity> poiEntities) {
showLoadingDialog(); showLoadingDialog();
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
ArrayList<PoiEntity> poiEntities = new ArrayList<>();
synchronized (allRoad) {
for (PoiEntity poiEntity : allRoad) {
if (poiEntity.isChecked()) {
poiEntities.add(poiEntity);
PoiEntityDeleteUtil.getInstance().deleteUtil(getContext(), poiEntity);
}
}
}
if (getActivity() != null) { if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() { getActivity().runOnUiThread(new Runnable() {
@Override @Override
@@ -385,7 +415,34 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
public void onSuccess(UnPolygonTaskBean response, int id) { public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog(); dismissLoadingDialog();
if (response.getCode() == 200) { if (response.getCode() == 200) {
staySubmitAdapter.setAllCheckedDelete(); // 启动线程删除对应的图片文件
Observable.fromIterable(poiEntities)
.subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) throws Exception {
PoiEntityDeleteUtil.getInstance().deleteUtil(getContext(), poiEntity);
}
})
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<PoiEntity>() {
@Override
public void accept(PoiEntity poiEntity) throws Exception {
logger.d("数据被删除:"+poiEntity.getId()+"-"+poiEntity.getName()+"-"+poiEntity.getTaskId()+"-"+poiEntity.getBodyId());
}
},
new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
}
},
new Action() { // 最终结束的处理
@Override
public void run() throws Exception {
staySubmitAdapter.setAllCheckedDelete();
}
});
} else if (response.getCode() == 230) { } else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity()); FlushTokenUtil.flushToken(getActivity());
} else { } else {
@@ -0,0 +1,954 @@
package com.navinfo.outdoor.fragment;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.widget.NestedScrollView;
import com.bumptech.glide.Glide;
import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.StringUtils;
import com.google.gson.Gson;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
import com.hjq.permissions.XXPermissions;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.bean.PoiVideoBean;
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.ui.view.SpinnerUtils;
import com.navinfo.outdoor.util.AWMp4ParserHelper;
import com.navinfo.outdoor.util.DataSaveUtils;
import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.PoiSaveUtils;
import com.navinfo.outdoor.util.PreserveUtils;
import com.navinfo.outdoor.util.TimestampUtil;
import com.navinfo.outdoor.util.ToastUtils;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.locationtech.jts.geom.Geometry;
import java.io.File;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
* 寻宝-上报弹窗-交通枢纽
*/
public class TrafficHubFragment extends BaseDrawerFragment implements View.OnClickListener {
private EditText etDesc;
private Spinner spnRoadName;
private ImageView ivPoiVideoPicture;
private Button btnRoadSave;
private File fileZip, logFile;
private FrameLayout fmPoiVideoPic;
private LatLng latLng;
private Marker markerPoiVideo;
private TextView tvCombo, tvShort;
private StringBuilder poiVideoBuilder;
private LatLng rearLatLng;
private boolean booleanExtra = true;
public static TrafficHubFragment newInstance(Bundle bundle) {
TrafficHubFragment fragment = new TrafficHubFragment();
fragment.setArguments(bundle);
return fragment;
}
@Override
protected int getLayout() {
return R.layout.traffic_hub_fragment;
}
@Override
public void onStart() {
super.onStart();
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this);
}
}
@Override
public void onResume() {
super.onResume();
View header = mView.findViewById(R.id.traffic_hub_header);
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
initBack();
}
});
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getActivity(), FragmentManagement.class);
intent.putExtra("tag", 8);
startActivity(intent);
}
});
moveLatlng(latLng, null);
}
@Override
public boolean onBackPressed() {
initBack();
return true;
}
private void initBack() {
if (showPoiEntity != null) {
if (showPoiEntity.getTaskStatus() == 5) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
requireActivity().getSupportFragmentManager().popBackStack();
return false;
}
});
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
if (showPoiEntity != null) {
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
filePath.delete();
}
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
requireActivity().getSupportFragmentManager().popBackStack();
return false;
}
});
} else {
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
Bundle arguments = getArguments();
if (arguments != null) {
isSliding = arguments.getBoolean("isSliding", true);
}
if (isSliding) {
Message obtain1 = Message.obtain();
obtain1.what = Constant.TREASURE_FRAGMENT;
obtain1.obj = isSliding;
EventBus.getDefault().post(obtain1);
}
requireActivity().getSupportFragmentManager().popBackStack();
}
}
}
@Override
protected void initView() {
super.initView();
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
if (slidingPaneLayout != null) {
slidingPaneLayout.setScrollableView(nestedScrollView);
}
spnRoadName = findViewById(R.id.spn_poi_video_name);
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
etDesc = findViewById(R.id.et_desc);
//点击拍照
tvShort = findViewById(R.id.tv_short);
tvShort.setOnClickListener(this);
//自动连拍
tvCombo = findViewById(R.id.tv_combo);
tvCombo.setOnClickListener(this);
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
fmPoiVideoPic.setOnClickListener(this);
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
@Override
public boolean onClick(BaseDialog baseDialog, View v) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
return false;
}
});
return false;
}
});
btnRoadSave = findViewById(R.id.btn_poi_video_save);
btnRoadSave.setOnClickListener(this);
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
btnPoiVideoUpload.setOnClickListener(this);
//添加数据
initShowPoi();
((TextView)findViewById(R.id.tv1)).setText("交通枢纽");
}
@Override
protected void initData() {
super.initData();
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
String pictures_time = sharedPreferences.getString("pictures_time", null);
if (pictures_time == null) {
sharedEdit.putString("pictures_time", newFormat);
sharedEdit.apply();
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
} else {
if (pictures_time.equals(newFormat)) {
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
} else {
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
}
}
poiVideoBuilder = new StringBuilder();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
if (Constant.USHERED != null) {
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
}
}
private void initShowPoi() {
// 添加信息:
assert getArguments() != null;
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
if (showPoiEntity != null) {
String name = showPoiEntity.getName();//名称
SpinnerUtils spinnerUtils = new SpinnerUtils();
String[] items = {"交通枢纽全景", "引导图", "出发、到达层", "上客、落客区", "停车场", "其他"};
if (StringUtils.isEmpty(name)) { // 如果从数据获取的名称为空,则设置name显示为默认的第一个选项
name = items[0];
}
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
spnRoadName.setTag(items[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
}, name, items);
String geoWkt = showPoiEntity.getGeoWkt();
if (geoWkt != null) {
String geo = Geohash.getInstance().decode(geoWkt);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //点
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //面
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);//起點
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String detail = showPoiEntity.getDetail();
if (detail != null) {
String geo = Geohash.getInstance().decode(detail);
Geometry geometry = GeometryTools.createGeometry(geo);
switch (geometry.getGeometryType()) {
case "Point": //点
latLng = GeometryTools.createLatLng(geo);
break;
case "LineString": //线
case "Polygon": //面
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
assert latLineString != null;
latLng = latLineString.get(0);
break;
}
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
} else {
String x = showPoiEntity.getX();
String y = showPoiEntity.getY();
if (x != null && y != null) {
latLng = new LatLng();
latLng.setLongitude(Double.parseDouble(x));
latLng.setLatitude(Double.parseDouble(y));
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
markerPoiVideo.setZIndex(4);
moveLatlng(latLng, null);
}
}
}
String memo = showPoiEntity.getMemo();//任务描述
if (memo != null && !memo.equals("")) {
etDesc.setText(memo);
}
showPoiEntity.setType(11);
String photoList = showPoiEntity.getPhoto();
if (!StringUtils.isEmpty(photoList)) {
boolean isImageLoad = false;
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
if (fileListByUUID.get(i).exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
if (showPoiEntity.getTaskStatus() == 3) {
disables();//禁用所有可操作的控件
}
// 如果是推送的POI录像,不允许修改名称
if (showPoiEntity.getTaskId()>0) {
spnRoadName.setEnabled(false);
}
}
}
private void disables() {
spnRoadName.setEnabled(false);
ivPoiVideoPicture.setEnabled(false);
tvShort.setEnabled(false);
tvCombo.setEnabled(false);
etDesc.setEnabled(false);
btnRoadSave.setEnabled(false);
}
@Subscribe
public void onEvent(Message data) {
if (data.what == Constant.PICTURE_VIDEO_WORD) {
if ((boolean) data.obj) {
initPoiVideoSharePre();
}
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() == 1) {
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
ivPoiVideoPicture.setImageDrawable(null);
fmPoiVideoPic.setTag(null);
} else {
boolean isImageLoad = false;
for (int i = 0; i < fileListByUUID.size(); i++) {
File videoFile = fileListByUUID.get(i);
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
if (videoFile.exists() && !isImageLoad) {
// 使用glide加载视频的第一帧
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
isImageLoad = true;
}
}
}
fmPoiVideoPic.setTag(fileListByUUID);
}
initPoiVideoSharePre();
}
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.fm_poi_video_picture:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID.size() > 1) {
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
photoAlbumIntent.putExtra("tag", 36);
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
startActivity(photoAlbumIntent);
} else {
ToastUtils.Message(getActivity(), "请拍摄");
}
break;
case R.id.btn_poi_video_save:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
initPoiSaveLocal(false);
break;
case R.id.tv_short://点击拍摄
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
if (matchTrack == 0) {
if (geometry > rearGeometry) {//用戶在终点开始作业
if (rearGeometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geometry > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
}
Intent intents = new Intent(getActivity(), PicturesActivity.class);
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRssi == 0) {
intents.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intents.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intents, 0x101);
break;
case R.id.tv_combo://自动连拍:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
double geom = GeometryTools.distanceToDouble(startLng, latLng);
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
if (geom > rearGeom) {//用戶在终点开始作业
if (rearGeom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
} else {//用户在起点开始作业
if (geom > 5000) {
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
return;
}
}
Intent intent = new Intent(getActivity(), PicturesActivity.class);
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
if (gpsRss == 0) {
intent.putExtra(Constant.INTENT_BOOLEAN, false);
} else {
intent.putExtra(Constant.INTENT_BOOLEAN, true);
}
startActivityForResult(intent, 0x102);
break;
case R.id.btn_poi_video_upload:
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
initPoiSaveLocal(true);
} else {
poiVideoUpload(poiEntity);
}
break;
}
}
public void initPoiSaveLocal(boolean isLocal) {
if (spnRoadName.getTag() == null) {
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称,无法保存!");
return;
}
XXPermissions.with(getContext())
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
.request(new OnPermissionCallback() {
@Override
public void onGranted(List<String> permissions, boolean all) {
if (all) {
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
Toast.makeText(getActivity(), "POI录像任务必须拍照!", Toast.LENGTH_LONG).show();
return;
}
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
if (poiCheckResult.getCode() == 1) {
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
return;
}
poiEntity.setTaskStatus(2);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (isLocal) {
poiVideoSave(poiEntity);
} else {
poiVideoSaveNet(poiEntity);
}
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
}
}
@Override
public void onDenied(List<String> permissions, boolean never) {
if (never) {
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
// 如果是被永久拒绝就跳转到应用权限系统设置页面
XXPermissions.startPermissionActivity(requireActivity(), permissions);
}
}
});
}
private void poiVideoSaveNet(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
if (getActivity() != null) {
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
WaitDialog.dismiss(1000);
}
}
private void poiVideoUpload(PoiEntity poiEntity) {
if (poiEntity.getBodyId() == 0) {
ToastUtils.Message(getActivity(), "请先保存本地在上传");
return;
}
if (Constant.isPresent) {
if (fmPoiVideoPic.getTag() != null) {
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
if (!existsPic) {
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
return;
}
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
@Override
public void onStart() {
dismissLoadingDialog();
Constant.isPresent = false;
getActivity().getSupportFragmentManager().popBackStack();//回退
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
WaitDialog.dismiss(3000);
}
@Override
public void onFinish() {
Constant.isPresent = true;
}
@Override
public void onError() {
}
});
} else {
dismissLoadingDialog();
ToastUtils.Message(getActivity(), "请录像拍照");
return;
}
} else {
ToastUtils.Message(getActivity(), "该任务正在提交中");
}
}
private void poiVideoSave(PoiEntity poiEntity) {
HttpParams httpParams = new HttpParams();
httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress());
httpParams.put("geo", poiEntity.getGeoWkt());
// httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
showLoadingDialog();
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(HttpInterface.INSIDE_API_LIST)
.cls(PoiVideoBean.class)
.params(httpParams)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
@Override
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
dismissLoadingDialog();
if (poiVideoBean.getCode() == 200) {
Integer poiVideoBody = poiVideoBean.getBody();
if (poiVideoBody != null && poiVideoBody != 0) {
poiEntity.setBodyId(poiVideoBody);
poiEntity.setTaskStatus(3);
new Thread(new Runnable() {
@Override
public void run() {
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
if (getActivity() != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
poiVideoUpload(poiEntity);
}
});
}
}
}).start();
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
} else if (poiVideoBean.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == 0x101 && resultCode == 0x111) {
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
assert videoPath != null;
File videoFile = new File(videoPath);
if (videoFile.exists()) {
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
fmPoiVideoPic.setTag(fileListByUUID);
}
// 更新当前POI的置信度
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
}
}
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
initPoiVideoSharePre();
}
/* 防止程序崩溃后数据丢失*/
public void initPoiVideoSharePre() {
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象
SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型,调用对应的put方法,
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
String newPoiEntity = new Gson().toJson(poiEntity);
//以键值对的形式添加新值。
edit.putString("poiEntity", newPoiEntity);
edit.putInt("roadVideoType", 1);
//提交新值。必须执行,否则前面的操作都无效。
edit.apply();
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
}
@Override
public void onPause() {
super.onPause();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
}
@Override
public void onStop() {
super.onStop();
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
}
@Override
public void onDestroy() {
if (EventBus.getDefault().isRegistered(this))//加上判断
EventBus.getDefault().unregister(this);
super.onDestroy();
if (markerPoiVideo != null) {
markerPoiVideo.remove();
}
if (poiVideoBuilder != null) {
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
poiVideoBuilder.append("\r\n");
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
}
}
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
if (poiEntity == null) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
if (poiEntity.getTaskId() == 0) {
ToastUtils.Message(getActivity(), "无此任务");
return;
}
HttpParams httpParams = new HttpParams();
httpParams.put("taskIds", poiEntity.getTaskId());
httpParams.put("auditIds", "");
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(getActivity())
.url(url)
.params(httpParams)
.cls(UnPolygonTaskBean.class)
.token(Constant.ACCESS_TOKEN);
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
@Override
public void onSuccess(UnPolygonTaskBean response, int id) {
dismissLoadingDialog();
if (response.getCode() == 200) {
new Thread(new Runnable() {
@Override
public void run() {
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
}
}).start();
if (poiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete();
}
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete();
}
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
obtain.obj = true;
EventBus.getDefault().post(obtain);
} else if (response.getCode() == 230) {
FlushTokenUtil.flushToken(getActivity());
} else {
ToastUtils.Message(getActivity(), response.getMessage());
}
}
@Override
public void onError(Throwable e, int id) {
dismissLoadingDialog();
String message = e.getMessage();
assert message != null;
if (message.equals("timeout") || message.equals("Read time out")) {
ToastUtils.Message(getActivity(), "请求超时");
} else {
ToastUtils.Message(getActivity(), message);
}
}
});
}
@Override
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
String roadName = spnRoadName.getTag().toString();
poiEntity.setName(roadName);
// if (!roadName.equals("")) {
// poiEntity.setName(roadName);
// } else {
// @SuppressLint("SimpleDateFormat")
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
// Calendar calendars = Calendar.getInstance();
// calendars.setTimeInMillis(System.currentTimeMillis());
// String formats = formatter.format(calendars.getTime());
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
// StringBuilder sb = new StringBuilder("poi录像上报");
// if (city != null && !"".equals(city)) {
// sb.append("-");
// sb.append(city);
// }
// if (district != null && !"".equals(district)) {
// sb.append(district);
// }
// sb.append("-").append(formats);
// poiEntity.setName(sb.toString());
// requireActivity().runOnUiThread(new Runnable() {
// @Override
// public void run() {
// etRoadName.setText(sb);
// }
// });
// }
String desc = etDesc.getText().toString().trim();
if (!desc.equals("")) {
poiEntity.setMemo(desc);
}
@SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
String format = formatter.format(calendar.getTime());
poiEntity.setCreateTime(format);
poiEntity.setChecked(false);
poiEntity.setType(11);
if (latLng != null) {
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
poiEntity.setGeoWkt(encode);
poiEntity.setX(String.valueOf(latLng.longitude));
poiEntity.setY(String.valueOf(latLng.latitude));
}
if (showPoiEntity.getId() != null) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
fmPoiVideoPic.setTag(fileListByUUID);
if (booleanExtra) {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
} else {
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
if (lineString != null) {
poiEntity.setDetail(lineString);
}
}
}
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
poiEntity.setPhoto(fileListByUUID.size()+"");
}
}
return poiEntity;
}
@Override
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
PoiCheckResult poiCheckResult = new PoiCheckResult();
if (entity.getPhoto() == null) {
poiCheckResult.setCode(1);
poiCheckResult.setMsg("请拍摄");
return poiCheckResult;
}
return poiCheckResult;
}
@Override
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
return null;
}
@Override
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
return null;
}
}
@@ -20,12 +20,13 @@ import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.Button; import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Spinner;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast; import android.widget.Toast;
@@ -39,6 +40,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.DensityUtil; import com.github.lazylibrary.util.DensityUtil;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -49,20 +51,20 @@ import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener; import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
import com.kongzue.dialog.util.BaseDialog; import com.kongzue.dialog.util.BaseDialog;
import com.kongzue.dialog.util.DialogSettings; import com.kongzue.dialog.util.DialogSettings;
import com.kongzue.dialog.v3.CustomDialog;
import com.kongzue.dialog.v3.MessageDialog; import com.kongzue.dialog.v3.MessageDialog;
import com.kongzue.dialog.v3.ShareDialog; import com.kongzue.dialog.v3.ShareDialog;
import com.lzy.okgo.OkGo; import com.kongzue.dialogx.dialogs.PopMenu;
import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Progress; import com.lzy.okgo.model.Progress;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.AutoTakePicture4PoiActivity;
import com.navinfo.outdoor.activity.AutoTakePictureActivity; import com.navinfo.outdoor.activity.AutoTakePictureActivity;
import com.navinfo.outdoor.activity.FragmentManagement; import com.navinfo.outdoor.activity.FragmentManagement;
import com.navinfo.outdoor.activity.HomeActivity;
import com.navinfo.outdoor.activity.WebActivity; import com.navinfo.outdoor.activity.WebActivity;
import com.navinfo.outdoor.adapter.MarkerAdapter; import com.navinfo.outdoor.adapter.MarkerAdapter;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.base.BaseDrawerFragment;
import com.navinfo.outdoor.base.BaseFragment; import com.navinfo.outdoor.base.BaseFragment;
import com.navinfo.outdoor.bean.GetPhoneBean; import com.navinfo.outdoor.bean.GetPhoneBean;
@@ -75,11 +77,11 @@ import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.http.UploadCallBack; import com.navinfo.outdoor.http.UploadCallBack;
import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.navinfo.outdoor.util.FlushTokenUtil; import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash; import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools; import com.navinfo.outdoor.util.GeometryTools;
import com.navinfo.outdoor.util.LocationLifeCycle;
import com.navinfo.outdoor.util.MapManager; import com.navinfo.outdoor.util.MapManager;
import com.navinfo.outdoor.util.MyTecentLocationSource; import com.navinfo.outdoor.util.MyTecentLocationSource;
import com.navinfo.outdoor.util.NaviUtils; import com.navinfo.outdoor.util.NaviUtils;
@@ -109,13 +111,11 @@ import com.tencent.tencentmap.mapsdk.maps.model.Polygon;
import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions; import com.tencent.tencentmap.mapsdk.maps.model.PolygonOptions;
import com.tencent.tencentmap.mapsdk.maps.model.Polyline; import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions; import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
import com.umeng.message.UmengNotificationClickHandler; import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
import com.umeng.message.entity.UMessage;
import org.locationtech.jts.geom.Coordinate; import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry; import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.MultiPoint; import org.locationtech.jts.geom.MultiPoint;
import org.locationtech.jts.geom.Point;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
@@ -126,12 +126,12 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
/** /**
@@ -168,6 +168,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
private File logFile; private File logFile;
private StringBuilder treasureBuilder; private StringBuilder treasureBuilder;
private Marker gatherMarker; private Marker gatherMarker;
private long lastClickTime = 0;
private int settingHookClickCount = 1;
private Handler handler = new Handler(new Handler.Callback() { private Handler handler = new Handler(new Handler.Callback() {
@Override @Override
public boolean handleMessage(@NonNull Message msg) { public boolean handleMessage(@NonNull Message msg) {
@@ -183,6 +185,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
private TencentMarkerUtils tencentMarkerUtils; private TencentMarkerUtils tencentMarkerUtils;
private ImageView imgAutoMatchRoad; // 自动匹配道路 private ImageView imgAutoMatchRoad; // 自动匹配道路
private ImageView ivNaviDistance; // 按距离自动导航 private ImageView ivNaviDistance; // 按距离自动导航
private List<Marker> drawLineMarkerList = new ArrayList<>();
private Polyline drawLinePolyline;
public static TreasureFragment newInstance(Bundle bundle) { public static TreasureFragment newInstance(Bundle bundle) {
TreasureFragment fragment = new TreasureFragment(); TreasureFragment fragment = new TreasureFragment();
@@ -200,11 +204,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
protected void initView() { protected void initView() {
super.initView(); super.initView();
tencentMarkerUtils = new TencentMarkerUtils(); tencentMarkerUtils = new TencentMarkerUtils();
sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
sharedEdit = sharedPreferences.edit(); sharedEdit = sharedPreferences.edit();
//fragment 管理器 //fragment 管理器
supportFragmentManager = Objects.requireNonNull(getActivity()).getSupportFragmentManager(); supportFragmentManager = requireActivity().getSupportFragmentManager();
builder = new AlertDialog.Builder(Objects.requireNonNull(getActivity())); builder = new AlertDialog.Builder(requireActivity());
frameLayout = findViewById(R.id.frame_layout); frameLayout = findViewById(R.id.frame_layout);
ivRaffish = findViewById(R.id.iv_refrish); ivRaffish = findViewById(R.id.iv_refrish);
ivRaffish.setOnClickListener(this); ivRaffish.setOnClickListener(this);
@@ -267,11 +271,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
tencentMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { tencentMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() {
@Override @Override
public void onMapLoaded() { public void onMapLoaded() {
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getTencentLocation() != null) {
// 地图中心点位置设置为当前用户所在位置 // 地图中心点位置设置为当前用户所在位置
CameraUpdate cameraSigma = CameraUpdate cameraSigma =
CameraUpdateFactory.newCameraPosition(new CameraPosition( CameraUpdateFactory.newCameraPosition(new CameraPosition(
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度 new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()), //中心点坐标,地图目标经纬度
17, //目标缩放级别 17, //目标缩放级别
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
0)); //目标旋转角 0~360° (正北方为0) 0)); //目标旋转角 0~360° (正北方为0)
@@ -300,7 +304,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
dismissLoadingDialog(); dismissLoadingDialog();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent); startActivity(intent);
ToastUtils.Message(getActivity(), "请先开启位置信息,在重新打开程序"); ToastUtils.Message(getActivity(), "请先开启位置信息,再重新打开程序");
getActivity().finish(); getActivity().finish();
} }
Constant.markerClickListener = markerClickListener; Constant.markerClickListener = markerClickListener;
@@ -317,44 +321,40 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
@RequiresApi(api = Build.VERSION_CODES.N) @RequiresApi(api = Build.VERSION_CODES.N)
@Override @Override
public void onClick(View v) { public void onClick(View v) {
Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class); PopMenu.build()
startActivity(autoMatchIntent); .setBaseView(v)
// // 设置亮度和摄像机刷新率 .setMenuList(new String[]{"道路任务", "POI录像"})
// CustomDialog.show((AppCompatActivity) getActivity(), R.layout.camera_setting_pre, new CustomDialog.OnBindView() { .setOverlayBaseView(false)
// @Override .setWidth(320)
// public void onBind(CustomDialog dialog, View v) { .setAlignGravity(Gravity.LEFT | Gravity.BOTTOM)
// SharedPreferences sharedPreferences = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE); .setOnIconChangeCallBack(new OnIconChangeCallBack<PopMenu>() {
// int brightness = sharedPreferences.getInt("brightness", 40); @Override
// EditText edtBrightness = v.findViewById(R.id.edt_camera_setting_brightness); public int getIcon(PopMenu dialog, int index, String menuText) {
// edtBrightness.setText(brightness+""); switch (index){
// case 0:
// int framness = sharedPreferences.getInt("framness", 30); return R.drawable.marker_road_show;
// EditText edtFramness = v.findViewById(R.id.edt_camera_setting_framness); case 1:
// edtFramness.setText(framness+""); return R.drawable.marker_poi_video_show;
// default:
// Button btnConfirm = v.findViewById(R.id.btn_camera_setting_confirm); break;
// btnConfirm.setOnClickListener(new View.OnClickListener() { }
// @Override return 0;
// public void onClick(View v) { }
// SharedPreferences.Editor editor = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE).edit(); })
// if (!edtBrightness.getText().toString().isEmpty()) { .setOnMenuItemClickListener(new OnMenuItemClickListener<PopMenu>() {
// int b = Integer.parseInt(edtBrightness.getText().toString()); @Override
// editor.putInt("brightness", b); public boolean onClick(PopMenu dialog, CharSequence text, int index) {
// } if (index == 0) { // 自动捕捉道路任务
// if (!edtFramness.getText().toString().isEmpty()) { Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
// int f = Integer.parseInt(edtFramness.getText().toString()); startActivity(autoMatchIntent);
// editor.putInt("framness", f); } else if (index == 1) {
// } Intent autoMatchIntent = new Intent(getContext(), AutoTakePicture4PoiActivity.class);
// editor.commit(); startActivity(autoMatchIntent);
// Toast.makeText(getActivity(), "设置完成", Toast.LENGTH_SHORT).show(); }
// return false;
// Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class); }
// startActivity(autoMatchIntent); })
// dialog.doDismiss(); .show();
// }
// });
// }
// }).setFullScreen(true);
} }
}); });
ivNaviDistance = findViewById(R.id.img_navi_distance); ivNaviDistance = findViewById(R.id.img_navi_distance);
@@ -376,6 +376,21 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
} }
} }
}); });
ivNaviDistance.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
NaviUtils.getInstance().selectNaviType((AppCompatActivity) getActivity(), new NaviUtils.SelectNaviTypeListener() {
@Override
public void selectNaviType(Constant.NAV_TYPE nav_type) {
// 显示导航类型选择的对话框
Constant.currentNaviType = nav_type;
}
});
return false;
}
});
} }
/** /**
@@ -388,7 +403,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
ivNaviDistance.setSelected(false); ivNaviDistance.setSelected(false);
return; return;
} }
Geometry currentGeometry = GeometryTools.createGeometry(new double[]{Constant.currentLocation.getLongitude(), Constant.currentLocation.getLatitude()}); Geometry currentGeometry = GeometryTools.createGeometry(new double[]{LocationLifeCycle.getInstance().getMainLocation().getLongitude(), LocationLifeCycle.getInstance().getMainLocation().getLatitude()});
Removable minRemoveable = removables.stream().filter(new Predicate<Removable>() { Removable minRemoveable = removables.stream().filter(new Predicate<Removable>() {
@Override @Override
public boolean test(Removable removable) { public boolean test(Removable removable) {
@@ -423,12 +438,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
public void selectNaviType(Constant.NAV_TYPE nav_type) { public void selectNaviType(Constant.NAV_TYPE nav_type) {
// 显示导航类型选择的对话框 // 显示导航类型选择的对话框
Constant.currentNaviType = nav_type; Constant.currentNaviType = nav_type;
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX()));
} }
}); });
} else { } else {
// 已选择导航方式 // 已选择导航方式
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(endPoint.getY(), endPoint.getX())); NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()), new LatLng(endPoint.getY(), endPoint.getX()));
} }
} }
@@ -492,8 +507,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
} }
}); });
} }
if (Constant.currentLocation != null) { //筛选从服务器获取到的数据 if (LocationLifeCycle.getInstance().getTencentLocation() != null) { //筛选从服务器获取到的数据
tencentMarkerUtils.initNetMarkerList(getActivity(), Constant.currentLocation, tencentMap, removables,null, null, removableHashMap, 200, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() { tencentMarkerUtils.initNetMarkerList(getActivity(), LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables,null, null, removableHashMap, 200, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
@Override @Override
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet, List<JobSearchBean.BodyBean.ListBean> listData) { public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet, List<JobSearchBean.BodyBean.ListBean> listData) {
@@ -601,7 +616,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
/* 得到电话区号,电话位数*/ /* 得到电话区号,电话位数*/
private void initPhone() { private void initPhone() {
String encode = Geohash.getInstance().encode(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); String encode = Geohash.getInstance().encode(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude());
if (encode == null) { if (encode == null) {
ToastUtils.Message(getActivity(), "没有确定经纬度"); ToastUtils.Message(getActivity(), "没有确定经纬度");
return; return;
@@ -675,7 +690,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
/*上传用户位置*/ /*上传用户位置*/
private void iniUserLocation() { private void iniUserLocation() {
String encode = Geohash.getInstance().encode(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); String encode = Geohash.getInstance().encode(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude());
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
if (encode != null) { if (encode != null) {
httpParams.put("geom", encode); httpParams.put("geom", encode);
@@ -892,30 +907,33 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
gatherMarker.setVisible(false); gatherMarker.setVisible(false);
} }
PoiEntity poiEntity = (PoiEntity) data.obj; PoiEntity poiEntity = (PoiEntity) data.obj;
Bundle bundle = new Bundle(); if (poiEntity!=null) {
bundle.putSerializable("poiEntity", poiEntity); Bundle bundle = new Bundle();
bundle.putBoolean("isSliding", true); // 通知抽屉不收回 bundle.putSerializable("poiEntity", poiEntity);
switch (poiEntity.getType()) { bundle.putBoolean("isSliding", true); // 通知抽屉不收回
case 1: bundle.putInt("matchTrack", data.arg1);
PoiFragment poiFragment = PoiFragment.newInstance(bundle); switch (poiEntity.getType()) {
showSlidingFragment(poiFragment); case 1:
break; PoiFragment poiFragment = PoiFragment.newInstance(bundle);
case 2: showSlidingFragment(poiFragment);
ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); break;
showSlidingFragment(chargingStationFragment); case 2:
break; ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
case 3: showSlidingFragment(chargingStationFragment);
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); break;
showSlidingFragment(poiVideoFragment); case 3:
break; PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
case 4: showSlidingFragment(poiVideoFragment);
RoadFragment roadFragment = RoadFragment.newInstance(bundle); break;
showSlidingFragment(roadFragment); case 4:
break; RoadFragment roadFragment = RoadFragment.newInstance(bundle);
case 5: showSlidingFragment(roadFragment);
OtherFragment otherFragment = OtherFragment.newInstance(bundle); break;
showSlidingFragment(otherFragment); case 5:
break; OtherFragment otherFragment = OtherFragment.newInstance(bundle);
showSlidingFragment(otherFragment);
break;
}
} }
frameLayout.setVisibility(View.GONE); frameLayout.setVisibility(View.GONE);
if (gatherGetFragment != null) { if (gatherGetFragment != null) {
@@ -1052,13 +1070,123 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
tvTenantGaps.setText("信号强度:强"); tvTenantGaps.setText("信号强度:强");
} }
} }
} else if (data.what == Constant.EVENT_WHAT_CHANGE_SLIDING_STATE) { // 改变滑动窗口的状态
if (sliding_layout!=null) {
if (data.arg1 == View.GONE || data.arg1 == View.INVISIBLE) {
sliding_layout.setPanelHeight(0);
} else {
int[] deviceInfo = DensityUtil.getDeviceInfo(getActivity());
sliding_layout.setPanelHeight(deviceInfo[1] / 2);
}
sliding_layout.setPanelState((SlidingUpPanelLayout.PanelState) data.obj);
}
} else if (data.what == Constant.EVENT_WHAT_START_DRAW_LINE) { // 开始绘制参考线
// 界面显示绘制结束按钮
TextView drawFinish = findViewById(R.id.tv_draw_line_finish);
TextView drawCancel = findViewById(R.id.tv_draw_line_cancel);
drawFinish.setVisibility(View.VISIBLE);
drawCancel.setVisibility(View.VISIBLE);
drawFinish.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 检查当前线型的点位数据,如果小于2个点,无法完成
if (drawLinePolyline.getPoints()==null||drawLinePolyline.getPoints().size()<2) {
// 绘制的线不存在
ToastUtils.Message(getActivity(), "绘制的线不存在!");
return;
}
Message drawLineFinishMsg = Message.obtain();
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
drawLineFinishMsg.obj = drawLinePolyline.getPoints();
drawLineFinishMsg.arg1=1; // arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
EventBus.getDefault().post(drawLineFinishMsg);
drawFinish.setVisibility(View.GONE);
drawCancel.setVisibility(View.GONE);
tencentMap.setOnMapClickListener(null);
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
@Override
public void accept(Marker marker) {
marker.remove();
}
});
drawLineMarkerList.clear();
}
if (drawLinePolyline!=null) {
drawLinePolyline.remove();
}
}
});
drawCancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Message drawLineFinishMsg = Message.obtain();
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
drawLineFinishMsg.arg1=0;// arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
EventBus.getDefault().post(drawLineFinishMsg);
drawFinish.setVisibility(View.GONE);
drawCancel.setVisibility(View.GONE);
tencentMap.setOnMapClickListener(null);
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
@Override
public void accept(Marker marker) {
marker.remove();
}
});
drawLineMarkerList.clear();
}
if (drawLinePolyline!=null) {
drawLinePolyline.remove();
}
}
});
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
@Override
public void accept(Marker marker) {
marker.remove();
}
});
drawLineMarkerList.clear();
}
if (drawLinePolyline!=null) {
drawLinePolyline.remove();
}
PolylineOptions drawLineOptions = new PolylineOptions() // 用户绘制参考线的线数据
// 折线设置圆形线头
.lineCap(true)
// 折线的颜色为绿色
.color(0xff00ff00)
.borderColor(0xff00ff00)
// 折线宽度为25像素
.width(12)
// 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
.borderWidth(5);
drawLinePolyline = tencentMap.addPolyline(drawLineOptions);
if (tencentMap!=null) {
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
drawLinePolyline.appendPoint(latLng);
drawLineMarkerList.add(tencentMap.addMarker(new MarkerOptions(latLng).icon(
BitmapDescriptorFactory.fromResource(R.drawable.green_point)
)));
}
});
}
} }
} }
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -1085,7 +1213,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
/*奔溃后的数据*/ /*奔溃后的数据*/
private void initSharePre() { private void initSharePre() {
//根据保存时所用的name属性,获取SharedPreferences对象 //根据保存时所用的name属性,获取SharedPreferences对象
SharedPreferences dataFile = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); SharedPreferences dataFile = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//根据数据类型,调用对应的get方法,通过键取得对应的值。 //根据数据类型,调用对应的get方法,通过键取得对应的值。
String dataFileString = dataFile.getString("poiEntity", null); String dataFileString = dataFile.getString("poiEntity", null);
if (dataFileString != null) { if (dataFileString != null) {
@@ -1094,7 +1222,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
case 1: case 1:
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false; DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "你poi页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了poi,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了poi,");
@@ -1110,7 +1238,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
case 2: case 2:
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false; DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你充电站页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "你充电站页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了充电站,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了充电站,");
@@ -1126,14 +1254,27 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
case 3: case 3:
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false; DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你poi录像页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "你poi录像页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@RequiresApi(api = Build.VERSION_CODES.N)
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了poi录像,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了poi录像,");
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); int roadVideoType = dataFile.getInt("roadVideoType", -1);
showSlidingFragment(poiVideoFragment); if (roadVideoType == -1) {
PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
showSlidingFragment(poiVideoFragment);
} else if (roadVideoType == 1) {
TrafficHubFragment trafficHubFragment = TrafficHubFragment.newInstance(bundle);
showSlidingFragment(trafficHubFragment);
} else if (roadVideoType == 2) {
BuildingInFragment buildingInFragment = BuildingInFragment.newInstance(bundle);
showSlidingFragment(buildingInFragment);
} else if (roadVideoType == 3) {
AreaHubFragment buildingInsideFragment = AreaHubFragment.newInstance(bundle);
showSlidingFragment(buildingInsideFragment);
}
initRemovePoiSharePre(); initRemovePoiSharePre();
return false; return false;
} }
@@ -1142,7 +1283,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
case 4: case 4:
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false; DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你道路页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "你道路页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了道路,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了道路,");
@@ -1158,7 +1299,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
case 5: case 5:
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
DialogSettings.cancelable = false; DialogSettings.cancelable = false;
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "你其他页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() { MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "你其他页面还有未提交完的数据,之前的成果已保存,点击确定可继续作业", "确定").setOkButton(new OnDialogButtonClickListener() {
@Override @Override
public boolean onClick(BaseDialog baseDialog, View v) { public boolean onClick(BaseDialog baseDialog, View v) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了其他,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("未提交完的数据-点击了其他,");
@@ -1181,12 +1322,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。 //方法注释得知,建议以0或者MODE_PRIVATE为默认值。
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0); SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
//获取Editor对象 //获取Editor对象
SharedPreferences.Editor edit = poi.edit(); SharedPreferences.Editor edit = poi.edit();
//根据要保存的数据的类型,调用对应的put方法, //根据要保存的数据的类型,调用对应的put方法,
//以键值对的形式添加新值。 //以键值对的形式添加新值。
edit.putString("poiEntity", null); edit.putString("poiEntity", null);
edit.putInt("roadVideoType", -1);
//提交新值。必须执行,否则前面的操作都无效。 //提交新值。必须执行,否则前面的操作都无效。
edit.apply(); edit.apply();
} }
@@ -1222,13 +1364,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
@Override @Override
public void onDestroy() { public void onDestroy() {
super.onDestroy();
if (EventBus.getDefault().isRegistered(this)) { if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this); EventBus.getDefault().unregister(this);
} }
super.onDestroy();
if (mapView != null) {
mapView.onDestroy();
}
if (treasureBuilder != null) { if (treasureBuilder != null) {
treasureBuilder.append(TimestampUtil.time()).append(",").append("onDestroy"); treasureBuilder.append(TimestampUtil.time()).append(",").append("onDestroy");
treasureBuilder.append("\r\n"); treasureBuilder.append("\r\n");
@@ -1244,6 +1383,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
} }
removableScreenMarker.clear(); removableScreenMarker.clear();
} }
if (mapView != null) {
mapView.onDestroy();
}
} }
@Override @Override
@@ -1265,9 +1407,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
break; break;
case R.id.iv_location://定位: case R.id.iv_location://定位:
treasureBuilder.append(TimestampUtil.time()).append(",").append("点击了定位的按钮,"); treasureBuilder.append(TimestampUtil.time()).append(",").append("点击了定位的按钮,");
if (Constant.currentLocation != null) { if (LocationLifeCycle.getInstance().getTencentLocation() != null) {
CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()),//中心点坐标,地图目标经纬度 new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()),//中心点坐标,地图目标经纬度
17,//目标缩放级别 17,//目标缩放级别
0,//目标倾斜角[0.0 ~ 45.0] (垂直地图时为0) 0,//目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
0));//目标旋转角 0~360° (正北方为0) 0));//目标旋转角 0~360° (正北方为0)
@@ -1321,32 +1463,44 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI; DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI;
List<ShareDialog.Item> itemList = new ArrayList<>(); List<ShareDialog.Item> itemList = new ArrayList<>();
if (upload.contains(1)) { if (upload.contains(1)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi, "POI")); itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.marker_poi, "POI"));
} }
if (upload.contains(2)) { if (upload.contains(2)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_charge, "充电站")); itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.marker_charge, "充电站"));
} }
if (upload.contains(3)) { if (upload.contains(3)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_poi_video, "POI录像")); itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.marker_poi_video, "POI录像"));
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_traffic_hub, "交通枢纽"));
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_parking_hub, "区域设施"));
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_building_inside, "建筑物内部"));
} }
if (upload.contains(4)) { if (upload.contains(4)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_road, "道路")); itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.marker_road, "道路"));
} }
if (upload.contains(5)) { if (upload.contains(5)) {
itemList.add(new ShareDialog.Item(Objects.requireNonNull(getContext()), R.drawable.marker_other, "其他")); itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.marker_other, "其他"));
}
if (upload.contains(11)) {
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_traffic_hub, "交通枢纽"));
}
if (upload.contains(12)) {
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_parking_hub, "区域设施"));
}
if (upload.contains(13)) {
itemList.add(new ShareDialog.Item(requireActivity(), R.drawable.icon_building_inside, "建筑物内部"));
} }
Bundle bundle = new Bundle(); Bundle bundle = new Bundle();
PoiEntity poiEntity = new PoiEntity(); PoiEntity poiEntity = new PoiEntity();
// 上报时以当前用户位置为准 // 上报时以当前用户位置为准
if (Constant.currentLocation == null) { if (LocationLifeCycle.getInstance().getTencentLocation() == null) {
ToastUtils.Message(getActivity(), "无法获取当前位置,请检查GPS是否打开!"); ToastUtils.Message(getActivity(), "无法获取当前位置,请检查GPS是否打开!");
return; return;
} }
LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); LatLng newPoiLatLng = new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude());
poiEntity.setX(String.valueOf(newPoiLatLng.getLongitude())); poiEntity.setX(String.valueOf(newPoiLatLng.getLongitude()));
poiEntity.setY(String.valueOf(newPoiLatLng.getLatitude())); poiEntity.setY(String.valueOf(newPoiLatLng.getLatitude()));
bundle.putSerializable("poiEntity", poiEntity); bundle.putSerializable("poiEntity", poiEntity);
ShareDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), itemList, new ShareDialog.OnItemClickListener() { ShareDialog.show((AppCompatActivity) requireActivity(), itemList, new ShareDialog.OnItemClickListener() {
@Override @Override
public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) { public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) {
if (item.getText().equals("POI")) { if (item.getText().equals("POI")) {
@@ -1369,6 +1523,18 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
OtherFragment otherFragment = OtherFragment.newInstance(bundle); OtherFragment otherFragment = OtherFragment.newInstance(bundle);
showSlidingFragment(otherFragment); showSlidingFragment(otherFragment);
treasureBuilder.append(TimestampUtil.time()).append("点击弹窗上的其他,"); treasureBuilder.append(TimestampUtil.time()).append("点击弹窗上的其他,");
} else if (item.getText().equals("交通枢纽")) {
TrafficHubFragment trafficHubFragment = TrafficHubFragment.newInstance(bundle);
showSlidingFragment(trafficHubFragment);
XLog.d("点击弹窗上的交通枢纽");
} else if (item.getText().equals("区域设施")) {
AreaHubFragment areaHubFragment = AreaHubFragment.newInstance(bundle);
showSlidingFragment(areaHubFragment);
XLog.d("点击弹窗上的区域设施");
} else if (item.getText().equals("建筑物内部")) {
BuildingInFragment buildingInsideFragment = BuildingInFragment.newInstance(bundle);
showSlidingFragment(buildingInsideFragment);
XLog.d("点击弹窗上的建筑物内部");
} }
return false; return false;
} }
@@ -1413,6 +1579,24 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
fragmentTransaction.hide(poiVideoFragment); fragmentTransaction.hide(poiVideoFragment);
} }
} }
if (!(fragment instanceof TrafficHubFragment)) {
TrafficHubFragment trafficHubFragment = (TrafficHubFragment) supportFragmentManager.findFragmentByTag(TrafficHubFragment.class.getName());
if (trafficHubFragment != null) {
fragmentTransaction.hide(trafficHubFragment);
}
}
if (!(fragment instanceof BuildingInFragment)) {
BuildingInFragment areaHubFragment = (BuildingInFragment) supportFragmentManager.findFragmentByTag(BuildingInFragment.class.getName());
if (areaHubFragment != null) {
fragmentTransaction.hide(areaHubFragment);
}
}
if (!(fragment instanceof AreaHubFragment)) {
AreaHubFragment buildingInsideFragment = (AreaHubFragment) supportFragmentManager.findFragmentByTag(AreaHubFragment.class.getName());
if (buildingInsideFragment != null) {
fragmentTransaction.hide(buildingInsideFragment);
}
}
if (!(fragment instanceof OtherFragment)) { if (!(fragment instanceof OtherFragment)) {
OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName()); OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName());
if (otherFragment != null) { if (otherFragment != null) {
@@ -1427,7 +1611,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
/*检查网络状态*/ /*检查网络状态*/
private void checkNetWork() { private void checkNetWork() {
showLoadingDialog(); showLoadingDialog();
if (NetWorkUtils.iConnected(Objects.requireNonNull(getContext()))) { // 当前网络可用 if (NetWorkUtils.iConnected(requireActivity())) { // 当前网络可用
checkMyLocation(); checkMyLocation();
} else { // 当前网络不可用 } else { // 当前网络不可用
dismissLoadingDialog(); dismissLoadingDialog();
@@ -1444,41 +1628,43 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
// 5 用户给予权限进行相应操作 // 5 用户给予权限进行相应操作
// 6 用户没有给予权限 作出相应提示 // 6 用户没有给予权限 作出相应提示
// 7 某些5.0权限的手机执行相应操作 // 7 某些5.0权限的手机执行相应操作
XXPermissions.with(this) //建立定位
// 位置权限 initLocation();
.permission(Permission.ACCESS_COARSE_LOCATION) // XXPermissions.with(this)
.permission(Permission.ACCESS_FINE_LOCATION) // // 位置权限
.permission(Permission.ACCESS_MEDIA_LOCATION) // .permission(Permission.ACCESS_COARSE_LOCATION)
//.permission(Permission.ACCESS_BACKGROUND_LOCATION) // .permission(Permission.ACCESS_FINE_LOCATION)
.request(new OnPermissionCallback() { //// .permission(Permission.ACCESS_MEDIA_LOCATION)
@Override // //.permission(Permission.ACCESS_BACKGROUND_LOCATION)
public void onGranted(List<String> permissions, boolean all) { // .request(new OnPermissionCallback() {
if (all) { // @Override
//建立定位 // public void onGranted(List<String> permissions, boolean all) {
initLocation(); // if (all) {
} else { // //建立定位
dismissLoadingDialog(); // initLocation();
ToastUtils.Message(getActivity(), "申请权限失败"); // } else {
} // dismissLoadingDialog();
} // ToastUtils.Message(getActivity(), "申请权限失败");
// }
@Override // }
public void onDenied(List<String> permissions, boolean never) { //
dismissLoadingDialog(); // @Override
if (never) { // public void onDenied(List<String> permissions, boolean never) {
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS; // dismissLoadingDialog();
DialogSettings.cancelable = false; // if (never) {
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", permissions.toString() + " 被永久拒绝授权,请手动授予定位权限,", "确定").setOkButton(new OnDialogButtonClickListener() { // DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
@Override // DialogSettings.cancelable = false;
public boolean onClick(BaseDialog baseDialog, View v) { // MessageDialog.show((AppCompatActivity) requireActivity(), "提示", permissions.toString() + " 被永久拒绝授权,请手动授予定位权限,", "确定").setOkButton(new OnDialogButtonClickListener() {
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions); // @Override
getActivity().finish(); // public boolean onClick(BaseDialog baseDialog, View v) {
return false; // XXPermissions.startPermissionActivity(requireActivity(), permissions);
} // getActivity().finish();
}); // return false;
} // }
} // });
}); // }
// }
// });
} }
/*设置定位图标样式*/ /*设置定位图标样式*/
@@ -1729,7 +1915,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
dialog.show(); dialog.show();
RecyclerView recyclerView = dialogView.findViewById(R.id.rv_marker_view); RecyclerView recyclerView = dialogView.findViewById(R.id.rv_marker_view);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity())); recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
recyclerView.addItemDecoration(new DividerItemDecoration(Objects.requireNonNull(getActivity()), DividerItemDecoration.VERTICAL)); recyclerView.addItemDecoration(new DividerItemDecoration(requireActivity(), DividerItemDecoration.VERTICAL));
MarkerAdapter markerAdapter = new MarkerAdapter(list, getActivity()); MarkerAdapter markerAdapter = new MarkerAdapter(list, getActivity());
recyclerView.setAdapter(markerAdapter); recyclerView.setAdapter(markerAdapter);
markerAdapter.setOnBankClick(new MarkerAdapter.OnBankClick() { markerAdapter.setOnBankClick(new MarkerAdapter.OnBankClick() {
@@ -92,7 +92,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
@Override @Override
protected void initData() { protected void initData() {
super.initData(); super.initData();
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE); SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
SharedPreferences.Editor sharedEdit = sharedPreferences.edit(); SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
@SuppressLint("SimpleDateFormat") @SuppressLint("SimpleDateFormat")
DateFormat formatter = new SimpleDateFormat("yyyyMMdd"); DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
@@ -120,6 +120,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
showLoadingDialog(); showLoadingDialog();
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
httpParams.put("pageNum", withPage); httpParams.put("pageNum", withPage);
httpParams.put("pageSize", 20);
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance() OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
.time(30) .time(30)
.Builder(getActivity()) .Builder(getActivity())
@@ -163,7 +164,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.iv_withdraw) { if (v.getId() == R.id.iv_withdraw) {
Objects.requireNonNull(getActivity()).finish(); requireActivity().finish();
withdrawalRecordBuilder.append(TimestampUtil.time()).append("点击了返回,"); withdrawalRecordBuilder.append(TimestampUtil.time()).append("点击了返回,");
} }
} }
@@ -2,9 +2,15 @@ package com.navinfo.outdoor.http;
public class HttpInterface { public class HttpInterface {
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP // public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网 // public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 // public static final String IP = "http://120.92.212.218/dtxb/test/m4";//金山云接口地址
// public static final String IP_UPLOAD = "http://120.131.12.158/dtxb/test/m4";//金山云接口地址-数据上传
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
public static final String IP4 = "http://10.130.23.166/dtxb/jinshan/m4";//心榕给的测试地址
public static final String USER_PATH = "/user/";//我的 public static final String USER_PATH = "/user/";//我的
public static final String MSG_LIST_PATH = "/msgList/";//发现 public static final String MSG_LIST_PATH = "/msgList/";//发现
public static final String USER_LOGIN_PATH = "/userlogin/";//登录 public static final String USER_LOGIN_PATH = "/userlogin/";//登录
@@ -203,34 +209,22 @@ public class HttpInterface {
SUBMIT_POI_TASK = IP + TASK_PATH + "poitask/" + userId + "/submitPoitask";//poi-保存本地 SUBMIT_POI_TASK = IP + TASK_PATH + "poitask/" + userId + "/submitPoitask";//poi-保存本地
//172.23.139.4:8003/othertask/1/submitOhtertask?taskId=5001&name=测试修改名称&address=测试修改地址&existence=1&geo=1rn7exd5uhxy&memo=测试备注 //172.23.139.4:8003/othertask/1/submitOhtertask?taskId=5001&name=测试修改名称&address=测试修改地址&existence=1&geo=1rn7exd5uhxy&memo=测试备注
SUBMIT_OTHER_TASK = IP + TASK_PATH + "othertask/" + userId + "/submitOthertask";//其他-保存本地 SUBMIT_OTHER_TASK = IP + TASK_PATH + "othertask/" + userId + "/submitOthertask";//其他-保存本地
//172.23.139.4:8003/othertask/1/uploadpic
OTHER_TASK_UPLOAD_PIC = IP + TASK_PATH + "othertask/" + userId + "/uploadpic";//其他-上传
//172.23.139.4:8003/ctask/1/receivedCtask/8608 //172.23.139.4:8003/ctask/1/receivedCtask/8608
RECEIVED_CTASK = IP + TASK_PATH + "ctask/" + userId + "/receivedCtask";//充电站-领取任务 RECEIVED_CTASK = IP + TASK_PATH + "ctask/" + userId + "/receivedCtask";//充电站-领取任务
//172.23.139.4:8003/ctask/1/submitCtask?id=8608&name=充电站&address=地址&telephone=18812345678|14712345678&geo=1rn7exd5uhxy&memo=测试备注&sptype=1 //172.23.139.4:8003/ctask/1/submitCtask?id=8608&name=充电站&address=地址&telephone=18812345678|14712345678&geo=1rn7exd5uhxy&memo=测试备注&sptype=1
SUBMIT_CTASK = IP + TASK_PATH + "ctask/" + userId + "/submitCtask";//充电站-保存本地 SUBMIT_CTASK = IP + TASK_PATH + "ctask/" + userId + "/submitCtask";//充电站-保存本地
//172.23.139.4:8003/cstask/1/submitCstask?taskId=0&name=充电站&geo=1rn7exd5uhxy&memo=测试备注&sptype=1&ffid=104&existence=1&detail={"cp_openType":"1,2","cp_floor":1,"cp_availableState":0,"sign_exist":0} //172.23.139.4:8003/cstask/1/submitCstask?taskId=0&name=充电站&geo=1rn7exd5uhxy&memo=测试备注&sptype=1&ffid=104&existence=1&detail={"cp_openType":"1,2","cp_floor":1,"cp_availableState":0,"sign_exist":0}
SUBMIT_CSTASK = IP + TASK_PATH + "cstask/" + userId + "/submitCstask";//充电桩保存 SUBMIT_CSTASK = IP + TASK_PATH + "cstask/" + userId + "/submitCstask";//充电桩保存
//172.23.139.4:8003/poitask/1/uploadpic
POI_TASK_UPLOAD_PIC = IP + TASK_PATH + "poitask/" + userId + "/uploadpic";//poi-上传
//172.23.139.4:8003/roadtask/1/receivedRoadtask/8569 //172.23.139.4:8003/roadtask/1/receivedRoadtask/8569
RECEIVED_ROAD_TASK = IP + TASK_PATH + "roadtask/" + userId + "/receivedRoadtask";//道路任务获取 RECEIVED_ROAD_TASK = IP + TASK_PATH + "roadtask/" + userId + "/receivedRoadtask";//道路任务获取
//172.23.139.4:8003/poivideotask/1/receivedPoivideotask/8569 //172.23.139.4:8003/poivideotask/1/receivedPoivideotask/8569
RECEIVED_POI_VIDEO_TASK = IP + TASK_PATH + "poivideotask/" + userId + "/receivedPoivideotask";//poi录像任务获取 RECEIVED_POI_VIDEO_TASK = IP + TASK_PATH + "poivideotask/" + userId + "/receivedPoivideotask";//poi录像任务获取
// 172.23.139.4:8003/poivideotask/1/submitPoivideotask // 172.23.139.4:8003/poivideotask/1/submitPoivideotask
INSIDE_API_LIST = IP + TASK_PATH + "poivideotask/" + userId + "/submitPoivideotask";//poi录像 保存 INSIDE_API_LIST = IP + TASK_PATH + "poivideotask/" + userId + "/submitPoivideotask";//poi录像 保存
//172.23.139.4:8003/poivideotask/1/uploadpic
POI_VIDEO_UPLOAD_PIC = IP + TASK_PATH + "poivideotask/" + userId + "/uploadpic";//poi录像-上传
//172.23.139.4:8003/roadtask/1/submitRoadtask?taskId=0&name=段哥&address=二娃&memo=1rn7exd5uhxy&workType=2 //172.23.139.4:8003/roadtask/1/submitRoadtask?taskId=0&name=段哥&address=二娃&memo=1rn7exd5uhxy&workType=2
ROAD_TASK_SUBMIT = IP + TASK_PATH + "roadtask/" + userId + "/submitRoadtask";//道路录像-保存本地 ROAD_TASK_SUBMIT = IP + TASK_PATH + "roadtask/" + userId + "/submitRoadtask";//道路录像-保存本地
//172.23.139.4:8003/roadtask/1/uploadpic
ROAD_TASK_UPLOAD_PIC = IP + TASK_PATH + "roadtask/" + userId + "/uploadpic";//道路录像—上传
//172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy //172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy
GET_PHONES = IP + TASK_PATH + "task/" + userId + "/getPhone";//电话区号和电话位数 GET_PHONES = IP + TASK_PATH + "task/" + userId + "/getPhone";//电话区号和电话位数
//172.23.139.4:8003/cstask/1/uploadpic
CS_TASK_UP_LOAD_PIC = IP + TASK_PATH + "cstask/" + userId + "/uploadpic";//充电桩-上传
//172.23.139.4:8003/ctask/1/uploadpic
C_TASK_UP_LOAD_PIC = IP + TASK_PATH + "ctask/" + userId + "/uploadpic";//充电站-上传
//172.23.139.4:8003/m4/task/1/taskName?geo=1rn7exd5uhxy&name=四维 //172.23.139.4:8003/m4/task/1/taskName?geo=1rn7exd5uhxy&name=四维
TASK_NAME = IP + TASK_PATH + "task/" + userId + "/taskName";//poi-查重 TASK_NAME = IP + TASK_PATH + "task/" + userId + "/taskName";//poi-查重
//172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1 //172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1
@@ -242,7 +236,20 @@ public class HttpInterface {
SUBMIT_POLYGON_TASK = IP + TASK_PATH + "polygonTask/" + userId + "/submitPolygontask";//面状任务开始采集 SUBMIT_POLYGON_TASK = IP + TASK_PATH + "polygonTask/" + userId + "/submitPolygontask";//面状任务开始采集
UPDATE_PHONE_NUM_URL = IP + UPDATE_PHONE_NUM_PATH.replace("{userId}", userId);// 修改手机号 UPDATE_PHONE_NUM_URL = IP + UPDATE_PHONE_NUM_PATH.replace("{userId}", userId);// 修改手机号
CREATE_UPLOAD_TASK = IP + TASK_PATH + "task/"+ userId+"/createUploadTask";// 创建断点续传任务 CREATE_UPLOAD_TASK = IP + TASK_PATH + "task/"+ userId+"/createUploadTask";// 创建断点续传任务
UPLOAD_SPLITE_TASK = IP + TASK_PATH + "task/"+ userId+"/uploadSplitTask";// 执行断点续传
UPLOAD_TASK_FINISH = IP + TASK_PATH + "task/"+ userId+"/uploadTaskFinish";// 断点续传完成 UPLOAD_TASK_FINISH = IP + TASK_PATH + "task/"+ userId+"/uploadTaskFinish";// 断点续传完成
//172.23.139.4:8003/othertask/1/uploadpic
OTHER_TASK_UPLOAD_PIC = IP_UPLOAD + TASK_PATH + "othertask/" + userId + "/uploadpic";//其他-上传
//172.23.139.4:8003/poitask/1/uploadpic
POI_TASK_UPLOAD_PIC = IP_UPLOAD + TASK_PATH + "poitask/" + userId + "/uploadpic";//poi-上传
//172.23.139.4:8003/poivideotask/1/uploadpic
POI_VIDEO_UPLOAD_PIC = IP_UPLOAD + TASK_PATH + "poivideotask/" + userId + "/uploadpic";//poi录像-上传
//172.23.139.4:8003/roadtask/1/uploadpic
ROAD_TASK_UPLOAD_PIC = IP_UPLOAD + TASK_PATH + "roadtask/" + userId + "/uploadpic";//道路录像—上传
//172.23.139.4:8003/cstask/1/uploadpic
CS_TASK_UP_LOAD_PIC = IP_UPLOAD + TASK_PATH + "cstask/" + userId + "/uploadpic";//充电桩-上传
//172.23.139.4:8003/ctask/1/uploadpic
C_TASK_UP_LOAD_PIC = IP_UPLOAD + TASK_PATH + "ctask/" + userId + "/uploadpic";//充电站-上传
UPLOAD_SPLITE_TASK = IP_UPLOAD + TASK_PATH + "task/"+ userId+"/uploadSplitTask";// 执行断点续传
} }
} }
@@ -3,6 +3,7 @@ package com.navinfo.outdoor.http;
import android.app.Activity; import android.app.Activity;
import android.widget.Toast; import android.widget.Toast;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.DES; import com.github.lazylibrary.util.DES;
import com.github.lazylibrary.util.MD5; import com.github.lazylibrary.util.MD5;
import com.google.gson.Gson; import com.google.gson.Gson;
@@ -292,6 +293,13 @@ public class OkGoBuilder<T> {
// 请求的 tag, 主要用于取消对应的请求 // 请求的 tag, 主要用于取消对应的请求
.params(params) .params(params)
.addFileParams("file", files) .addFileParams("file", files)
.uploadInterceptor(new ProgressRequestBody.UploadInterceptor() {
@Override
public void uploadProgress(Progress progress) {
XLog.d(progress.speed);
XLog.d(progress.currentSize);
}
})
.tag(this) .tag(this)
.execute(); .execute();
} catch (IOException e) { } catch (IOException e) {
@@ -1,6 +1,7 @@
package com.navinfo.outdoor.room; package com.navinfo.outdoor.room;
import android.content.Context; import android.content.Context;
import android.database.Cursor;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.room.Database; import androidx.room.Database;
@@ -9,6 +10,7 @@ import androidx.room.RoomDatabase;
import androidx.room.migration.Migration; import androidx.room.migration.Migration;
import androidx.sqlite.db.SupportSQLiteDatabase; import androidx.sqlite.db.SupportSQLiteDatabase;
import com.elvishew.xlog.XLog;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.bean.LocationRecorder; import com.navinfo.outdoor.bean.LocationRecorder;
import com.navinfo.outdoor.util.SdkFolderCreate; import com.navinfo.outdoor.util.SdkFolderCreate;
@@ -28,7 +30,7 @@ import java.io.File;
* 如果需要在主线程调用则使用allowMainThreadQueries进行说明。 * 如果需要在主线程调用则使用allowMainThreadQueries进行说明。
*/ */
@Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 3, exportSchema = false) @Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 6, exportSchema = false)
public abstract class PoiDatabase extends RoomDatabase { public abstract class PoiDatabase extends RoomDatabase {
private static final String DB_NAME = "navinfo.db"; private static final String DB_NAME = "navinfo.db";
private static volatile PoiDatabase instance; private static volatile PoiDatabase instance;
@@ -52,6 +54,9 @@ public abstract class PoiDatabase extends RoomDatabase {
return Room.databaseBuilder(context, PoiDatabase.class, Constant.POI_DAO+"/"+DB_NAME) return Room.databaseBuilder(context, PoiDatabase.class, Constant.POI_DAO+"/"+DB_NAME)
.addMigrations(migration_1_2) .addMigrations(migration_1_2)
.addMigrations(migration_2_3) .addMigrations(migration_2_3)
.addMigrations(migration_3_4)
.addMigrations(migration_4_5)
.addMigrations(migration_5_6)
//.fallbackToDestructiveMigration()//数据库更新时删除数据重新创建 改动特别大的时候在用 //.fallbackToDestructiveMigration()//数据库更新时删除数据重新创建 改动特别大的时候在用
.build(); .build();
} }
@@ -80,6 +85,47 @@ public abstract class PoiDatabase extends RoomDatabase {
} }
}; };
// 增加POI字段
private static Migration migration_3_4 = new Migration(3, 4) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
try {
database.execSQL("ALTER TABLE poi ADD COLUMN uploadProgress INTEGER NOT NULL DEFAULT 'null'");//添加了一个上传进度
database.execSQL("ALTER TABLE poi ADD COLUMN score INTEGER NOT NULL DEFAULT 'null'");//添加了一个置信度
database.execSQL("ALTER TABLE poi ADD COLUMN drawLine TEXT DEFAULT 'null'");//添加了一个用户绘制线型
} catch (Exception e) {
XLog.e(e.toString());
}
}
};
// 增加POI字段
private static Migration migration_4_5 = new Migration(4, 5) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
try {
database.execSQL("ALTER TABLE poi ADD COLUMN uploadMax INTEGER NOT NULL DEFAULT 'null'");//添加了一个上传总数
database.execSQL("ALTER TABLE poi ADD COLUMN uploadResult TEXT DEFAULT 'null'");//添加了一个上传结果
} catch (Exception e) {
XLog.e(e.toString());
}
}
};
private static Migration migration_5_6 = new Migration(5, 6) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase database) {
try {
database.execSQL("UPDATE poi set uploadProgress = 0 where uploadProgress = 'null'");
database.execSQL("UPDATE poi set score = 0 where score = 'null'");
database.execSQL("UPDATE poi set uploadMax = 0 where uploadMax = 'null'");
} catch (Exception e) {
XLog.e(e.toString());
}
}
};
public abstract PoiDao getPoiDao();//其他信息 public abstract PoiDao getPoiDao();//其他信息
public abstract ChargingPileDao getChargingPileDao();//充电桩 public abstract ChargingPileDao getChargingPileDao();//充电桩
public abstract LocationRecorderDao getRecorderDao(); public abstract LocationRecorderDao getRecorderDao();
@@ -2,6 +2,7 @@ package com.navinfo.outdoor.room;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.room.Entity; import androidx.room.Entity;
import androidx.room.Ignore;
import androidx.room.PrimaryKey; import androidx.room.PrimaryKey;
import androidx.room.TypeConverters; import androidx.room.TypeConverters;
@@ -43,13 +44,18 @@ public class PoiEntity implements Serializable {
private String detail;//需要保存的数据的wkt private String detail;//需要保存的数据的wkt
private String dist;//距离用户位置 private String dist;//距离用户位置
private int taskStatus;//任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集).5 立即采集,100 上传成功 private int taskStatus;//任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集).5 立即采集,100 上传成功
private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" 11-“交通枢纽” 12-“区域设施” 13-“建筑物内部”
private int station_type;//1."充电站"2 "充换电站"3 "充电桩组"4 "换电站"5 "门牌", "公交:6 情报:7 private int station_type;//1."充电站"2 "充换电站"3 "充电桩组"4 "换电站"5 "门牌", "公交:6 情报:7
private int isLocalData;//是否是本地数据 0,服务 1,本地 private int isLocalData;//是否是本地数据 0,服务 1,本地
private int isExclusive;//任务类型 0.普通任务,1.专属任务 2挑战任务, 3奖励任务 private int isExclusive;//任务类型 0.普通任务,1.专属任务 2挑战任务, 3奖励任务
private int bodyId;//保存本地的bodyId private int bodyId;//保存本地的bodyId
private int work_type;//0,待提交 1,提交中 private int work_type;//0,待提交 1,提交中 2,已上传
private int record_way; //等同于 canReceived : 1是可领取 0是不可领取 private int record_way; //等同于 canReceived : 1是可领取 0是不可领取
private int uploadProgress; // 上传进度
private int uploadMax; // 上传数据总量-这里一般使用需要上传的文件数量作为总数,因此上传进度为已上传的文件数
private int score; // 置信度
private String drawLine; // 用户绘制的线型
private String uploadResult; //上传结果
public int getRecord_way() { public int getRecord_way() {
return record_way; return record_way;
@@ -280,6 +286,46 @@ public class PoiEntity implements Serializable {
this.detail = detail; this.detail = detail;
} }
public int getUploadProgress() {
return uploadProgress;
}
public void setUploadProgress(int uploadProgress) {
this.uploadProgress = uploadProgress;
}
public int getUploadMax() {
return uploadMax;
}
public void setUploadMax(int uploadMax) {
this.uploadMax = uploadMax;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public String getDrawLine() {
return drawLine;
}
public void setDrawLine(String drawLine) {
this.drawLine = drawLine;
}
public String getUploadResult() {
return uploadResult;
}
public void setUploadResult(String uploadResult) {
this.uploadResult = uploadResult;
}
@Override @Override
public String toString() { public String toString() {
return "PoiEntity{" + return "PoiEntity{" +
@@ -0,0 +1,36 @@
package com.navinfo.outdoor.ui.view;
import android.content.Context;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
public class SpinnerUtils {
public void initSpinner(Context mContext, Spinner spinner, AdapterView.OnItemSelectedListener selectedListener, String selectItem, String... items) {
if (spinner == null) {
return;
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_dropdown_item_1line,
android.R.id.text1, items);
spinner.setAdapter(adapter);
for (int i = 0; i < items.length; i++) {
if (items[i]!=null) {
if (items[i].equals(selectItem)) {
spinner.setSelection(i);
spinner.setTag(items[i]);
break;
}
}
if (selectItem!=null) {
// 如果是楼层选项,则被选中要素为“楼层选择”
if (items[i].startsWith("楼层选择")&&selectItem.endsWith("层")) {
spinner.setSelection(i);
spinner.setTag(selectItem);
break;
}
}
}
// 增加监听
spinner.setOnItemSelectedListener(selectedListener);
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,92 @@
package com.navinfo.outdoor.util;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Looper;
import android.os.SystemClock;
import android.widget.Toast;
import com.elvishew.xlog.XLog;
import com.navinfo.outdoor.api.UserApplication;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
public class CrashHandler implements Thread.UncaughtExceptionHandler {
private static volatile CrashHandler INSTANCE;
private CrashHandler() {
}
public static CrashHandler getInstance() {
if (INSTANCE == null) {
synchronized (CrashHandler.class) {
if (INSTANCE == null) {
synchronized (CrashHandler.class) {
INSTANCE = new CrashHandler();
}
}
}
}
return INSTANCE;
}
private Thread.UncaughtExceptionHandler mDefaultHandler;
/**
* 初始化默认异常捕获
*/
public void init() {
// 获取默认异常处理器
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
// 将当前类设为默认异常处理器
Thread.setDefaultUncaughtExceptionHandler(this);
}
@Override
public void uncaughtException(Thread t, Throwable e) {
if (handleException(e)) {
Toast.makeText(UserApplication.getUserApplication(), "抱歉,出现不可预知错误,请联系工作人员!", Toast.LENGTH_SHORT).show();
// 已经处理,APP重启
restartApp();
} else {
// 如果不处理,则调用系统默认处理异常,弹出系统强制关闭的对话框
if (mDefaultHandler != null) {
mDefaultHandler.uncaughtException(t, e);
}
}
}
private boolean handleException(Throwable e) {
if (e == null) {
return false;
}
Writer writer = new StringWriter();
PrintWriter pw = new PrintWriter(writer);
e.printStackTrace(pw);
pw.close();
String result = writer.toString();
// 打印出错误日志
XLog.e(result);
return true;
}
/**
* 1s后让APP重启
*/
private void restartApp() {
Intent intent = UserApplication.getUserApplication().getPackageManager()
.getLaunchIntentForPackage(UserApplication.getUserApplication().getPackageName());
PendingIntent restartIntent = PendingIntent.getActivity(UserApplication.getUserApplication(), 0, intent, 0);
AlarmManager mgr = (AlarmManager) UserApplication.getUserApplication().getSystemService(Context.ALARM_SERVICE);
// 1秒钟后重启应用
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent);
System.exit(0);
}
}
@@ -2,11 +2,15 @@ package com.navinfo.outdoor.util;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.elvishew.xlog.Logger;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.FileUtils; import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.MD5; import com.github.lazylibrary.util.MD5;
import com.github.lazylibrary.util.ZipUtil; import com.github.lazylibrary.util.ZipUtil;
@@ -18,27 +22,38 @@ import com.kongzue.dialog.v3.WaitDialog;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import com.navinfo.outdoor.activity.PicturesActivity;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.api.UserApplication; import com.navinfo.outdoor.api.UserApplication;
import com.navinfo.outdoor.bean.CommonRequestSend; import com.navinfo.outdoor.bean.CommonRequestSend;
import com.navinfo.outdoor.bean.CommonResponse; import com.navinfo.outdoor.bean.CommonResponse;
import com.navinfo.outdoor.bean.LocationRecorder;
import com.navinfo.outdoor.bean.PoiSaveBean; import com.navinfo.outdoor.bean.PoiSaveBean;
import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.Callback;
import com.navinfo.outdoor.http.DialogCallback; import com.navinfo.outdoor.http.DialogCallback;
import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.HttpInterface;
import com.navinfo.outdoor.http.OkGoBuilder; import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.room.InsertAndUpdateUtils; import com.navinfo.outdoor.room.InsertAndUpdateUtils;
import com.navinfo.outdoor.room.LocationRecorderDao;
import com.navinfo.outdoor.room.PoiDatabase; import com.navinfo.outdoor.room.PoiDatabase;
import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.room.PoiEntity;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import com.umeng.commonsdk.debug.UMLog; import com.umeng.commonsdk.debug.UMLog;
import com.umeng.umcrash.UMCrash; import com.umeng.umcrash.UMCrash;
import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.EventBus;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.geom.LineString;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@@ -59,10 +74,12 @@ import io.reactivex.schedulers.Schedulers;
public class DataSaveUtils { public class DataSaveUtils {
private static DataSaveUtils instance; private static DataSaveUtils instance;
private static Logger logger;
public static DataSaveUtils getInstance() { public static DataSaveUtils getInstance() {
if (instance == null) { if (instance == null) {
instance = new DataSaveUtils(); instance = new DataSaveUtils();
logger = XLogUtils.Companion.getInstance().getUploadLogWriter();
} }
return instance; return instance;
} }
@@ -73,13 +90,17 @@ public class DataSaveUtils {
public void onError(); public void onError();
} }
public Single<List<Map.Entry<Integer, File>>> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) { public Single<PoiEntity> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
poiEntity.setUploadResult("");
int auditId = poiEntity.getBodyId(); int auditId = poiEntity.getBodyId();
File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip"); File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip");
return Observable.create(new ObservableOnSubscribe<File>() { return Observable.create(new ObservableOnSubscribe<File>() {
@Override @Override
public void subscribe(ObservableEmitter<File> emitter) throws Exception { public void subscribe(ObservableEmitter<File> emitter) throws Exception {
if (!zipFile.exists()) { if (!zipFile.exists()) {
// 首先检查图片中是否存在已损坏的图片
List<File> corruptImage = filterCorruptImages(poiPicList);
logger.d("存在损坏的照片:"+poiEntity.getId()+":"+poiEntity.getName()+list2Str(corruptImage));
// 开始压缩文件 // 开始压缩文件
ZipUtil.zipFiles(poiPicList, zipFile, "", null); ZipUtil.zipFiles(poiPicList, zipFile, "", null);
} }
@@ -94,12 +115,25 @@ public class DataSaveUtils {
.map(new Function<File, Map<Integer, File>>() { .map(new Function<File, Map<Integer, File>>() {
@Override @Override
public Map<Integer, File> apply(File file) throws Exception { public Map<Integer, File> apply(File file) throws Exception {
// 计算按照当前分包大小切分的个数,超过200个则按照最多200个切分
long splitFileSize = Constant.DEFAULT_CUT_SIZE;
long count = file.length()/Constant.DEFAULT_CUT_SIZE;
if (count>180) {
splitFileSize = file.length()/180L;
}
// 每次执行上传都会切分数据,因为都会执行第一步,向服务器请求需要上传的分包数据 // 每次执行上传都会切分数据,因为都会执行第一步,向服务器请求需要上传的分包数据
List<File> splitFiles = FileSpliteMergeUtils.splitFile(file, Constant.DEFAULT_CUT_SIZE); List<File> splitFiles = FileSpliteMergeUtils.splitFile(file, splitFileSize);
poiEntity.setUploadMax(splitFiles.size());
sendRefreshItem(poiEntity);
List<Long> chunkSizeList = new ArrayList<>(); List<Long> chunkSizeList = new ArrayList<>();
long slipeFileSizeCount = 0;
for (File f: splitFiles) { for (File f: splitFiles) {
chunkSizeList.add(f.length()); chunkSizeList.add(f.length());
slipeFileSizeCount+=f.length();
} }
XLog.d("各个分包的数据和为:"+slipeFileSizeCount);
XLog.d("zip包的文件大小为:"+file.length());
XLog.d("是否一致:"+(Long.compare(slipeFileSizeCount, file.length())));
CommonResponse<String> response = createUploadTask(mContext, auditId, file.length(), chunkSizeList); CommonResponse<String> response = createUploadTask(mContext, auditId, file.length(), chunkSizeList);
if (response!=null) { if (response!=null) {
// 请求成功,获取需要上传的分包index // 请求成功,获取需要上传的分包index
@@ -108,11 +142,15 @@ public class DataSaveUtils {
poiEntity.setTaskStatus(100); poiEntity.setTaskStatus(100);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity); PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
ToastUtils.Message(mContext, "数据:"+poiEntity.getName()+"已成功上传!"); ToastUtils.Message(mContext, "数据:"+poiEntity.getName()+"已成功上传!");
poiEntity.setUploadProgress(splitFiles.size()); // 上传进度为当前文件个数
sendRefreshItem(poiEntity);
} }
if (body==null) { if (body==null) {
throw new Exception(response.getMessage()); throw new Exception(response.getMessage());
} }
if (body.isEmpty()) { if (body.isEmpty()) { // 服务返回空数据,说明该数据的所有分包数据都上传完成,没有需要上传的分包了
poiEntity.setUploadProgress(splitFiles.size()); // 上传进度为当前文件个数
sendRefreshItem(poiEntity);
return new HashMap<>(); return new HashMap<>();
} }
String[] needUploadStrIndex = body.split(","); String[] needUploadStrIndex = body.split(",");
@@ -121,6 +159,8 @@ public class DataSaveUtils {
for (int i = 0; i < needUploadStrIndex.length; i++) { for (int i = 0; i < needUploadStrIndex.length; i++) {
needUploadIndex[i] = Integer.parseInt(needUploadStrIndex[i]); needUploadIndex[i] = Integer.parseInt(needUploadStrIndex[i]);
} }
poiEntity.setUploadProgress(splitFiles.size()-needUploadIndex.length); // 上传进度为当前文件个数
sendRefreshItem(poiEntity);
// 根据返回的index,将需要上传的切分包数据流转到下一个流程 // 根据返回的index,将需要上传的切分包数据流转到下一个流程
Map<Integer, File> needUploadFileMap = new HashMap<>(); Map<Integer, File> needUploadFileMap = new HashMap<>();
for (int index: needUploadIndex) { for (int index: needUploadIndex) {
@@ -153,8 +193,12 @@ public class DataSaveUtils {
// 执行上传流程 // 执行上传流程
CommonResponse response = uploadSplitTask(mContext, auditId, fileEntry.getKey(), fileEntry.getValue()); CommonResponse response = uploadSplitTask(mContext, auditId, fileEntry.getKey(), fileEntry.getValue());
if (response.getCode() != 200) { if (response.getCode() != 200) {
poiEntity.setUploadResult("第"+fileEntry.getKey()+"个分包数据上传失败");
sendRefreshItem(poiEntity);
throw new Exception(response.getMessage()); throw new Exception(response.getMessage());
} else { } else {
poiEntity.setUploadProgress(poiEntity.getUploadProgress()+1); // 上传进度为当前文件个数
sendRefreshItem(poiEntity);
UMLog.mutlInfo(3, "已上传分包"+fileEntry.getKey()); UMLog.mutlInfo(3, "已上传分包"+fileEntry.getKey());
// 上传成功,则删除该分包数据 // 上传成功,则删除该分包数据
if (fileEntry.getValue().exists()) { if (fileEntry.getValue().exists()) {
@@ -171,39 +215,51 @@ public class DataSaveUtils {
@Override @Override
public void accept(List<Map.Entry<Integer, File>> entries) throws Exception { public void accept(List<Map.Entry<Integer, File>> entries) throws Exception {
// 最终成功,调用finish接口 // 最终成功,调用finish接口
poiEntity.setUploadResult("附件上传完成");
CommonResponse response = uploadTaskFinish(mContext, auditId); CommonResponse response = uploadTaskFinish(mContext, auditId);
if (response.getCode() == 200) { // 更新成功,再次更新本地数据库 if (response.getCode() == 200) { // 更新成功,再次更新本地数据库
poiEntity.setTaskStatus(100); poiEntity.setTaskStatus(100);
poiEntity.setUploadProgress(poiEntity.getUploadMax());
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity); PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// 同时删除关联的照片文件和压缩包文件 // 同时删除关联的照片文件和压缩包文件
if (zipFile.exists()) { if (zipFile.getParentFile().exists()&&!zipFile.getParentFile().getName().endsWith("picture")) {
zipFile.delete(); // 删除对应的文件夹
} FileUtils.deleteFile(zipFile.getParentFile().getAbsolutePath());
if (poiPicList!=null&&!poiPicList.isEmpty()) {
for (File picFile: poiPicList
) {
picFile.delete();
}
} }
// if (zipFile.exists()) {
// zipFile.delete();
// }
// if (poiPicList!=null&&!poiPicList.isEmpty()) {
// for (File picFile: poiPicList
// ) {
// picFile.delete();
// }
// }
} else { } else {
throw new Exception("数据:" + poiEntity.getName() + " 上传失败"); throw new Exception("数据:" + poiEntity.getName() + " 上传失败");
} }
} }
})
.map(new Function<List<Map.Entry<Integer, File>>, PoiEntity>() {
@Override
public PoiEntity apply(List<Map.Entry<Integer, File>> entries) throws Exception {
return poiEntity;
}
}); });
} }
// 批量上传文件 // 批量上传文件
public void uploadFiles(Activity mContext, PoiEntity poiEntity, List<File> poiPicList, UploadCallback callback) { public void uploadFiles(Activity mContext, PoiEntity poiEntity, List<File> poiPicList, UploadCallback callback) {
getUploadSpliteFilesObservble(mContext, poiEntity, poiPicList) getUploadSpliteFilesObservble(mContext ,poiEntity, poiPicList)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new SingleObserver<List<Map.Entry<Integer, File>>>() { .subscribe(new SingleObserver<PoiEntity>() {
@Override @Override
public void onSubscribe(Disposable d) { public void onSubscribe(Disposable d) {
callback.onStart(); callback.onStart();
} }
@Override @Override
public void onSuccess(List<Map.Entry<Integer, File>> entries) { public void onSuccess(PoiEntity poiEntity) {
ToastUtils.Message(mContext, "分包数据上传完成!"); ToastUtils.Message(mContext, "分包数据上传完成!");
Message obtain1 = Message.obtain(); Message obtain1 = Message.obtain();
obtain1.what = Constant.NEST_WORD_SUBMIT; obtain1.what = Constant.NEST_WORD_SUBMIT;
@@ -248,6 +304,16 @@ public class DataSaveUtils {
return null; return null;
} }
/**
* EventBus通知列表当前的上传进度
* */
private void sendRefreshItem(PoiEntity poiEntity) {
Message msg = Message.obtain();
msg.what = Constant.EVENT_WHAT_UPLOAD_PROGRESS;
msg.obj = poiEntity;
EventBus.getDefault().post(msg);
}
/** /**
* 上传分包数据 * 上传分包数据
* */ * */
@@ -349,4 +415,72 @@ public class DataSaveUtils {
} }
return result.toString(); return result.toString();
} }
private List<File> filterCorruptImages(List<File> files) {
List<File> corruptImage = new ArrayList<>();
Iterator<File> iterator = files.iterator();
while (iterator.hasNext()) {
File file = iterator.next();
if (file.getName().endsWith(".json")||file.getName().endsWith(".txt")) {
continue;
}
if (file.length()==0) {
corruptImage.add(file);
iterator.remove();
continue;
}
try {
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath());
if (bitmap == null) {
corruptImage.add(file);
iterator.remove();
}
} catch (Exception e) {
corruptImage.add(file);
iterator.remove();
}
}
return corruptImage;
}
/**
* 检查道路POI的照片数据,轨迹与道路任务长度比率必须大于0.1
* */
public static void checkRoadPoiPicture(PoiEntity poiEntity, List<File> fileList, RoadPercentCheckCallback callback) {
new Thread(new Runnable() {
@Override
public void run() {
double lengthPercent = 0.0;
// 获取任务数据长度
String geoWkt = poiEntity.getGeoWkt();
if (geoWkt!=null) {
String geoDecode = Geohash.getInstance().decode(geoWkt);
Geometry originGeometry = GeometryTools.createGeometry(geoDecode);
// 获取轨迹对应的geometry
if (fileList!=null&&!fileList.isEmpty()) {
File txtFile = new File(fileList.get(0).getParentFile(), "paper.txt");
// 读取第一条数据和最后一条数据,获取时间,然后根据数据查询轨迹数据
List<String> txtStringList = FileUtils.readFileToList(txtFile.getAbsolutePath(), "utf-8");
// 读取位置信息
List<LatLng> latLngList = new ArrayList<>(txtStringList.size());
for (String line: txtStringList) {
String[] itemArray = line.split(",");
// 获取数据的经纬度
latLngList.add(new LatLng(Double.parseDouble(itemArray[2]), Double.parseDouble(itemArray[3])));
}
// 构建轨迹的geometry
LineString trackLine = GeometryTools.getLineStainGeo(latLngList);
lengthPercent = trackLine.getLength()/originGeometry.getLength();
}
}
callback.callback(lengthPercent);
}
}).start();
}
public interface RoadPercentCheckCallback{
void callback(double percent);
}
} }
@@ -16,7 +16,6 @@ import java.lang.Exception
object FileSpliteMergeUtils { object FileSpliteMergeUtils {
const val TAG = "FileUtils" const val TAG = "FileUtils"
//默认切割文件的大小 //默认切割文件的大小
// private const val DEFAULT_CUT_SIZE: Long = 5*1024*1024//5MB
private const val DEFAULT_CUT_SIZE: Long = Constant.DEFAULT_CUT_SIZE//5MB private const val DEFAULT_CUT_SIZE: Long = Constant.DEFAULT_CUT_SIZE//5MB
/** /**
@@ -70,6 +69,32 @@ object FileSpliteMergeUtils {
} }
return singleFileList return singleFileList
} }
// @JvmStatic
// fun splitFile(file: File, chunkSize: Long = DEFAULT_CUT_SIZE): List<File> {
// val fileSize = file.length()
// val numChunks = (fileSize / chunkSize).toInt() + if (fileSize % chunkSize > 0) 1 else 0
// val chunks = mutableListOf<File>()
//
// RandomAccessFile(file, "r").use { raf ->
// for (i in 0 until numChunks) {
// val chunkFile = File(file.parent, "${file.nameWithoutExtension}_${i + 1}.tmp")
// if (chunkFile.exists()){
// chunkFile.delete()
// }
// RandomAccessFile(chunkFile, "rw").use { chunkRaf ->
// val start = i * chunkSize
// val end = if (i == numChunks - 1) fileSize else (i + 1) * chunkSize
// raf.seek(start)
// while (raf.filePointer < end) {
// chunkRaf.write(raf.read())
// }
// }
// chunks.add(chunkFile)
// }
// }
// return chunks.toList()
// }
private fun createSingleFile(sourceFile: File,index: Long): File{ private fun createSingleFile(sourceFile: File,index: Long): File{
val path = sourceFile.absolutePath.substringBeforeLast(".") val path = sourceFile.absolutePath.substringBeforeLast(".")
@@ -90,18 +115,18 @@ object FileSpliteMergeUtils {
val out = RandomAccessFile(single,"rw") val out = RandomAccessFile(single,"rw")
var index = 0 var index = 0
try { try {
val byte = ByteArray(1024) val byte = ByteArray((end-begin).toInt())
inFile.seek(begin) inFile.seek(begin)
while (inFile.read(byte).also { index = it } != -1 && inFile.filePointer <= end){ while (inFile.read(byte).also { index = it } != -1&&inFile.filePointer <= end){
out.write(byte,0,index) out.write(byte,0,index)
endPointer = inFile.filePointer
} }
endPointer = inFile.filePointer
}catch (e: Exception){ }catch (e: Exception){
e.printStackTrace() e.printStackTrace()
}finally { }finally {
out.close() out.close()
} }
return endPointer - index // 减去最后一次读取的字节数,因为while循环中会先读取文件,导致filePointer字段向后移动index,但是后面的判断条件导致循环跳出,所以要将下次读取的offset向前移动 return endPointer
} }
/** /**
@@ -14,18 +14,31 @@ import android.location.Location;
import android.location.LocationListener; import android.location.LocationListener;
import android.location.LocationManager; import android.location.LocationManager;
import android.location.LocationProvider; import android.location.LocationProvider;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Message;
import android.provider.Settings; import android.provider.Settings;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import com.navinfo.outdoor.api.Constant;
import com.tencent.map.fusionlocation.model.TencentGeoLocation;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import org.greenrobot.eventbus.EventBus;
import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
@SuppressLint("MissingPermission") @SuppressLint("MissingPermission")
@RequiresApi(api = Build.VERSION_CODES.N)
public class GPSUtils { public class GPSUtils {
private LocationManager mLocationManager; private LocationManager mLocationManager;
@@ -34,35 +47,50 @@ public class GPSUtils {
private Location mLocation = null; private Location mLocation = null;
private Activity mContext; private Context mContext;
public GPSUtils(Activity context) { private static GPSUtils instance;
private int sateliteCount; // 卫星颗数
public static GPSUtils getInstance(Context mContext) {
if (instance == null) {
instance = new GPSUtils(mContext);
}
return instance;
}
private GPSUtils(Context context) {
this.mContext = context; this.mContext = context;
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
// 判断GPS是否正常启动 // 判断GPS是否正常启动
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
ToastUtils.Message(context,"请开启GPS导航..."); com.github.lazylibrary.util.ToastUtils.showToast(context, "请开启GPS导航...");
// 返回开启GPS导航设置界面 Map<String, String> mapData = new HashMap<>();
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); mapData.put("code", "101");
context.startActivityForResult(intent, 0); EventBus.getDefault().post(mapData);
return; return;
} }
// 为获取地理位置信息时设置查询条件 // 为获取地理位置信息时设置查询条件
String bestProvider = mLocationManager.getBestProvider(getCriteria(), true); String bestProvider = mLocationManager.getBestProvider(getCriteria(), true);
// 获取位置信息 if (bestProvider!=null) {
// 如果不设置查询要求,getLastKnownLocation方法传人的参数为LocationManager.GPS_PROVIDER // 获取位置信息
// 如果不设置查询要求,getLastKnownLocation方法传人的参数为LocationManager.GPS_PROVIDER
// getLocationData(location); // getLocationData(location);
mLocation = mLocationManager.getLastKnownLocation(bestProvider); mLocation = mLocationManager.getLastKnownLocation(bestProvider);
// 监听状态 // 监听状态
mLocationManager.registerGnssStatusCallback(listener); mLocationManager.registerGnssStatusCallback(listener);
}
}
public void startLocation() {
// 绑定监听,有4个参数 // 绑定监听,有4个参数
// 参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种 // 参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种
// 参数2,位置信息更新周期,单位毫秒 // 参数2,位置信息更新周期,单位毫秒
// 参数3,位置变化最小距离:当位置距离变化超过此值时,将更新位置信息 // 参数3,位置变化最小距离:当位置距离变化超过此值时,将更新位置信息
// 参数4,监听 // 参数4,监听
// 备注:参数2和3,如果参数3不为0,则以参数3为准;参数3为0,则通过时间来定时更新;两者为0,则随时刷新 // 备注:参数2和3,如果参数3不为0,则以参数3为准;参数3为0,则通过时间来定时更新;两者为0,则随时刷新
// 1秒更新一次,或最小位移变化超过1米更新一次; // 1秒更新一次,或最小位移变化超过1米更新一次;
// 注意:此处更新准确度非常低,推荐在service里面启动一个Thread,在run中sleep(10000);然后执行handler.sendMessage(),更新位置 // 注意:此处更新准确度非常低,推荐在service里面启动一个Thread,在run中sleep(10000);然后执行handler.sendMessage(),更新位置
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locationListener); mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locationListener);
@@ -76,15 +104,15 @@ public class GPSUtils {
// 设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细 // 设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细
criteria.setAccuracy(Criteria.ACCURACY_FINE); criteria.setAccuracy(Criteria.ACCURACY_FINE);
// 设置是否要求速度 // 设置是否要求速度
criteria.setSpeedRequired(false); criteria.setSpeedRequired(true);
// 设置是否允许运营商收费 // 设置是否允许运营商收费
criteria.setCostAllowed(false); criteria.setCostAllowed(true);
// 设置是否需要方位信息 // 设置是否需要方位信息
criteria.setBearingRequired(false); criteria.setBearingRequired(true);
// 设置是否需要海拔信息 // 设置是否需要海拔信息
criteria.setAltitudeRequired(false); criteria.setAltitudeRequired(true);
// 设置对电源的需求 // 设置对电源的需求
criteria.setPowerRequirement(Criteria.POWER_LOW); criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
return criteria; return criteria;
} }
@@ -137,11 +165,22 @@ public class GPSUtils {
mLocationManager.removeUpdates(this); mLocationManager.removeUpdates(this);
return; return;
} }
double[] gpsLatLng = Gps.toGCJ02Point(location.getLatitude(), location.getLongitude());
location.setLatitude(gpsLatLng[0]);
location.setLongitude(gpsLatLng[1]);
mLocation = location; mLocation = location;
Log.i(TAG, "时间:" + location.getTime()); Log.i(TAG, "时间:" + location.getTime());
Log.i(TAG, "经度:" + location.getLongitude()); Log.i(TAG, "经度:" + location.getLongitude());
Log.i(TAG, "纬度:" + location.getLatitude()); Log.i(TAG, "纬度:" + location.getLatitude());
Log.i(TAG, "海拔:" + location.getAltitude()); Log.i(TAG, "海拔:" + location.getAltitude());
TencentLocation tencentLocation = TencentLocationObtain.obtainTecentLocation(location);
Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_WHAT_LOCATION_CHANGE;
currentLocationMsg.arg1 = LocationLifeCycle.LOCATION_FROM.ORIGIN.ordinal(); // 设置定位来源
currentLocationMsg.obj = tencentLocation;
EventBus.getDefault().post(currentLocationMsg);
} }
//GPS状态变化时触发 //GPS状态变化时触发
@@ -217,19 +256,16 @@ public class GPSUtils {
return; return;
} }
Log.i(TAG, "卫星状态改变"); Log.i(TAG, "卫星状态改变");
if (onClickGPSStatus != null) { if (status != null) {
onClickGPSStatus.onGpsCount(status.getSatelliteCount()); sateliteCount = status.getSatelliteCount();
} else {
sateliteCount = 0;
} }
} }
}; };
public OnClickGPSStatus onClickGPSStatus;
public void setOnClickGPSStatus(OnClickGPSStatus onClickGPSStatus) { public int getSateliteCount() {
this.onClickGPSStatus = onClickGPSStatus; return sateliteCount;
}
public interface OnClickGPSStatus {
void onGpsCount(int count);
} }
public void unRegisterAllListener() { public void unRegisterAllListener() {
@@ -0,0 +1,210 @@
package com.navinfo.outdoor.util;
import android.content.Context;
import android.location.Location;
import android.os.Message;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.lifecycle.DefaultLifecycleObserver;
import androidx.lifecycle.LifecycleOwner;
import com.navinfo.outdoor.api.Constant;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import java.util.List;
public class LocationLifeCycle implements DefaultLifecycleObserver {
private Context mContext;
private LOCATION_FROM mainLocationFrom = LOCATION_FROM.TENCENT/*主要位置源*/, referenceLocationFrom = LOCATION_FROM.ORIGIN/*参考位置源*/;
private TencentLocation tencentLocation; // 腾讯定位获取到的最新位置信息
private TencentLocation gpsLocation; // 原生系统获取到的最新位置
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
private static LocationLifeCycle instance;
public static LocationLifeCycle getInstance() {
if (instance == null) {
instance = new LocationLifeCycle();
}
return instance;
}
public void init(Context mContext) {
this.mContext = mContext;
}
@Override
public void onCreate(@NonNull LifecycleOwner owner) {
DefaultLifecycleObserver.super.onCreate(owner);
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().register(this);
}
startTencentLocation();
}
public void startTencentLocation() {
// 开启腾讯定位
if (!TalentLocationUtils.getInstance(mContext).isLocationStart()) {
TalentLocationUtils.getInstance(mContext).startLocation(mContext);
}
}
public void stopTencentLocation() {
// 停止腾讯定位
TalentLocationUtils.getInstance(mContext).stopLocation();
}
public void startGPSLocation() {
GPSUtils.getInstance(mContext).startLocation();
}
public void stopGPSLocation() {
GPSUtils.getInstance(mContext).startLocation();
}
@Override
public void onDestroy(@NonNull LifecycleOwner owner) {
DefaultLifecycleObserver.super.onDestroy(owner);
locationChangedListenerList.clear();
locationChangedListenerList = null;
stopTencentLocation();
GPSUtils.getInstance(mContext).unRegisterAllListener();
if (EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEventMessageMainThread(Message msg) {
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
if (msg.arg1 == LOCATION_FROM.ORIGIN.ordinal()) {
gpsLocation = (TencentLocation) msg.obj;
if (msg.arg1 == mainLocationFrom.ordinal()) { // 如果当前定位方式是主要定位方式
MyLocation location = new MyLocation(gpsLocation.getProvider(), gpsLocation);
//设置经纬度以及精度
location.setLatitude(gpsLocation.getLatitude());
location.setLongitude(gpsLocation.getLongitude());
if (gpsLocation.getBearing()!=0) {
location.setBearing(gpsLocation.getBearing());
} else {
location.setBearing((float) gpsLocation.getDirection());
}
location.setAccuracy(gpsLocation.getAccuracy());
if (locationChangedListenerList!=null) {
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
locationChangedListener.onLocationChanged(location);
}
}
}
} else if (msg.arg1 == LOCATION_FROM.TENCENT.ordinal()) {
tencentLocation = (TencentLocation) msg.obj;
// Log.d("LocationLifeCycle",
// "isMockGps:"+tencentLocation.isMockGps()
// +",FakeReason:"+tencentLocation.getFakeReason()
// +"Provider:"+tencentLocation.getProvider()
// +"SourceProvider:"+tencentLocation.getSourceProvider()+tencentLocation.getGpsQuality());
if (msg.arg1 == mainLocationFrom.ordinal()) { // 如果当前定位方式是主要定位方式
MyLocation location = new MyLocation(tencentLocation.getProvider(), tencentLocation);
//设置经纬度以及精度
location.setLatitude(tencentLocation.getLatitude());
location.setLongitude(tencentLocation.getLongitude());
if (tencentLocation.getBearing()!=0) {
location.setBearing(tencentLocation.getBearing());
} else {
location.setBearing((float) tencentLocation.getDirection());
}
location.setAccuracy(tencentLocation.getAccuracy());
if (locationChangedListenerList!=null) {
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
locationChangedListener.onLocationChanged(location);
}
}
}
}
}
}
public List<LocationSource.OnLocationChangedListener> getLocationChangedListenerList() {
if (locationChangedListenerList == null) {
locationChangedListenerList = new ArrayList<>();
}
return locationChangedListenerList;
}
/**
* 设置主要可用的定位来源
* */
public void setMainLocationFrom(LOCATION_FROM mainLocationFrom) {
this.mainLocationFrom = mainLocationFrom;
}
/**
* 设置次要可用的定位来源
* */
public void setReferenceLocationFrom(LOCATION_FROM referenceLocationFrom) {
this.referenceLocationFrom = referenceLocationFrom;
}
/**
* 获取主要位置信息
* */
public MyLocation getMainLocation() {
switch (mainLocationFrom) {
case ORIGIN:
if (gpsLocation!=null) {
return new MyLocation(gpsLocation.getProvider(), gpsLocation);
}
break;
case TENCENT:
if (tencentLocation!=null) {
return new MyLocation(tencentLocation.getProvider(), tencentLocation);
}
break;
}
return null;
}
/**
* 获取参考位置信息
* */
/**
* 获取主要位置信息
* */
public MyLocation getReferenceLocation() {
switch (referenceLocationFrom) {
case ORIGIN:
if (gpsLocation!=null) {
return new MyLocation(gpsLocation.getProvider(), gpsLocation);
}
break;
case TENCENT:
if (tencentLocation!=null) {
return new MyLocation(tencentLocation.getProvider(), tencentLocation);
}
break;
}
return null;
}
public enum LOCATION_FROM {
ORIGIN, TENCENT, SIMULATOR/*模拟定位*/, BAIDU, AMAP
}
public TencentLocation getTencentLocation() {
return tencentLocation;
}
private boolean checkInit() throws Exception {
if (this.mContext == null) {
throw new Exception("LocationLifeCycle 没有初始化!");
}
return true;
}
}
@@ -0,0 +1,39 @@
package com.navinfo.outdoor.util;
import android.location.Address;
import android.location.Geocoder;
import android.location.Location;
import com.tencent.map.geolocation.TencentLocation;
import java.util.List;
import java.util.Locale;
public class MyLocation extends Location {
private String city;
private String cityCode;
private String cityPhoneCode;
public MyLocation(String provider, TencentLocation tencentLocation) {
super(provider);
this.city = tencentLocation.getCity();
this.cityCode = tencentLocation.getCityCode();
this.cityPhoneCode = tencentLocation.getCityPhoneCode();
this.setAccuracy(tencentLocation.getAccuracy());
this.setAltitude(tencentLocation.getAltitude());
if (tencentLocation.getBearing()!=0) {
this.setBearing(tencentLocation.getBearing());
} else {
this.setBearing((float) tencentLocation.getDirection());
}
this.setElapsedRealtimeNanos(tencentLocation.getElapsedRealtime());
this.setLatitude(tencentLocation.getLatitude());
this.setLongitude(tencentLocation.getLongitude());
this.setSpeed(tencentLocation.getSpeed());
this.setTime(tencentLocation.getTime());
}
public MyLocation(String provider, Location location) {
super(location);
}
}
@@ -0,0 +1,54 @@
package com.navinfo.outdoor.util;
import android.content.Context;
import android.location.Location;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
import java.util.ArrayList;
import java.util.List;
public class MyLocationObserve{
public MyLocationObserve instance;
private LOCATION_FROM currentLocationFrom = LOCATION_FROM.ORIGIN; // 当前正在启用的定位系统
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
private Location currentUseLocation; // 当前正在使用的location信息
public MyLocationObserve() {
locationChangedListenerList = new ArrayList<>();
}
public void init(Context mContext) {
}
public void destroy() {
}
public MyLocationObserve getInstance() {
if (instance == null) {
instance = new MyLocationObserve();
}
return instance;
}
public enum LOCATION_FROM {
ORIGIN, TENCENT, BAIDU, AMAP
}
public void onLocationChangeListener(LOCATION_FROM from, Location location) {
if (from == currentLocationFrom) {
if (currentUseLocation == null) {
currentUseLocation = location;
} else {
currentUseLocation.set(location);
}
for (LocationSource.OnLocationChangedListener locationChangedListener: locationChangedListenerList
) {
locationChangedListener.onLocationChanged(currentUseLocation);
}
}
}
}
@@ -20,13 +20,13 @@ public class MyTecentLocationSource implements LocationSource{
@Override @Override
public void activate(OnLocationChangedListener onLocationChangedListener) { public void activate(OnLocationChangedListener onLocationChangedListener) {
locationChangedListener = onLocationChangedListener; locationChangedListener = onLocationChangedListener;
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().add(onLocationChangedListener); LocationLifeCycle.getInstance().getLocationChangedListenerList().add(onLocationChangedListener);
} }
@Override @Override
public void deactivate() { public void deactivate() {
if (locationChangedListener!=null) { if (locationChangedListener!=null) {
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().remove(locationChangedListener); LocationLifeCycle.getInstance().getLocationChangedListenerList().remove(locationChangedListener);
} }
} }
} }
@@ -12,6 +12,7 @@ import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.app.AppCompatActivity;
import com.elvishew.xlog.XLog;
import com.kongzue.dialog.v3.CustomDialog; import com.kongzue.dialog.v3.CustomDialog;
import com.navinfo.outdoor.R; import com.navinfo.outdoor.R;
import com.navinfo.outdoor.activity.NaviCarActivity; import com.navinfo.outdoor.activity.NaviCarActivity;
@@ -62,6 +63,7 @@ public class NaviUtils {
private Context mContext; private Context mContext;
private TencentMap tencentMap; private TencentMap tencentMap;
private TencentNaviManager naviManager = null; private TencentNaviManager naviManager = null;
private NaviTts naviTts = new NaviTts();
public static NaviUtils getInstance() { public static NaviUtils getInstance() {
if (instance == null) { if (instance == null) {
instance = new NaviUtils(); instance = new NaviUtils();
@@ -125,7 +127,9 @@ public class NaviUtils {
public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, NaviView naviView) { public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, NaviView naviView) {
if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车 if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车
CarNaviView carNaviView = (CarNaviView) naviView; CarNaviView carNaviView = (CarNaviView) naviView;
naviManager = new TencentCarNaviManager(mContext); if (naviManager==null||!naviManager.isNavigating()) {
naviManager = new TencentCarNaviManager(mContext);
}
carNaviView.setVisibility(View.VISIBLE); carNaviView.setVisibility(View.VISIBLE);
naviManager.addNaviView(carNaviView); naviManager.addNaviView(carNaviView);
CarNaviInfoPanel carNaviInfoPanel = carNaviView.showNaviInfoPanel(); CarNaviInfoPanel carNaviInfoPanel = carNaviView.showNaviInfoPanel();
@@ -145,19 +149,22 @@ public class NaviUtils {
@Override @Override
public void onStopNavi() { public void onStopNavi() {
NaviTts naviTts = new NaviTts();
naviTts.setText("结束导航"); naviTts.setText("结束导航");
mContext.finish(); mContext.finish();
} }
@Override @Override
public void onOffRoute() { public void onOffRoute() {
// 请求重新规划路径
XLog.d("Car已偏航");
naviTts.setText("您已偏航,重新计算路径信息");
} }
@Override @Override
public void onRecalculateRouteSuccess(int i, ArrayList<RouteData> arrayList) { public void onRecalculateRouteSuccess(int i, ArrayList<RouteData> arrayList) {
XLog.d("Car重新计算路径信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+arrayList.get(0).getRoutePoints().get(0));
currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
zoomToRoute(mContext, arrayList.get(0), tencentMap);
} }
@Override @Override
@@ -172,22 +179,22 @@ public class NaviUtils {
@Override @Override
public void onRecalculateSuccess(CalcRouteResult calcRouteResult) { public void onRecalculateSuccess(CalcRouteResult calcRouteResult) {
XLog.d("Car重新计算路径信息成功");
} }
@Override @Override
public void onRecalculateFailure(CalcRouteResult calcRouteResult) { public void onRecalculateFailure(CalcRouteResult calcRouteResult) {
XLog.d("Car重新计算路径信息失败");
} }
@Override @Override
public void onRecalculateRouteStarted(int i) { public void onRecalculateRouteStarted(int i) {
XLog.d("Car开始重新计算路径信息");
} }
@Override @Override
public void onRecalculateRouteCanceled() { public void onRecalculateRouteCanceled() {
XLog.d("Car取消重新计算路径信息");
} }
@Override @Override
@@ -232,7 +239,9 @@ public class NaviUtils {
}); });
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行 } else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行
RideNaviView rideNaviView = (RideNaviView) naviView; RideNaviView rideNaviView = (RideNaviView) naviView;
naviManager = new TencentRideNaviManager(mContext); if (naviManager==null||!naviManager.isNavigating()) {
naviManager = new TencentRideNaviManager(mContext);
}
rideNaviView.setVisibility(View.VISIBLE); rideNaviView.setVisibility(View.VISIBLE);
((TencentRideNaviManager)naviManager).addTencentNaviListener(rideNaviView); ((TencentRideNaviManager)naviManager).addTencentNaviListener(rideNaviView);
CarNaviInfoPanel carNaviInfoPanel = rideNaviView.showNaviInfoPanel(); CarNaviInfoPanel carNaviInfoPanel = rideNaviView.showNaviInfoPanel();
@@ -247,7 +256,9 @@ public class NaviUtils {
((TencentRideNaviManager) naviManager).addTencentNaviListener(new TencentRideNaviListener() { ((TencentRideNaviManager) naviManager).addTencentNaviListener(new TencentRideNaviListener() {
@Override @Override
public void onRecalculateRouteSuccess(ArrayList<RouteData> arrayList) { public void onRecalculateRouteSuccess(ArrayList<RouteData> arrayList) {
currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
zoomToRoute(mContext, arrayList.get(0), tencentMap);
XLog.d("RIDE重新计算路径信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+arrayList.get(0).getRoutePoints().get(0));
} }
@Override @Override
@@ -262,14 +273,21 @@ public class NaviUtils {
@Override @Override
public void onStopNavi() { public void onStopNavi() {
NaviTts naviTts = new NaviTts();
naviTts.setText("结束导航"); naviTts.setText("结束导航");
mContext.finish(); mContext.finish();
} }
@Override @Override
public void onOffRoute() { public void onOffRoute() {
XLog.d("RIDE已偏航");
naviTts.setText("您已偏航,重新计算路径信息");
// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "您已偏航,重新规划路线!");
// try {
// NaviUtils.getInstance().reSearchRoute(naviManager, new NaviPoi(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
// } catch (Exception e) {
// e.printStackTrace();
// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "出现异常:"+e.getMessage());
// }
} }
@Override @Override
@@ -324,7 +342,9 @@ public class NaviUtils {
}); });
} else { } else {
WalkNaviView walkNaviView = (WalkNaviView) naviView; WalkNaviView walkNaviView = (WalkNaviView) naviView;
naviManager = new TencentRideNaviManager(mContext); if (naviManager==null||!naviManager.isNavigating()) {
naviManager = new TencentWalkNaviManager(mContext);
}
walkNaviView.setVisibility(View.VISIBLE); walkNaviView.setVisibility(View.VISIBLE);
((TencentWalkNaviManager)naviManager).addTencentNaviListener(walkNaviView); ((TencentWalkNaviManager)naviManager).addTencentNaviListener(walkNaviView);
CarNaviInfoPanel carNaviInfoPanel = walkNaviView.showNaviInfoPanel(); CarNaviInfoPanel carNaviInfoPanel = walkNaviView.showNaviInfoPanel();
@@ -339,7 +359,10 @@ public class NaviUtils {
((TencentWalkNaviManager) naviManager).addTencentNaviListener(new TencentWalkNaviListener() { ((TencentWalkNaviManager) naviManager).addTencentNaviListener(new TencentWalkNaviListener() {
@Override @Override
public void onRecalculateRouteSuccess(ArrayList<RouteData> arrayList) { public void onRecalculateRouteSuccess(ArrayList<RouteData> arrayList) {
XLog.d("重新计算路径信息");
currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
zoomToRoute(mContext, arrayList.get(0), tencentMap);
XLog.d("WALK重新计算路径信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+arrayList.get(0).getRoutePoints().get(0));
} }
@Override @Override
@@ -354,14 +377,21 @@ public class NaviUtils {
@Override @Override
public void onStopNavi() { public void onStopNavi() {
NaviTts naviTts = new NaviTts();
naviTts.setText("结束导航"); naviTts.setText("结束导航");
mContext.finish(); mContext.finish();
} }
@Override @Override
public void onOffRoute() { public void onOffRoute() {
XLog.d("Walk已偏航");
naviTts.setText("您已偏航,重新计算路径信息");
// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "您已偏航,重新规划路线!");
// try {
// NaviUtils.getInstance().reSearchRoute(naviManager, new NaviPoi(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
// } catch (Exception e) {
// e.printStackTrace();
// com.github.lazylibrary.util.ToastUtils.showToast(mContext, "出现异常:"+e.getMessage());
// }
} }
@Override @Override
@@ -386,6 +416,7 @@ public class NaviUtils {
@Override @Override
public void onUpdateNavigationData(NavigationData navigationData) { public void onUpdateNavigationData(NavigationData navigationData) {
XLog.d("Walk更新导航信息");
} }
@@ -406,7 +437,7 @@ public class NaviUtils {
@Override @Override
public void onUpdateCurrentRoute(RouteData routeData) { public void onUpdateCurrentRoute(RouteData routeData) {
XLog.d("Walk更新当前route信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+routeData.getRoutePoints().get(0));
} }
@Override @Override
@@ -415,12 +446,8 @@ public class NaviUtils {
} }
}); });
} }
if (tencentMap == null) { this.tencentMap = naviView.getMap();
tencentMap = naviView.getMap(); this.mContext = mContext;
}
if (this.mContext == null) {
this.mContext = mContext;
}
// 开启语音播报 // 开启语音播报
naviManager.setInternalTtsEnabled(true); naviManager.setInternalTtsEnabled(true);
@@ -432,22 +459,46 @@ public class NaviUtils {
/** /**
* 获取路径规划 * 获取路径规划
* */ * */
// private NaviPoi currentStart, currentEnd;
// private Constant.NAV_TYPE currentNaviType;
public void searchRoute(Constant.NAV_TYPE nav_type, TencentNaviManager naviManager, public void searchRoute(Constant.NAV_TYPE nav_type, TencentNaviManager naviManager,
NaviPoi start, NaviPoi end) throws Exception { NaviPoi start, NaviPoi end) throws Exception {
// currentStart = start;
// currentEnd = end;
// currentNaviType = nav_type;
if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车模式 if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车模式
TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager; TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager;
CarRouteSearchOptions options = CarRouteSearchOptions.create(); CarRouteSearchOptions options = CarRouteSearchOptions.create();
carNaviManager.searchRoute(start, end, new ArrayList<>(), options, routeSearchCallback); NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude());
carNaviManager.searchRoute(newStart, end, new ArrayList<>(), options, routeSearchCallback);
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行模式 } else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行模式
TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager; TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager;
RideRouteSearchOptions options = RideRouteSearchOptions.create(); RideRouteSearchOptions options = RideRouteSearchOptions.create();
rideNaviManager.searchRoute(start, end, options, routeSearchCallback); rideNaviManager.searchRoute(start, end, options, routeSearchCallback);
} else { // 步行模式 } else { // 步行模式
TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager; TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager;
walkNaviManager.searchRoute(start, end, routeSearchCallback); NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude());
walkNaviManager.searchRoute(newStart, end, routeSearchCallback);
} }
} }
// public void reSearchRoute(TencentNaviManager naviManager,
// NaviPoi start) throws Exception {
// currentStart = start;
// if (currentNaviType == Constant.NAV_TYPE.CAR) { // 驾车模式
// TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager;
// CarRouteSearchOptions options = CarRouteSearchOptions.create();
// carNaviManager.searchRoute(start, currentEnd, new ArrayList<>(), options, routeSearchCallback);
// } else if (currentNaviType == Constant.NAV_TYPE.RIDE) { // 骑行模式
// TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager;
// RideRouteSearchOptions options = RideRouteSearchOptions.create();
// rideNaviManager.searchRoute(start, currentEnd, options, routeSearchCallback);
// } else { // 步行模式
// TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager;
// walkNaviManager.searchRoute(start, currentEnd, routeSearchCallback);
// }
// }
/** /**
* 仅进行路径规划,无需导航 * 仅进行路径规划,无需导航
* */ * */
@@ -471,6 +522,7 @@ public class NaviUtils {
/** /**
* 算路回调 * 算路回调
*/ */
private Polyline currentRouteLine; // 当前绘制的道路线
private TencentRouteSearchCallback routeSearchCallback = new TencentRouteSearchCallback() { private TencentRouteSearchCallback routeSearchCallback = new TencentRouteSearchCallback() {
@Override @Override
public void onRouteSearchFailure(int i, String s) { public void onRouteSearchFailure(int i, String s) {
@@ -481,19 +533,25 @@ public class NaviUtils {
@Override @Override
public void onRouteSearchSuccess(ArrayList<RouteData> arrayList) { public void onRouteSearchSuccess(ArrayList<RouteData> arrayList) {
// 添加道路Route到地图,默认选取第一条 // 添加道路Route到地图,默认选取第一条
addRoutes(arrayList.get(0), tencentMap); currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
zoomToRoute(mContext, arrayList.get(0), tencentMap); zoomToRoute(mContext, arrayList.get(0), tencentMap);
try { try {
// 自动开始导航 // 自动开始导航
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) { if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
((TencentCarNaviManager)naviManager).startNavi(0); if (!((TencentCarNaviManager)naviManager).isNavigating()) {
// ((TencentCarNaviManager)naviManager).startSimulateNavi(0); ((TencentCarNaviManager)naviManager).startNavi(0);
// ((TencentCarNaviManager)naviManager).startSimulateNavi(0);
}
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) { } else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
((TencentRideNaviManager)naviManager).startNavi(0); if (!((TencentRideNaviManager)naviManager).isNavigating()) {
// ((TencentRideNaviManager)naviManager).startSimulateNavi(0); ((TencentRideNaviManager)naviManager).startNavi(0);
// ((TencentRideNaviManager)naviManager).startSimulateNavi(0);
}
} else { } else {
((TencentWalkNaviManager)naviManager).startNavi(0); if (!((TencentWalkNaviManager)naviManager).isNavigating()) {
// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0); ((TencentWalkNaviManager)naviManager).startNavi(0);
// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0);
}
} }
} catch (Exception e) { } catch (Exception e) {
@@ -544,6 +602,10 @@ public class NaviUtils {
} }
public Polyline addRoutes(RouteData routeData, TencentMap map) { public Polyline addRoutes(RouteData routeData, TencentMap map) {
if (currentRouteLine!=null&&!currentRouteLine.isRemoved()) {
currentRouteLine.remove();
currentRouteLine = null;
}
ArrayList<TrafficItem> traffics = getTrafficItemsFromList(routeData.getTrafficIndexList()); ArrayList<TrafficItem> traffics = getTrafficItemsFromList(routeData.getTrafficIndexList());
List<LatLng> mRoutePoints = routeData.getRoutePoints(); List<LatLng> mRoutePoints = routeData.getRoutePoints();
// 点的个数 // 点的个数
@@ -661,7 +723,7 @@ public class NaviUtils {
* 开始路径规划 * 开始路径规划
* */ * */
public void startNav(Activity mContext, LatLng startLatlng, LatLng endLatlng) { public void startNav(Activity mContext, LatLng startLatlng, LatLng endLatlng) {
if (Constant.currentLocation == null) { if (LocationLifeCycle.getInstance().getMainLocation() == null) {
ToastUtils.Message(mContext, "无法获取当前位置,请检查是否授权应用获取位置权限!"); ToastUtils.Message(mContext, "无法获取当前位置,请检查是否授权应用获取位置权限!");
return; return;
} }
@@ -0,0 +1,318 @@
package com.navinfo.outdoor.util
import android.app.Activity
import android.content.Context
import com.elvishew.xlog.XLog
import com.github.lazylibrary.util.FileUtils
import com.github.lazylibrary.util.PreferencesUtils
import com.google.gson.Gson
import com.lzy.okgo.model.HttpParams
import com.navinfo.ocr.OCRManager.Companion.instance
import com.navinfo.ocr.model.OcrViewResultModel
import com.navinfo.outdoor.api.Constant
import com.navinfo.outdoor.bean.TaskNameBean
import com.navinfo.outdoor.http.Callback
import com.navinfo.outdoor.http.HttpInterface
import com.navinfo.outdoor.http.OkGoBuilder
import com.otaliastudios.cameraview.PictureResult
import java.io.File
/**
* 照片辅助检查工具类
* */
class PictureCheckHelper(val context: Context, val checkFile: File) {
var checkResult = CheckResult()
val gson = Gson()
private val sensorDegree by lazy { PreferencesUtils.getString(context, "sensorDegree", "45").toInt()}
private val poiMinSpeed by lazy { PreferencesUtils.getString(context, "poiMinSpeed", "5").toDouble() }
private val poiMaxSpeed by lazy { PreferencesUtils.getString(context, "poiMaxSpeed", "30").toDouble() }
private val roadMinSpeed by lazy { PreferencesUtils.getString(context, "roadMinSpeed", "20").toDouble() }
private val roadMaxSpeed by lazy { PreferencesUtils.getString(context, "roadMaxSpeed", "120").toDouble() }
private val satelliteCount by lazy { PreferencesUtils.getString(context, "satelliteCount", "15").toInt() }
private val nameSet: MutableSet<String> = mutableSetOf()
init {
// 初始化时读取已有文件,如果存在按照文件内容初始化数据
if (checkFile!=null&&checkFile.exists()) {
val checkResultStr = FileUtils.readFileContent(checkFile.absolutePath)
checkResult = gson.fromJson(checkResultStr, CheckResult::class.java)
}
}
fun addocrCheck(result: Boolean) {
if (result) checkResult.ocrChecked++
checkResult.ocrCount++
}
fun addAngleCheck(result: Boolean) {
if (result) checkResult.angleChecked++
checkResult.angleCount++
}
fun addNearestCheck(result: Boolean) {
if (result) checkResult.nearestChecked++
checkResult.nearestCount++
}
fun addSpeedCheck(result: Boolean) {
if (result) checkResult.speedChecked++
checkResult.speedCount++
}
fun setMockLocationCheck(result: Boolean) { // 只要检查到模拟信号,该数据的模拟信号值就为true
if (result and !checkResult.mockLocationChecker) {
checkResult.mockLocationChecker = true
}
}
fun setAutoTakeCheck(result: Boolean) { // 只要是自动捕捉,设置该值为自动捕捉值就是true
if (result and !checkResult.autoTakeChecker) {
checkResult.autoTakeChecker = true
}
}
fun addSatelliteCheck(result: Boolean) {
if (result) checkResult.satelliteChecked++
checkResult.satelliteCount++
}
fun addGpsRssiCheck(result: Int) {
checkResult.gpsRssiChecked=checkResult.gpsRssiChecked+result
checkResult.gpsRssiCount=checkResult.gpsRssiCount++
}
fun addDistanceCheck(result: Boolean) {
if (result) checkResult.distanceChecked++
checkResult.distanceCount++
}
inner class CheckResult {
// ocr检查结果
var ocrChecked: Int = 0
var ocrCount: Int = 0
// 方向检查结果,判断手机姿态
var angleChecked = 0
var angleCount = 0
// 附近POI查询结果
var nearestChecked = 0
var nearestCount = 0
// 速度检查结果
var speedChecked = 0
var speedCount = 0
// 模拟定位结果
var mockLocationChecker = false
// 是否为自动捕捉检查
var autoTakeChecker = false
// 卫星个数检查
var satelliteChecked = 0
var satelliteCount = 0
// 信号强度检查
var gpsRssiChecked = 0
var gpsRssiCount = 0
// 距离检查
var distanceChecked = 0
var distanceCount = 0
}
fun savePictureCheckResult(activity: Activity, type: Int/*采集类型*/,
map: android.util.Pair<Int, PictureResult>,
yDegree: Float/*y轴上的旋转角*/, currentSpeed: Double, distance: Double, isAutoTakePicture: Boolean) {
val resultMap: MutableMap<String, String> = mutableMapOf()
val pictureResult = map.second
// 如果当前拍照是POI拍照模式,才需要做ocr识别以及附近POI查询
// 如果当前拍照是POI拍照模式,才需要做ocr识别以及附近POI查询
if (type == 3) {
// 开始ocr文字识别
val ocrViewResultModels = instance.ocr(
BitmapUtil.getBitmapFromBytes(
pictureResult!!.data
)
)
if (ocrViewResultModels != null && !ocrViewResultModels.isEmpty()) {
this.addocrCheck(true)
resultMap["ocr"] = "true"
// 该照片存在文字信息,获取占比最大的文字,为后续POI判定做准备
val maxOcrViewResult = ocrViewResultModels.stream()
.max { t0, t1 ->
val t0Value = (Math.abs(t0.bounds[2].x - t0.bounds[0].x)
* Math.abs(t0.bounds[2].y - t0.bounds[0].y))
val t1Value = (Math.abs(t1.bounds[2].x - t1.bounds[0].x)
* Math.abs(t1.bounds[2].y - t1.bounds[0].y))
if (t0Value > t1Value) {
return@max 1
} else if (t0Value < t1Value) {
return@max -1
}
return@max 0
}
.get()
resultMap["name"] = maxOcrViewResult.name
// 周边搜索,判定周边POI是否存在
if (this.checkResult.nearestChecked < 3 && !nameSet.contains(maxOcrViewResult.name)) {
// 发送请求,查询周边POI是否存在
val name = maxOcrViewResult.name
val httpParams = HttpParams()
val encode = Geohash.getInstance().encode(
LocationLifeCycle.getInstance().mainLocation.latitude,
LocationLifeCycle.getInstance().mainLocation.longitude
)
httpParams.put("geo", encode)
httpParams.put("name", name)
val okGoBuilder = OkGoBuilder.getInstance()
.time(30)
.Builder(activity)
.url(HttpInterface.TASK_NAME)
.cls(TaskNameBean::class.java)
.params(httpParams)
.token(Constant.ACCESS_TOKEN)
okGoBuilder.getRequest(object : Callback<TaskNameBean?> {
override fun onSuccess(taskNameBean: TaskNameBean?, id: Int) {
if (taskNameBean!!.code == 200&&taskNameBean.body!=null) { // body中保存了当前名称是否在周边存在对应的POI
this@PictureCheckHelper.addNearestCheck(true)
XLog.d("nearest: ${name}, taskBean: ${gson.toJson(taskNameBean)}")
} else {
this@PictureCheckHelper.addNearestCheck(false)
}
FileUtils.writeFile(
checkFile.getAbsolutePath(),
gson.toJson(this@PictureCheckHelper.checkResult),
false
)
}
override fun onError(e: Throwable, id: Int) {
this@PictureCheckHelper.addNearestCheck(false)
FileUtils.writeFile(
checkFile.getAbsolutePath(),
gson.toJson(this@PictureCheckHelper.checkResult),
false
)
}
})
}
// 将当前名称添加到name缓存中
nameSet.add(maxOcrViewResult.name)
} else {
this@PictureCheckHelper.addocrCheck(false)
resultMap["ocr"] = "false"
resultMap["name"] = "null"
}
}
// 获取当前手机姿态,判定该照片手机姿态是否合格
// 获取当前手机姿态,判定该照片手机姿态是否合格
// val yDegree: Float = sensorOritationLifecycle.yDegree
resultMap["angle"] = yDegree.toString() + ""
if (yDegree > -90 - sensorDegree && yDegree < -90 + sensorDegree) {
this@PictureCheckHelper.addAngleCheck(true)
} else {
this@PictureCheckHelper.addAngleCheck(false)
}
// 检查当前速度
resultMap["speed"] = currentSpeed.toString() + ""
if (type == 3) { // poi录像
if (currentSpeed in poiMinSpeed..poiMaxSpeed) {
this@PictureCheckHelper.addSpeedCheck(true)
} else {
this@PictureCheckHelper.addSpeedCheck(false)
}
} else if (type == 4) { // 道路任务
if (currentSpeed in roadMinSpeed..roadMaxSpeed) {
this@PictureCheckHelper.addSpeedCheck(true)
} else {
this@PictureCheckHelper.addSpeedCheck(false)
}
}
// 记录卫星颗数
resultMap["satellite"] = GPSUtils.getInstance(activity).sateliteCount.toString() + ""
if (GPSUtils.getInstance(activity).sateliteCount >= satelliteCount) {
this@PictureCheckHelper.addSatelliteCheck(true)
} else {
this@PictureCheckHelper.addSatelliteCheck(false)
}
// 记录卫星强度
resultMap["gpsRssi"] = LocationLifeCycle.getInstance().tencentLocation.gpsRssi.toString() + ""
this@PictureCheckHelper.addGpsRssiCheck(LocationLifeCycle.getInstance().tencentLocation.gpsRssi)
// 记录距离检查
resultMap["distance"] = distance.toString()
if (distance<50) {
this@PictureCheckHelper.addDistanceCheck(true)
} else {
this@PictureCheckHelper.addDistanceCheck(false)
}
// 记录json文件到指定文件
FileUtils.writeFile(
checkFile.absolutePath,
gson.toJson(this@PictureCheckHelper.checkResult),
false
)
FileUtils.writeFile(
checkFile.parentFile.absolutePath + "/result.json",
gson.toJson(resultMap) + "\r",
true
)
}
/**
* 获取当前测评结果
* */
fun getCheckResultScore(): Int {
var score = 0
if (checkResult!=null) {
// 是否有模拟定位
if (Constant.mockGPSMap!=null&&Constant.mockGPSMap.isNotEmpty()) {
score -= 100
}
//任务线与定位点匹配
if (checkResult.distanceCount!=0&&checkResult.distanceChecked.toFloat()/checkResult.distanceCount>0.5f) {
score += 20
}
//TODO 使用自动捕捉
//作业速度
if (checkResult.speedCount!=0&&checkResult.speedChecked.toFloat()/checkResult.speedCount>0.7f) {
score += 20
}
// 拍照姿态
if (checkResult.angleCount!=0&&checkResult.angleChecked.toFloat()/checkResult.angleCount>0.7f) {
score += 10
}
// 照片清晰度
if (checkResult.ocrChecked>5) {
score += 30
}
// 信号强度
if (checkResult.gpsRssiCount!=0) {
val rssiCheckResult = checkResult.gpsRssiChecked.toFloat()/checkResult.gpsRssiCount
if (rssiCheckResult >= 0f&&rssiCheckResult<0.2f) {
// 无信号
score -= 100
} else if (rssiCheckResult>=0.2f&&rssiCheckResult<1.2f) {
score -= 20
} else if (rssiCheckResult>=1.2f&&rssiCheckResult<2.2f) {
score -= 0
}else {
score += 20
}
}
if (checkResult.nearestChecked>=3) {
score += 30
}
}
return score
}
}
@@ -0,0 +1,43 @@
package com.navinfo.outdoor.util
import com.tencent.tencentmap.mapsdk.maps.model.LatLng
class PicturesSpeedCheck {
val pointList = mutableListOf<MyLocation>()
val LIST_SIZE = 5
val DISTANCE = 2
/**
* 与前面的4个点做检查,如果当前点位距离前面4个点的距离超过阈值,且当前卫星信号强度为中以上(8颗),则返回false
* */
fun checkIsMove(myLocation: MyLocation, gpsRssi: Int/*定位信号强度*/): Boolean {
pointList.add(myLocation)
if (pointList.size<5) { // 点位小于4个,不做判断,默认为运动中
return true
}
if (pointList.size>5) { // 如果点位信息超过5个,移除第一个数据
pointList.removeAt(0)
}
if (gpsRssi<3) { // 腾讯定位信号强度不是“强”,则忽略速度判定
return true
}
var distance = 0.0
for (index in pointList.indices) {
if (index+1<pointList.size) {
distance += GeometryTools.distanceToDouble(
LatLng(
pointList[index].latitude,
pointList[index].longitude
),
LatLng(pointList[index + 1].latitude, pointList[index + 1].longitude)
)
}
if (distance>DISTANCE) { // 如果距离已经大于设置的距离阈值,无需再计算后面的点位,车辆运动中
return true
}
}
return false
}
}
@@ -45,7 +45,9 @@ public class PoiEntityDeleteUtil {
if (poiEntity.getPhotoInfo() != null) { if (poiEntity.getPhotoInfo() != null) {
for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) { for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) {
File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto()); File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto());
file.delete(); if (file.exists()) {
file.delete();
}
} }
} }
if (poiEntity.getId() != null) { if (poiEntity.getId() != null) {
@@ -59,7 +61,9 @@ public class PoiEntityDeleteUtil {
} }
} }
for (int i = 0; i < chargingPileFileList.size(); i++) { for (int i = 0; i < chargingPileFileList.size(); i++) {
chargingPileFileList.get(i).delete(); if (chargingPileFileList.get(i).exists()) {
chargingPileFileList.get(i).delete();
}
} }
PoiDatabase.getInstance(context).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity); PoiDatabase.getInstance(context).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
} }
@@ -71,10 +75,14 @@ public class PoiEntityDeleteUtil {
private void initPicture(PoiEntity poiEntity) { private void initPicture(PoiEntity poiEntity) {
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId()); List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
for (int i = 0; i < fileListByUUID.size(); i++) { for (int i = 0; i < fileListByUUID.size(); i++) {
fileListByUUID.get(i).delete(); if (fileListByUUID.get(i).exists()) {
fileListByUUID.get(i).delete();
}
} }
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId()); File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
filePath.delete(); if (filePath.exists()) {
filePath.delete();
}
} }
@@ -83,7 +91,9 @@ public class PoiEntityDeleteUtil {
if (poiEntity.getPhotoInfo() != null) { if (poiEntity.getPhotoInfo() != null) {
for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) { for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) {
File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto()); File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto());
file.delete(); if (file.exists()) {
file.delete();
}
} }
} }
} }
@@ -5,10 +5,10 @@ import android.os.Message;
import android.util.Log; import android.util.Log;
import android.widget.Toast; import android.widget.Toast;
import com.elvishew.xlog.Logger;
import com.github.lazylibrary.util.FileUtils;
import com.github.lazylibrary.util.ToastUtils; import com.github.lazylibrary.util.ToastUtils;
import com.github.lazylibrary.util.ZipUtil;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.HttpParams; import com.lzy.okgo.model.HttpParams;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.navinfo.outdoor.api.UserApplication; import com.navinfo.outdoor.api.UserApplication;
@@ -28,17 +28,16 @@ import org.greenrobot.eventbus.EventBus;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.AbstractMap;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import io.reactivex.Observable; import io.reactivex.Observable;
import io.reactivex.ObservableSource; import io.reactivex.ObservableSource;
import io.reactivex.Observer; import io.reactivex.Observer;
import io.reactivex.Single;
import io.reactivex.android.schedulers.AndroidSchedulers; import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable; import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer; import io.reactivex.functions.Consumer;
@@ -56,6 +55,8 @@ public class PoiSaveUtils {
private int anInt = 0; // 上传成功的个数 private int anInt = 0; // 上传成功的个数
private int bInt = 0; // 上传失败的个数 private int bInt = 0; // 上传失败的个数
private int uploadCount = 0; // 上传的总个数 private int uploadCount = 0; // 上传的总个数
private Logger logger = XLogUtils.Companion.getInstance().getUploadLogWriter();
private Disposable mDisposable;// Observeable取消订阅的对象
public static PoiSaveUtils getInstance(Activity mContext) { public static PoiSaveUtils getInstance(Activity mContext) {
if (instance == null) { if (instance == null) {
@@ -74,55 +75,47 @@ public class PoiSaveUtils {
*/ */
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) { public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
if (poiEntityList != null&&!poiEntityList.isEmpty()) { if (poiEntityList != null&&!poiEntityList.isEmpty()) {
logger.d("开始批量上传-------------------------共"+poiEntityList.size()+"个");
// 因为道路任务和POI录像任务需要分包提交,因此和其他要素分开,分别放在两个管道里 // 因为道路任务和POI录像任务需要分包提交,因此和其他要素分开,分别放在两个管道里
List<PoiEntity> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/ List<Map.Entry<Integer, PoiEntity>> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
List<PoiEntity> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/ List<Map.Entry<Integer, PoiEntity>> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
List<PoiEntity> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/ List<Map.Entry<Integer, PoiEntity>> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
for (PoiEntity poiEntity: poiEntityList) { for (int i = 0; i < poiEntityList.size(); i++) {
PoiEntity poiEntity = poiEntityList.get(i);
logger.d("准备数据:"+poiEntity.getId()+"-"+poiEntity.getName());
if (Constant.submitIdSet.contains(poiEntity.getId())) { if (Constant.submitIdSet.contains(poiEntity.getId())) {
continue; continue;
} }
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
if (poiEntity.getType()==2) { if (poiEntity.getType()==2) {
chargePoiEntityList.add(poiEntity); chargePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
} else if (poiEntity.getType() == 3 || poiEntity.getType() == 4) { } else if (poiEntity.getType() == 3 || poiEntity.getType() == 4 || poiEntity.getType() == 11 || poiEntity.getType() == 12 || poiEntity.getType() == 13) {
spliteFilePoiEntityList.add(poiEntity); spliteFilePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
} else { } else {
otherPoiEntityList.add(poiEntity); otherPoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
} }
} }
Observable chargePoiObserable = Observable.fromIterable(chargePoiEntityList) Observable chargePoiObserable = Observable.fromIterable(chargePoiEntityList)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() { .doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
@Override @Override
public void accept(PoiEntity poiEntity) throws Exception { public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据 PoiEntity poiEntity = integerPoiEntityEntry.getValue();
logger.d("开始上传充电站数据:"+poiEntity.getId()+"-"+poiEntity.getName());
if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功 if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
if (Constant.submitIdSet.contains(poiEntity.getId())) {
Constant.submitIdSet.remove(poiEntity.getId());
}
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作 if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
// 开始上传流程 // 开始上传流程
if (saveChargingPileUploadChargingStation(poiEntity)) { if (saveChargingPileUploadChargingStation(poiEntity)) {
uploadPoiNet(poiEntity); uploadPoiNet(integerPoiEntityEntry);
}else { }else {
bInt++; poiEntityUploadFailed(poiEntity, "充电桩数据上传失败!");
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
} }
}else { }else {
bInt++; poiEntityUploadFailed(poiEntity, "网络保存失败");
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
} }
} else { } else {
bInt++; poiEntityUploadFailed(poiEntity, "网络保存失败");
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
Constant.submitIdSet.remove(poiEntity.getId());
} }
} }
}) })
@@ -130,17 +123,16 @@ public class PoiSaveUtils {
// 处理普通数据 // 处理普通数据
Observable otherObserable = Observable.fromIterable(otherPoiEntityList) Observable otherObserable = Observable.fromIterable(otherPoiEntityList)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() { .doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
@Override @Override
public void accept(PoiEntity poiEntity) throws Exception { public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
logger.d("开始上传普通数据:"+poiEntity.getId()+"-"+poiEntity.getName());
if (savePoiNet(poiEntity) == 200) { // 网络保存成功 if (savePoiNet(poiEntity) == 200) { // 网络保存成功
//走上传流程: //走上传流程:
uploadPoiNet(poiEntity); uploadPoiNet(integerPoiEntityEntry);
}else { }else {
bInt++; poiEntityUploadFailed(poiEntity, "网络保存失败");
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
} }
} }
}) })
@@ -148,44 +140,44 @@ public class PoiSaveUtils {
// 处理需要分包上传数据的POI录像和道路数据 // 处理需要分包上传数据的POI录像和道路数据
Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList) Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.doOnNext(new Consumer<PoiEntity>() { .doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
@Override @Override
public void accept(PoiEntity poiEntity) throws Exception { public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
logger.d("开始上传分包数据:"+poiEntity.getId()+"-"+poiEntity.getName());
if (savePoiNet(poiEntity) == 200) { // 网络保存成功 if (savePoiNet(poiEntity) == 200) { // 网络保存成功
//走上传流程: //走上传流程:
if (poiEntity == null) { if (poiEntity == null) {
bInt++; poiEntityUploadFailed(poiEntity, "当前数据为null!");
return; return;
} }
int bodyId = poiEntity.getBodyId(); int bodyId = poiEntity.getBodyId();
if (bodyId == 0) { if (bodyId == 0) {
bInt++; poiEntityUploadFailed(poiEntity, "bodyId为0");
return; return;
} }
}else { }else {
bInt++; poiEntityUploadFailed(poiEntity, "网络保存失败");
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
} }
} }
}) })
.concatMap(new Function<PoiEntity, ObservableSource<?>>() { .concatMap(new Function<Map.Entry<Integer, PoiEntity>, ObservableSource<PoiEntity>>() {
@Override @Override
public ObservableSource<?> apply(PoiEntity poiEntity) throws Exception { public ObservableSource<PoiEntity> apply(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
List<File> photoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId()); List<File> photoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
if (photoFileList == null||photoFileList.isEmpty()) { if (photoFileList == null||photoFileList.size()<2/*如果文件压缩包内小于2个文件,说明拍摄的照片丢失了*/) {
bInt++; poiEntityUploadFailed(poiEntity, "照片数据获取为空!");
return Observable.empty(); return Observable.empty();
} }
return DataSaveUtils.getInstance().getUploadSpliteFilesObservble(mContext, poiEntity, photoFileList) return DataSaveUtils.getInstance().getUploadSpliteFilesObservble(mContext, poiEntity, photoFileList)
.toObservable(); .toObservable();
} }
}) })
.doOnNext(new Consumer<Object>() { .doOnNext(new Consumer<PoiEntity>() {
@Override @Override
public void accept(Object o) throws Exception { public void accept(PoiEntity poiEntity) throws Exception {
anInt++; poiEntityUploadSuccess(poiEntity, "上传成功");
} }
}) })
.doOnError(new Consumer<Throwable>() { .doOnError(new Consumer<Throwable>() {
@@ -208,6 +200,7 @@ public class PoiSaveUtils {
uploadCount = chargePoiEntityList.size()+spliteFilePoiEntityList.size()+otherPoiEntityList.size(); uploadCount = chargePoiEntityList.size()+spliteFilePoiEntityList.size()+otherPoiEntityList.size();
Log.d("PoiSaveUtils", "开始上传"); Log.d("PoiSaveUtils", "开始上传");
ToastUtils.showToast(mContext, "开始批量上传数据,本次共需上传"+uploadCount+"条数据"); ToastUtils.showToast(mContext, "开始批量上传数据,本次共需上传"+uploadCount+"条数据");
mDisposable = d;
} }
@Override @Override
@@ -234,80 +227,33 @@ public class PoiSaveUtils {
Constant.isPresent = true; Constant.isPresent = true;
} }
}); });
// new Thread(new Runnable() {
// @Override
// public void run() {
// anInt = 0;
// bInt = 0;
// Log.d("PoiSaveUtils", "开始上传");
// for (int i = 0; i < poiEntityList.size(); i++) {
// PoiEntity poiEntity = poiEntityList.get(i);
// Log.d("PoiSaveUtils", "poiEntity.getType():"+poiEntity.getType());
// if (Constant.submitIdSet.contains(poiEntity.getId())) {
// continue;
// }
// if (poiEntity.getType() == 2) { // 如果是充电站数据,首先检查子充电桩的状态
// Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
// if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
// Constant.submitIdSet.remove(poiEntity.getId());
// if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
// // 开始上传流程
// if (saveChargingPileUploadChargingStation(poiEntity)) {
// uploadPoiNet(poiEntity);
// }else {
// bInt++;
// poiEntity.setChecked(false);
// poiEntity.setWork_type(0);
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
// }
// }else {
// bInt++;
// poiEntity.setChecked(false);
// poiEntity.setWork_type(0);
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
// }
// } else {
// bInt++;
// poiEntity.setChecked(false);
// poiEntity.setWork_type(0);
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// Constant.submitIdSet.remove(poiEntity.getId());
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
// }
// } else {//其他类型
// if (savePoiNet(poiEntity) == 200) { // 网络保存成功
// //走上传流程:
// uploadPoiNet(poiEntity);
// }else {
// bInt++;
// poiEntity.setChecked(false);
// poiEntity.setWork_type(0);
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
// }
// }
// }
// }
// }).start();
} }
} }
private void sendUploadMessage(int count, int success, int fail) { /**
if (success+fail == count) { // 成功和失败的个数与数据总数相同 * 处理poi数据上传失败
Message obtain = Message.obtain(); * */
obtain.what = Constant.STAY_SUBMIT_ITEM; private void poiEntityUploadFailed(PoiEntity poiEntity, String errorInfo) {
obtain.obj = true; poiEntity.setUploadResult(errorInfo);
EventBus.getDefault().post(obtain); bInt++;
} poiEntity.setWork_type(-1);
Message obtain1 = Message.obtain(); poiEntity.setUploadProgress(0);
obtain1.what = Constant.NEST_WORD_SUBMIT; PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
obtain1.obj = "批量提交数据,共选中"+count+"条数据,成功:" + anInt + "条, 失败:" + bInt+"条"; Constant.submitIdSet.remove(poiEntity.getId());
EventBus.getDefault().post(obtain1); sendRefreshItem(poiEntity);
logger.d("数据上传失败:"+poiEntity.getId()+"-"+poiEntity.getName()+"-"+errorInfo);
}
/**
* 处理poi数据上传成功
* */
private void poiEntityUploadSuccess(PoiEntity poiEntity, String info) {
poiEntity.setUploadResult(info);
anInt++;
poiEntity.setWork_type(2);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
Constant.submitIdSet.remove(poiEntity.getId());
sendRefreshItem(poiEntity);
logger.d("数据上传成功:"+poiEntity.getId()+"-"+poiEntity.getName());
} }
/* /*
@@ -342,14 +288,16 @@ public class PoiSaveUtils {
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 1); // httpParams.put("workType", 1);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
httpParams.put("score", poiEntity.getScore());
httpParams.put("drawLine", poiEntity.getDrawLine());
url = HttpInterface.INSIDE_API_LIST; url = HttpInterface.INSIDE_API_LIST;
} else if (poiEntity.getType() == 4) { } else if (poiEntity.getType() == 4) {
httpParams.put("taskId", poiEntity.getTaskId()); httpParams.put("taskId", poiEntity.getTaskId());
httpParams.put("name", poiEntity.getName()); httpParams.put("name", poiEntity.getName());
httpParams.put("address", poiEntity.getAddress()); httpParams.put("address", poiEntity.getAddress());
httpParams.put("workType", 0); // httpParams.put("workType", 0);
httpParams.put("memo", poiEntity.getMemo()); httpParams.put("memo", poiEntity.getMemo());
url = HttpInterface.ROAD_TASK_SUBMIT; url = HttpInterface.ROAD_TASK_SUBMIT;
} else if (poiEntity.getType() == 5) { } else if (poiEntity.getType() == 5) {
@@ -404,14 +352,15 @@ public class PoiSaveUtils {
/** /**
* 最终上传POI数据到服务 * 最终上传POI数据到服务
*/ */
public void uploadPoiNet(PoiEntity poiEntity) { public void uploadPoiNet(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) {
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
if (poiEntity == null) { if (poiEntity == null) {
bInt++; poiEntityUploadFailed(poiEntity, "poiEntity为null");
return; return;
} }
int bodyId = poiEntity.getBodyId(); int bodyId = poiEntity.getBodyId();
if (bodyId == 0) { if (bodyId == 0) {
bInt++; poiEntityUploadFailed(poiEntity, "bodyId为0");
return; return;
} }
ArrayList<File> photoFile = new ArrayList<>(); ArrayList<File> photoFile = new ArrayList<>();
@@ -424,14 +373,16 @@ public class PoiSaveUtils {
} }
} }
} }
poiEntity.setUploadMax(photoFile.size());
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" //1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
if (poiEntity.getType() == 1) { if (poiEntity.getType() == 1) {
initList(HttpInterface.POI_TASK_UPLOAD_PIC, photoFile, poiEntity); initList(HttpInterface.POI_TASK_UPLOAD_PIC, photoFile, poiEntity);
} else if (poiEntity.getType() == 2) { } else if (poiEntity.getType() == 2) {
initList(HttpInterface.C_TASK_UP_LOAD_PIC, photoFile, poiEntity); initList(HttpInterface.C_TASK_UP_LOAD_PIC, photoFile, poiEntity);
} else if (poiEntity.getType() == 3) { }
else if (poiEntity.getType() == 3) {
List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId()); List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
if (videoFileList != null && !videoFileList.isEmpty()) { if (videoFileList != null && videoFileList.size()<2) {
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList); boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
if (!existsPic) { if (!existsPic) {
bInt++; bInt++;
@@ -475,7 +426,7 @@ public class PoiSaveUtils {
// } // }
} else if (poiEntity.getType() == 4) { } else if (poiEntity.getType() == 4) {
List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId()); List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
if (videoFileList != null && !videoFileList.isEmpty()) { if (videoFileList != null && videoFileList.size()<2) {
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList); boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
if (!existsPic) { if (!existsPic) {
bInt++; bInt++;
@@ -505,31 +456,21 @@ public class PoiSaveUtils {
// File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip"); // File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
// ZipUtil.zipFiles(videoFileList, fileZip, null); // ZipUtil.zipFiles(videoFileList, fileZip, null);
// photoFile.add(fileZip); // photoFile.add(fileZip);
} else { }
else {
Log.d("TAGSS", "videoFileList: 失败" + bInt); Log.d("TAGSS", "videoFileList: 失败" + bInt);
bInt++; bInt++;
return; return;
} }
// if (photoFile.size() > 0) { }
// long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath()); else if (poiEntity.getType() == 5) {
// if (zipTrueSize > 0) {
// initList(HttpInterface.ROAD_TASK_UPLOAD_PIC, photoFile, poiEntity);
// } else {
// Log.d("TAGSS", "photoFile: 失败" + bInt);
// for (int i = 0; i < photoFile.size(); i++) {
// photoFile.get(i).delete();
// }
// bInt++;
// return;
// }
// }
} else if (poiEntity.getType() == 5) {
initList(HttpInterface.OTHER_TASK_UPLOAD_PIC, photoFile, poiEntity); initList(HttpInterface.OTHER_TASK_UPLOAD_PIC, photoFile, poiEntity);
} }
} }
private void initList(String url, List<File> list, PoiEntity poiEntity) { private void initList(String url, List<File> list, PoiEntity poiEntity) {
try { try {
poiEntity.setUploadResult("");
HttpParams httpParams = new HttpParams(); HttpParams httpParams = new HttpParams();
httpParams.put("auditId", poiEntity.getBodyId()); httpParams.put("auditId", poiEntity.getBodyId());
Response execute = OkGoBuilder.getInstance() Response execute = OkGoBuilder.getInstance()
@@ -542,56 +483,46 @@ public class PoiSaveUtils {
.postFileSynchronization(); .postFileSynchronization();
if (execute == null) { if (execute == null) {
Log.d("TAGSS", "execute: 失败" + bInt); Log.d("TAGSS", "execute: 失败" + bInt);
poiEntity.setChecked(false); poiEntityUploadFailed(poiEntity, "服务返回结果为null");
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
bInt++;
return; return;
} }
if (execute.code() != 200) { if (execute.code() != 200) {
Log.d("TAGSS", "code: 失败" + bInt); Log.d("TAGSS", "code: 失败" + bInt);
poiEntity.setChecked(false); poiEntityUploadFailed(poiEntity, "服务返回code码不为200"+execute.code());
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
bInt++;
return; return;
} }
String bodyStr = execute.body().string(); String bodyStr = execute.body().string();
if (bodyStr == null) { if (bodyStr == null) {
Log.d("TAGSS", "bodyStr: 失败" + bInt); Log.d("TAGSS", "bodyStr: 失败" + bInt);
poiEntity.setChecked(false); poiEntityUploadFailed(poiEntity, "服务返回body为null");
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
bInt++;
return; return;
} }
OtherUploadPicBean otherUploadPicBean = new Gson().fromJson(bodyStr, OtherUploadPicBean.class); OtherUploadPicBean otherUploadPicBean = new Gson().fromJson(bodyStr, OtherUploadPicBean.class);
if (otherUploadPicBean!=null){ if (otherUploadPicBean!=null){
if (otherUploadPicBean.getCode() == 200) { if (otherUploadPicBean.getCode() == 200) {
poiEntity.setChecked(false);
poiEntity.setTaskStatus(100); poiEntity.setTaskStatus(100);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity); PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
for (int i = 0; i < list.size(); i++) { // 同时删除关联的照片文件和压缩包文件
list.get(i).delete(); if (!list.isEmpty()&&list.get(0).getParentFile().exists()&&!list.get(0).getParentFile().getName().endsWith("picture")) {
// 删除对应的文件夹
FileUtils.deleteFile(list.get(0).getParentFile().getAbsolutePath());
} }
// for (int i = 0; i < list.size(); i++) {
// list.get(i).delete();
// }
PoiEntityDeleteUtil.getInstance().deleteUtil(mContext, poiEntity); PoiEntityDeleteUtil.getInstance().deleteUtil(mContext, poiEntity);
Log.d("TAGSS", "uploadPoiNet: 成功" + anInt); Log.d("TAGSS", "uploadPoiNet: 成功" + anInt);
anInt++; poiEntity.setUploadProgress(poiEntity.getUploadMax());
poiEntityUploadSuccess(poiEntity, "");
return; return;
} else { } else {
poiEntity.setChecked(false); poiEntityUploadFailed(poiEntity, "错误:"+otherUploadPicBean.getMessage());
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
Log.d("TAGSS", "uploadPoiNet: 失败" + bInt); Log.d("TAGSS", "uploadPoiNet: 失败" + bInt);
bInt++;
return; return;
} }
}else { }else {
poiEntity.setChecked(false);
poiEntity.setWork_type(0);
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
Log.d("TAGSS", "uploadPoiNet: 失败" + bInt); Log.d("TAGSS", "uploadPoiNet: 失败" + bInt);
bInt++; poiEntityUploadFailed(poiEntity, "Json转换失败");
return; return;
} }
@@ -600,6 +531,16 @@ public class PoiSaveUtils {
} }
} }
/**
* EventBus通知列表当前的上传进度
* */
private void sendRefreshItem(PoiEntity poiEntity) {
Message msg = Message.obtain();
msg.what = Constant.EVENT_WHAT_UPLOAD_PROGRESS;
msg.obj = poiEntity;
EventBus.getDefault().post(msg);
}
/** /**
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存 * 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
*/ */
@@ -762,11 +703,21 @@ public class PoiSaveUtils {
public boolean checkPicExists(List<File> fileList) { public boolean checkPicExists(List<File> fileList) {
boolean isExistsPic = false; // 是否记录的照片全部不存在 boolean isExistsPic = false; // 是否记录的照片全部不存在
for (File picFile: fileList) { for (File picFile: fileList) {
if (picFile!=null&&picFile.exists()) { if (picFile!=null&&picFile.exists()&&!picFile.getName().endsWith(".txt")/*至少包含1张照片*/) {
isExistsPic = true; isExistsPic = true;
break; break;
} }
} }
return isExistsPic; return isExistsPic;
} }
public void cancelUploadPoiEntityBatch() {
if (mDisposable!=null&&!mDisposable.isDisposed()) {
mDisposable.dispose();
Toast.makeText(mContext, "已取消批量上传流程", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(mContext, "没有需要取消的批量上传数据", Toast.LENGTH_SHORT).show();
}
Constant.submitIdSet.clear(); // 清空记录的正在上传的id表
}
} }
@@ -0,0 +1,94 @@
package com.navinfo.outdoor.util
import android.content.Context
import android.hardware.Sensor
import android.hardware.SensorEvent
import android.hardware.SensorEventListener
import android.hardware.SensorManager
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.LifecycleOwner
class SensorOritationLifecycle(val context: Context): DefaultLifecycleObserver {
private var sensorManager: SensorManager? = null
private var accelerometer: Sensor? = null
private var magnetic :android.hardware.Sensor? = null
private var seneorListener: SensorEventListener? = null
private var accelerometerValues = FloatArray(3)
private var magneticFieldValues = FloatArray(3)
var zDegree: Float = 0f
var xDegree: Float = 0f
var yDegree: Float = 0f
var degreesChangeListener: DegreesChangeListener? = null
override fun onCreate(owner: LifecycleOwner) {
super.onCreate(owner)
/**
* 初始化传感器
* */
/**
* 初始化传感器
*/
seneorListener = object : SensorEventListener {
override fun onSensorChanged(sensorEvent: SensorEvent) {
// 获取角度信息
if (sensorEvent.sensor.type == Sensor.TYPE_ACCELEROMETER) {
accelerometerValues = sensorEvent.values
}
if (sensorEvent.sensor.type == Sensor.TYPE_MAGNETIC_FIELD) {
magneticFieldValues = sensorEvent.values
}
calculateOrientation()
}
override fun onAccuracyChanged(sensor: Sensor, i: Int) {}
}
sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager
if (sensorManager!=null) {
with(sensorManager!!) {
accelerometer = getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
magnetic = getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD)
registerListener(
seneorListener,
accelerometer,
SensorManager.SENSOR_DELAY_NORMAL
)
registerListener(
seneorListener,
magnetic,
SensorManager.SENSOR_DELAY_NORMAL
)
}
}
}
override fun onDestroy(owner: LifecycleOwner) {
super.onDestroy(owner)
if (sensorManager != null) {
sensorManager!!.unregisterListener(seneorListener)
}
}
// 计算方向
private fun calculateOrientation() {
val values = FloatArray(3)
val R = FloatArray(9)
SensorManager.getRotationMatrix(
R, null, accelerometerValues,
magneticFieldValues
)
SensorManager.getOrientation(R, values)
zDegree = Math.toDegrees(values[0].toDouble()).toFloat()
xDegree = Math.toDegrees(values[1].toDouble()).toFloat()
yDegree = Math.toDegrees(values[2].toDouble()).toFloat()
degreesChangeListener?.onDegreesChangeListener(xDegree, yDegree, zDegree)
}
fun getDegrees(): FloatArray {
return floatArrayOf(xDegree, yDegree, zDegree)
}
interface DegreesChangeListener {
fun onDegreesChangeListener(xDegree: Float, yDegree: Float, zDegree: Float)
}
}
@@ -97,5 +97,11 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
} }
public boolean isSpeaking() {
if (textToSpeech!=null) {
return textToSpeech.isSpeaking();
}
return false;
}
} }
@@ -6,7 +6,10 @@ import android.os.Looper;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
import com.elvishew.xlog.XLog;
import com.github.lazylibrary.util.ToastUtils;
import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.api.Constant;
import com.tencent.map.fusionlocation.observer.TencentGeoLocationObserver;
import com.tencent.map.geolocation.TencentLocation; import com.tencent.map.geolocation.TencentLocation;
import com.tencent.map.geolocation.TencentLocationListener; import com.tencent.map.geolocation.TencentLocationListener;
import com.tencent.map.geolocation.TencentLocationManager; import com.tencent.map.geolocation.TencentLocationManager;
@@ -21,7 +24,6 @@ import java.util.List;
public class TalentLocationUtils implements TencentLocationListener { public class TalentLocationUtils implements TencentLocationListener {
private TencentLocationManager locationManager; private TencentLocationManager locationManager;
private TencentLocationRequest locationRequest; private TencentLocationRequest locationRequest;
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
private boolean isLocationStart; // 标识是否已经启动定位 private boolean isLocationStart; // 标识是否已经启动定位
private static TalentLocationUtils instance; private static TalentLocationUtils instance;
public static TalentLocationUtils getInstance(Context mContext) { public static TalentLocationUtils getInstance(Context mContext) {
@@ -36,7 +38,6 @@ public class TalentLocationUtils implements TencentLocationListener {
} }
private void init(Context mContext) { private void init(Context mContext) {
locationChangedListenerList = new ArrayList<>();
//用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
locationManager = TencentLocationManager.getInstance(mContext, null); locationManager = TencentLocationManager.getInstance(mContext, null);
//设置坐标系 //设置坐标系
@@ -55,16 +56,17 @@ public class TalentLocationUtils implements TencentLocationListener {
} }
if (!isLocationStart) { if (!isLocationStart) {
int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper(), 0); int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper(), 0);
XLog.d( "开始腾讯定位");
isLocationStart = true; isLocationStart = true;
switch (err) { switch (err) {
case 1: case 1:
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE1); ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE1);
break; break;
case 2: case 2:
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE2); ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE2);
break; break;
case 3: case 3:
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE3); ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE3);
break; break;
default: default:
break; break;
@@ -74,14 +76,17 @@ public class TalentLocationUtils implements TencentLocationListener {
public void stopLocation() { // 停止定位服务 public void stopLocation() { // 停止定位服务
if (isLocationStart) { if (isLocationStart) {
isLocationStart = false;
locationManager.removeUpdates(this); locationManager.removeUpdates(this);
locationManager = null; locationManager = null;
locationRequest = null; locationRequest = null;
locationChangedListenerList.clear();
locationChangedListenerList = null;
} }
} }
public boolean isLocationStart() {
return isLocationStart;
}
/** /**
* 实现位置监听 * 实现位置监听
* @param tencentLocation location * @param tencentLocation location
@@ -89,46 +94,31 @@ public class TalentLocationUtils implements TencentLocationListener {
@Override @Override
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
if (i == TencentLocation.ERROR_OK) {//定位成功 if (i == TencentLocation.ERROR_OK) {//定位成功
Location location = new Location(tencentLocation.getProvider());
// //设置经纬度以及精度
location.setLatitude(tencentLocation.getLatitude());
location.setLongitude(tencentLocation.getLongitude());
location.setAccuracy(tencentLocation.getAccuracy());
if (tencentLocation.getBearing()!=0) {
location.setBearing(tencentLocation.getBearing());
} else {
location.setBearing((float) tencentLocation.getDirection());
}
if (locationChangedListenerList!=null) {
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
locationChangedListener.onLocationChanged(location);
}
}
Constant.currentLocation = tencentLocation;
Message currentLocationMsg = Message.obtain(); Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_WHAT_LOCATION_CHANGE; currentLocationMsg.what = Constant.EVENT_WHAT_LOCATION_CHANGE;
currentLocationMsg.obj = Constant.currentLocation; currentLocationMsg.arg1 = LocationLifeCycle.LOCATION_FROM.TENCENT.ordinal(); // 设置定位来源
EventBus.getDefault().post(currentLocationMsg); currentLocationMsg.obj = tencentLocation;
EventBus.getDefault().postSticky(currentLocationMsg);
}else if (i==TencentLocation.ERROR_NETWORK){//网络问题引起的定位失败 }else if (i==TencentLocation.ERROR_NETWORK){//网络问题引起的定位失败
Message currentLocationMsg = Message.obtain(); Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_MESSAGE; currentLocationMsg.what = Constant.EVENT_MESSAGE;
currentLocationMsg.obj = "网络问题引起的定位失败"; currentLocationMsg.obj = "网络问题引起的定位失败";
EventBus.getDefault().post(currentLocationMsg); EventBus.getDefault().postSticky(currentLocationMsg);
}else if (i==TencentLocation.ERROR_BAD_JSON){//GPS, Wi-Fi 或基站错误引起的定位失败: 1、用户的手机确实采集不到定位凭据,比如偏远地区比如地下车库电梯内等; 2、开关跟权限问题,比如用户关闭了位置信息,关闭了Wi-Fi,未授予app定位权限等。 }else if (i==TencentLocation.ERROR_BAD_JSON){//GPS, Wi-Fi 或基站错误引起的定位失败: 1、用户的手机确实采集不到定位凭据,比如偏远地区比如地下车库电梯内等; 2、开关跟权限问题,比如用户关闭了位置信息,关闭了Wi-Fi,未授予app定位权限等。
Message currentLocationMsg = Message.obtain(); Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_MESSAGE; currentLocationMsg.what = Constant.EVENT_MESSAGE;
currentLocationMsg.obj = "GPS, Wi-Fi 或基站错误引起的定位失败"; currentLocationMsg.obj = "GPS, Wi-Fi 或基站错误引起的定位失败";
EventBus.getDefault().post(currentLocationMsg); EventBus.getDefault().postSticky(currentLocationMsg);
}else if (i==TencentLocation.ERROR_WGS84){ }else if (i==TencentLocation.ERROR_WGS84){
Message currentLocationMsg = Message.obtain(); Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_MESSAGE; currentLocationMsg.what = Constant.EVENT_MESSAGE;
currentLocationMsg.obj ="无法将WGS84坐标转换成GCJ-02坐标时的定位失败"; currentLocationMsg.obj ="无法将WGS84坐标转换成GCJ-02坐标时的定位失败";
EventBus.getDefault().post(currentLocationMsg); EventBus.getDefault().postSticky(currentLocationMsg);
}else if (i==TencentLocation.ERROR_UNKNOWN){ }else if (i==TencentLocation.ERROR_UNKNOWN){
Message currentLocationMsg = Message.obtain(); Message currentLocationMsg = Message.obtain();
currentLocationMsg.what = Constant.EVENT_MESSAGE; currentLocationMsg.what = Constant.EVENT_MESSAGE;
currentLocationMsg.obj ="未知原因引起的定位失败"; currentLocationMsg.obj ="未知原因引起的定位失败";
EventBus.getDefault().post(currentLocationMsg); EventBus.getDefault().postSticky(currentLocationMsg);
} }
} }
@@ -147,8 +137,4 @@ public class TalentLocationUtils implements TencentLocationListener {
public void onNmeaMsgChanged(String s) { public void onNmeaMsgChanged(String s) {
} }
public List<LocationSource.OnLocationChangedListener> getLocationChangedListenerList() {
return locationChangedListenerList;
}
} }
@@ -0,0 +1,212 @@
package com.navinfo.outdoor.util;
import android.location.Location;
import android.os.Bundle;
import com.tencent.map.geolocation.TencentLocation;
import com.tencent.map.geolocation.TencentMotion;
import com.tencent.map.geolocation.TencentPoi;
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
import java.util.List;
public class TencentLocationObtain {
public static TencentLocation obtainTecentLocation(Location location) {
return new TencentLocation() {
@Override
public String getProvider() {
return location.getProvider();
}
@Override
public String getFusionProvider() {
return null;
}
@Override
public String getSourceProvider() {
return null;
}
@Override
public double getLatitude() {
return location.getLatitude();
}
@Override
public double getLongitude() {
return location.getLongitude();
}
@Override
public double getAltitude() {
return location.getAltitude();
}
@Override
public float getAccuracy() {
return location.getAccuracy();
}
@Override
public String getName() {
return "null";
}
@Override
public String getAddress() {
return "null";
}
@Override
public String getNation() {
return "null";
}
@Override
public String getProvince() {
return "null";
}
@Override
public String getCity() {
return "null";
}
@Override
public String getDistrict() {
return "null";
}
@Override
public String getTown() {
return null;
}
@Override
public String getVillage() {
return null;
}
@Override
public String getStreet() {
return null;
}
@Override
public String getStreetNo() {
return null;
}
@Override
public Integer getAreaStat() {
return null;
}
@Override
public List<TencentPoi> getPoiList() {
return null;
}
@Override
public float getBearing() {
return location.getBearing();
}
@Override
public float getSpeed() {
return location.getSpeed();
}
@Override
public long getTime() {
return location.getTime();
}
@Override
public long getElapsedRealtime() {
return location.getElapsedRealtimeNanos();
}
@Override
public int getGPSRssi() {
return 0;
}
@Override
public int getInOutStatus() {
return 0;
}
@Override
public String getIndoorBuildingId() {
return null;
}
@Override
public String getIndoorBuildingFloor() {
return null;
}
@Override
public int getIndoorLocationType() {
return 0;
}
@Override
public double getDirection() {
return 0;
}
@Override
public String getCityCode() {
return null;
}
@Override
public String getCityPhoneCode() {
return null;
}
@Override
public TencentMotion getMotion() {
return null;
}
@Override
public int getGpsQuality() {
return 0;
}
@Override
public float getDeltaAngle() {
return 0;
}
@Override
public float getDeltaSpeed() {
return 0;
}
@Override
public int getCoordinateType() {
return 0;
}
@Override
public int getFakeReason() {
return 0;
}
@Override
public int isMockGps() {
return 0;
}
@Override
public Bundle getExtra() {
return null;
}
};
}
}
@@ -3,6 +3,7 @@ package com.navinfo.outdoor.util;
import android.app.Activity; import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.graphics.Color; import android.graphics.Color;
import android.location.Location;
import android.os.Message; import android.os.Message;
import android.util.Log; import android.util.Log;
@@ -1,246 +0,0 @@
package com.navinfo.outdoor.util;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;
/**
* 项目名称:ToastUtil
* 创建人:mwb
* 创建时间:2018/9/3 9:25
*/
public class ToastUtil {
private static boolean isShow = true;//默认显示
private static Toast mToast = null;//全局唯一的Toast
/*private控制不应该被实例化*/
private ToastUtil() {
throw new UnsupportedOperationException("不能被实例化");
}
/**
* 全局控制是否显示Toast
*/
public static void controlShow(boolean isShowToast) {
isShow = isShowToast;
}
/**
* 取消Toast显示
*/
public void cancelToast() {
if (isShow && mToast != null) {
mToast.cancel();
}
}
/**
* 短时间显示Toast
*/
@SuppressLint("ShowToast")
public static void showShort(Context context, CharSequence message) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
} else {
mToast.setText(message);
}
mToast.show();
}
}
/**
* 短时间显示Toast
* @param resId 资源ID:getResources().getString(R.string);
*/
@SuppressLint("ShowToast")
public static void showShort(Context context, int resId) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
} else {
mToast.setText(resId);
}
mToast.show();
}
}
/**
* 长时间显示Toast
*/
@SuppressLint("ShowToast")
public static void showLong(Context context, CharSequence message) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, Toast.LENGTH_LONG);
} else {
mToast.setText(message);
}
mToast.show();
}
}
/**
* 长时间显示Toast
* @param resId 资源ID:getResources().getString(R.string);
*/
@SuppressLint("ShowToast")
public static void showLong(Context context, int resId) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
} else {
mToast.setText(resId);
}
mToast.show();
}
}
/**
* 自定义显示Toast时间
* @param duration 单位:毫秒
*/
@SuppressLint("ShowToast")
public static void show(Context context, CharSequence message, int duration) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
}
mToast.show();
}
}
/**
* 自定义显示Toast时间
* @param resId 资源ID:getResources().getString(R.string);
* @param duration 单位:毫秒
*/
@SuppressLint("ShowToast")
public static void show(Context context, int resId, int duration) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, resId, duration);
} else {
mToast.setText(resId);
}
mToast.show();
}
}
/**
* 自定义Toast的View
* @param duration 单位:毫秒
* @param view 显示自己的View
*/
@SuppressLint("ShowToast")
public static void customToastView(Context context, CharSequence message, int duration, View view) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
}
if (view != null) {
mToast.setView(view);
}
mToast.show();
}
}
/**
* 自定义Toast的位置
* @param duration 单位:毫秒
*/
@SuppressLint("ShowToast")
public static void customToastGravity(Context context, CharSequence message, int duration, int gravity, int xOffset, int yOffset) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
}
mToast.setGravity(gravity, xOffset, yOffset);
mToast.show();
}
}
/**
* 自定义带图片和文字的Toast,最终的效果就是上面是图片,下面是文字
* @param iconResId 图片的资源id,如:R.drawable.icon
*/
@SuppressLint("ShowToast")
public static void showToastWithImageAndText(Context context, CharSequence message, int iconResId, int duration, int gravity, int xOffset, int yOffset) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
}
mToast.setGravity(gravity, xOffset, yOffset);
LinearLayout toastView = (LinearLayout) mToast.getView();
ImageView imageView = new ImageView(context);
imageView.setImageResource(iconResId);
toastView.addView(imageView, 0);
mToast.show();
}
}
/**
* 自定义Toast,针对类型CharSequence
* @param isGravity true,表示后面的三个布局参数生效,false,表示不生效
* @param isMargin true,表示后面的两个参数生效,false,表示不生效
*/
@SuppressLint("ShowToast")
public static void customToastAll(Context context, CharSequence message, int duration, View view, boolean isGravity, int gravity, int xOffset, int yOffset, boolean isMargin, float horizontalMargin, float verticalMargin) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, message, duration);
} else {
mToast.setText(message);
}
if (view != null) {
mToast.setView(view);
}
if (isMargin) {
mToast.setMargin(horizontalMargin, verticalMargin);
}
if (isGravity) {
mToast.setGravity(gravity, xOffset, yOffset);
}
mToast.show();
}
}
/**
* 自定义Toast,针对类型resId
* @param view :应该是一个布局,布局中包含了自己设置好的内容
* @param isGravity true,表示后面的三个布局参数生效,false,表示不生效
* @param isMargin true,表示后面的两个参数生效,false,表示不生效
*/
@SuppressLint("ShowToast")
public static void customToastAll(Context context, int resId, int duration, View view, boolean isGravity, int gravity, int xOffset, int yOffset, boolean isMargin, float horizontalMargin, float verticalMargin) {
if (isShow) {
if (mToast == null) {
mToast = Toast.makeText(context, resId, duration);
} else {
mToast.setText(resId);
}
if (view != null) {
mToast.setView(view);
}
if (isMargin) {
mToast.setMargin(horizontalMargin, verticalMargin);
}
if (isGravity) {
mToast.setGravity(gravity, xOffset, yOffset);
}
mToast.show();
}
}
}
@@ -0,0 +1,73 @@
package com.navinfo.outdoor.util
import com.elvishew.xlog.Logger
import com.elvishew.xlog.XLog
import com.elvishew.xlog.flattener.ClassicFlattener
import com.elvishew.xlog.printer.Printer
import com.elvishew.xlog.printer.file.FilePrinter
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
import com.navinfo.outdoor.api.Constant
import java.text.SimpleDateFormat
import java.util.*
class XLogUtils {
val uploadLogWriter by lazy {
obtainUploadLogWriter()
}
val autoTakePictureLogWriter by lazy {
obtainAutoTakePictureLogWriter()
}
companion object {
val instance by lazy { XLogUtils() }
}
fun obtainUploadLogWriter(): Logger {
val filePrinter: Printer = FilePrinter.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
.fileNameGenerator(object : DateFileNameGenerator() {
var mLocalDateFormat: ThreadLocal<SimpleDateFormat?> =
object : ThreadLocal<SimpleDateFormat?>() {
override fun initialValue(): SimpleDateFormat {
return SimpleDateFormat("yyyy-MM-dd", Locale.US)
}
}
override fun isFileNameChangeable(): Boolean {
return true
}
override fun generateFileName(logLevel: Int, timestamp: Long): String {
val sdf = mLocalDateFormat.get()
sdf!!.timeZone = TimeZone.getDefault()
return "批量上传-" + Constant.USHERED+ "-"+ sdf.format(Date(timestamp))
}
}) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.flattener(ClassicFlattener())
.build()
return XLog.printers(filePrinter).build()
}
fun obtainAutoTakePictureLogWriter(): Logger {
val filePrinter: Printer = FilePrinter.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
.fileNameGenerator(object : DateFileNameGenerator() {
var mLocalDateFormat: ThreadLocal<SimpleDateFormat?> =
object : ThreadLocal<SimpleDateFormat?>() {
override fun initialValue(): SimpleDateFormat {
return SimpleDateFormat("yyyy-MM-dd", Locale.US)
}
}
override fun isFileNameChangeable(): Boolean {
return true
}
override fun generateFileName(logLevel: Int, timestamp: Long): String {
val sdf = mLocalDateFormat.get()
sdf!!.timeZone = TimeZone.getDefault()
return "AutoTakePicture-"+ Constant.USHERED+ "-" + sdf.format(Date(timestamp))
}
}) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
.flattener(ClassicFlattener())
.build()
return XLog.printers(filePrinter).build()
}
}
@@ -0,0 +1,42 @@
package com.navinfo.outdoor.viewmodel
import android.content.Intent
import androidx.lifecycle.ViewModel
import com.navinfo.outdoor.api.Constant
import com.tencent.tencentmap.mapsdk.maps.interfaces.Removable
import java.io.File
import java.util.*
class RxPicturesViewModel: ViewModel() {
private var finalVideoPath: String? = null// 摄像后最终保存的文件名
private var geoWkt:String? = null
private var detail:String? = null
private var type = 0
private val radioPicture = 0
private var videoIndex = -1
private var paperFile: File? = null
private var logFile:java.io.File? = null
private val removables = mutableListOf<Removable>()
private fun initDataFromIntent(intent: Intent): Boolean {
if (intent != null) {
finalVideoPath = intent.getStringExtra(Constant.INTENT_JPG_PATH)
type = intent.getIntExtra(Constant.INTENT_TYPE, 0)
geoWkt = intent.getStringExtra(Constant.INTENT_GEO_WKT)
detail = intent.getStringExtra(Constant.INTENT_DETAIL)
if (finalVideoPath != null) {
val file: File = File(finalVideoPath)
paperFile =
File(Objects.requireNonNull(file.parentFile).absoluteFile.toString() + "/" + "paper.txt")
videoIndex = file.name.replace(".webp", "").toInt()
if (videoIndex == 0) {
videoIndex = -1
} else {
videoIndex = videoIndex - 1
}
}
return true
}
return false
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<corners <corners
android:radius="@dimen/default_corner_radius" /> android:radius="@dimen/cardview_default_radius" />
<padding <padding
android:bottom="@dimen/default_widget_padding" android:bottom="@dimen/default_widget_padding"
android:left="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding"
@@ -2,7 +2,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"> android:shape="rectangle">
<corners <corners
android:radius="@dimen/default_corner_radius" /> android:radius="@dimen/cardview_default_radius" />
<padding <padding
android:bottom="@dimen/default_widget_padding" android:bottom="@dimen/default_widget_padding"
android:left="@dimen/default_widget_padding" android:left="@dimen/default_widget_padding"
@@ -0,0 +1,26 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@android:id/background">
<shape>
<corners android:radius="0.1dip" />
<solid android:color="@color/colorGrays"></solid>
</shape>
</item>
<item android:id="@android:id/secondaryProgress">
<clip>
<shape>
<corners android:radius="0.1dip" />
<solid android:color="@color/black"></solid>
</shape>
</clip>
</item>
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="0.1dip" />
<solid android:color="@color/colorBlue"></solid>
</shape>
</clip>
</item>
</layer-list>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#460D0D"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M7,14l5,-5 5,5z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12.06,19v-2.01c-0.02,0 -0.04,0 -0.06,0c-1.28,0 -2.56,-0.49 -3.54,-1.46c-1.71,-1.71 -1.92,-4.35 -0.64,-6.29l1.1,1.1c-0.71,1.33 -0.53,3.01 0.59,4.13c0.7,0.7 1.62,1.03 2.54,1.01v-2.14l2.83,2.83L12.06,19zM16.17,14.76l-1.1,-1.1c0.71,-1.33 0.53,-3.01 -0.59,-4.13C13.79,8.84 12.9,8.5 12,8.5c-0.02,0 -0.04,0 -0.06,0v2.15L9.11,7.83L11.94,5v2.02c1.3,-0.02 2.61,0.45 3.6,1.45C17.24,10.17 17.45,12.82 16.17,14.76z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#8C8C8C"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12.06,19v-2.01c-0.02,0 -0.04,0 -0.06,0c-1.28,0 -2.56,-0.49 -3.54,-1.46c-1.71,-1.71 -1.92,-4.35 -0.64,-6.29l1.1,1.1c-0.71,1.33 -0.53,3.01 0.59,4.13c0.7,0.7 1.62,1.03 2.54,1.01v-2.14l2.83,2.83L12.06,19zM16.17,14.76l-1.1,-1.1c0.71,-1.33 0.53,-3.01 -0.59,-4.13C13.79,8.84 12.9,8.5 12,8.5c-0.02,0 -0.04,0 -0.06,0v2.15L9.11,7.83L11.94,5v2.02c1.3,-0.02 2.61,0.45 3.6,1.45C17.24,10.17 17.45,12.82 16.17,14.76z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94V1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11H1v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94V23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94H23v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
</vector>
@@ -0,0 +1,7 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M10,8l0,6l4.7,2.9l0.8,-1.2l-4,-2.4l0,-5.3z"/>
<path android:fillColor="@android:color/white" android:pathData="M17.92,12c0.05,0.33 0.08,0.66 0.08,1c0,3.9 -3.1,7 -7,7s-7,-3.1 -7,-7c0,-3.9 3.1,-7 7,-7c0.7,0 1.37,0.1 2,0.29V4.23C12.36,4.08 11.69,4 11,4c-5,0 -9,4 -9,9s4,9 9,9s9,-4 9,-9c0,-0.34 -0.02,-0.67 -0.06,-1H17.92z"/>
<path android:fillColor="@android:color/white" android:pathData="M20,5l0,-3l-2,0l0,3l-3,0l0,2l3,0l0,3l2,0l0,-3l3,0l0,-2z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="32dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.44,0.59l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L11.55,7.3c-0.78,-0.78 -2.05,-0.78 -2.83,0L7.3,8.72c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L6.6,12.25c-0.78,-0.78 -2.05,-0.78 -2.83,0l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l3.54,3.54c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-1.24,-1.24l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l1.41,-1.41c0.78,-0.78 0.78,-2.05 0,-2.83L13.84,9.6l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-3.54,-3.54C17.48,-0.2 16.22,-0.2 15.44,0.59zM6.6,19.32l-1.06,1.06L2,16.85l1.06,-1.06L6.6,19.32zM8.72,17.2l-1.06,1.06l-3.54,-3.54l1.06,-1.06L8.72,17.2zM18.26,7.66L17.2,8.72l-3.54,-3.54l1.06,-1.06L18.26,7.66zM20.38,5.54L19.32,6.6l-3.54,-3.54L16.85,2L20.38,5.54zM14,21l0,2c4.97,0 9,-4.03 9,-9l-2,0C21,17.87 17.87,21 14,21zM14,17l0,2c2.76,0 5,-2.24 5,-5l-2,0C17,15.66 15.66,17 14,17z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="32dp" android:tint="#8C8C8C"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M15.44,0.59l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L11.55,7.3c-0.78,-0.78 -2.05,-0.78 -2.83,0L7.3,8.72c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L6.6,12.25c-0.78,-0.78 -2.05,-0.78 -2.83,0l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l3.54,3.54c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-1.24,-1.24l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l1.41,-1.41c0.78,-0.78 0.78,-2.05 0,-2.83L13.84,9.6l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-3.54,-3.54C17.48,-0.2 16.22,-0.2 15.44,0.59zM6.6,19.32l-1.06,1.06L2,16.85l1.06,-1.06L6.6,19.32zM8.72,17.2l-1.06,1.06l-3.54,-3.54l1.06,-1.06L8.72,17.2zM18.26,7.66L17.2,8.72l-3.54,-3.54l1.06,-1.06L18.26,7.66zM20.38,5.54L19.32,6.6l-3.54,-3.54L16.85,2L20.38,5.54zM14,21l0,2c4.97,0 9,-4.03 9,-9l-2,0C21,17.87 17.87,21 14,21zM14,17l0,2c2.76,0 5,-2.24 5,-5l-2,0C17,15.66 15.66,17 14,17z"/>
</vector>
@@ -0,0 +1,10 @@
<vector android:height="32dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M13.02,19.93v2.02c2.01,-0.2 3.84,-1 5.32,-2.21l-1.42,-1.43C15.81,19.17 14.48,19.75 13.02,19.93z"/>
<path android:fillColor="@android:color/white" android:pathData="M4.03,12c0,-4.05 3.03,-7.41 6.95,-7.93V2.05C5.95,2.58 2.03,6.84 2.03,12c0,5.16 3.92,9.42 8.95,9.95v-2.02C7.06,19.41 4.03,16.05 4.03,12z"/>
<path android:fillColor="@android:color/white" android:pathData="M19.95,11h2.02c-0.2,-2.01 -1,-3.84 -2.21,-5.32l-1.43,1.43C19.19,8.21 19.77,9.54 19.95,11z"/>
<path android:fillColor="@android:color/white" android:pathData="M18.34,4.26c-1.48,-1.21 -3.32,-2.01 -5.32,-2.21v2.02c1.46,0.18 2.79,0.76 3.9,1.62L18.34,4.26z"/>
<path android:fillColor="@android:color/white" android:pathData="M18.33,16.9l1.43,1.42c1.21,-1.48 2.01,-3.31 2.21,-5.32h-2.02C19.77,14.46 19.19,15.79 18.33,16.9z"/>
<path android:fillColor="@android:color/white" android:pathData="M16,11.1C16,8.61 14.1,7 12,7s-4,1.61 -4,4.1c0,1.66 1.33,3.63 4,5.9C14.67,14.73 16,12.76 16,11.1zM12,12c-0.59,0 -1.07,-0.48 -1.07,-1.07c0,-0.59 0.48,-1.07 1.07,-1.07s1.07,0.48 1.07,1.07C13.07,11.52 12.59,12 12,12z"/>
</vector>
@@ -0,0 +1,10 @@
<vector android:height="32dp" android:tint="#8C8C8C"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M13.02,19.93v2.02c2.01,-0.2 3.84,-1 5.32,-2.21l-1.42,-1.43C15.81,19.17 14.48,19.75 13.02,19.93z"/>
<path android:fillColor="@android:color/white" android:pathData="M4.03,12c0,-4.05 3.03,-7.41 6.95,-7.93V2.05C5.95,2.58 2.03,6.84 2.03,12c0,5.16 3.92,9.42 8.95,9.95v-2.02C7.06,19.41 4.03,16.05 4.03,12z"/>
<path android:fillColor="@android:color/white" android:pathData="M19.95,11h2.02c-0.2,-2.01 -1,-3.84 -2.21,-5.32l-1.43,1.43C19.19,8.21 19.77,9.54 19.95,11z"/>
<path android:fillColor="@android:color/white" android:pathData="M18.34,4.26c-1.48,-1.21 -3.32,-2.01 -5.32,-2.21v2.02c1.46,0.18 2.79,0.76 3.9,1.62L18.34,4.26z"/>
<path android:fillColor="@android:color/white" android:pathData="M18.33,16.9l1.43,1.42c1.21,-1.48 2.01,-3.31 2.21,-5.32h-2.02C19.77,14.46 19.19,15.79 18.33,16.9z"/>
<path android:fillColor="@android:color/white" android:pathData="M16,11.1C16,8.61 14.1,7 12,7s-4,1.61 -4,4.1c0,1.66 1.33,3.63 4,5.9C14.67,14.73 16,12.76 16,11.1zM12,12c-0.59,0 -1.07,-0.48 -1.07,-1.07c0,-0.59 0.48,-1.07 1.07,-1.07s1.07,0.48 1.07,1.07C13.07,11.52 12.59,12 12,12z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M2,19.99l7.5,-7.51l4,4l7.09,-7.97L22,9.92l-8.5,9.56l-4,-4l-6,6.01L2,19.99zM3.5,15.49l6,-6.01l4,4L22,3.92l-1.41,-1.41l-7.09,7.97l-4,-4L2,13.99L3.5,15.49z"/>
</vector>
@@ -0,0 +1,5 @@
<vector android:height="24dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M19,13H5v-2h14v2z"/>
</vector>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/ic_baseline_change_circle_24_press"/> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/ic_baseline_change_circle_24_press"/> <!-- focused -->
<item android:state_selected="true"
android:drawable="@drawable/ic_baseline_change_circle_24_press"/>
<item android:state_checked="true"
android:drawable="@drawable/ic_baseline_change_circle_24_press"/>
<item android:state_enabled="false"
android:drawable="@drawable/ic_baseline_change_circle_24_press"/>
<item android:drawable="@drawable/ic_baseline_change_circle_24" /> <!-- default -->
</selector>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/ic_baseline_satellite_alt_24"/> <!-- pressed -->
<item android:state_focused="true"
android:drawable="@drawable/ic_baseline_satellite_alt_24"/> <!-- focused -->
<item android:state_selected="true"
android:drawable="@drawable/ic_baseline_satellite_alt_24"/>
<item android:state_checked="true"
android:drawable="@drawable/ic_baseline_satellite_alt_24"/>
<item android:state_enabled="false"
android:drawable="@drawable/ic_baseline_satellite_alt_24"/>
<item android:drawable="@drawable/ic_baseline_share_location_24" /> <!-- default -->
</selector>
@@ -5,7 +5,7 @@
<item android:state_focused="true" <item android:state_focused="true"
android:drawable="@drawable/round_bg_gray"/> <!-- focused --> android:drawable="@drawable/round_bg_gray"/> <!-- focused -->
<item android:state_selected="true" <item android:state_selected="true"
android:drawable="@drawable/round_bg_gray"/> android:drawable="@drawable/round_bg_white"/>
<item android:state_checked="true" <item android:state_checked="true"
android:drawable="@drawable/round_bg_gray"/> android:drawable="@drawable/round_bg_gray"/>
<item android:state_enabled="false" <item android:state_enabled="false"
@@ -53,6 +53,7 @@
app:layout_constraintTop_toBottomOf="@+id/view1"> app:layout_constraintTop_toBottomOf="@+id/view1">
<ImageView <ImageView
android:id="@+id/img_logo"
android:layout_width="100dp" android:layout_width="100dp"
android:layout_height="100dp" android:layout_height="100dp"
android:layout_gravity="center" android:layout_gravity="center"
@@ -180,6 +181,37 @@
android:gravity="center" android:gravity="center"
android:textSize="16sp" /> android:textSize="16sp" />
</RelativeLayout> </RelativeLayout>
<LinearLayout
android:id="@+id/layer_setting"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"
android:orientation="vertical">
<RelativeLayout
android:id="@+id/rl_picture_check_setting"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginLeft="15dp"
android:background="?android:attr/selectableItemBackground"
android:gravity="center_vertical">
<TextView
style="@style/main_about_text_style"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图像检查参数设置" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="15dp"
android:background="@drawable/ic_baseline_arrow_forward"
android:gravity="center"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>
@@ -48,7 +48,7 @@
android:background="@android:color/transparent" android:background="@android:color/transparent"
app:layout_constraintHeight_default="percent" app:layout_constraintHeight_default="percent"
app:layout_constraintHeight_percent="0.4" app:layout_constraintHeight_percent="0.4"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintWidth_default="percent" app:layout_constraintWidth_default="percent"
app:layout_constraintWidth_percent="0.4" /> app:layout_constraintWidth_percent="0.4" />
@@ -80,26 +80,36 @@
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> </LinearLayout>
<ImageView <LinearLayout
android:id="@+id/iv_zoom_add" android:id="@+id/layer_map_controller"
android:layout_width="50dp" android:layout_width="wrap_content"
android:layout_height="50dp" android:layout_height="wrap_content"
android:layout_marginEnd="25dp" android:orientation="vertical"
android:src="@mipmap/zoom_add"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/btn_stop_picture" android:padding="@dimen/default_widget_padding"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@id/btn_stop_picture"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintRight_toRightOf="parent">
<ImageView
android:id="@+id/iv_zoom_add"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:src="@drawable/ic_baseline_add_24"
android:padding="@dimen/default_widget_padding"
android:background="@drawable/selector_round_bg"
app:layout_constraintBottom_toTopOf="@+id/btn_stop_picture"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/iv_zoom_del" android:id="@+id/iv_zoom_del"
android:layout_width="50dp" android:layout_width="@dimen/default_round_widget"
android:layout_height="50dp" android:layout_height="@dimen/default_round_widget"
android:layout_marginTop="15dp" android:layout_marginTop="@dimen/default_widget_padding"
android:src="@mipmap/zoom_del" android:src="@drawable/ic_baseline_sub_24"
android:visibility="gone" android:padding="@dimen/default_widget_padding"
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_add" android:background="@drawable/selector_round_bg"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_add" /> app:layout_constraintLeft_toLeftOf="@id/iv_zoom_add"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_add" />
<!--<CheckBox <!--<CheckBox
android:id="@+id/cb_map_type" android:id="@+id/cb_map_type"
@@ -113,77 +123,95 @@
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del" app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />--> app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />-->
<ImageView <ImageView
android:id="@+id/iv_location" android:id="@+id/iv_location"
android:layout_width="50dp" android:layout_width="@dimen/default_round_widget"
android:layout_height="50dp" android:layout_height="@dimen/default_round_widget"
android:layout_marginTop="15dp" android:layout_marginTop="@dimen/default_widget_padding"
android:background="@drawable/selector_round_bg" android:src="@drawable/ic_baseline_location_searching_24"
android:src="@mipmap/location_auto_pic" android:padding="@dimen/default_widget_padding"
android:padding="8dp" android:background="@drawable/selector_round_bg"
android:visibility="gone" app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del"
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del" app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" /> </LinearLayout>
<ImageView <LinearLayout
android:id="@+id/btn_switch"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="@drawable/selector_round_bg"
android:layout_marginTop="35dp"
android:src="@drawable/selector_picture_map_change"
android:padding="@dimen/default_widget_padding"
android:layout_marginRight="@dimen/default_widget_padding"
android:text="切换"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/btn_setting"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone"
android:text="设置"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintTop_toBottomOf="@id/btn_switch"
app:layout_constraintRight_toRightOf="parent"></Button>
<Switch
android:id="@+id/location_switch"
android:text="启用定位"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:padding="@dimen/default_widget_padding"
app:layout_constraintTop_toBottomOf="@id/btn_setting"
app:layout_constraintRight_toRightOf="parent"></Switch>
<ImageView
android:id="@+id/img_navi_distance"
android:layout_width="36dp"
android:layout_height="36dp"
android:src="@drawable/selector_navi_distance"
android:background="@drawable/selector_round_bg"
android:text="按距离自动导航"
android:visibility="gone"
android:padding="@dimen/default_widget_padding"
android:layout_margin="@dimen/default_widget_padding"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/location_switch"/> app:layout_constraintTop_toTopOf="parent"
<ImageView
android:id="@+id/img_road_direction"
android:layout_width="36dp"
android:layout_height="36dp"
android:visibility="gone"
android:background="@drawable/selector_round_bg"
android:text="起点方向捕捉"
android:src="@drawable/selector_direction"
android:padding="@dimen/default_widget_padding" android:padding="@dimen/default_widget_padding"
android:layout_margin="@dimen/default_widget_padding" android:layout_marginTop="@dimen/fab_margin"
app:layout_constraintRight_toRightOf="parent" android:orientation="vertical">
app:layout_constraintTop_toBottomOf="@id/img_navi_distance"></ImageView> <ImageView
android:id="@+id/btn_switch"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:background="@drawable/selector_round_bg"
android:src="@drawable/selector_camera_switch"
android:padding="@dimen/default_widget_padding"
android:text="切换"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/img_navi_distance"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:src="@drawable/selector_navi_distance"
android:background="@drawable/selector_round_bg"
android:text="按距离自动导航"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintRight_toRightOf="parent"/>
<ImageView
android:id="@+id/img_road_direction"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:visibility="gone"
android:background="@drawable/selector_round_bg"
android:text="起点方向捕捉"
android:src="@drawable/selector_direction"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/img_navi_distance"></ImageView>
<ImageView
android:id="@+id/img_location_type"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:background="@drawable/selector_round_bg"
android:text="定位方式"
android:src="@drawable/selector_location_type"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/img_road_direction"></ImageView>
<Button
android:id="@+id/btn_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:text="设置"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintTop_toBottomOf="@id/btn_switch"
app:layout_constraintRight_toRightOf="parent"></Button>
<Switch
android:id="@+id/location_switch"
android:text="启用定位"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintTop_toBottomOf="@id/btn_setting"
app:layout_constraintRight_toRightOf="parent"></Switch>
</LinearLayout>
<RadioGroup <RadioGroup
android:id="@+id/radio_group_picture" android:id="@+id/radio_group_picture"
@@ -31,4 +31,10 @@
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" /> app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/tv_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/tab_layout"></TextView>
</androidx.constraintlayout.widget.ConstraintLayout > </androidx.constraintlayout.widget.ConstraintLayout >
+1 -1
View File
@@ -132,7 +132,7 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@+id/btn_switch" app:layout_constraintTop_toTopOf="@+id/btn_switch"
android:background="@color/whiteAlpha50" android:background="@color/white50"
android:padding="@dimen/default_widget_padding" android:padding="@dimen/default_widget_padding"
android:textColor="@color/colorRead" android:textColor="@color/colorRead"
android:format="00:00:00" android:format="00:00:00"
+104 -46
View File
@@ -78,27 +78,36 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
</LinearLayout> </LinearLayout>
<LinearLayout
<ImageView android:id="@+id/layer_map_controller"
android:id="@+id/iv_zoom_add" android:layout_width="wrap_content"
android:layout_width="50dp" android:layout_height="wrap_content"
android:layout_height="50dp" android:orientation="vertical"
android:layout_marginEnd="25dp"
android:src="@mipmap/zoom_add"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toTopOf="@+id/btn_stop_picture" android:padding="@dimen/default_widget_padding"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintBottom_toTopOf="@id/btn_stop_picture"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintRight_toRightOf="parent">
<ImageView
android:id="@+id/iv_zoom_add"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:src="@drawable/ic_baseline_add_24"
android:padding="@dimen/default_widget_padding"
android:background="@drawable/selector_round_bg"
app:layout_constraintBottom_toTopOf="@+id/btn_stop_picture"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView <ImageView
android:id="@+id/iv_zoom_del" android:id="@+id/iv_zoom_del"
android:layout_width="50dp" android:layout_width="@dimen/default_round_widget"
android:layout_height="50dp" android:layout_height="@dimen/default_round_widget"
android:layout_marginTop="15dp" android:layout_marginTop="@dimen/default_widget_padding"
android:src="@mipmap/zoom_del" android:src="@drawable/ic_baseline_sub_24"
android:visibility="gone" android:padding="@dimen/default_widget_padding"
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_add" android:background="@drawable/selector_round_bg"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_add" /> app:layout_constraintLeft_toLeftOf="@id/iv_zoom_add"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_add" />
<!--<CheckBox <!--<CheckBox
android:id="@+id/cb_map_type" android:id="@+id/cb_map_type"
@@ -112,37 +121,80 @@
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del" app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />--> app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />-->
<ImageView <ImageView
android:id="@+id/iv_location" android:id="@+id/iv_location"
android:layout_width="50dp" android:layout_width="@dimen/default_round_widget"
android:layout_height="50dp" android:layout_height="@dimen/default_round_widget"
android:layout_marginTop="15dp" android:layout_marginTop="@dimen/default_widget_padding"
android:src="@mipmap/mine_location" android:src="@drawable/ic_baseline_location_searching_24"
android:visibility="gone" android:padding="@dimen/default_widget_padding"
app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del" android:background="@drawable/selector_round_bg"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" /> app:layout_constraintLeft_toLeftOf="@id/iv_zoom_del"
app:layout_constraintTop_toBottomOf="@id/iv_zoom_del" />
</LinearLayout>
<ImageView <LinearLayout
android:id="@+id/btn_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:layout_marginEnd="25dp"
android:text="切换"
android:padding="@dimen/default_widget_padding"
android:src="@mipmap/switcher"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="@dimen/fab_margin"
android:padding="@dimen/default_widget_padding"
android:orientation="vertical">
<ImageView
android:id="@+id/btn_switch"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:background="@drawable/selector_round_bg"
android:text="切换"
android:padding="@dimen/default_widget_padding"
android:src="@drawable/selector_camera_switch"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button <Button
android:id="@+id/btn_setting" android:id="@+id/btn_setting"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="设置" android:text="设置"
android:layout_marginTop="@dimen/default_widget_padding" android:layout_marginTop="@dimen/default_widget_padding"
android:visibility="gone" android:visibility="gone"
app:layout_constraintTop_toBottomOf="@id/btn_switch" app:layout_constraintTop_toBottomOf="@id/btn_switch"
app:layout_constraintRight_toRightOf="parent"></Button> app:layout_constraintRight_toRightOf="parent"></Button>
<ImageView
android:id="@+id/img_location_type"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:background="@drawable/selector_round_bg"
android:text="定位方式"
android:src="@drawable/selector_location_type"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/btn_setting"></ImageView>
<ImageView
android:id="@+id/img_track_select_point"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:background="@drawable/selector_round_bg"
android:text="从轨迹选择"
android:visibility="gone"
android:src="@drawable/ic_baseline_stacked_line_chart_24"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"></ImageView>
<ImageView
android:id="@+id/img_track_select_confirm"
android:layout_width="@dimen/default_round_widget"
android:layout_height="@dimen/default_round_widget"
android:visibility="gone"
android:background="@drawable/selector_round_bg"
android:text="确认轨迹选择时间"
android:src="@drawable/ic_baseline_more_time_24"
android:padding="@dimen/default_widget_padding"
android:layout_marginTop="@dimen/default_widget_padding"></ImageView>
</LinearLayout>
<RadioGroup <RadioGroup
android:id="@+id/radio_group_picture" android:id="@+id/radio_group_picture"
@@ -244,5 +296,11 @@
app:layout_constraintBottom_toBottomOf="@id/capture_picture" app:layout_constraintBottom_toBottomOf="@id/capture_picture"
app:layout_constraintLeft_toRightOf="@id/capture_picture" app:layout_constraintLeft_toRightOf="@id/capture_picture"
app:layout_constraintRight_toRightOf="parent" /> app:layout_constraintRight_toRightOf="parent" />
<TextView
android:id="@+id/tv_degrees"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
></TextView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
+1 -1
View File
@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/dialogButtonMIUITextGray" android:background="@color/colorGrey"
android:padding="@dimen/fab_margin" android:padding="@dimen/fab_margin"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/dialogButtonMIUITextGray" android:background="@color/colorGrey"
android:padding="@dimen/fab_margin" android:padding="@dimen/fab_margin"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout <LinearLayout
@@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple_200"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
style="@style/text_style_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="是否可用参数:"></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="设备姿态偏移量:"></TextView>
<EditText
android:id="@+id/sensor_degree"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POI拍摄速度(最小):"></TextView>
<EditText
android:id="@+id/poi_speed_min"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="POI拍摄速度(最大):"></TextView>
<EditText
android:id="@+id/poi_speed_max"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="道路拍摄速度(最小):"></TextView>
<EditText
android:id="@+id/road_speed_min"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="道路拍摄速度(最大):"></TextView>
<EditText
android:id="@+id/road_speed_max"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="卫星颗数:"></TextView>
<EditText
android:id="@+id/satellite_count"
android:inputType="number"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
</LinearLayout>
<TextView
style="@style/text_style_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="得分参数:"></TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.Tooltip"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_picture_setting_confirm"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="确定"
style="@style/Widget.AppCompat.Button.Colored"></TextView>
<TextView
android:id="@+id/tv_picture_setting_cancel"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="取消"
android:textColor="@color/chuck_status_500"
style="@style/Widget.AppCompat.Button.Colored"></TextView>
</LinearLayout>
</LinearLayout>
</ScrollView>
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/default_widget_padding"
android:text="选择楼层"
android:gravity="center"
android:textSize="@dimen/pickerview_topbar_title_textsize"></TextView>
<NumberPicker
android:id="@+id/number_picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
></NumberPicker>
<TextView
android:id="@+id/btn_select_floor_confirm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="确定"
android:background="@drawable/selector_hui_bg"
android:padding="@dimen/default_widget_padding"
android:gravity="center"
android:textSize="@dimen/pickerview_textsize"></TextView>
</LinearLayout>

Some files were not shown because too many files have changed in this diff Show More