Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
098597c110 | ||
|
|
c0e8025c3b |
+1
-3
@@ -13,6 +13,4 @@
|
|||||||
/captures
|
/captures
|
||||||
.externalNativeBuild
|
.externalNativeBuild
|
||||||
.cxx
|
.cxx
|
||||||
app/release/
|
app/release/
|
||||||
app/build/
|
|
||||||
ocr/build/
|
|
||||||
Generated
-40
@@ -46,45 +46,5 @@
|
|||||||
<option name="name" value="maven" />
|
<option name="name" value="maven" />
|
||||||
<option name="url" value="https://maven.aliyun.com/repository/apache-snapshots" />
|
<option name="url" value="https://maven.aliyun.com/repository/apache-snapshots" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven4" />
|
|
||||||
<option name="name" value="maven4" />
|
|
||||||
<option name="url" value="https://oss.sonatype.org/content/groups/public" />
|
|
||||||
</remote-repository>
|
|
||||||
<remote-repository>
|
|
||||||
<option name="id" value="maven5" />
|
|
||||||
<option name="name" value="maven5" />
|
|
||||||
<option name="url" value="https://maven.google.com/" />
|
|
||||||
</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>
|
||||||
+28
-116
@@ -1,63 +1,18 @@
|
|||||||
plugins {
|
apply plugin: 'com.android.application'
|
||||||
id 'com.android.application'
|
|
||||||
id 'kotlin-android'
|
|
||||||
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 31
|
compileSdkVersion 30
|
||||||
// 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 24
|
minSdkVersion 22
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 118
|
versionCode 21
|
||||||
versionName "8.231110-通用测试版"
|
versionName "8.220510"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
ndk {
|
|
||||||
// 设置支持的SO库架构(开发者可以根据需要,选择一个或多个平台的so)
|
|
||||||
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
|
|
||||||
}
|
|
||||||
|
|
||||||
configurations {
|
|
||||||
cleanedAnnotations
|
|
||||||
// implementation.exclude group: 'org.jetbrains' , module:'annotations'
|
|
||||||
implementation.exclude group: 'com.intellij' , module:'annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
manifestPlaceholders = [
|
|
||||||
XG_ACCESS_ID : "1580017520",
|
|
||||||
XG_ACCESS_KEY : "ABQZ9Z3PDWXM",
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
checkReleaseBuilds false
|
checkReleaseBuilds false
|
||||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||||
@@ -78,25 +33,10 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_11
|
sourceCompatibility JavaVersion.VERSION_1_8
|
||||||
targetCompatibility JavaVersion.VERSION_11
|
targetCompatibility JavaVersion.VERSION_1_8
|
||||||
}
|
}
|
||||||
ndkVersion '21.3.6528147'
|
ndkVersion '21.3.6528147'
|
||||||
packagingOptions {
|
|
||||||
pickFirst 'lib/x86/libc++_shared.so'
|
|
||||||
pickFirst 'lib/x86_64/libjsc.so'
|
|
||||||
pickFirst 'lib/arm64-v8a/libjsc.so'
|
|
||||||
pickFirst 'lib/arm64-v8a/libc++_shared.so'
|
|
||||||
pickFirst 'lib/x86_64/libc++_shared.so'
|
|
||||||
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
|
|
||||||
}
|
|
||||||
buildFeatures {
|
|
||||||
viewBinding true
|
|
||||||
}
|
|
||||||
// configurations.all {
|
|
||||||
// all*.exclude group: "com.squareup.okhttp3", module: "okhttp3"
|
|
||||||
// all*.exclude group: "com.squareup.okio", module: "okio"
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
//efs {
|
//efs {
|
||||||
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
|
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
|
||||||
@@ -115,19 +55,17 @@ android {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||||
implementation 'com.google.android.material:material:1.6.0'
|
implementation 'com.google.android.material:material:1.0.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')
|
implementation files('libs\\jts-1.13.jar')
|
||||||
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-process:2.4.1"
|
|
||||||
//友盟自动检测bug
|
//友盟自动检测bug
|
||||||
implementation 'com.umeng.umsdk:apm:1.2.0'
|
implementation 'com.umeng.umsdk:apm:1.2.0'
|
||||||
//友盟基础库依赖(必须)
|
//友盟基础库依赖(必须)
|
||||||
@@ -141,17 +79,16 @@ 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.google.code.gson:gson:2.8.5'
|
implementation 'com.google.code.gson:gson:2.8.5'
|
||||||
implementation 'com.readystatesoftware.chuck:library:1.1.0'
|
|
||||||
|
|
||||||
// //retrofit+rxJava
|
//retrofit+rxJava
|
||||||
// implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||||
// implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||||
// //转换器,请求结果转换成Model
|
//转换器,请求结果转换成Model
|
||||||
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||||
//配合RxJava 使用
|
//配合RxJava 使用
|
||||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
||||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||||
@@ -167,8 +104,6 @@ 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
|
||||||
@@ -179,26 +114,21 @@ dependencies {
|
|||||||
|
|
||||||
//腾讯地图
|
//腾讯地图
|
||||||
// 地图库
|
// 地图库
|
||||||
implementation 'com.tencent.map:tencent-map-vector-sdk:4.5.10'
|
implementation 'com.tencent.map:tencent-map-vector-sdk:4.4.2'
|
||||||
// // 地图组件库,包括小车平移、点聚合等组件功能,详见开发指南。
|
// 地图组件库,包括小车平移、点聚合等组件功能,详见开发指南。
|
||||||
// implementation 'com.tencent.map:sdk-utilities:1.0.6'
|
implementation 'com.tencent.map:sdk-utilities:1.0.6'
|
||||||
// 导航库
|
|
||||||
implementation ("com.tencent.map:tencent-map-nav-sdk:5.4.2.3")
|
|
||||||
// 导航依赖库
|
|
||||||
implementation ("com.tencent.map:tencent-map-nav-surport:1.1.0.1")
|
|
||||||
|
|
||||||
// //腾讯地图 定位
|
//腾讯地图 定位
|
||||||
// implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9'
|
implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.2.6'
|
||||||
|
|
||||||
// 权限请求框架:https://github.com/getActivity/XXPermissions
|
// 权限请求框架:https://github.com/getActivity/XXPermissions
|
||||||
implementation 'com.github.getActivity:XXPermissions:18.0'
|
implementation 'com.github.getActivity:XXPermissions:11.6'
|
||||||
|
|
||||||
//room 数据库
|
//room 数据库
|
||||||
def room_version = "2.2.0-alpha01"
|
def room_version = "2.2.0-alpha01"
|
||||||
|
|
||||||
implementation "androidx.room:room-runtime:$room_version"
|
implementation "androidx.room:room-runtime:$room_version"
|
||||||
implementation "androidx.room:room-ktx:$room_version"
|
annotationProcessor "androidx.room:room-compiler:$room_version"
|
||||||
kapt "androidx.room:room-compiler:$room_version"
|
|
||||||
implementation "androidx.room:room-rxjava2:$room_version"
|
implementation "androidx.room:room-rxjava2:$room_version"
|
||||||
implementation "androidx.room:room-guava:$room_version"
|
implementation "androidx.room:room-guava:$room_version"
|
||||||
testImplementation "androidx.room:room-testing:$room_version"
|
testImplementation "androidx.room:room-testing:$room_version"
|
||||||
@@ -211,25 +141,7 @@ 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
|
|
||||||
implementation 'com.teprinciple:mailsender:1.2.0'
|
|
||||||
// // https://github.com/JiongBull/jlog/blob/master/README_ZH.md 日志记录
|
|
||||||
// implementation 'com.github.JiongBull:jlog:0.1.0'
|
|
||||||
// // https://github.com/JiongBull/jlog-storage-qiniu 自动将日志上传到七牛云
|
|
||||||
// implementation 'com.github.JiongBull:jlog-storage-qiniu:0.1.0'
|
|
||||||
// https://github.com/elvishew/xLog/blob/master/README_ZH.md 日志记录
|
|
||||||
implementation 'com.elvishew:xlog:1.10.1'
|
|
||||||
// // 百度定位
|
|
||||||
// implementation 'com.baidu.lbsyun:BaiduMapSDK_Location:9.3.7'
|
|
||||||
// 腾讯推送依赖
|
|
||||||
//添加以下依赖
|
|
||||||
implementation 'com.tencent.tpns:tpns:1.4.3.1-release'
|
|
||||||
// 金刚扫描库
|
|
||||||
implementation 'com.tencent.jg:jg:1.1'
|
|
||||||
//推送保活库
|
|
||||||
implementation 'com.github.xuexiangjys.XPush:keeplive:1.0.0'
|
|
||||||
// // Android应用白名单添加 https://github.com/WaseemSabir/BatteryPermissionHelper
|
|
||||||
// implementation 'com.waseemsabir:betterypermissionhelper:1.0.3'
|
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,24 +2,6 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="com.navinfo.outdoor">
|
package="com.navinfo.outdoor">
|
||||||
|
|
||||||
<!-- 移动推送TPNS自定义权限,用于发送接收广播权限校验(必选)-->
|
|
||||||
<permission
|
|
||||||
android:name="com.navinfo.outdoor.permission.XGPUSH_RECEIVE"
|
|
||||||
android:protectionLevel="signature" />
|
|
||||||
<uses-permission android:name="com.navinfo.outdoor.permission.XGPUSH_RECEIVE" />
|
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
|
|
||||||
|
|
||||||
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE" /><!-- 华为角标 -->
|
|
||||||
<uses-permission android:name="com.vivo.notification.permission.BADGE_ICON" /><!-- VIVO角标权限 -->
|
|
||||||
<uses-permission android:name="android.permission.VIBRATE" /><!--振动器权限,小米推送必须-->
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" /><!--允许应用可以接收点亮屏幕或解锁广播 -->
|
|
||||||
<uses-permission android:name="android.permission.RESTART_PACKAGES" /><!--允许程序结束任务,用户关闭推送服务,推送服务退出 -->
|
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE " /><!--允许程序写入外部存储,用于保存SDK运行日志 -->
|
|
||||||
<uses-permission android:name="android.permission.GET_TASKS" /><!--允许程序获取任务信息 -->
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <!-- 允许后台运行的权限 -->
|
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||||
<uses-permission android:name="android.permission.READ_CALENDAR" /> <!-- <uses-permission android:name="android.permission.WRITE_CALENDAR" /> -->
|
<uses-permission android:name="android.permission.READ_CALENDAR" /> <!-- <uses-permission android:name="android.permission.WRITE_CALENDAR" /> -->
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
@@ -27,13 +9,13 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.CAMERA" /> <!-- <uses-sdk android:minSdkVersion="8"></uses-sdk> -->
|
<uses-permission android:name="android.permission.CAMERA" /> <!-- <uses-sdk android:minSdkVersion="8"></uses-sdk> -->
|
||||||
<!-- 在SDCard中创建与删除文件权限 -->
|
<!-- 在SDCard中创建与删除文件权限 -->
|
||||||
<uses-permission
|
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" tools:ignore="ProtectedPermissions" /> <!-- 安装APK权限 -->
|
||||||
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
|
||||||
tools:ignore="ProtectedPermissions" /> <!-- 安装APK权限 -->
|
|
||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- 友盟检测bug -->
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <!-- 友盟检测bug -->
|
||||||
<uses-permission
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" tools:node="remove" /><!--移除自启动能力-->
|
||||||
android:name="android.permission.RECEIVE_BOOT_COMPLETED"
|
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
|
||||||
tools:node="remove" /> <!-- 移除自启动能力 -->
|
<!-- <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.READ_PHONE_STATE" /> -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.INTERNET" /> -->
|
||||||
<!-- 腾讯地图 定位权限 -->
|
<!-- 腾讯地图 定位权限 -->
|
||||||
<!-- 通过GPS得到精确位置 -->
|
<!-- 通过GPS得到精确位置 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 -->
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 -->
|
||||||
@@ -49,21 +31,14 @@
|
|||||||
<uses-permission android:name="android.permission.ACTION_LOCATION_SOURCE_SETTINGS" />
|
<uses-permission android:name="android.permission.ACTION_LOCATION_SOURCE_SETTINGS" />
|
||||||
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 支持A-GPS辅助定位 -->
|
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- 支持A-GPS辅助定位 -->
|
||||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 用于 log 日志 -->
|
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" /> <!-- 用于 log 日志 -->
|
||||||
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" /><!--允许程序在手机屏幕关闭后,后台进程仍然运行,保持推送长链接 -->
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
android:name="android.hardware.camera"
|
android:name="android.hardware.camera"
|
||||||
android:required="true" />
|
android:required="true" />
|
||||||
|
|
||||||
<queries>
|
<queries>
|
||||||
<intent>
|
<intent>
|
||||||
<action android:name="android.intent.action.TTS_SERVICE" />
|
<action android:name="android.intent.action.TTS_SERVICE" />
|
||||||
</intent>
|
</intent>
|
||||||
</queries>
|
</queries>
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".api.UserApplication"
|
android:name=".api.UserApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
@@ -76,42 +51,26 @@
|
|||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.WhiteScreen"
|
android:theme="@style/Theme.WhiteScreen"
|
||||||
tools:targetApi="n">
|
tools:targetApi="n">
|
||||||
<!-- <activity-->
|
<activity android:name=".activity.RegardMapActivity" />
|
||||||
<!-- android:name=".NaviActivity"-->
|
<activity android:name=".activity.StatementActivity" />
|
||||||
<!-- android:exported="false">-->
|
|
||||||
<!-- <meta-data-->
|
|
||||||
<!-- android:name="android.app.lib_name"-->
|
|
||||||
<!-- android:value="" />-->
|
|
||||||
<!-- </activity>-->
|
|
||||||
<activity android:name=".activity.RegardMapActivity"
|
|
||||||
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: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"
|
||||||
android:value="true" /> <!-- <meta-data -->
|
android:value="true" />
|
||||||
<!-- android:name="TencentMapSDK" -->
|
|
||||||
<!-- 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="EWWBZ-2PB62-6JXUL-CEX7G-N7UE6-XRB4V" />
|
||||||
<!-- 今日头屏幕适配 -->
|
<!-- 今日头屏幕适配 -->
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="design_width_in_dp"
|
android:name="design_width_in_dp"
|
||||||
@@ -119,63 +78,41 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
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" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<!--
|
<!-- <activity
|
||||||
<activity
|
|
||||||
android:name=".activity.UMClickActivity"
|
android:name=".activity.UMClickActivity"
|
||||||
android:launchMode="singleTask"
|
android:launchMode="singleTask"
|
||||||
android:exported="true" />
|
android:exported="true" />-->
|
||||||
-->
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.LoginActivity"
|
android:name=".activity.LoginActivity"
|
||||||
android:configChanges="keyboardHidden|orientation"
|
android:configChanges="keyboardHidden|orientation"
|
||||||
android:screenOrientation="portrait" /> <!-- |screenSize -->
|
android:screenOrientation="portrait" /> <!-- |screenSize -->
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.HomeActivity"
|
android:name=".activity.HomeActivity"
|
||||||
android:exported="true"
|
|
||||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.WebActivity"
|
android:name=".activity.WebActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.FragmentManagement"
|
android:name=".activity.FragmentManagement"
|
||||||
android:configChanges="orientation|keyboardHidden|screenSize"
|
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
android:configChanges="orientation|keyboardHidden|screenSize"
|
||||||
android:windowSoftInputMode="adjustPan" />
|
android:windowSoftInputMode="adjustPan" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.ImageShowActivity"
|
android:name=".activity.ImageShowActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
<activity
|
||||||
android:name=".activity.VideoActivity"
|
android:name=".activity.VideoActivity"
|
||||||
android:screenOrientation="portrait" /> <!-- 自动拍照界面 -->
|
android:screenOrientation="portrait" />
|
||||||
<!-- 自动捕捉道路任务 -->
|
|
||||||
<activity
|
|
||||||
android:name=".activity.AutoTakePictureActivity"
|
|
||||||
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"
|
||||||
@@ -183,15 +120,6 @@
|
|||||||
<activity
|
<activity
|
||||||
android:name=".activity.GuidanceActivity"
|
android:name=".activity.GuidanceActivity"
|
||||||
android:screenOrientation="portrait" />
|
android:screenOrientation="portrait" />
|
||||||
<activity
|
|
||||||
android:name=".activity.NaviCarActivity"
|
|
||||||
android:screenOrientation="sensor" />
|
|
||||||
<activity
|
|
||||||
android:name=".activity.NaviRideActivity"
|
|
||||||
android:screenOrientation="sensor" />
|
|
||||||
<activity
|
|
||||||
android:name=".activity.NaviWalkActivity"
|
|
||||||
android:screenOrientation="sensor" />
|
|
||||||
|
|
||||||
<provider
|
<provider
|
||||||
android:name="androidx.core.content.FileProvider"
|
android:name="androidx.core.content.FileProvider"
|
||||||
@@ -201,7 +129,8 @@
|
|||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
android:resource="@xml/file_paths" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider> <!-- 移除关联启动能力 -->
|
</provider>
|
||||||
|
<!--移除关联启动能力-->
|
||||||
<service
|
<service
|
||||||
android:name="com.taobao.accs.ChannelService"
|
android:name="com.taobao.accs.ChannelService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -210,7 +139,6 @@
|
|||||||
android:name="com.taobao.accs.data.MsgDistributeService"
|
android:name="com.taobao.accs.data.MsgDistributeService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
tools:replace="android:exported" />
|
tools:replace="android:exported" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="com.taobao.accs.EventReceiver"
|
android:name="com.taobao.accs.EventReceiver"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -219,7 +147,6 @@
|
|||||||
android:name="com.taobao.accs.ServiceReceiver"
|
android:name="com.taobao.accs.ServiceReceiver"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
tools:replace="android:exported" />
|
tools:replace="android:exported" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name="org.android.agoo.accs.AgooService"
|
android:name="org.android.agoo.accs.AgooService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
@@ -232,117 +159,15 @@
|
|||||||
android:name="com.umeng.message.XiaomiIntentService"
|
android:name="com.umeng.message.XiaomiIntentService"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
tools:replace="android:exported" />
|
tools:replace="android:exported" />
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
android:name="com.taobao.agoo.AgooCommondReceiver"
|
android:name="com.taobao.agoo.AgooCommondReceiver"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
tools:replace="android:exported" />
|
tools:replace="android:exported" />
|
||||||
|
|
||||||
<service
|
<service
|
||||||
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" />
|
||||||
|
|
||||||
<service android:name=".service.ForegroundCoreService"
|
|
||||||
android:foregroundServiceType="location"
|
|
||||||
android:exported="true"
|
|
||||||
android:enabled="true"
|
|
||||||
android:directBootAware="true"/>
|
|
||||||
|
|
||||||
<!-- 告知 XXPermissions 当前项目已经适配了分区存储特性 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="ScopedStorage"
|
|
||||||
android:value="true" />
|
|
||||||
|
|
||||||
<!-- 设置推送节点为上海 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="XG_SERVER_SUFFIX"
|
|
||||||
android:value="tpns.sh.tencent.com" />
|
|
||||||
<uses-library android:name="org.apache.http.legacy"
|
|
||||||
android:required="false"/>
|
|
||||||
|
|
||||||
<!-- <!– 【必须】 信鸽receiver广播接收 –>-->
|
|
||||||
<!-- <receiver-->
|
|
||||||
<!-- android:name="com.tencent.android.tpush.XGPushReceiver"-->
|
|
||||||
<!-- android:exported="false"-->
|
|
||||||
<!-- android:process=":xg_vip_service">-->
|
|
||||||
<!-- <intent-filter android:priority="0x7fffffff">-->
|
|
||||||
<!-- <!– 【必须】 信鸽SDK的内部广播 –>-->
|
|
||||||
<!-- <action android:name="com.tencent.android.xg.vip.action.SDK" />-->
|
|
||||||
<!-- <action android:name="com.tencent.android.xg.vip.action.INTERNAL_PUSH_MESSAGE" />-->
|
|
||||||
<!-- <action android:name="com.tencent.android.xg.vip.action.ACTION_SDK_KEEPALIVE" />-->
|
|
||||||
<!-- </intent-filter>-->
|
|
||||||
<!-- </receiver>-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <!– 【必须】移动推送 TPNS service –>-->
|
|
||||||
<!-- <service-->
|
|
||||||
<!-- android:name="com.tencent.android.tpush.service.XGVipPushService"-->
|
|
||||||
<!-- android:exported="false"-->
|
|
||||||
<!-- android:process=":xg_vip_service">-->
|
|
||||||
<!-- </service>-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <!– 【必须】通知 service ,android:name 部分改为包名.XGVIP_PUSH_ACTION –>-->
|
|
||||||
<!-- <service android:name="com.tencent.android.tpush.rpc.XGRemoteService"-->
|
|
||||||
<!-- android:exported="false">-->
|
|
||||||
<!-- <intent-filter>-->
|
|
||||||
<!-- <!– 【必须】请修改为当前APP名包.XGVIP_PUSH_ACTION –>-->
|
|
||||||
<!-- <action android:name="com.navinfo.outdoor.XGVIP_PUSH_ACTION" />-->
|
|
||||||
<!-- </intent-filter>-->
|
|
||||||
<!-- </service>-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <!– 【必须】【注意】authorities 修改为包名.XGVIP_PUSH_AUTH –>-->
|
|
||||||
<!-- <provider-->
|
|
||||||
<!-- android:name="com.tencent.android.tpush.XGPushProvider"-->
|
|
||||||
<!-- android:authorities="com.navinfo.outdoor.XGVIP_PUSH_AUTH" />-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <!– 【必须】【注意】authorities 修改为包名.TPUSH_PROVIDER –>-->
|
|
||||||
<!-- <provider-->
|
|
||||||
<!-- android:name="com.tencent.android.tpush.SettingsContentProvider"-->
|
|
||||||
<!-- android:authorities="com.navinfo.outdoor.TPUSH_PROVIDER" />-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <!– 【可选】用于增强保活能力 –>-->
|
|
||||||
<!-- <provider-->
|
|
||||||
<!-- android:name="com.tencent.android.tpush.XGVipPushKAProvider"-->
|
|
||||||
<!-- android:authorities="com.navinfo.outdoor.AUTH_XGPUSH_KEEPALIVE"-->
|
|
||||||
<!-- android:exported="true" />-->
|
|
||||||
<!-- <!– MQTT START –>-->
|
|
||||||
<!-- <service android:exported="false"-->
|
|
||||||
<!-- android:process=":xg_vip_service"-->
|
|
||||||
<!-- android:name="com.tencent.tpns.mqttchannel.services.MqttService" />-->
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <provider-->
|
|
||||||
<!-- android:exported="false"-->
|
|
||||||
<!-- android:name="com.tencent.tpns.baseapi.base.SettingsContentProvider"-->
|
|
||||||
<!-- android:authorities="com.navinfo.outdoor.XG_SETTINGS_PROVIDER" />-->
|
|
||||||
<!-- <!– MQTT END–>-->
|
|
||||||
|
|
||||||
<!-- 【可选】APP实现的Receiver,用于接收消息透传和操作结果的回调,请根据需要添加 -->
|
|
||||||
<!-- YOUR_PACKAGE_PATH.CustomPushReceiver需要改为自己的Receiver: -->
|
|
||||||
<receiver android:name="com.navinfo.outdoor.receiver.MessageReceiver"
|
|
||||||
android:exported="false">
|
|
||||||
<intent-filter>
|
|
||||||
<!-- 接收消息透传 -->
|
|
||||||
<action android:name="com.tencent.android.xg.vip.action.PUSH_MESSAGE" />
|
|
||||||
<!-- 监听注册、反注册、设置/删除标签、通知被点击等处理结果 -->
|
|
||||||
<action android:name="com.tencent.android.xg.vip.action.FEEDBACK" />
|
|
||||||
</intent-filter>
|
|
||||||
</receiver>
|
|
||||||
|
|
||||||
<!-- 【必须】 请修改为 APP 的 AccessId,“15”开头的10位数字,中间没空格 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="XG_V2_ACCESS_ID"
|
|
||||||
android:value="1580017520" />
|
|
||||||
<!-- 【必须】 请修改为APP的AccessKey,“A”开头的12位字符串,中间没空格 -->
|
|
||||||
<meta-data
|
|
||||||
android:name="XG_V2_ACCESS_KEY"
|
|
||||||
android:value="ABQZ9Z3PDWXM" />
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
File diff suppressed because it is too large
Load Diff
-1990
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,13 +1,10 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
package com.navinfo.outdoor.activity;
|
||||||
|
|
||||||
import com.elvishew.xlog.XLog;
|
|
||||||
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;
|
||||||
@@ -18,40 +15,28 @@ import com.navinfo.outdoor.fragment.RecordFragment;
|
|||||||
import com.navinfo.outdoor.fragment.TreasureFragment;
|
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.service.ForegroundCoreService;
|
|
||||||
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.NoSlideViewPager;
|
import com.navinfo.outdoor.util.NoSlideViewPager;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
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;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
|
||||||
import android.content.pm.PackageInfo;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
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;
|
||||||
import com.google.android.material.tabs.TabLayout;
|
import com.google.android.material.tabs.TabLayout;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.navinfo.outdoor.util.WhiteListHelper;
|
import com.umeng.message.PushAgent;
|
||||||
import com.teprinciple.mailsender.Mail;
|
|
||||||
import com.teprinciple.mailsender.MailSender;
|
|
||||||
import com.umeng.message.UmengNotificationClickHandler;
|
import com.umeng.message.UmengNotificationClickHandler;
|
||||||
import com.umeng.message.entity.UMessage;
|
import com.umeng.message.entity.UMessage;
|
||||||
|
|
||||||
@@ -59,23 +44,10 @@ import org.greenrobot.eventbus.EventBus;
|
|||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
|
||||||
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.Consumer;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 首页
|
* 首页
|
||||||
* tabLayout + viewPager
|
* tabLayout + viewPager
|
||||||
@@ -85,18 +57,16 @@ public class HomeActivity extends BaseActivity {
|
|||||||
private final String[] names = {"寻宝", "记录", "发现", "我的"};
|
private final String[] names = {"寻宝", "记录", "发现", "我的"};
|
||||||
private final int[] pic = {R.drawable.selector_map, R.drawable.selector_task, R.drawable.selector_article, R.drawable.selector_mine};
|
private final int[] pic = {R.drawable.selector_map, R.drawable.selector_task, R.drawable.selector_article, R.drawable.selector_mine};
|
||||||
private boolean isBack = false;
|
private boolean isBack = false;
|
||||||
private WhiteListHelper whiteListHelper;
|
|
||||||
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) {
|
||||||
if (msg.what == 0x100) {
|
if (msg.what == 0x100) {
|
||||||
isBack = false;
|
isBack = false;
|
||||||
} else if (msg.what == 0x101) {
|
|
||||||
checkMockLocation();
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayout() {
|
protected int getLayout() {
|
||||||
return R.layout.activity_home;
|
return R.layout.activity_home;
|
||||||
@@ -105,38 +75,13 @@ 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()));
|
|
||||||
Log.d("HomeActivity", "作弊检查:"+result);
|
|
||||||
|
|
||||||
// 注册位置更新的lifeCycle
|
|
||||||
getLifecycle().addObserver(LocationLifeCycle.getInstance());
|
|
||||||
// 初始化图像识别组件
|
|
||||||
OCRManager.Companion.getInstance().init(HomeActivity.this);
|
|
||||||
// // 开始申请后台运行的权限
|
|
||||||
// boolean isOpenBatteryPermission = BatteryPermissionHelper.Companion.getInstance().isBatterySaverPermissionAvailable(HomeActivity.this, true);
|
|
||||||
// if (!isOpenBatteryPermission) {
|
|
||||||
// boolean batteryPermission = BatteryPermissionHelper.Companion.getInstance().getPermission(HomeActivity.this, true, true);
|
|
||||||
// System.out.println("batteryPermission:"+batteryPermission);
|
|
||||||
// }
|
|
||||||
whiteListHelper = new WhiteListHelper();
|
|
||||||
if (!whiteListHelper.isIgnoringBatteryOptimizations(HomeActivity.this)) {
|
|
||||||
whiteListHelper.requestIgnoreBatteryOptimizations(HomeActivity.this);
|
|
||||||
} else {
|
|
||||||
String phoneBrand = whiteListHelper.checkPhoneFirm();
|
|
||||||
}
|
|
||||||
// 开启前台服务
|
|
||||||
startService(new Intent(getApplicationContext(), ForegroundCoreService.class));
|
|
||||||
} else {
|
} else {
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
@@ -149,46 +94,6 @@ public class HomeActivity extends BaseActivity {
|
|||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
initUM();
|
initUM();
|
||||||
// Toast.makeText(this, "作弊检查:"+result, Toast.LENGTH_SHORT).show();
|
|
||||||
// 检查是否存在新的推荐任务,如果存在,则显示推荐任务按钮
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onNewIntent(Intent intent) {
|
|
||||||
super.onNewIntent(intent);
|
|
||||||
if (intent != null) {
|
|
||||||
String intentFrom = intent.getStringExtra(Constant.NOTIFYCATION_INTENT_FROM);
|
|
||||||
if (intentFrom != null){
|
|
||||||
if (intentFrom.equals("recommandTask")) {
|
|
||||||
// 从notifycation跳转过来的
|
|
||||||
// 获取要跳转的定位点位和zoom,自动跳转到该位置后刷新地图界面
|
|
||||||
String geom = intent.getStringExtra(Constant.NOTIFYCATION_TASK_GEOM);
|
|
||||||
int zoom = intent.getIntExtra(Constant.NOTIFYCATION_TASK_ZOOM, 17);
|
|
||||||
if (geom != null && zoom > 0) {
|
|
||||||
if (mTab.getSelectedTabPosition()!=0) {
|
|
||||||
mTab.getTabAt(0).select(); // 默认选中第一个选项
|
|
||||||
}
|
|
||||||
// 地图定位到指定位置,发送Event
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("geom", geom);
|
|
||||||
map.put("zoom", zoom);
|
|
||||||
Message msg = Message.obtain();
|
|
||||||
msg.obj = map;
|
|
||||||
msg.what = Constant.EVENT_WHAT_NOTIFYCATION_RECOMMAND_TASK;
|
|
||||||
EventBus.getDefault().post(msg);
|
|
||||||
}
|
|
||||||
} else if (intentFrom.equals("normalNotification")) {
|
|
||||||
String title = intent.getStringExtra(Constant.NOTIFYCATION_TITLE);
|
|
||||||
String content = intent.getStringExtra(Constant.NOTIFYCATION_CONTENT);
|
|
||||||
if (title != null && content != null) {
|
|
||||||
// 显示对话框
|
|
||||||
MessageDialog.show(HomeActivity.this, title, content, "确定")
|
|
||||||
.setCancelable(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initUM() {
|
private void initUM() {
|
||||||
@@ -232,7 +137,7 @@ public class HomeActivity extends BaseActivity {
|
|||||||
Log.i("TAGEE", "click dismissNotification: " + msg.getRaw().toString());
|
Log.i("TAGEE", "click dismissNotification: " + msg.getRaw().toString());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
// UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -280,14 +185,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.SWITCH_RECORFER_ITEM; // 发送消息给Recorder界面,根据子tab的选项请求数据
|
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||||
|
obtain.obj = true;
|
||||||
EventBus.getDefault().post(obtain);
|
EventBus.getDefault().post(obtain);
|
||||||
|
|
||||||
// 待提交页面暂时不需要获取,当用户在记录tab下点击已提交后,再去请求 #2023-0216
|
Message obtain1 = Message.obtain();
|
||||||
// Message obtain1 = Message.obtain();
|
obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||||
// obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
obtain1.obj = true;
|
||||||
// obtain1.obj = true;
|
EventBus.getDefault().post(obtain1);
|
||||||
// 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;
|
||||||
@@ -364,224 +269,6 @@ public class HomeActivity extends BaseActivity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查是否为模拟定位
|
|
||||||
* */
|
|
||||||
private void checkMockLocation() {
|
|
||||||
Log.d("HomeActivity", "checkMockLocation开始:");
|
|
||||||
Observable.create(new ObservableOnSubscribe<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void subscribe(ObservableEmitter<Map<String, Boolean>> emitter) throws Exception {
|
|
||||||
emitter.onNext(new HashMap<>());
|
|
||||||
emitter.onComplete();
|
|
||||||
}
|
|
||||||
}).subscribeOn(AndroidSchedulers.mainThread())
|
|
||||||
.observeOn(Schedulers.computation())
|
|
||||||
.doOnNext(new Consumer<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
|
|
||||||
if (isInstallVirtual(HomeActivity.this)) {
|
|
||||||
stringBooleanMap.put("安装有虚拟定位软件", true);
|
|
||||||
}else {
|
|
||||||
Log.d("HomeActivity", "不安装有虚拟定位软件:");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).doOnNext(new Consumer<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
|
|
||||||
if (isOpenMockLocationSetting()) {
|
|
||||||
stringBooleanMap.put("打开了虚拟定位设置", true);
|
|
||||||
}else {
|
|
||||||
Log.d("HomeActivity", "不打开了虚拟定位设置:");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).doOnNext(new Consumer<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
|
|
||||||
if (isRunInVirtual()) {
|
|
||||||
stringBooleanMap.put("程序运行在虚拟环境中", true);
|
|
||||||
}else {
|
|
||||||
Log.d("HomeActivity", "不程序运行在虚拟环境中:");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).doOnNext(new Consumer<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
|
|
||||||
if (checkPkg(HomeActivity.this)) {
|
|
||||||
stringBooleanMap.put("存在应用双开", true);
|
|
||||||
} else {
|
|
||||||
Log.d("HomeActivity", "不存在应用双开:");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Consumer<Map<String, Boolean>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map<String, Boolean> stringBooleanMap) throws Exception {
|
|
||||||
Log.d("HomeActivity", "checkMockLocation结果:"+stringBooleanMap.isEmpty());
|
|
||||||
if (!stringBooleanMap.isEmpty()) {
|
|
||||||
Constant.mockGPSMap = stringBooleanMap;
|
|
||||||
StringBuilder stringBuilder = new StringBuilder("检查到疑似存在以下违规行为:\n");
|
|
||||||
for (String key: stringBooleanMap.keySet()
|
|
||||||
) {
|
|
||||||
stringBuilder.append(key).append("\n");
|
|
||||||
}
|
|
||||||
stringBuilder.append("请及时修正,否则可能会影响到您的收益,如有疑问可联系管理员!");
|
|
||||||
|
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
|
||||||
DialogSettings.cancelable = false;
|
|
||||||
MessageDialog.show(HomeActivity.this, "提示", stringBuilder, "确定").setOkButton(new OnDialogButtonClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
|
||||||
// 将违规行为通知给运营人员
|
|
||||||
// 创建邮箱
|
|
||||||
Mail mail = new Mail();
|
|
||||||
mail.setMailServerHost("smtp.163.com");
|
|
||||||
mail.setMailServerPort("25");
|
|
||||||
mail.setFromAddress("xiaoyan159@163.com");
|
|
||||||
mail.setPassword("YGPSXLMRPMADRHPS");
|
|
||||||
ArrayList<String> toAddressList = new ArrayList<>();
|
|
||||||
toAddressList.add("xiaoyan159@qq.com");
|
|
||||||
toAddressList.add("huangjichao@navinfo.com");
|
|
||||||
toAddressList.add("HanFei1100@navinfo.com");
|
|
||||||
mail.setToAddress(toAddressList);
|
|
||||||
mail.setSubject("疑似违规记录");
|
|
||||||
mail.setContent(stringBuilder.append("用户名:").append(Constant.USER_NAME).append("\n")
|
|
||||||
.append("身份证号:").append(Constant.ID_NUMBER).append("\n")
|
|
||||||
.append("姓名:").append(Constant.NAME).append("\n")
|
|
||||||
.append("手机号:").append(Constant.MOBILE).toString());
|
|
||||||
// mail.attachFiles = arrayListOf(file);
|
|
||||||
|
|
||||||
// 发送邮箱
|
|
||||||
MailSender.getInstance().sendMail(mail, new MailSender.OnMailSendListener() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess() {
|
|
||||||
// 发送成功,无需再报告
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable throwable) {
|
|
||||||
handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random()));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
baseDialog.doDismiss();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isInstallVirtual(Context context) {
|
|
||||||
Map<String, String> packageNames = getVirtualPackageNames();
|
|
||||||
PackageManager packageManager = context.getPackageManager();
|
|
||||||
List<PackageInfo> pinfo = packageManager.getInstalledPackages(0);
|
|
||||||
for (int i = 0; i < pinfo.size(); i++) {
|
|
||||||
if (packageNames.get(pinfo.get(i).packageName) != null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, String> getVirtualPackageNames() {
|
|
||||||
Map<String, String> packageNames = new HashMap<>();
|
|
||||||
packageNames.put("com.lerist.fakelocation", "com.lerist.fakelocation");// Fake-location虚拟定位
|
|
||||||
packageNames.put("top.a1024bytes.mockloc.ca.pro", "top.a1024bytes.mockloc.ca.pro");// 天下任我行
|
|
||||||
packageNames.put("com.qgwapp.shadowside", "com.qgwapp.shadowside");// 任我行免ROOT
|
|
||||||
packageNames.put("net.superal", "net.superal");// 超级神行者
|
|
||||||
packageNames.put("com.deniu.daniu", "com.deniu.daniu");// 大牛
|
|
||||||
packageNames.put("com.deniu.multi", "com.deniu.multi");// 大牛助手
|
|
||||||
packageNames.put("com.txy.anywhere", "com.txy.anywhere");// 天下游
|
|
||||||
packageNames.put("de.robv.android.xposed.installer", "de.robv.android.xposed.installer");// Xposed
|
|
||||||
packageNames.put("github.tornaco.xposedmoduletest", "github.tornaco.xposedmoduletest");// 应用管理Xposed
|
|
||||||
return packageNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 是否开启虚拟定位设置
|
|
||||||
* */
|
|
||||||
private boolean isOpenMockLocationSetting() {
|
|
||||||
return Settings.Secure.getInt(getContentResolver(),Settings.Secure.ALLOW_MOCK_LOCATION, 0) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isRunInVirtual() {
|
|
||||||
// 获取当前应用的uid
|
|
||||||
String filter = getUid(this);
|
|
||||||
ShellUtils.CommandResult commandResult = ShellUtils.execCommand("ps", false);
|
|
||||||
Log.d("HomeActivity: commandResult", commandResult.errorMsg+":::"+commandResult.successMsg+":::"+commandResult.result);
|
|
||||||
if (commandResult==null&&commandResult.successMsg==null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String result = commandResult.successMsg;
|
|
||||||
if (result == null || result.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String[] lines = result.split("\n");
|
|
||||||
if (lines == null || lines.length <= 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int exitDirCount = 0;
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
|
||||||
if (lines[i].contains(filter)) {
|
|
||||||
int pkgStartIndex = lines[i].lastIndexOf(" ");
|
|
||||||
String processName = lines[i].substring(pkgStartIndex <= 0
|
|
||||||
? 0 : pkgStartIndex + 1, lines[i].length());
|
|
||||||
File dataFile = new File(String.format("/data/data/%s",
|
|
||||||
processName, Locale.CHINA));
|
|
||||||
if (dataFile.exists()) {
|
|
||||||
exitDirCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return exitDirCount > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 应用列表检查,防止应用多开
|
|
||||||
* */
|
|
||||||
private boolean checkPkg(Context context) {
|
|
||||||
try {
|
|
||||||
if (context == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
int count = 0;
|
|
||||||
String packageName = context.getPackageName();
|
|
||||||
PackageManager pm = context.getPackageManager();
|
|
||||||
List<PackageInfo> pkgs = pm.getInstalledPackages(0);
|
|
||||||
for (PackageInfo info : pkgs) {
|
|
||||||
if (packageName.equals(info.packageName)) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count > 1;
|
|
||||||
} catch (Exception ignore) {}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getCurrentTabSelected() {
|
|
||||||
if (mTab!=null) {
|
|
||||||
return mTab.getSelectedTabPosition();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getUid(Context context) {
|
|
||||||
String uid = "";
|
|
||||||
try {
|
|
||||||
PackageManager pm = context.getPackageManager();
|
|
||||||
ApplicationInfo ai = pm.getApplicationInfo("com.navinfo.outdoor", PackageManager.GET_META_DATA);
|
|
||||||
uid = String.valueOf(ai.uid);
|
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return uid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBackPressed() {
|
public void onBackPressed() {
|
||||||
if (!BackHandlerHelper.handleBackPress(this)) {
|
if (!BackHandlerHelper.handleBackPress(this)) {
|
||||||
@@ -601,8 +288,5 @@ public class HomeActivity extends BaseActivity {
|
|||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
PoiDatabase.destroy();
|
PoiDatabase.destroy();
|
||||||
// 清空登录信息
|
|
||||||
Constant.clearLoginInfo();
|
|
||||||
getLifecycle().removeObserver(LocationLifeCycle.getInstance());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,6 @@ import android.widget.Toast;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.github.lazylibrary.util.AppUtils;
|
|
||||||
import com.github.lazylibrary.util.FileUtils;
|
import com.github.lazylibrary.util.FileUtils;
|
||||||
import com.lzy.okgo.model.HttpParams;
|
import com.lzy.okgo.model.HttpParams;
|
||||||
import com.lzy.okgo.model.Progress;
|
import com.lzy.okgo.model.Progress;
|
||||||
@@ -33,10 +32,10 @@ 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.http.UploadCallBack;
|
import com.navinfo.outdoor.http.UploadCallBack;
|
||||||
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;
|
||||||
|
|
||||||
@@ -126,7 +125,7 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
navInfoEditor = navInfo.edit();
|
navInfoEditor = navInfo.edit();
|
||||||
TextView tvRegister = findViewById(R.id.tv_register);
|
TextView tvRegister = findViewById(R.id.tv_register);
|
||||||
TextView tvView = findViewById(R.id.tv_view);
|
TextView tvView = findViewById(R.id.tv_view);
|
||||||
tvView.setText("版本号:"+AppUtils.getVerName(this));
|
tvView.setText(Constant.NAVIN_FO);
|
||||||
etLoginName = findViewById(R.id.et_login_name);
|
etLoginName = findViewById(R.id.et_login_name);
|
||||||
etLoginPaw = findViewById(R.id.et_login_paw);
|
etLoginPaw = findViewById(R.id.et_login_paw);
|
||||||
TextView tvForgetPaw = findViewById(R.id.tv_forget_paw);
|
TextView tvForgetPaw = findViewById(R.id.tv_forget_paw);
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ 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;
|
||||||
@@ -23,18 +19,7 @@ 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.hjq.permissions.OnPermissionCallback;
|
import com.hjq.permissions.OnPermissionCallback;
|
||||||
import com.hjq.permissions.Permission;
|
import com.hjq.permissions.Permission;
|
||||||
import com.hjq.permissions.XXPermissions;
|
import com.hjq.permissions.XXPermissions;
|
||||||
@@ -45,7 +30,6 @@ 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;
|
||||||
@@ -56,7 +40,9 @@ 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.LocationLifeCycle;
|
import com.navinfo.outdoor.util.Base64;
|
||||||
|
import com.navinfo.outdoor.util.Md5Util;
|
||||||
|
import com.navinfo.outdoor.util.ToastUtil;
|
||||||
import com.navinfo.outdoor.util.ToastUtils;
|
import com.navinfo.outdoor.util.ToastUtils;
|
||||||
|
|
||||||
|
|
||||||
@@ -73,6 +59,7 @@ 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) {
|
||||||
@@ -127,13 +114,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)
|
||||||
//读写权限
|
//读写权限
|
||||||
@@ -142,34 +129,11 @@ 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();
|
||||||
@@ -529,6 +493,5 @@ public class MainActivity extends BaseActivity {
|
|||||||
Constant.REFRESH_TOKEN = navInfo.getString("refresh_token", null);
|
Constant.REFRESH_TOKEN = navInfo.getString("refresh_token", null);
|
||||||
Constant.ACCESS_TOKEN = navInfo.getString("access_token", null);
|
Constant.ACCESS_TOKEN = navInfo.getString("access_token", null);
|
||||||
initPermission();
|
initPermission();
|
||||||
((TextView)findViewById(R.id.tv_view)).setText("版本号:"+ AppUtils.getVerName(this));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
|
||||||
|
|
||||||
public class MyCoordinate {
|
|
||||||
private double x;
|
|
||||||
private double Y;
|
|
||||||
|
|
||||||
public MyCoordinate() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyCoordinate(double x, double y) {
|
|
||||||
this.x = x;
|
|
||||||
Y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setX(double x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getY() {
|
|
||||||
return Y;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setY(double y) {
|
|
||||||
Y = y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
|
||||||
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.api.Constant;
|
|
||||||
import com.navinfo.outdoor.base.BaseActivity;
|
|
||||||
import com.navinfo.outdoor.base.NaviLifeCycle;
|
|
||||||
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.car.CarNaviView;
|
|
||||||
import com.tencent.map.navi.data.NaviPoi;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|
||||||
|
|
||||||
public class NaviCarActivity extends BaseActivity {
|
|
||||||
private CarNaviView carNaviView;
|
|
||||||
private LifecycleObserver lifecycleObserver;
|
|
||||||
private NaviCarViewModel naviCarViewModel;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getLayout() {
|
|
||||||
return R.layout.activity_navi_car;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initView() {
|
|
||||||
super.initView();
|
|
||||||
carNaviView = findViewById(R.id.carnaviview);
|
|
||||||
lifecycleObserver = new NaviLifeCycle(carNaviView);
|
|
||||||
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);
|
|
||||||
if (naviCarViewModel.getNaviManager() == null) {
|
|
||||||
naviCarViewModel.setNaviManager(naviManager);
|
|
||||||
} else {
|
|
||||||
naviCarViewModel.getNaviManager().addNaviView(carNaviView);
|
|
||||||
}
|
|
||||||
// 获取起终点
|
|
||||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
|
||||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
|
||||||
try {
|
|
||||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
getLifecycle().removeObserver(lifecycleObserver);
|
|
||||||
// 如果当前正在导航,自动停止
|
|
||||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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,62 +0,0 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.base.BaseActivity;
|
|
||||||
import com.navinfo.outdoor.base.NaviLifeCycle;
|
|
||||||
import com.navinfo.outdoor.util.NaviUtils;
|
|
||||||
import com.tencent.map.navi.TencentNaviManager;
|
|
||||||
import com.tencent.map.navi.car.CarNaviView;
|
|
||||||
import com.tencent.map.navi.data.NaviPoi;
|
|
||||||
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;
|
|
||||||
|
|
||||||
public class NaviRideActivity extends BaseActivity {
|
|
||||||
private RideNaviView rideNaviView;
|
|
||||||
private LifecycleObserver lifecycleObserver;
|
|
||||||
private NaviCarViewModel naviCarViewModel;
|
|
||||||
@Override
|
|
||||||
protected int getLayout() {
|
|
||||||
return R.layout.activity_navi_ride;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initView() {
|
|
||||||
super.initView();
|
|
||||||
rideNaviView = findViewById(R.id.ridenaviview);
|
|
||||||
lifecycleObserver = new NaviLifeCycle(rideNaviView);
|
|
||||||
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);
|
|
||||||
if (naviCarViewModel.getNaviManager() == null) {
|
|
||||||
naviCarViewModel.setNaviManager(naviManager);
|
|
||||||
} else {
|
|
||||||
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(rideNaviView);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取起终点
|
|
||||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
|
||||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
|
||||||
try {
|
|
||||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
getLifecycle().removeObserver(lifecycleObserver);
|
|
||||||
// 如果当前正在导航,自动停止
|
|
||||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
|
||||||
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(rideNaviView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
|
||||||
|
|
||||||
import androidx.lifecycle.LifecycleObserver;
|
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.base.BaseActivity;
|
|
||||||
import com.navinfo.outdoor.base.NaviLifeCycle;
|
|
||||||
import com.navinfo.outdoor.util.NaviUtils;
|
|
||||||
import com.tencent.map.navi.TencentNaviManager;
|
|
||||||
import com.tencent.map.navi.data.NaviPoi;
|
|
||||||
import com.tencent.map.navi.ride.RideNaviView;
|
|
||||||
import com.tencent.map.navi.walk.TencentWalkNaviManager;
|
|
||||||
import com.tencent.map.navi.walk.WalkNaviView;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|
||||||
|
|
||||||
public class NaviWalkActivity extends BaseActivity {
|
|
||||||
private WalkNaviView walkNaviView;
|
|
||||||
private LifecycleObserver lifecycleObserver;
|
|
||||||
private NaviCarViewModel naviCarViewModel;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getLayout() {
|
|
||||||
return R.layout.activity_navi_walk;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initView() {
|
|
||||||
super.initView();
|
|
||||||
walkNaviView = findViewById(R.id.walknaviview);
|
|
||||||
lifecycleObserver = new NaviLifeCycle(walkNaviView);
|
|
||||||
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);
|
|
||||||
if (naviCarViewModel.getNaviManager() == null) {
|
|
||||||
naviCarViewModel.setNaviManager(naviManager);
|
|
||||||
} else {
|
|
||||||
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).addTencentNaviListener(walkNaviView);
|
|
||||||
}
|
|
||||||
// 获取起终点
|
|
||||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
|
||||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
|
||||||
try {
|
|
||||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
getLifecycle().removeObserver(lifecycleObserver);
|
|
||||||
// 如果当前正在导航,自动停止
|
|
||||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
|
||||||
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(walkNaviView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
|
||||||
|
|
||||||
import com.lzy.okgo.OkGo;
|
|
||||||
import com.lzy.okgo.adapter.AdapterParam;
|
|
||||||
import com.lzy.okgo.adapter.Call;
|
|
||||||
import com.lzy.okgo.adapter.CallAdapter;
|
|
||||||
import com.lzy.okgo.convert.StringConvert;
|
|
||||||
import com.lzy.okgo.model.Response;
|
|
||||||
import com.lzy.okgo.request.GetRequest;
|
|
||||||
import com.lzy.okgo.request.PostRequest;
|
|
||||||
import com.lzy.okrx2.adapter.ObservableBody;
|
|
||||||
import com.lzy.okrx2.adapter.ObservableResponse;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.reactivex.Flowable;
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
public class OkHttpUtils {
|
|
||||||
private static OkHttpUtils instance;
|
|
||||||
|
|
||||||
public static OkHttpUtils getInstance() {
|
|
||||||
if (instance==null) {
|
|
||||||
instance = new OkHttpUtils();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T>Observable<Response<T>> obtainOkGet(String url, Object tag, Map<String, String> params) {
|
|
||||||
GetRequest<T> getRequest = OkGo.getInstance().<T>get(url).tag(tag);
|
|
||||||
if (params!=null&&!params.isEmpty()) {
|
|
||||||
getRequest.params(params, true);
|
|
||||||
}
|
|
||||||
return getRequest.adapt(new ObservableResponse<T>());
|
|
||||||
}
|
|
||||||
|
|
||||||
public <T>Observable<Response<T>> obtainOkPost(String url, Object tag, Map<String, String> params) {
|
|
||||||
PostRequest<T> postRequest = OkGo.getInstance().<T>post(url).tag(tag);
|
|
||||||
if (params!=null&&!params.isEmpty()) {
|
|
||||||
postRequest.params(params, true);
|
|
||||||
}
|
|
||||||
return postRequest.adapt(new ObservableResponse<T>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -35,7 +35,7 @@ import com.otaliastudios.cameraview.CameraView;
|
|||||||
import com.otaliastudios.cameraview.FileCallback;
|
import com.otaliastudios.cameraview.FileCallback;
|
||||||
import com.otaliastudios.cameraview.PictureResult;
|
import com.otaliastudios.cameraview.PictureResult;
|
||||||
import com.otaliastudios.cameraview.controls.Mode;
|
import com.otaliastudios.cameraview.controls.Mode;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import com.wanghong.webpnative.WebPNative;
|
import com.wanghong.webpnative.WebPNative;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
@@ -109,7 +109,7 @@ public class PhotographActivity extends BaseActivity implements View.OnClickL
|
|||||||
if (getIntent() != null) {
|
if (getIntent() != null) {
|
||||||
photo_path = getIntent().getStringExtra(Constant.INTENT_PHOTO_PATH);
|
photo_path = getIntent().getStringExtra(Constant.INTENT_PHOTO_PATH);
|
||||||
}
|
}
|
||||||
// this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||||
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
|
CameraLogger.setLogLevel(CameraLogger.LEVEL_VERBOSE);
|
||||||
cameraView = findViewById(R.id.camera);
|
cameraView = findViewById(R.id.camera);
|
||||||
cameraView.setOnClickListener(this);
|
cameraView.setOnClickListener(this);
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ 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;
|
||||||
@@ -62,7 +61,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
import com.tencent.tencentmap.mapsdk.maps.model.MyLocationStyle;
|
||||||
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 org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -477,10 +476,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 (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
if (Constant.currentLocation != null) {
|
||||||
CameraUpdate cameraSigma =
|
CameraUpdate cameraSigma =
|
||||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||||
new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), //中心点坐标,地图目标经纬度
|
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.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)
|
||||||
@@ -681,21 +680,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)
|
tencentLocation.getBearing())); //目标旋转角 0~360° (正北方为0)
|
||||||
// tencentMap.animateCamera(cameraSigma);
|
tencentMap.animateCamera(cameraSigma);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 记录视频拍摄的时间及经纬度
|
* 记录视频拍摄的时间及经纬度
|
||||||
@@ -723,17 +722,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(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
|
sb.append(Constant.currentLocation.getLatitude());
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
|
sb.append(Constant.currentLocation.getLongitude());
|
||||||
sb.append(",");
|
sb.append(",");
|
||||||
if (LocationLifeCycle.getInstance().getTencentLocation().getBearing() != 0) {
|
if (Constant.currentLocation.getBearing() != 0) {
|
||||||
sb.append(LocationLifeCycle.getInstance().getMainLocation().getBearing());
|
sb.append(Constant.currentLocation.getBearing());
|
||||||
} else {
|
} else {
|
||||||
sb.append(LocationLifeCycle.getInstance().getTencentLocation().getDirection());
|
sb.append(Constant.currentLocation.getDirection());
|
||||||
}
|
}
|
||||||
sb.append("\r\n");
|
sb.append("\r\n");
|
||||||
LatLng latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
|
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.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
@@ -1,15 +1,12 @@
|
|||||||
package com.navinfo.outdoor.activity;
|
package com.navinfo.outdoor.activity;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.CountDownTimer;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
@@ -25,10 +22,7 @@ import com.github.lazylibrary.util.FileUtils;
|
|||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
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.interfaces.OnShowListener;
|
|
||||||
import com.kongzue.dialog.util.BaseDialog;
|
import com.kongzue.dialog.util.BaseDialog;
|
||||||
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.lzy.okgo.model.HttpParams;
|
import com.lzy.okgo.model.HttpParams;
|
||||||
import com.lzy.okgo.model.Progress;
|
import com.lzy.okgo.model.Progress;
|
||||||
@@ -37,7 +31,6 @@ import com.navinfo.outdoor.api.Constant;
|
|||||||
import com.navinfo.outdoor.base.BaseActivity;
|
import com.navinfo.outdoor.base.BaseActivity;
|
||||||
import com.navinfo.outdoor.bean.CityBean;
|
import com.navinfo.outdoor.bean.CityBean;
|
||||||
import com.navinfo.outdoor.bean.JsonBean;
|
import com.navinfo.outdoor.bean.JsonBean;
|
||||||
import com.navinfo.outdoor.bean.MessageCodeBean;
|
|
||||||
import com.navinfo.outdoor.bean.UserBean;
|
import com.navinfo.outdoor.bean.UserBean;
|
||||||
import com.navinfo.outdoor.http.Callback;
|
import com.navinfo.outdoor.http.Callback;
|
||||||
import com.navinfo.outdoor.http.HttpInterface;
|
import com.navinfo.outdoor.http.HttpInterface;
|
||||||
@@ -56,9 +49,7 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -77,9 +68,6 @@ public class UserActivity extends BaseActivity implements View.OnClickListener {
|
|||||||
private StringBuilder userBuilder;
|
private StringBuilder userBuilder;
|
||||||
private String region_text;
|
private String region_text;
|
||||||
private SharedPreferences spNavinfo;
|
private SharedPreferences spNavinfo;
|
||||||
private Button btnPhoneEdit;
|
|
||||||
private String sessionId, updatePhone;
|
|
||||||
private CountDownTimer timer;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getLayout() {
|
protected int getLayout() {
|
||||||
@@ -136,8 +124,6 @@ public class UserActivity extends BaseActivity implements View.OnClickListener {
|
|||||||
etPhone = findViewById(R.id.et_phone);
|
etPhone = findViewById(R.id.et_phone);
|
||||||
etPhone.setEnabled(false);
|
etPhone.setEnabled(false);
|
||||||
etPhone.setOnClickListener(this);
|
etPhone.setOnClickListener(this);
|
||||||
btnPhoneEdit = findViewById(R.id.btn_phone_edit);
|
|
||||||
btnPhoneEdit.setOnClickListener(this);
|
|
||||||
etQq = findViewById(R.id.edit_qq);
|
etQq = findViewById(R.id.edit_qq);
|
||||||
etQq.setOnClickListener(this);
|
etQq.setOnClickListener(this);
|
||||||
etMailbox = findViewById(R.id.edit_mailbox);
|
etMailbox = findViewById(R.id.edit_mailbox);
|
||||||
@@ -183,6 +169,16 @@ public class UserActivity extends BaseActivity implements View.OnClickListener {
|
|||||||
Intent gatheringIntent = new Intent(this, FragmentManagement.class);
|
Intent gatheringIntent = new Intent(this, FragmentManagement.class);
|
||||||
gatheringIntent.putExtra("tag", 24);
|
gatheringIntent.putExtra("tag", 24);
|
||||||
startActivity(gatheringIntent);
|
startActivity(gatheringIntent);
|
||||||
|
|
||||||
|
/* if (Constant.AUDIOTAPES == -1) {
|
||||||
|
ToastUtils.Message(UserActivity.this,"请先实名认证");
|
||||||
|
} else if (Constant.AUDIOTAPES == 1) {//认证通过
|
||||||
|
Intent gatheringIntent = new Intent(this, FragmentManagement.class);
|
||||||
|
gatheringIntent.putExtra("tag", 24);
|
||||||
|
startActivity(gatheringIntent);
|
||||||
|
} else if (Constant.AUDIOTAPES == 0) {
|
||||||
|
ToastUtils.Message(this,Constant.AUDITING + "");
|
||||||
|
}*/
|
||||||
break;
|
break;
|
||||||
case R.id.btn_attestations:
|
case R.id.btn_attestations:
|
||||||
userBuilder.append(TimestampUtil.time()).append(",").append("点击了去认证的返回 ,");
|
userBuilder.append(TimestampUtil.time()).append(",").append("点击了去认证的返回 ,");
|
||||||
@@ -208,192 +204,9 @@ public class UserActivity extends BaseActivity implements View.OnClickListener {
|
|||||||
userBuilder.append(TimestampUtil.time()).append(",").append("点击了微信 去提交的按钮 ,");
|
userBuilder.append(TimestampUtil.time()).append(",").append("点击了微信 去提交的按钮 ,");
|
||||||
ToastUtils.Message(UserActivity.this,"此功能未开通");
|
ToastUtils.Message(UserActivity.this,"此功能未开通");
|
||||||
break;
|
break;
|
||||||
case R.id.btn_phone_edit:
|
|
||||||
// 用户修改手机号
|
|
||||||
View dialogRootView = LayoutInflater.from(UserActivity.this).inflate(R.layout.edit_phone, null);
|
|
||||||
MessageDialog.show(UserActivity.this, "修改手机号", "")
|
|
||||||
.setCustomView(dialogRootView)
|
|
||||||
.setOnShowListener(new OnShowListener() {
|
|
||||||
@Override
|
|
||||||
public void onShow(BaseDialog dialog) {
|
|
||||||
EditText edtPhoneNew = dialogRootView.findViewById(R.id.edt_phone_new);
|
|
||||||
EditText edtConfirmCode = dialogRootView.findViewById(R.id.edt_phone_confirm_code);
|
|
||||||
TextView btnConfirmCode = dialogRootView.findViewById(R.id.tv_confirm_code);
|
|
||||||
btnConfirmCode.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
// 获取手机验证码
|
|
||||||
EditText edtPhoneNew = dialogRootView.findViewById(R.id.edt_phone_new);
|
|
||||||
EditText edtConfirmCode = dialogRootView.findViewById(R.id.edt_phone_confirm_code);
|
|
||||||
TextView btnConfirmCode = dialogRootView.findViewById(R.id.tv_confirm_code);
|
|
||||||
String newPhone=edtPhoneNew.getText().toString();
|
|
||||||
if (checkPhoneNum(newPhone)) {
|
|
||||||
// 发送请求拉取新的验证码
|
|
||||||
getConfirmCode(UserActivity.this, newPhone, btnConfirmCode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// Button btnFinish = dialogRootView.findViewById(R.id.btn_finish);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setCancelable(true)
|
|
||||||
.setOkButton("确定", new OnDialogButtonClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
|
||||||
EditText edtPhoneNew = dialogRootView.findViewById(R.id.edt_phone_new);
|
|
||||||
EditText edtConfirmCode = dialogRootView.findViewById(R.id.edt_phone_confirm_code);
|
|
||||||
TextView btnConfirmCode = dialogRootView.findViewById(R.id.tv_confirm_code);
|
|
||||||
String newPhone=edtPhoneNew.getText().toString();
|
|
||||||
String confirmCode = edtConfirmCode.getText().toString().trim();
|
|
||||||
// 检查是否获取过验证码
|
|
||||||
if (sessionId == null) {
|
|
||||||
Toast.makeText(UserActivity.this, "请先获取验证码", Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (!checkPhoneNum(updatePhone)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (confirmCode.isEmpty()) {
|
|
||||||
Toast.makeText(UserActivity.this, "请输入验证码", Toast.LENGTH_SHORT).show();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("pid", Constant.USHERED);
|
|
||||||
httpParams.put("datetime", System.currentTimeMillis());
|
|
||||||
httpParams.put("mobile", updatePhone);
|
|
||||||
httpParams.put("sessionId", sessionId);
|
|
||||||
httpParams.put("code", confirmCode);
|
|
||||||
showLoadingDialog();
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
|
||||||
.time(30)
|
|
||||||
.Builder(UserActivity.this)
|
|
||||||
.url(HttpInterface.UPDATE_PHONE_NUM_URL)
|
|
||||||
.cls(MessageCodeBean.class)
|
|
||||||
.token(null)
|
|
||||||
.params(httpParams);
|
|
||||||
okGoBuilder.postRequest(new UploadCallBack<MessageCodeBean>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(MessageCodeBean response, int id) {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
// 手机号修改成功
|
|
||||||
ToastUtils.Message(UserActivity.this, "手机号修改成功!");
|
|
||||||
Constant.MOBILE = updatePhone;
|
|
||||||
etPhone.setText(updatePhone);
|
|
||||||
baseDialog.doDismiss();
|
|
||||||
} else {
|
|
||||||
// 手机号修改失败,提示用户
|
|
||||||
ToastUtils.Message(UserActivity.this, response.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void uploadProgress(Progress progress) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@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(UserActivity.this, "请求超时");
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(UserActivity.this, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setCancelButton("取消", new OnDialogButtonClickListener() {
|
|
||||||
@Override
|
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkPhoneNum(String newPhone) {
|
|
||||||
if (newPhone == null || newPhone.length()!=11 || !newPhone.startsWith("1")) {
|
|
||||||
Toast.makeText(UserActivity.this, "请检查手机号是否正确!", Toast.LENGTH_SHORT).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (newPhone.equals(Constant.MOBILE)) {
|
|
||||||
Toast.makeText(UserActivity.this, "与原有手机号相同!", Toast.LENGTH_SHORT).show();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void getConfirmCode(Activity context, String phone, TextView btnPhoneConfirmCode) {
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("mobile", phone);
|
|
||||||
httpParams.put("type", 3);
|
|
||||||
sessionId = null;
|
|
||||||
updatePhone = null;
|
|
||||||
showLoadingDialog();
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
|
||||||
.time(30)
|
|
||||||
.Builder(context)
|
|
||||||
.url(HttpInterface.USER_MESSAGE)
|
|
||||||
.cls(MessageCodeBean.class)
|
|
||||||
.token(null)
|
|
||||||
.params(httpParams);
|
|
||||||
okGoBuilder.getRequest(new Callback<MessageCodeBean>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(MessageCodeBean response, int id) {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
sessionId = response.getBody();
|
|
||||||
updatePhone = phone; // 记录用户获取验证码的手机号
|
|
||||||
registerNote(btnPhoneConfirmCode);
|
|
||||||
ToastUtils.Message(context, "验证码已发送");
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(context, 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(context, "请求超时");
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(context, message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerNote(TextView btnConfirm) {
|
|
||||||
if (timer != null) {
|
|
||||||
timer.cancel();
|
|
||||||
timer = null;
|
|
||||||
}
|
|
||||||
btnConfirm.setEnabled(false);
|
|
||||||
timer = new CountDownTimer(60 * 1000, 1000) {
|
|
||||||
@Override
|
|
||||||
public void onTick(long millisUntilFinished) {
|
|
||||||
btnConfirm.setText(millisUntilFinished / 1000 + "秒后重新获取验证码");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
btnConfirm.setEnabled(true);
|
|
||||||
btnConfirm.setText("重新获取");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
timer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void netWork() {
|
private void netWork() {
|
||||||
userBuilder.append(TimestampUtil.time()).append(",").append("点击了保存的按钮 ,");
|
userBuilder.append(TimestampUtil.time()).append(",").append("点击了保存的按钮 ,");
|
||||||
String userphone = etPhone.getText().toString().trim();
|
String userphone = etPhone.getText().toString().trim();
|
||||||
|
|||||||
@@ -1,241 +0,0 @@
|
|||||||
package com.navinfo.outdoor.adapter;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.ProgressBar;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.room.PoiDatabase;
|
|
||||||
import com.navinfo.outdoor.room.PoiEntity;
|
|
||||||
import com.navinfo.outdoor.util.PoiEntityDeleteUtil;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
public class HasReceiveAdapter extends RecyclerView.Adapter<HasReceiveAdapter.ViewHolder> {
|
|
||||||
private final Vector<PoiEntity> allRoad = new Vector<>();
|
|
||||||
private Context context;
|
|
||||||
|
|
||||||
public HasReceiveAdapter(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PoiEntity> getAllRoad() {
|
|
||||||
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) {
|
|
||||||
this.allRoad.clear();
|
|
||||||
this.allRoad.addAll(allRoad);
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdateWork() {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
synchronized (allRoad) {
|
|
||||||
for (PoiEntity poiEntity : allRoad) {
|
|
||||||
if (poiEntity.isChecked()) {
|
|
||||||
poiEntity.setWork_type(1);
|
|
||||||
poiEntity.setChecked(true);
|
|
||||||
} else {
|
|
||||||
poiEntity.setWork_type(0);
|
|
||||||
poiEntity.setChecked(false);
|
|
||||||
}
|
|
||||||
PoiDatabase.getInstance(context).getPoiDao().updatePoiEntity(poiEntity);
|
|
||||||
}
|
|
||||||
handler.sendEmptyMessage(0x105);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).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) {
|
|
||||||
for (PoiEntity entity : this.allRoad) {
|
|
||||||
entity.setChecked(isChecked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//条目删除
|
|
||||||
public void setAllCheckedDelete() {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
synchronized (allRoad) {
|
|
||||||
Iterator<PoiEntity> iterator = allRoad.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
PoiEntity poiEntity = (PoiEntity) iterator.next();
|
|
||||||
if (poiEntity.isChecked()) {
|
|
||||||
PoiEntityDeleteUtil.getInstance().deleteUtil(context, poiEntity);
|
|
||||||
PoiDatabase.getInstance(context).getPoiDao().deletePoiEntity(poiEntity);
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
handler.sendEmptyMessage(0x105);
|
|
||||||
}
|
|
||||||
Message obtain = Message.obtain();
|
|
||||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
|
||||||
obtain.obj = true;
|
|
||||||
EventBus.getDefault().post(obtain);
|
|
||||||
}
|
|
||||||
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
|
|
||||||
View inflate = LayoutInflater.from(context).inflate(R.layout.has_receive_item, parent, false);
|
|
||||||
return new ViewHolder(inflate);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBindViewHolder(@NotNull ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
|
||||||
PoiEntity poiEntity = allRoad.get(position);
|
|
||||||
holder.tvName.setText(poiEntity.getName());
|
|
||||||
holder.tvDay.setText(poiEntity.getCreateTime());
|
|
||||||
//获取checkBox点击的记录
|
|
||||||
holder.cbUnSubmit.setChecked(allRoad.get(position).isChecked());
|
|
||||||
holder.cbUnSubmit.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
holder.cbUnSubmit.setChecked(!poiEntity.isChecked());
|
|
||||||
poiEntity.setChecked(!poiEntity.isChecked());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (poiEntity.getWork_type() == 0) {
|
|
||||||
holder.tvText.setText("待提交");
|
|
||||||
} else if (poiEntity.getWork_type() == 1) {
|
|
||||||
holder.tvText.setText("提交中");
|
|
||||||
// poiEntity.setChecked(true);
|
|
||||||
} else if (poiEntity.getWork_type() == 2) {
|
|
||||||
holder.tvText.setText("完成");
|
|
||||||
} else if (poiEntity.getWork_type() == -1) {
|
|
||||||
holder.tvText.setText("出错");
|
|
||||||
}
|
|
||||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (onClickItem != null) {
|
|
||||||
onClickItem.item(position, poiEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// 显示进度
|
|
||||||
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
|
|
||||||
public int getItemCount() {
|
|
||||||
return allRoad.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
private TextView tvName, tvText, tvDay;
|
|
||||||
private CheckBox cbUnSubmit;
|
|
||||||
private ProgressBar pbUpload;
|
|
||||||
private TextView tvUploadProgress, tvUploadResult;
|
|
||||||
private View layerProgress;
|
|
||||||
|
|
||||||
public ViewHolder(@NonNull View itemView) {
|
|
||||||
super(itemView);
|
|
||||||
tvName = itemView.findViewById(R.id.tv_road_name);
|
|
||||||
tvText = itemView.findViewById(R.id.tv_text);
|
|
||||||
tvDay = itemView.findViewById(R.id.tv_road_day);
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Handler handler = new Handler() {
|
|
||||||
@SuppressLint("HandlerLeak")
|
|
||||||
@Override
|
|
||||||
public void handleMessage(@NonNull @NotNull Message msg) {
|
|
||||||
super.handleMessage(msg);
|
|
||||||
switch (msg.what) {
|
|
||||||
case 0x105:
|
|
||||||
notifyDataSetChanged();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public onClickItem onClickItem;
|
|
||||||
|
|
||||||
public void setOnClickItem(onClickItem onClickItem) {
|
|
||||||
this.onClickItem = onClickItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface onClickItem {
|
|
||||||
void item(int position, PoiEntity allRoad);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ 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;
|
||||||
@@ -23,7 +22,6 @@ 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;
|
||||||
@@ -40,18 +38,6 @@ 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);
|
||||||
@@ -79,26 +65,6 @@ 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) {
|
||||||
@@ -153,15 +119,20 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
|||||||
poiEntity.setChecked(!poiEntity.isChecked());
|
poiEntity.setChecked(!poiEntity.isChecked());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (poiEntity.getWork_type() == 0) {
|
if (allRoad.get(position).isChecked()) {
|
||||||
holder.tvText.setText("待提交");
|
if (poiEntity.getWork_type() == 0) {
|
||||||
} else if (poiEntity.getWork_type() == 1) {
|
holder.tvText.setText("待提交");
|
||||||
holder.tvText.setText("提交中");
|
} else if (poiEntity.getWork_type() == 1) {
|
||||||
// poiEntity.setChecked(true);
|
holder.tvText.setText("提交中");
|
||||||
} else if (poiEntity.getWork_type() == 2) {
|
allRoad.get(position).setChecked(true);
|
||||||
holder.tvText.setText("完成");
|
}
|
||||||
} else if (poiEntity.getWork_type() == -1) {
|
} else {
|
||||||
holder.tvText.setText("出错");
|
if (poiEntity.getWork_type() == 1) {
|
||||||
|
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
|
||||||
@@ -171,23 +142,6 @@ 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
|
||||||
@@ -198,9 +152,6 @@ 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);
|
||||||
@@ -208,10 +159,6 @@ 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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|||||||
import com.umeng.umcrash.UMCrash;
|
import com.umeng.umcrash.UMCrash;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 常量
|
* 常量
|
||||||
@@ -44,8 +41,6 @@ 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 String PUSH_TOKEN = null;
|
|
||||||
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;
|
||||||
@@ -152,15 +147,6 @@ 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 int EVENT_WHAT_NOTIFYCATION_RECOMMAND_TASK=66;//记录界面请求数据提醒
|
|
||||||
|
|
||||||
public static final int HAS_RECEIVE_ITEM = 67;//记录tab下的已领取子tab
|
|
||||||
public static final int EVENT_WHAT_HAS_RECEIVE_ITEM = 68;//用户点击了已领取的item数据,打开半页弹出界面
|
|
||||||
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
|
||||||
@@ -171,6 +157,7 @@ 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;
|
||||||
@@ -180,14 +167,13 @@ 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;
|
||||||
|
public static final String NAVIN_FO = "12.10";//版本日期
|
||||||
|
|
||||||
//marker
|
//marker
|
||||||
public static final BitmapDescriptor MARKER_CHARGE_SHOW = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_show);
|
public static final BitmapDescriptor MARKER_CHARGE_SHOW = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_show);
|
||||||
@@ -238,59 +224,4 @@ public class Constant {
|
|||||||
public static String REGION_YUE_PHONE = "892781071";
|
public static String REGION_YUE_PHONE = "892781071";
|
||||||
public static String REGION_YUN_NAME = "云贵-地图寻宝群";
|
public static String REGION_YUN_NAME = "云贵-地图寻宝群";
|
||||||
public static String REGION_YUN_PHONE = "284447253";
|
public static String REGION_YUN_PHONE = "284447253";
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取信号强度描述文字
|
|
||||||
* */
|
|
||||||
public static String getRssiDesStr(int rssi) {
|
|
||||||
if (rssi == 0) {
|
|
||||||
return "无信号";
|
|
||||||
} else if (rssi <= 3) {
|
|
||||||
return "弱";
|
|
||||||
} else if (rssi <= 8) {
|
|
||||||
return "中";
|
|
||||||
} else {
|
|
||||||
return "强";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Set<String> submitIdSet = new HashSet<>();
|
|
||||||
public static final String SUBMIT_TOAST_MSG= "当前POI已经在提交列表中,无需重复提交!";
|
|
||||||
public static final long DEFAULT_CUT_SIZE = 5*1024*1024; // 文件切分默认大小为5MB
|
|
||||||
public static final int DEFAULT_TIME_OUT = 300; // 默认http超时时间设置为300秒
|
|
||||||
|
|
||||||
public static void clearLoginInfo() {
|
|
||||||
ACCESS_TOKEN = null;
|
|
||||||
REFRESH_TOKEN = null;
|
|
||||||
USHERED = null;
|
|
||||||
USER_NAME = null;//登录账号/修改账号/注册
|
|
||||||
PASS_WORD = null;//登录密码/修改密码/注册密码
|
|
||||||
AUDITING = null;//身份证审核信息
|
|
||||||
AUDIOTAPES = -1;//身份证审核状态 //0:不通過,1:通過,-1:待审核
|
|
||||||
ID_NUM = null;//身份证号
|
|
||||||
NAME = null;//身份证姓名
|
|
||||||
ID_NUMBER = null;//身份证号
|
|
||||||
BACKGROUND = null;//银行卡号
|
|
||||||
BACKGROUND_NAME = null;//银行卡名称
|
|
||||||
SEX = -1;//性别
|
|
||||||
QQ = null;
|
|
||||||
WCHAR = null;
|
|
||||||
MOBILE = null;//手机号
|
|
||||||
FILE_PATH = null;//银行卡图片途径
|
|
||||||
LEVEL = 0;//用户等级
|
|
||||||
}
|
|
||||||
|
|
||||||
// 导航方式
|
|
||||||
public enum NAV_TYPE {
|
|
||||||
CAR, RIDE, WALK
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NAV_TYPE currentNaviType; // 当前的导航方式
|
|
||||||
public static boolean NAV_NEAREST_POI = false;
|
|
||||||
|
|
||||||
public static String NOTIFYCATION_INTENT_FROM = "NOTIFYCATION_INTENT_FROM";
|
|
||||||
public static String NOTIFYCATION_TASK_GEOM = "NOTIFYCATION_TASK_GEOM";
|
|
||||||
public static String NOTIFYCATION_TASK_ZOOM = "NOTIFYCATION_TASK_ZOOM";
|
|
||||||
public static String NOTIFYCATION_TITLE = "NOTIFYCATION_TITLE";
|
|
||||||
public static String NOTIFYCATION_CONTENT = "NOTIFYCATION_CONTENT";
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package com.navinfo.outdoor.api;
|
|
||||||
|
|
||||||
import android.app.Application;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
|
|
||||||
import com.github.lazylibrary.util.AppUtils;
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.xuexiang.keeplive.KeepLive;
|
|
||||||
import com.xuexiang.keeplive.config.ForegroundNotification;
|
|
||||||
import com.xuexiang.keeplive.config.ForegroundNotificationClickListener;
|
|
||||||
import com.xuexiang.keeplive.config.KeepLiveService;
|
|
||||||
|
|
||||||
public class KeepLiveUtils {
|
|
||||||
/**
|
|
||||||
* 初始化保活,配置完成后即可实现程序的保活
|
|
||||||
*/
|
|
||||||
private void initKeepLive(Application application) {
|
|
||||||
//定义前台服务的默认样式。即标题、描述和图标
|
|
||||||
ForegroundNotification notification = new ForegroundNotification("推送服务", "推送服务正在运行中...", R.mipmap.ic_launcher,
|
|
||||||
//定义前台服务的通知点击事件
|
|
||||||
new ForegroundNotificationClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onNotificationClick(Context context, Intent intent) {
|
|
||||||
//可以做一些唤醒程序的操作,这里只是简单地启动了应用
|
|
||||||
// AppUtils.launchApp(application.getPackageName());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//要想不显示通知,可以设置为false,默认是false
|
|
||||||
.setIsShow(true);
|
|
||||||
//启动保活服务
|
|
||||||
KeepLive.startWork(application, KeepLive.RunMode.ENERGY, notification,
|
|
||||||
//你需要保活的服务,如socket连接、定时任务等,建议不用匿名内部类的方式在这里写
|
|
||||||
new KeepLiveService() {
|
|
||||||
/**
|
|
||||||
* 运行中
|
|
||||||
* 由于服务可能会多次自动启动,该方法可能重复调用
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onWorking() {
|
|
||||||
//可以做一些保活的处理,比如说恢复推送连接等
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务终止
|
|
||||||
* 由于服务可能会被多次终止,该方法可能重复调用,需同onWorking配套使用,如注册和注销broadcast
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
//该回调方法可能会不回调
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,13 +7,11 @@ 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.lifecycle.ProcessLifecycleOwner;
|
import androidx.core.app.NotificationCompat;
|
||||||
|
|
||||||
import com.elvishew.xlog.XLog;
|
import com.google.gson.Gson;
|
||||||
import com.kongzue.dialogx.DialogX;
|
|
||||||
import com.kongzue.dialogx.style.MIUIStyle;
|
|
||||||
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,14 +19,20 @@ 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.util.CrashHandler;
|
import com.navinfo.outdoor.R;
|
||||||
import com.tencent.android.tpush.XGIOperateCallback;
|
import com.navinfo.outdoor.activity.FragmentManagement;
|
||||||
import com.tencent.android.tpush.XGPushConfig;
|
import com.navinfo.outdoor.activity.HomeActivity;
|
||||||
import com.tencent.android.tpush.XGPushManager;
|
import com.navinfo.outdoor.activity.WebActivity;
|
||||||
import com.tencent.map.navi.TencentNavi;
|
import com.navinfo.outdoor.bean.NotificationBean;
|
||||||
import com.tencent.navi.surport.utils.DeviceUtils;
|
import com.navinfo.outdoor.http.HttpInterface;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
import com.navinfo.outdoor.util.TalentLocationUtils;
|
||||||
import com.umeng.commonsdk.UMConfigure;
|
import com.umeng.commonsdk.UMConfigure;
|
||||||
|
import com.umeng.message.IUmengRegisterCallback;
|
||||||
|
import com.umeng.message.MsgConstant;
|
||||||
|
import com.umeng.message.PushAgent;
|
||||||
|
import com.umeng.message.UmengMessageHandler;
|
||||||
|
import com.umeng.message.UmengNotificationClickHandler;
|
||||||
|
import com.umeng.message.entity.UMessage;
|
||||||
import com.umeng.umcrash.UMCrash;
|
import com.umeng.umcrash.UMCrash;
|
||||||
import com.umeng.umcrash.UMCrashCallback;
|
import com.umeng.umcrash.UMCrashCallback;
|
||||||
|
|
||||||
@@ -44,7 +48,7 @@ import okhttp3.OkHttpClient;
|
|||||||
public class UserApplication extends Application {
|
public class UserApplication extends Application {
|
||||||
public static UserApplication userApplication;
|
public static UserApplication userApplication;
|
||||||
public static ExecutorService fixedThreadPool;
|
public static ExecutorService fixedThreadPool;
|
||||||
// public static PushAgent instance;
|
public static PushAgent instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
@@ -52,39 +56,9 @@ public class UserApplication extends Application {
|
|||||||
userApplication = this;
|
userApplication = this;
|
||||||
initUMSDK();
|
initUMSDK();
|
||||||
initOkGo();
|
initOkGo();
|
||||||
|
TalentLocationUtils.getInstance(this).startLocation(this);
|
||||||
//创建一个线程池
|
//创建一个线程池
|
||||||
fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池
|
fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池
|
||||||
|
|
||||||
TencentMapInitializer.setAgreePrivacy(true);
|
|
||||||
TencentNavi.setUserAgreePrivacy(true);
|
|
||||||
// 初始化腾讯导航
|
|
||||||
TencentNavi.Config config = new TencentNavi.Config();
|
|
||||||
// 记录设备标识,反馈导航问题时请提供该设备标识以及发生问题的时间
|
|
||||||
String deviceID = DeviceUtils.getImei(getApplicationContext());
|
|
||||||
config.setDeviceId(deviceID);
|
|
||||||
// 或者设置开发者自己的的设备号config.setDeviceId(xxxxxxxx);
|
|
||||||
TencentNavi.init(this, config);
|
|
||||||
// 初始化对话框组件
|
|
||||||
DialogX.init(this);
|
|
||||||
DialogX.globalStyle = new MIUIStyle();
|
|
||||||
CrashHandler.getInstance().init();
|
|
||||||
// 注册腾讯推送
|
|
||||||
XGPushConfig.enableDebug(this,true);
|
|
||||||
XGPushManager.registerPush(this, new XGIOperateCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Object data, int flag) {
|
|
||||||
//token在设备卸载重装的时候有可能会变
|
|
||||||
// Log.d("TPush", "注册成功,设备token为:" + data);
|
|
||||||
// 推送注册成功,将当前用户token上传给服务器
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFail(Object data, int errCode, String msg) {
|
|
||||||
Log.d("TPush", "注册失败,错误码:" + errCode + ",错误信息:" + msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserApplication getUserApplication() {
|
public static UserApplication getUserApplication() {
|
||||||
@@ -102,49 +76,49 @@ public class UserApplication extends Application {
|
|||||||
return "注册友盟异常查看功能";
|
return "注册友盟异常查看功能";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// instance = PushAgent.getInstance(this);
|
instance = PushAgent.getInstance(this);
|
||||||
// instance.register(new IUmengRegisterCallback() {
|
instance.register(new IUmengRegisterCallback() {
|
||||||
// @Override
|
@Override
|
||||||
// public void onSuccess(String s) {
|
public void onSuccess(String s) {
|
||||||
// //注册成功会返回deviceToken deviceToken是推送消息的唯一标志
|
//注册成功会返回deviceToken deviceToken是推送消息的唯一标志
|
||||||
// Constant.DEVICE_TOKEN = s;
|
Constant.DEVICE_TOKEN = s;
|
||||||
// Log.i("TAGEE", "Success 注册成功:deviceToken:--> " + Constant.DEVICE_TOKEN);
|
Log.i("TAGEE", "Success 注册成功:deviceToken:--> " + Constant.DEVICE_TOKEN);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// @Override
|
@Override
|
||||||
// public void onFailure(String s, String s1) {
|
public void onFailure(String s, String s1) {
|
||||||
// Log.e("TAGEE", "Failure 注册失败:--> " + "code:" + s + ", desc:" + s1);
|
Log.e("TAGEE", "Failure 注册失败:--> " + "code:" + s + ", desc:" + s1);
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
// instance.onAppStart();
|
instance.onAppStart();
|
||||||
// UmengMessageHandler msgHandler = new UmengMessageHandler() {
|
UmengMessageHandler msgHandler = new UmengMessageHandler() {
|
||||||
// //处理通知栏消息
|
//处理通知栏消息
|
||||||
// @Override
|
@Override
|
||||||
// public void dealWithNotificationMessage(Context context, UMessage msg) {
|
public void dealWithNotificationMessage(Context context, UMessage msg) {
|
||||||
// super.dealWithNotificationMessage(context, msg);
|
super.dealWithNotificationMessage(context, msg);
|
||||||
// Log.i("TAGEE", "dealWithNotificationMessage:" + msg.getRaw().toString());
|
Log.i("TAGEE", "dealWithNotificationMessage:" + msg.getRaw().toString());
|
||||||
// Constant.NOTIFICATION=msg.getRaw().toString();
|
Constant.NOTIFICATION=msg.getRaw().toString();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //自定义通知样式,此方法可以修改通知样式等
|
//自定义通知样式,此方法可以修改通知样式等
|
||||||
// @Override
|
@Override
|
||||||
// public Notification getNotification(Context context, UMessage msg) {
|
public Notification getNotification(Context context, UMessage msg) {
|
||||||
// Log.i("TAGEE", "getNotification: "+msg.getRaw().toString());
|
Log.i("TAGEE", "getNotification: "+msg.getRaw().toString());
|
||||||
// return super.getNotification(context, msg);
|
return super.getNotification(context, msg);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// //处理透传消息
|
//处理透传消息
|
||||||
// @Override
|
@Override
|
||||||
// public void dealWithCustomMessage(Context context, UMessage msg) {
|
public void dealWithCustomMessage(Context context, UMessage msg) {
|
||||||
// super.dealWithCustomMessage(context, msg);
|
super.dealWithCustomMessage(context, msg);
|
||||||
// Log.i("TAGEE", "dealWithCustomMessage:" + msg.getRaw().toString());
|
Log.i("TAGEE", "dealWithCustomMessage:" + msg.getRaw().toString());
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
// instance.setMessageHandler(msgHandler);
|
instance.setMessageHandler(msgHandler);
|
||||||
//App处于前台时不显示通知
|
//App处于前台时不显示通知
|
||||||
//instance.setNotificationOnForeground(false);
|
//instance.setNotificationOnForeground(false);
|
||||||
//设置显示通知的数量
|
//设置显示通知的数量
|
||||||
// instance.setDisplayNotificationNumber(0);
|
instance.setDisplayNotificationNumber(0);
|
||||||
//服务端控制声音
|
//服务端控制声音
|
||||||
//instance.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SERVER);
|
//instance.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SERVER);
|
||||||
//通知免打扰时段
|
//通知免打扰时段
|
||||||
@@ -187,7 +161,7 @@ public class UserApplication extends Application {
|
|||||||
//设置公共请求头
|
//设置公共请求头
|
||||||
.addCommonHeaders(headers)
|
.addCommonHeaders(headers)
|
||||||
//全局统一超时重连次数,默认为三次,那么最差的情况会请求4次(一次原始请求,三次重连请求),不需要可以设置为0;
|
//全局统一超时重连次数,默认为三次,那么最差的情况会请求4次(一次原始请求,三次重连请求),不需要可以设置为0;
|
||||||
.setRetryCount(3);
|
.setRetryCount(0);
|
||||||
StrictMode.VmPolicy.Builder picBuilder = new StrictMode.VmPolicy.Builder();
|
StrictMode.VmPolicy.Builder picBuilder = new StrictMode.VmPolicy.Builder();
|
||||||
StrictMode.setVmPolicy(picBuilder.build());
|
StrictMode.setVmPolicy(picBuilder.build());
|
||||||
picBuilder.detectFileUriExposure();
|
picBuilder.detectFileUriExposure();
|
||||||
|
|||||||
@@ -1,18 +1,12 @@
|
|||||||
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;
|
||||||
@@ -23,15 +17,10 @@ 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.jcodecraeer.xrecyclerview.XRecyclerView;
|
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
||||||
import com.navinfo.outdoor.R;
|
import com.navinfo.outdoor.R;
|
||||||
import com.navinfo.outdoor.activity.WebActivity;
|
import com.navinfo.outdoor.activity.WebActivity;
|
||||||
@@ -40,11 +29,7 @@ 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;
|
||||||
@@ -68,10 +53,6 @@ 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) {
|
||||||
@@ -99,10 +80,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void showLoadingDialog() {
|
public void showLoadingDialog() {
|
||||||
showLoadingDialog(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showLoadingDialog(String msg) {
|
|
||||||
if (alertDialog!=null) {
|
if (alertDialog!=null) {
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
}
|
}
|
||||||
@@ -114,10 +91,6 @@ public abstract class BaseActivity extends AppCompatActivity {
|
|||||||
});
|
});
|
||||||
//loading样式
|
//loading样式
|
||||||
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
View view = LayoutInflater.from(this).inflate(R.layout.loading, null);
|
||||||
TextView tv = view.findViewById(R.id.progressBar_tx);
|
|
||||||
if (!StringUtils.isBlank(msg)) {
|
|
||||||
tv.setText(msg);
|
|
||||||
}
|
|
||||||
alertDialog.setView(view);
|
alertDialog.setView(view);
|
||||||
alertDialog.setCanceledOnTouchOutside(false);
|
alertDialog.setCanceledOnTouchOutside(false);
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
@@ -161,9 +134,6 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -178,92 +148,4 @@ 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,7 +13,6 @@ 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;
|
||||||
@@ -32,15 +31,14 @@ 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 (LocationLifeCycle.getInstance().getTencentLocation()!=null){
|
if (Constant.currentLocation!=null){
|
||||||
int mockGps = LocationLifeCycle.getInstance().getTencentLocation().isMockGps();
|
int mockGps = Constant.currentLocation.isMockGps();
|
||||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();//无信号,信号弱,信号中,信号强
|
int gpsRssi = Constant.currentLocation.getGPSRssi();//无信号,信号弱,信号中,信号强
|
||||||
//1为是,0为否,-1为无法判断
|
//1为是,0为否,-1为无法判断
|
||||||
if (mockGps == 1) {
|
if (mockGps == 1) {
|
||||||
onBackPressed();
|
onBackPressed();
|
||||||
@@ -140,7 +138,6 @@ 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();
|
||||||
}
|
}
|
||||||
@@ -176,14 +173,4 @@ 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,8 +23,15 @@ 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;
|
||||||
@@ -75,7 +82,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 requireView().findViewById(id);
|
return Objects.requireNonNull(getView()).findViewById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void debounce(View view) {
|
protected void debounce(View view) {
|
||||||
@@ -92,7 +99,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
|
|||||||
if (alertDialog != null) {
|
if (alertDialog != null) {
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
}
|
}
|
||||||
alertDialog = new AlertDialog.Builder(requireActivity()).create();
|
alertDialog = new AlertDialog.Builder(Objects.requireNonNull(getActivity())).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) -> {
|
||||||
|
|||||||
@@ -1,84 +0,0 @@
|
|||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.navinfo.outdoor.base;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
|
||||||
import androidx.lifecycle.LifecycleOwner;
|
|
||||||
|
|
||||||
import com.tencent.map.navi.car.CarNaviView;
|
|
||||||
import com.tencent.map.ui.NaviView;
|
|
||||||
|
|
||||||
public class NaviLifeCycle implements DefaultLifecycleObserver {
|
|
||||||
private NaviView naviView;
|
|
||||||
|
|
||||||
public NaviLifeCycle(NaviView naviView) {
|
|
||||||
this.naviView = naviView;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart(@NonNull LifecycleOwner owner) {
|
|
||||||
DefaultLifecycleObserver.super.onStart(owner);
|
|
||||||
naviView.onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume(@NonNull LifecycleOwner owner) {
|
|
||||||
DefaultLifecycleObserver.super.onResume(owner);
|
|
||||||
naviView.onResume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause(@NonNull LifecycleOwner owner) {
|
|
||||||
DefaultLifecycleObserver.super.onPause(owner);
|
|
||||||
naviView.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop(@NonNull LifecycleOwner owner) {
|
|
||||||
DefaultLifecycleObserver.super.onStop(owner);
|
|
||||||
naviView.onStop();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
|
||||||
DefaultLifecycleObserver.super.onDestroy(owner);
|
|
||||||
naviView.onDestroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,275 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.lzy.okgo.OkGo;
|
|
||||||
import com.lzy.okgo.cache.CacheEntity;
|
|
||||||
import com.lzy.okgo.cache.CacheMode;
|
|
||||||
import com.lzy.okgo.convert.Converter;
|
|
||||||
import com.lzy.okgo.convert.StringConvert;
|
|
||||||
import com.lzy.okgo.model.HttpHeaders;
|
|
||||||
import com.lzy.okgo.model.HttpParams;
|
|
||||||
import com.lzy.okgo.model.Response;
|
|
||||||
import com.lzy.okgo.request.GetRequest;
|
|
||||||
import com.lzy.okgo.request.PostRequest;
|
|
||||||
import com.lzy.okgo.request.base.Request;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.api.UserApplication;
|
|
||||||
import com.navinfo.outdoor.http.Callback;
|
|
||||||
import com.navinfo.outdoor.http.JsonCallback;
|
|
||||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
|
||||||
import com.navinfo.outdoor.util.Md5Util;
|
|
||||||
import com.navinfo.outdoor.util.NetWorkUtils;
|
|
||||||
import com.navinfo.outdoor.util.ToastUtils;
|
|
||||||
import com.umeng.umcrash.UMCrash;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
public class CommonRequestSend<T extends CommonResponseBase> {
|
|
||||||
public void getMethodCommon(Activity mContext, String url, HttpParams params, int timeOut, Callback<CommonResponse<T>> callback, Class<T> tClass) {
|
|
||||||
try {
|
|
||||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 0, tClass))
|
|
||||||
.adapt()
|
|
||||||
.execute();
|
|
||||||
if (response.code() == 200) {
|
|
||||||
if (response.body().getCode() == 200) {
|
|
||||||
callback.onSuccess(response.body(), 1);
|
|
||||||
} else if (response.body().getCode() == 230){
|
|
||||||
FlushTokenUtil.flushToken(mContext);
|
|
||||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
|
||||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
|
||||||
callback.onError(throwable, -1);
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
|
||||||
Throwable throwable = new Throwable(response.message());
|
|
||||||
callback.onError(throwable, -2);
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Throwable throwable = e;
|
|
||||||
if (throwable != null) {
|
|
||||||
throwable.printStackTrace();
|
|
||||||
callback.onError(throwable, -3);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommonResponse<T> getMethodCommonSync(Activity mContext, String url, HttpParams params, int timeOut, Class<T> tClass) {
|
|
||||||
try {
|
|
||||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 0, tClass))
|
|
||||||
.adapt()
|
|
||||||
.execute();
|
|
||||||
if (response.code() == 200) {
|
|
||||||
if (response.body().getCode() == 230){
|
|
||||||
FlushTokenUtil.flushToken(mContext);
|
|
||||||
}
|
|
||||||
return response.body();
|
|
||||||
} else {
|
|
||||||
return new CommonResponse<T>(response.code(), response.message(), null);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
String message = e.getMessage();
|
|
||||||
assert message != null;
|
|
||||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
|
||||||
ToastUtils.Message(mContext, "请求超时");
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(mContext, message);
|
|
||||||
}
|
|
||||||
Log.d("TAG", "onError: " + e.getMessage());
|
|
||||||
return new CommonResponse<T>(e.hashCode(), e.getMessage(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void postMethodCommon(Activity mContext, String url, HttpParams params, int timeOut, Callback<CommonResponse<T>> callback, Class<T> tClass) {
|
|
||||||
try {
|
|
||||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 1, tClass))
|
|
||||||
.adapt()
|
|
||||||
.execute();
|
|
||||||
if (response.code() == 200) {
|
|
||||||
if (response.body().getCode() == 200) {
|
|
||||||
callback.onSuccess(response.body(), 1);
|
|
||||||
} else if (response.body().getCode() == 230){
|
|
||||||
FlushTokenUtil.flushToken(mContext);
|
|
||||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
|
||||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
|
||||||
callback.onError(throwable, -1);
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
|
||||||
Throwable throwable = new Throwable(response.message());
|
|
||||||
callback.onError(throwable, -2);
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
Throwable throwable = e;
|
|
||||||
if (throwable != null) {
|
|
||||||
throwable.printStackTrace();
|
|
||||||
callback.onError(throwable, -3);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* 友盟+
|
|
||||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
|
||||||
*/
|
|
||||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommonResponse<T> postMethodCommonSync(Activity mContext, String url, HttpParams params, int timeOut, List<File> files, Class<T> tClass) {
|
|
||||||
try {
|
|
||||||
PostRequest<CommonResponse<T>> postRequest = (PostRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 1, tClass);
|
|
||||||
if (files!=null) {
|
|
||||||
postRequest.addFileParams("file", files);
|
|
||||||
}
|
|
||||||
Response<CommonResponse<T>> response = postRequest
|
|
||||||
.adapt()
|
|
||||||
.execute();
|
|
||||||
if (response.code() == 200) {
|
|
||||||
if (response.body().getCode() == 230){
|
|
||||||
FlushTokenUtil.flushToken(mContext);
|
|
||||||
}
|
|
||||||
return response.body();
|
|
||||||
} else {
|
|
||||||
return new CommonResponse<T>(response.code(), response.message(), null);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
String message = e.getMessage();
|
|
||||||
assert message != null;
|
|
||||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
|
||||||
ToastUtils.Message(mContext, "请求超时");
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(mContext, message);
|
|
||||||
}
|
|
||||||
Log.d("TAG", "onError: " + e.getMessage());
|
|
||||||
return new CommonResponse<T>(e.hashCode(), e.getMessage(), null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成通用请求
|
|
||||||
* @param requestType 0-默认为get请求,非0-post请求
|
|
||||||
* */
|
|
||||||
private Request obitainRequest(Activity mContext, String url, HttpParams params, int timeOut, int requestType, Class<T> clazz) throws Exception{
|
|
||||||
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
|
|
||||||
throw new Exception("网络不可用");
|
|
||||||
}
|
|
||||||
initTimeOut(timeOut);
|
|
||||||
long time = System.currentTimeMillis();
|
|
||||||
params.put("datetime", time);
|
|
||||||
Request request = null;
|
|
||||||
if (requestType != 0) {
|
|
||||||
request= OkGo
|
|
||||||
// 请求方式和请求url
|
|
||||||
.<CommonResponse<T>>post(url);
|
|
||||||
} else {
|
|
||||||
request= OkGo
|
|
||||||
// 请求方式和请求url
|
|
||||||
.<CommonResponse<T>>get(url);
|
|
||||||
}
|
|
||||||
return request
|
|
||||||
.headers(getHeader(params))
|
|
||||||
.params(params)
|
|
||||||
.retryCount(3)
|
|
||||||
.converter(new MyJsonCallback(clazz) {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(Response response) {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 请求的 tag, 主要用于取消对应的请求
|
|
||||||
.tag(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initTimeOut(int time) {
|
|
||||||
OkHttpClient.Builder builder = new OkHttpClient.Builder();
|
|
||||||
builder.readTimeout(time, TimeUnit.SECONDS);
|
|
||||||
//全局的写入超时时间
|
|
||||||
builder.writeTimeout(time, TimeUnit.SECONDS);
|
|
||||||
//全局的连接超时时间
|
|
||||||
builder.connectTimeout(time, TimeUnit.SECONDS);
|
|
||||||
OkGo.getInstance().init(UserApplication.getUserApplication()).setOkHttpClient(builder.build())
|
|
||||||
//全局统一缓存模式,默认不使用缓存,可以不传
|
|
||||||
.setCacheMode(CacheMode.NO_CACHE)
|
|
||||||
//全局统一缓存时间,默认永不过期,可以不传
|
|
||||||
.setCacheTime(CacheEntity.CACHE_NEVER_EXPIRE)
|
|
||||||
.setRetryCount(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpHeaders getHeader(HttpParams params) {
|
|
||||||
HttpHeaders headers = new HttpHeaders();
|
|
||||||
try {
|
|
||||||
if (Constant.ACCESS_TOKEN == null) {
|
|
||||||
headers.put("Authorization", "Basic YXBwOmFwcHNlY3JldA==");
|
|
||||||
} else {
|
|
||||||
headers.put("Authorization", "bearer " + Constant.ACCESS_TOKEN);
|
|
||||||
}
|
|
||||||
StringBuilder util = new StringBuilder();//k1=v1&k2=v2&k3=v3
|
|
||||||
if (params != null && params.urlParamsMap != null) {
|
|
||||||
for (Map.Entry<String, List<String>> entry : params.urlParamsMap.entrySet()) {
|
|
||||||
if (!"file".equals(entry.getKey())) {
|
|
||||||
util.append(entry.getKey()).append("=").append(entry.getValue().get(0).toString()).append("&");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!util.toString().equals("")) {
|
|
||||||
util = new StringBuilder(util.substring(0, util.length() - 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
headers.put("key", Md5Util.toMD5("dtxb_2021_navinfo" + util));
|
|
||||||
headers.put("Accept-Encoding", "identity");
|
|
||||||
return headers;
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
public class CommonResponse<T> extends CommonResponseBase{
|
|
||||||
public CommonResponse(int code, String message, T body) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommonResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T body;
|
|
||||||
|
|
||||||
public T getBody() {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBody(T body) {
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
public class CommonResponseBase {
|
|
||||||
protected Integer code;
|
|
||||||
protected String message;
|
|
||||||
|
|
||||||
public Integer getCode() {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCode(Integer code) {
|
|
||||||
this.code = code;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommonResponse toLzyResponse() {
|
|
||||||
CommonResponse lzyResponse = new CommonResponse();
|
|
||||||
lzyResponse.code = code;
|
|
||||||
lzyResponse.message = message;
|
|
||||||
return lzyResponse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonIOException;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.google.gson.JsonSyntaxException;
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.readystatesoftware.chuck.internal.support.JsonConvertor;
|
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
public class Convert {
|
|
||||||
|
|
||||||
private static Gson create() {
|
|
||||||
return Convert.GsonHolder.gson;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class GsonHolder {
|
|
||||||
private static Gson gson = new Gson();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T fromJson(String json, Class<T> type) throws JsonIOException, JsonSyntaxException {
|
|
||||||
return create().fromJson(json, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T fromJson(String json, Type type) {
|
|
||||||
return create().fromJson(json, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T fromJson(JsonReader reader, Type typeOfT) throws JsonIOException, JsonSyntaxException {
|
|
||||||
return create().fromJson(reader, typeOfT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T fromJson(Reader json, Class<T> classOfT) throws JsonSyntaxException, JsonIOException {
|
|
||||||
return create().fromJson(json, classOfT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> T fromJson(Reader json, Type typeOfT) throws JsonIOException, JsonSyntaxException {
|
|
||||||
return create().fromJson(json, typeOfT);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toJson(Object src) {
|
|
||||||
return create().toJson(src);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String toJson(Object src, Type typeOfSrc) {
|
|
||||||
return create().toJson(src, typeOfSrc);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatJson(String json) {
|
|
||||||
try {
|
|
||||||
JsonParser jp = new JsonParser();
|
|
||||||
JsonElement je = jp.parse(json);
|
|
||||||
return JsonConvertor.getInstance().toJson(je);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return json;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String formatJson(Object src) {
|
|
||||||
try {
|
|
||||||
JsonParser jp = new JsonParser();
|
|
||||||
JsonElement je = jp.parse(toJson(src));
|
|
||||||
return JsonConvertor.getInstance().toJson(je);
|
|
||||||
} catch (Exception e) {
|
|
||||||
return e.getMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -88,7 +88,7 @@ public class JobSearchBean implements Serializable {
|
|||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ListBean implements Serializable{
|
public static class ListBean {
|
||||||
/**
|
/**
|
||||||
* id : 8992
|
* id : 8992
|
||||||
* geo : dy3feM6SkaeY3Q3FrUcdfMyvvsAqu2MktMG2JtDX/+gDQ7IT9aNcPn2v1Rvi
|
* geo : dy3feM6SkaeY3Q3FrUcdfMyvvsAqu2MktMG2JtDX/+gDQ7IT9aNcPn2v1Rvi
|
||||||
@@ -115,8 +115,6 @@ public class JobSearchBean implements Serializable {
|
|||||||
private String memo;
|
private String memo;
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
|
||||||
private int publish; // 是否已发布,如果是未发布的数据,则用半透明形式展示
|
|
||||||
|
|
||||||
public int getCanReceived() {
|
public int getCanReceived() {
|
||||||
return canReceived;
|
return canReceived;
|
||||||
}
|
}
|
||||||
@@ -212,14 +210,6 @@ public class JobSearchBean implements Serializable {
|
|||||||
public void setTelephone(String telephone) {
|
public void setTelephone(String telephone) {
|
||||||
this.telephone = telephone;
|
this.telephone = telephone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPublish() {
|
|
||||||
return publish;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPublish(int publish) {
|
|
||||||
this.publish = publish;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class LatestPushMessageResponse extends CommonResponseBase{
|
|
||||||
public LatestPushMessageResponse(int code, String message, Map<String, String> body) {
|
|
||||||
this.code = code;
|
|
||||||
this.message = message;
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public LatestPushMessageResponse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected Map<String, String> body;
|
|
||||||
|
|
||||||
public Map<String, String> getBody() {
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBody(Map<String, String> body) {
|
|
||||||
this.body = body;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,136 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
import android.location.Location;
|
|
||||||
|
|
||||||
import androidx.room.Entity;
|
|
||||||
import androidx.room.PrimaryKey;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.tencent.map.geolocation.TencentLocation;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Entity(tableName = "LocationRecorder")
|
|
||||||
public class LocationRecorder implements Serializable {
|
|
||||||
@PrimaryKey
|
|
||||||
private long time; // 采集时间
|
|
||||||
private double tencentLocationX;
|
|
||||||
private double tencentLocationY;
|
|
||||||
private double gpsLocationX;
|
|
||||||
private double gpsLocationY;
|
|
||||||
private int rssi; // 信号强度
|
|
||||||
private double bearing; // 角度方向
|
|
||||||
private int satelliteCount; // 卫星颗数
|
|
||||||
private String imgFileName; // 照片名称
|
|
||||||
|
|
||||||
public long getTime() {
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTime(long time) {
|
|
||||||
this.time = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTencentLocationX() {
|
|
||||||
return tencentLocationX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTencentLocationX(double tencentLocationX) {
|
|
||||||
this.tencentLocationX = tencentLocationX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getTencentLocationY() {
|
|
||||||
return tencentLocationY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTencentLocationY(double tencentLocationY) {
|
|
||||||
this.tencentLocationY = tencentLocationY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getGpsLocationX() {
|
|
||||||
return gpsLocationX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGpsLocationX(double gpsLocationX) {
|
|
||||||
this.gpsLocationX = gpsLocationX;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getGpsLocationY() {
|
|
||||||
return gpsLocationY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGpsLocationY(double gpsLocationY) {
|
|
||||||
this.gpsLocationY = gpsLocationY;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRssi() {
|
|
||||||
return rssi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRssi(int rssi) {
|
|
||||||
this.rssi = rssi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getBearing() {
|
|
||||||
return bearing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBearing(double bearing) {
|
|
||||||
this.bearing = bearing;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getSatelliteCount() {
|
|
||||||
return satelliteCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSatelliteCount(int satelliteCount) {
|
|
||||||
this.satelliteCount = satelliteCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImgFileName() {
|
|
||||||
return imgFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImgFileName(String imgFileName) {
|
|
||||||
this.imgFileName = imgFileName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "LocationRecorder{" +
|
|
||||||
"time=" + time +
|
|
||||||
", tencentLocationX=" + tencentLocationX +
|
|
||||||
", tencentLocationY=" + tencentLocationY +
|
|
||||||
", gpsLocationX=" + gpsLocationX +
|
|
||||||
", gpsLocationY=" + gpsLocationY +
|
|
||||||
", rssi=" + rssi +
|
|
||||||
", bearing=" + bearing +
|
|
||||||
", satelliteCount=" + satelliteCount +
|
|
||||||
", imgFileName='" + imgFileName + '\'' +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
public String toString(SimpleDateFormat dateFormat, int index) {
|
|
||||||
return new StringBuilder()
|
|
||||||
.append(dateFormat.format(new Date(time)))
|
|
||||||
.append(",")
|
|
||||||
.append(index)
|
|
||||||
.append(",")
|
|
||||||
.append(tencentLocationY)
|
|
||||||
.append(",")
|
|
||||||
.append(tencentLocationX)
|
|
||||||
.append(",")
|
|
||||||
.append(bearing)
|
|
||||||
.append(",")
|
|
||||||
.append(Constant.getRssiDesStr(rssi))
|
|
||||||
.append(",")
|
|
||||||
.append(satelliteCount)
|
|
||||||
.append(",")
|
|
||||||
.append(gpsLocationY)
|
|
||||||
.append(",")
|
|
||||||
.append(gpsLocationX)
|
|
||||||
.append("\r\n")
|
|
||||||
.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
import com.google.gson.stream.JsonReader;
|
|
||||||
import com.lzy.okgo.callback.AbsCallback;
|
|
||||||
|
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
|
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.ResponseBody;
|
|
||||||
|
|
||||||
public abstract class MyJsonCallback<T> extends AbsCallback<T> {
|
|
||||||
|
|
||||||
private Type type;
|
|
||||||
private Class<T> clazz;
|
|
||||||
|
|
||||||
public MyJsonCallback() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyJsonCallback(Type type) {
|
|
||||||
this.type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MyJsonCallback(Class<T> clazz) {
|
|
||||||
this.clazz = clazz;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T convertResponse(Response response) throws Throwable {
|
|
||||||
|
|
||||||
if (type == null) {
|
|
||||||
if (clazz == null) {
|
|
||||||
// 如果没有通过构造函数传进来,就自动解析父类泛型的真实类型(有局限性,继承后就无法解析到)
|
|
||||||
Type genType = getClass().getGenericSuperclass();
|
|
||||||
type = ((ParameterizedType) genType).getActualTypeArguments()[0];
|
|
||||||
} else {
|
|
||||||
return parseClass(response, clazz);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type instanceof ParameterizedType) {
|
|
||||||
return parseParameterizedType(response, (ParameterizedType) type);
|
|
||||||
} else if (type instanceof Class) {
|
|
||||||
return parseClass(response, (Class<?>) type);
|
|
||||||
} else {
|
|
||||||
return parseType(response, type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private T parseClass(Response response, Class<?> rawType) throws Exception {
|
|
||||||
if (rawType == null) return null;
|
|
||||||
ResponseBody body = response.body();
|
|
||||||
if (body == null) return null;
|
|
||||||
JsonReader jsonReader = new JsonReader(body.charStream());
|
|
||||||
|
|
||||||
if (rawType == String.class) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) body.string();
|
|
||||||
} else if (rawType == JSONObject.class) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) new JSONObject(body.string());
|
|
||||||
} else if (rawType == JSONArray.class) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) new JSONArray(body.string());
|
|
||||||
} else {
|
|
||||||
T t = Convert.fromJson(jsonReader, rawType);
|
|
||||||
response.close();
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private T parseType(Response response, Type type) throws Exception {
|
|
||||||
if (type == null) return null;
|
|
||||||
ResponseBody body = response.body();
|
|
||||||
if (body == null) return null;
|
|
||||||
JsonReader jsonReader = new JsonReader(body.charStream());
|
|
||||||
|
|
||||||
// 泛型格式如下: new JsonCallback<任意JavaBean>(this)
|
|
||||||
T t = Convert.fromJson(jsonReader, type);
|
|
||||||
response.close();
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
private T parseParameterizedType(Response response, ParameterizedType type) throws Exception {
|
|
||||||
if (type == null) return null;
|
|
||||||
ResponseBody body = response.body();
|
|
||||||
if (body == null) return null;
|
|
||||||
JsonReader jsonReader = new JsonReader(body.charStream());
|
|
||||||
|
|
||||||
Type rawType = type.getRawType(); // 泛型的实际类型
|
|
||||||
Type typeArgument = type.getActualTypeArguments()[0]; // 泛型的参数
|
|
||||||
if (rawType != CommonResponse.class) {
|
|
||||||
// 泛型格式如下: new JsonCallback<外层BaseBean<内层JavaBean>>(this)
|
|
||||||
T t = Convert.fromJson(jsonReader, type);
|
|
||||||
response.close();
|
|
||||||
return t;
|
|
||||||
} else {
|
|
||||||
if (typeArgument == Void.class) {
|
|
||||||
// 泛型格式如下: new JsonCallback<LzyResponse<Void>>(this)
|
|
||||||
CommonResponseBase simpleResponse = Convert.fromJson(jsonReader, CommonResponseBase.class);
|
|
||||||
response.close();
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) simpleResponse.toLzyResponse();
|
|
||||||
} else {
|
|
||||||
// 泛型格式如下: new JsonCallback<LzyResponse<内层JavaBean>>(this)
|
|
||||||
CommonResponse lzyResponse = Convert.fromJson(jsonReader, type);
|
|
||||||
response.close();
|
|
||||||
int code = lzyResponse.code;
|
|
||||||
// 一般来说服务器会和客户端约定一个数表示成功,如200,其余的表示失败,如400,300等,这里根据实际情况罗列并抛出
|
|
||||||
if (code == 0) {
|
|
||||||
//noinspection unchecked
|
|
||||||
return (T) lzyResponse;
|
|
||||||
} else if (code == 230) {
|
|
||||||
throw new IllegalStateException("Token已过期");
|
|
||||||
} /*else if (code == 300) {
|
|
||||||
throw new IllegalStateException("用户名密码错误");
|
|
||||||
} */else {
|
|
||||||
// 直接将服务端的错误信息抛出,onError中可以获取
|
|
||||||
throw new IllegalStateException("错误代码:" + code + ",错误信息:" + lzyResponse.message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -52,8 +52,6 @@ public class PolygonTaskBean {
|
|||||||
private String name;
|
private String name;
|
||||||
private int isExclusive;
|
private int isExclusive;
|
||||||
|
|
||||||
private String unReceivedTime; // 任务领取后自动释放的时间
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -93,17 +91,5 @@ public class PolygonTaskBean {
|
|||||||
public void setIsExclusive(int isExclusive) {
|
public void setIsExclusive(int isExclusive) {
|
||||||
this.isExclusive = isExclusive;
|
this.isExclusive = isExclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnReceivedTime() {
|
|
||||||
return unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnReceivedTime(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BodyBean(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,17 +43,7 @@ public class ReceivedBean {
|
|||||||
private String name;
|
private String name;
|
||||||
private Integer isExclusive;
|
private Integer isExclusive;
|
||||||
private String memo;
|
private String memo;
|
||||||
|
|
||||||
public String getUnReceivedTime() {
|
|
||||||
return unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnReceivedTime(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String endDate;
|
private String endDate;
|
||||||
private String unReceivedTime;
|
|
||||||
|
|
||||||
public String getMemo() {
|
public String getMemo() {
|
||||||
return memo;
|
return memo;
|
||||||
|
|||||||
@@ -58,8 +58,6 @@ public class ReceivedPoiBean {
|
|||||||
private String endDate;
|
private String endDate;
|
||||||
private String telephone;
|
private String telephone;
|
||||||
|
|
||||||
private String unReceivedTime;
|
|
||||||
|
|
||||||
public String getTelephone() {
|
public String getTelephone() {
|
||||||
return telephone;
|
return telephone;
|
||||||
}
|
}
|
||||||
@@ -131,13 +129,5 @@ public class ReceivedPoiBean {
|
|||||||
public void setIsExclusive(int isExclusive) {
|
public void setIsExclusive(int isExclusive) {
|
||||||
this.isExclusive = isExclusive;
|
this.isExclusive = isExclusive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnReceivedTime() {
|
|
||||||
return unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnReceivedTime(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,203 +0,0 @@
|
|||||||
package com.navinfo.outdoor.bean;
|
|
||||||
|
|
||||||
import androidx.room.ColumnInfo;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.activity.MyCoordinate;
|
|
||||||
import com.navinfo.outdoor.room.PoiEntity;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|
||||||
|
|
||||||
import org.locationtech.jts.geom.Coordinate;
|
|
||||||
import org.locationtech.jts.geom.Envelope;
|
|
||||||
import org.locationtech.jts.geom.Geometry;
|
|
||||||
import org.locationtech.jts.geom.LineString;
|
|
||||||
import org.locationtech.jts.geom.Point;
|
|
||||||
import org.locationtech.jts.geom.Polygon;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 道路匹配的封装类
|
|
||||||
* */
|
|
||||||
public class RoadMatchEntity implements Serializable {
|
|
||||||
private int id; // 唯一id
|
|
||||||
private PoiEntity dataDetail; // 具体的内容信息
|
|
||||||
private double angle=0; // 起点匹配方向
|
|
||||||
private double length=0; //geometry的长度
|
|
||||||
private String geometry; // 数据的geometry,此处应该为lineString
|
|
||||||
// private String buffer; // line外扩的buffer,用来判断行驶过程中是否可以与当前geometry匹配
|
|
||||||
private String sPoint; // 起点
|
|
||||||
private String ePoint; // 起点
|
|
||||||
private long startMatchTime; // 开始匹配的时间
|
|
||||||
private long endMathchTime; // 结束匹配的时间
|
|
||||||
private double currentLineDistance=0f; // 当前匹配到的距离道路线的距离
|
|
||||||
private double lastEndDistance=0f; // 上次匹配到的距离终点的距离
|
|
||||||
private int matchCount; // <连续>匹配到的点位个数
|
|
||||||
private int unMatchCount; // <连续>未匹配到的点位个数
|
|
||||||
private List<MyCoordinate> matchPointList = new ArrayList<>(); // 已匹配的点位列表
|
|
||||||
private List<MyCoordinate> unMatchPointList = new ArrayList<>(); // 未匹配的点位列表
|
|
||||||
private double matchedLength = 0;
|
|
||||||
|
|
||||||
public int getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(int id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PoiEntity getDataDetail() {
|
|
||||||
return dataDetail;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDataDetail(PoiEntity poiEntity) {
|
|
||||||
this.dataDetail = poiEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getAngle() {
|
|
||||||
return angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAngle(double angle) {
|
|
||||||
this.angle = angle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGeometry() {
|
|
||||||
return geometry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGeometry(LineString geometry) {
|
|
||||||
this.geometry = geometry.toString();
|
|
||||||
this.length = geometry.getLength();
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
// public String getBuffer() {
|
|
||||||
// return buffer;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// public void setBuffer(String buffer) {
|
|
||||||
// this.buffer = buffer;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public String getsPoint() {
|
|
||||||
return sPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setsPoint(String sPoint) {
|
|
||||||
this.sPoint = sPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getePoint() {
|
|
||||||
return ePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setePoint(String ePoint) {
|
|
||||||
this.ePoint = ePoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getStartMatchTime() {
|
|
||||||
return startMatchTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStartMatchTime(long startMatchTime) {
|
|
||||||
this.startMatchTime = startMatchTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getEndMathchTime() {
|
|
||||||
return endMathchTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndMathchTime(long endMathchTime) {
|
|
||||||
this.endMathchTime = endMathchTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getLastEndDistance() {
|
|
||||||
return lastEndDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLastEndDistance(double lastEndDistance) {
|
|
||||||
this.lastEndDistance = lastEndDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMatchCount() {
|
|
||||||
return matchCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMatchCount(int matchCount) {
|
|
||||||
this.matchCount = matchCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getUnMatchCount() {
|
|
||||||
return unMatchCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnMatchCount(int unMatchCount) {
|
|
||||||
this.unMatchCount = unMatchCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MyCoordinate> getMatchPointList() {
|
|
||||||
return matchPointList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMatchPointList(List<MyCoordinate> matchPointList) {
|
|
||||||
this.matchPointList = matchPointList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<MyCoordinate> getUnMatchPointList() {
|
|
||||||
return unMatchPointList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnMatchPointList(List<MyCoordinate> unMatchPointList) {
|
|
||||||
this.unMatchPointList = unMatchPointList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getCurrentLineDistance() {
|
|
||||||
return currentLineDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCurrentLineDistance(double currentLineDistance) {
|
|
||||||
this.currentLineDistance = currentLineDistance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getMatchedLength() {
|
|
||||||
return matchedLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMatchedLength(double matchedLength) {
|
|
||||||
this.matchedLength = matchedLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object o) {
|
|
||||||
if (this == o) return true;
|
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
|
||||||
|
|
||||||
RoadMatchEntity that = (RoadMatchEntity) o;
|
|
||||||
|
|
||||||
if (id != that.id) return false;
|
|
||||||
return true;
|
|
||||||
// if (angle != that.angle) return false;
|
|
||||||
// if (dataDetail != null ? !dataDetail.equals(that.dataDetail) : that.dataDetail != null)
|
|
||||||
// return false;
|
|
||||||
// if (geometry != null ? !geometry.equals(that.geometry) : that.geometry != null)
|
|
||||||
// return false;
|
|
||||||
// if (buffer != null ? !buffer.equals(that.buffer) : that.buffer != null) return false;
|
|
||||||
// if (sPoint != null ? !sPoint.equals(that.sPoint) : that.sPoint != null) return false;
|
|
||||||
// return ePoint != null ? ePoint.equals(that.ePoint) : that.ePoint == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
int result = id;
|
|
||||||
result = 31 * result + (dataDetail != null ? dataDetail.hashCode() : 0);
|
|
||||||
result = 31 * result + (geometry != null ? geometry.hashCode() : 0);
|
|
||||||
result = 31 * result + (sPoint != null ? sPoint.hashCode() : 0);
|
|
||||||
result = 31 * result + (ePoint != null ? ePoint.hashCode() : 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -56,15 +56,6 @@ public class TaskByNetBean {
|
|||||||
private int isExclusive;
|
private int isExclusive;
|
||||||
private String memo;
|
private String memo;
|
||||||
private String endDate;
|
private String endDate;
|
||||||
private String unReceivedTime;
|
|
||||||
|
|
||||||
public String getUnReceivedTime() {
|
|
||||||
return unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnReceivedTime(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMemo() {
|
public String getMemo() {
|
||||||
return memo;
|
return memo;
|
||||||
|
|||||||
@@ -3,19 +3,16 @@ 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;
|
||||||
|
|
||||||
@@ -23,9 +20,7 @@ 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);
|
||||||
@@ -51,103 +46,13 @@ 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:
|
||||||
requireActivity().finish();
|
Objects.requireNonNull(getActivity()).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);
|
||||||
|
|||||||
@@ -1,954 +0,0 @@
|
|||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File panoramaFile = PhotoUtils.showPhotoFile("a", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File codingFile = PhotoUtils.showPhotoFile("b", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File equipmentFile = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File facilityFile = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File scutcheonFile = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File deviceFile = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File usableFile = PhotoUtils.showPhotoFile("d", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File availableFile = PhotoUtils.showPhotoFile("d", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File parkingFile = PhotoUtils.showPhotoFile("e", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File numberFile = PhotoUtils.showPhotoFile("e", latLng);
|
||||||
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,7 +52,6 @@ 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;
|
||||||
@@ -85,7 +84,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -100,16 +99,7 @@ import java.util.Date;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableEmitter;
|
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.Scheduler;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -784,7 +774,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
if (getPhoneBean.getCode() == 200) {
|
if (getPhoneBean.getCode() == 200) {
|
||||||
String code = getPhoneBean.getBody().getCode();
|
String code = getPhoneBean.getBody().getCode();
|
||||||
Integer telLength = getPhoneBean.getBody().getTelLength();
|
Integer telLength = getPhoneBean.getBody().getTelLength();
|
||||||
if (code!=null&&!Constant.CODE.equals(code)) {
|
if (!code.equals(Constant.CODE)) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "此地区区号为" + code + ",请手动修改", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "此地区区号为" + code + ",请手动修改", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -889,7 +879,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
if (currentChargingPileList != null && !currentChargingPileList.isEmpty()) {
|
if (currentChargingPileList != null && !currentChargingPileList.isEmpty()) {
|
||||||
for (int i = 0; i < currentChargingPileList.size(); i++) {
|
for (int i = 0; i < currentChargingPileList.size(); i++) {
|
||||||
if (currentChargingPileList.get(i).getPileId() == chargingPileEntity.getPileId()) {
|
if (currentChargingPileList.get(i).getPileId() == chargingPileEntity.getPileId()) {
|
||||||
currentChargingPileList.set(i, chargingPileEntity);
|
currentChargingPileList.add(i, chargingPileEntity);
|
||||||
|
currentChargingPileList.remove(i + 1);
|
||||||
break m;
|
break m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1053,35 +1044,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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File PanoramaFile = PhotoUtils.showPhotoFile("a", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File nameFile = PhotoUtils.showPhotoFile("b", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File internalFile = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File elseFile = PhotoUtils.showPhotoFile("d", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File scutcheonFile = PhotoUtils.showPhotoFile("e", latLng);
|
||||||
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
|
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
|
||||||
startActivityForResult(intentScutcheon, 105);
|
startActivityForResult(intentScutcheon, 105);
|
||||||
break;
|
break;
|
||||||
@@ -1172,85 +1163,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用RxJava提交充电站数据,附带提交充电桩数据
|
|
||||||
* */
|
|
||||||
private Observable submitChargingStation(PoiEntity poiEntity) {
|
|
||||||
return Observable.just(poiEntity).subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
|
||||||
.doOnEach(poiEntityNotification -> {
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("taskId", poiEntity.getTaskId());
|
|
||||||
httpParams.put("sptype", poiEntity.getStation_type());
|
|
||||||
httpParams.put("existence", poiEntity.getExistence());
|
|
||||||
httpParams.put("name", poiEntity.getName());
|
|
||||||
httpParams.put("address", poiEntity.getAddress());
|
|
||||||
httpParams.put("telephone", poiEntity.getTelPhone());
|
|
||||||
httpParams.put("memo", poiEntity.getMemo());
|
|
||||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
|
||||||
.time(30)
|
|
||||||
.Builder(getActivity())
|
|
||||||
.url(HttpInterface.SUBMIT_CTASK)
|
|
||||||
.cls(ChargingStationBean.class)
|
|
||||||
.params(httpParams)
|
|
||||||
.token(Constant.ACCESS_TOKEN);
|
|
||||||
Response response = okGoBuilder.getSynchronization();
|
|
||||||
Gson gson = new Gson();
|
|
||||||
ChargingStationBean chargingStationBean = gson.fromJson(response.body().string(), ChargingStationBean.class);
|
|
||||||
if (chargingStationBean.getCode() == 200) {
|
|
||||||
Integer bodyId = chargingStationBean.getBody();
|
|
||||||
if (bodyId != null && bodyId != 0) {
|
|
||||||
poiEntity.setBodyId(bodyId);
|
|
||||||
poiEntity.setTaskStatus(3);
|
|
||||||
|
|
||||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
|
||||||
// 实时禁用当前的保存按钮,防止用户再次点击保存,重新生成新的POI数据
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.CHARGING_STATION_DISABLE;
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
} else {
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_REGISTER;
|
|
||||||
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
}
|
|
||||||
} else if (chargingStationBean.getCode() == 230) {
|
|
||||||
FlushTokenUtil.flushToken(getActivity());
|
|
||||||
} else {
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_REGISTER;
|
|
||||||
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.concatMap(new Function<PoiEntity, ObservableSource<ChargingPileEntity>>() {
|
|
||||||
@Override
|
|
||||||
public ObservableSource<ChargingPileEntity> apply(PoiEntity chargingStationPoiEntity) throws Exception {
|
|
||||||
if (chargingStationPoiEntity != null) {
|
|
||||||
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(chargingStationPoiEntity.getId());
|
|
||||||
PoiEntity poiEntity = PoiDatabase.getInstance(getActivity()).getPoiDao().getPoiEntity(chargingStationPoiEntity.getId());
|
|
||||||
if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) {
|
|
||||||
chargingPileEntityList = chargingPileEntityList.stream().filter(chargingPileEntity -> chargingPileEntity.getBodyId()==0).collect(Collectors.toList());
|
|
||||||
return getSaveChargingObservable(chargingPileEntityList, poiEntity.getBodyId());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Observable.never();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private Observable<ChargingPileEntity> getSaveChargingObservable(List<ChargingPileEntity> chargingPileEntityList, int bodyId) {
|
|
||||||
return Observable.fromIterable(chargingPileEntityList).subscribeOn(Schedulers.io()).observeOn(Schedulers.io())
|
|
||||||
.doOnEach(chargingPileEntityNotification -> {
|
|
||||||
saveChargingPileByWork(chargingPileEntityNotification.getValue(), bodyId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void chargingStationSaveWork(PoiEntity poiEntity) {
|
private void chargingStationSaveWork(PoiEntity poiEntity) {
|
||||||
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
|
||||||
ToastUtils.Message(getActivity(), Constant.SUBMIT_TOAST_MSG);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("taskId", poiEntity.getTaskId());
|
httpParams.put("taskId", poiEntity.getTaskId());
|
||||||
httpParams.put("sptype", poiEntity.getStation_type());
|
httpParams.put("sptype", poiEntity.getStation_type());
|
||||||
@@ -1302,7 +1215,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("auditId", chargingPileEntity.getBodyId());
|
httpParams.put("auditId", chargingPileEntity.getBodyId());
|
||||||
Response execute = OkGoBuilder.getInstance()
|
Response execute = OkGoBuilder.getInstance()
|
||||||
.time(600)
|
.time(0)
|
||||||
.url(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
.url(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
||||||
.params(httpParams)
|
.params(httpParams)
|
||||||
.token(Constant.ACCESS_TOKEN)
|
.token(Constant.ACCESS_TOKEN)
|
||||||
@@ -1346,7 +1259,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("auditId", poiEntity.getBodyId());
|
httpParams.put("auditId", poiEntity.getBodyId());
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
.time(600)
|
.time(0)
|
||||||
.Builder(getActivity())
|
.Builder(getActivity())
|
||||||
.url(HttpInterface.C_TASK_UP_LOAD_PIC)
|
.url(HttpInterface.C_TASK_UP_LOAD_PIC)
|
||||||
.cls(PoiUploadBean.class)
|
.cls(PoiUploadBean.class)
|
||||||
@@ -1367,10 +1280,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
|
|
||||||
/*保存充电站数据到服务器*/
|
/*保存充电站数据到服务器*/
|
||||||
private void chargingStationSaveByWork(PoiEntity poiEntity) {
|
private void chargingStationSaveByWork(PoiEntity poiEntity) {
|
||||||
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
|
||||||
ToastUtils.Message(getActivity(), Constant.SUBMIT_TOAST_MSG);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("taskId", poiEntity.getTaskId());
|
httpParams.put("taskId", poiEntity.getTaskId());
|
||||||
httpParams.put("sptype", poiEntity.getStation_type());
|
httpParams.put("sptype", poiEntity.getStation_type());
|
||||||
@@ -1388,10 +1297,10 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
.cls(ChargingStationBean.class)
|
.cls(ChargingStationBean.class)
|
||||||
.params(httpParams)
|
.params(httpParams)
|
||||||
.token(Constant.ACCESS_TOKEN);
|
.token(Constant.ACCESS_TOKEN);
|
||||||
Constant.submitIdSet.add(poiEntity.getId());
|
|
||||||
okGoBuilder.getRequest(new Callback<ChargingStationBean>() {
|
okGoBuilder.getRequest(new Callback<ChargingStationBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(ChargingStationBean chargingStationBean, int id) {
|
public void onSuccess(ChargingStationBean chargingStationBean, int id) {
|
||||||
|
dismissLoadingDialog();
|
||||||
if (chargingStationBean.getCode() == 200) {
|
if (chargingStationBean.getCode() == 200) {
|
||||||
Integer bodyId = chargingStationBean.getBody();
|
Integer bodyId = chargingStationBean.getBody();
|
||||||
if (bodyId != null && bodyId != 0) {
|
if (bodyId != null && bodyId != 0) {
|
||||||
@@ -1408,7 +1317,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
|
|
||||||
// 充电站数据已经保存在服务上,批量保存充电桩数据
|
// 充电站数据已经保存在服务上,批量保存充电桩数据
|
||||||
saveChargingPileByChargingStation(poiEntity);
|
saveChargingPileByChargingStation(poiEntity);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
if (getActivity() != null) {
|
if (getActivity() != null) {
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -1423,16 +1331,12 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
}).start();
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.Message(getActivity(), chargingStationBean.getMessage());
|
ToastUtils.Message(getActivity(), chargingStationBean.getMessage());
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
} else if (chargingStationBean.getCode() == 230) {
|
} else if (chargingStationBean.getCode() == 230) {
|
||||||
FlushTokenUtil.flushToken(getActivity());
|
FlushTokenUtil.flushToken(getActivity());
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.Message(getActivity(), chargingStationBean.getMessage());
|
ToastUtils.Message(getActivity(), chargingStationBean.getMessage());
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
dismissLoadingDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1446,7 +1350,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
ToastUtils.Message(getActivity(), message);
|
ToastUtils.Message(getActivity(), message);
|
||||||
}
|
}
|
||||||
Log.d("TAG", "onError: " + e.getMessage());
|
Log.d("TAG", "onError: " + e.getMessage());
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1501,7 +1404,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ToastUtils.Message(getActivity(), taskNameBean.getMessage()+"");
|
ToastUtils.Message(getActivity(), taskNameBean.getMessage());
|
||||||
editNameContent.setTextColor(Color.RED);
|
editNameContent.setTextColor(Color.RED);
|
||||||
btnSaveLocal.setEnabled(false);
|
btnSaveLocal.setEnabled(false);
|
||||||
btnUploading.setEnabled(false);
|
btnUploading.setEnabled(false);
|
||||||
@@ -1641,7 +1544,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
/**
|
/**
|
||||||
* 保存充电桩数据到服务端
|
* 保存充电桩数据到服务端
|
||||||
*/
|
*/
|
||||||
private ChargingPileEntity saveChargingPileByWork(ChargingPileEntity chargingPileEntity, int bodyId) {
|
private void saveChargingPileByWork(ChargingPileEntity chargingPileEntity, int bodyId) {
|
||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("taskId", chargingPileEntity.getTaskId());
|
httpParams.put("taskId", chargingPileEntity.getTaskId());
|
||||||
httpParams.put("name", chargingPileEntity.getName());
|
httpParams.put("name", chargingPileEntity.getName());
|
||||||
@@ -1679,7 +1582,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return chargingPileEntity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initList() {
|
private void initList() {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import com.navinfo.outdoor.util.GeometryTools;
|
|||||||
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.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ package com.navinfo.outdoor.fragment;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
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;
|
||||||
@@ -17,17 +15,12 @@ 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.NaviRideActivity;
|
|
||||||
import com.navinfo.outdoor.activity.NaviWalkActivity;
|
|
||||||
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.PolygonTaskBean;
|
import com.navinfo.outdoor.bean.PolygonTaskBean;
|
||||||
@@ -47,11 +40,11 @@ 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.TimestampUtil;
|
import com.navinfo.outdoor.util.TimestampUtil;
|
||||||
|
import com.navinfo.outdoor.util.ToastUtils;
|
||||||
|
import com.tencent.lbssearch.httpresponse.Poi;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
@@ -60,7 +53,6 @@ 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,8 +65,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
private PoiEntity poiEntity;
|
private PoiEntity poiEntity;
|
||||||
private File logFile;
|
private File logFile;
|
||||||
private StringBuilder gatherGetBuilder;
|
private StringBuilder gatherGetBuilder;
|
||||||
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();
|
||||||
@@ -85,7 +75,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
super.initData();
|
super.initData();
|
||||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).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");
|
||||||
@@ -117,7 +107,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
|
|
||||||
//主界面获取焦点
|
//主界面获取焦点
|
||||||
private void getFocus() {
|
private void getFocus() {
|
||||||
requireView().setFocusableInTouchMode(true);
|
Objects.requireNonNull(getView()).setFocusableInTouchMode(true);
|
||||||
getView().requestFocus();
|
getView().requestFocus();
|
||||||
getView().setOnKeyListener(new View.OnKeyListener() {
|
getView().setOnKeyListener(new View.OnKeyListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -154,8 +144,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
TextView tvTime = findViewById(R.id.tv_time);
|
TextView tvTime = findViewById(R.id.tv_time);
|
||||||
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);
|
|
||||||
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);//取消领取
|
||||||
@@ -197,73 +185,8 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
assert poiEntity != null;
|
assert poiEntity != null;
|
||||||
int taskStatus = poiEntity.getTaskStatus();
|
int taskStatus = poiEntity.getTaskStatus();
|
||||||
initViewByTaskStatus(taskStatus);
|
initViewByTaskStatus(taskStatus);
|
||||||
// 用户点击开始导航
|
|
||||||
tvStartNav.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (Constant.currentNaviType == null) {
|
|
||||||
NaviUtils.getInstance().selectNaviType((AppCompatActivity) getActivity(), new NaviUtils.SelectNaviTypeListener() {
|
|
||||||
@Override
|
|
||||||
public void selectNaviType(Constant.NAV_TYPE nav_type) {
|
|
||||||
// 显示导航类型选择的对话框
|
|
||||||
Constant.currentNaviType = nav_type;
|
|
||||||
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 {
|
|
||||||
// 已选择导航方式
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存小数点后两位
|
* 保存小数点后两位
|
||||||
@@ -328,7 +251,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
EventBus.getDefault().post(obtains);
|
EventBus.getDefault().post(obtains);
|
||||||
break;
|
break;
|
||||||
case R.id.btn_cancel_get://结束领取
|
case R.id.btn_cancel_get://结束领取
|
||||||
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了取消领取的按钮 ,");
|
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了结束领取的按钮 ,");
|
||||||
if (poiEntity != null) {
|
if (poiEntity != null) {
|
||||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, poiEntity);
|
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, poiEntity);
|
||||||
}
|
}
|
||||||
@@ -344,9 +267,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, 0);
|
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, false, 1);
|
||||||
} else if (type == 4) {//道路的领取类型
|
} else if (type == 4) {//道路的领取类型
|
||||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1, 0);
|
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1);
|
||||||
} else if (type == 5) {//其他的领取类型
|
} else if (type == 5) {//其他的领取类型
|
||||||
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, false, 1);
|
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, false, 1);
|
||||||
}
|
}
|
||||||
@@ -355,28 +278,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 = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
double latitude = Constant.currentLocation.getLatitude();
|
||||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
double longitude = Constant.currentLocation.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.showToast(getActivity(),"作业不在领取范围内,无法采集");
|
ToastUtils.Message(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) requireActivity(), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
initGather(0);
|
initGather();
|
||||||
//Voice.sprat("注意在附近50米范围内进行采集",1);
|
//Voice.sprat("注意在附近50米范围内进行采集",1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
initGather(0);
|
initGather();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -386,13 +309,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.getTaskId(), poiEntity);
|
initSubmitPolygonTask(HttpInterface.COMPLETE, 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);
|
||||||
requireActivity().runOnUiThread(new Runnable() {
|
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
poiEntity.setTaskStatus(0);
|
poiEntity.setTaskStatus(0);
|
||||||
@@ -407,7 +330,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGather(int matchTrack/*是否为根据轨迹手动匹配*/) {
|
private void initGather() {
|
||||||
if (poiEntity != null) {
|
if (poiEntity != null) {
|
||||||
int type = poiEntity.getType();
|
int type = poiEntity.getType();
|
||||||
if (type == 6) {
|
if (type == 6) {
|
||||||
@@ -422,9 +345,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, matchTrack);
|
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, true, 5);
|
||||||
} else if (type == 4) {//道路的领取类型
|
} else if (type == 4) {//道路的领取类型
|
||||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5, matchTrack);
|
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5);
|
||||||
} else if (type == 5) {//其他的领取类型
|
} else if (type == 5) {//其他的领取类型
|
||||||
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, true, 5);
|
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, true, 5);
|
||||||
}
|
}
|
||||||
@@ -457,13 +380,10 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
if (taskIdPoiEntity == null) {
|
if (taskIdPoiEntity == null) {
|
||||||
PoiEntity chargingStationEntity = new PoiEntity();
|
PoiEntity chargingStationEntity = new PoiEntity();
|
||||||
chargingStationEntity.setTaskId(poiEntity.getTaskId());
|
chargingStationEntity.setTaskId(poiEntity.getTaskId());
|
||||||
chargingStationEntity.setRecord_way(poiEntity.getRecord_way());
|
|
||||||
chargingStationEntity.setWork_type(poiEntity.getWork_type());
|
|
||||||
chargingStationEntity.setStation_type(stationBean.getSptype());
|
chargingStationEntity.setStation_type(stationBean.getSptype());
|
||||||
chargingStationEntity.setName(stationBean.getName());
|
chargingStationEntity.setName(stationBean.getName());
|
||||||
chargingStationEntity.setDescribe(stationBean.getMemo());
|
chargingStationEntity.setDescribe(stationBean.getMemo());
|
||||||
chargingStationEntity.setCreateTime(stationBean.getEndDate());
|
chargingStationEntity.setCreateTime(stationBean.getEndDate());
|
||||||
chargingStationEntity.setUnReceivedTime(stationBean.getUnReceivedTime());
|
|
||||||
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
|
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
|
||||||
chargingStationEntity.setAddress(stationBean.getAddress());
|
chargingStationEntity.setAddress(stationBean.getAddress());
|
||||||
if (stationBean.getTelephone() == null || stationBean.getTelephone().equals("") || stationBean.getTelephone().equals("null")) {
|
if (stationBean.getTelephone() == null || stationBean.getTelephone().equals("") || stationBean.getTelephone().equals("null")) {
|
||||||
@@ -500,7 +420,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
initViewByTaskStatus(1);
|
initViewByTaskStatus(1);
|
||||||
ToastUtils.showToast(requireContext(), "领取成功");
|
|
||||||
if (isSaver) {
|
if (isSaver) {
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.GATHER_GET_MAP;
|
obtain.what = Constant.GATHER_GET_MAP;
|
||||||
@@ -543,7 +462,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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,9 +472,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
Log.d("TAG", "onError: " + e.getMessage());
|
Log.d("TAG", "onError: " + e.getMessage());
|
||||||
}
|
}
|
||||||
@@ -567,103 +486,78 @@ 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.showToast(getActivity(),"无此任务");
|
ToastUtils.Message(getActivity(),"无此任务");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 如果当前存在未关闭的面状任务,提示用户无法领取,先关闭已领取的面状任务
|
showLoadingDialog();
|
||||||
new Thread(new Runnable() {
|
OkGoBuilder.getInstance()
|
||||||
@Override
|
.time(30)
|
||||||
public void run() {
|
.Builder(getActivity())
|
||||||
List<PoiEntity> recivePolygonPoi = new ArrayList<>();
|
.url(url + "/" + poiEntity.getTaskId())
|
||||||
// 如果点击立即采集,则面状任务taskstatus可能是2,如果点击领取任务,则可能是1,所以需要查询两个状态的数据
|
.cls(PolygonTaskBean.class)
|
||||||
List<PoiEntity> recivePolygonPoi1 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(1, 6);
|
.token(Constant.ACCESS_TOKEN)
|
||||||
List<PoiEntity> recivePolygonPoi2 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(2, 6);
|
.params(new HttpParams())
|
||||||
recivePolygonPoi.addAll(recivePolygonPoi1);
|
.getRequest(new Callback<PolygonTaskBean>() {
|
||||||
recivePolygonPoi.addAll(recivePolygonPoi2);
|
|
||||||
requireActivity().runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void onSuccess(PolygonTaskBean response, int id) {
|
||||||
if (recivePolygonPoi!=null&&!recivePolygonPoi.isEmpty()) {
|
dismissLoadingDialog();
|
||||||
ToastUtils.showToast(requireActivity(),"您当前存在已领取的其他面状任务,请先关闭该任务后再领取!");
|
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集),
|
||||||
return;
|
PolygonTaskBean.BodyBean listBean = response.getBody();
|
||||||
}
|
PoiEntity polygonEntity = new PoiEntity();
|
||||||
|
if (listBean != null) {
|
||||||
showLoadingDialog();
|
polygonEntity.setTaskId(listBean.getId());
|
||||||
OkGoBuilder.getInstance()
|
polygonEntity.setName(listBean.getName());
|
||||||
.time(30)
|
polygonEntity.setType(listBean.getType());
|
||||||
.Builder(getActivity())
|
polygonEntity.setGeoWkt(listBean.getGeo());
|
||||||
.url(url + "/" + poiEntity.getTaskId())
|
String encodeStr = listBean.getGeo();
|
||||||
.cls(PolygonTaskBean.class)
|
String geo = Geohash.getInstance().decode(encodeStr);
|
||||||
.token(Constant.ACCESS_TOKEN)
|
// 生成对应的x和y poiEntity.setX
|
||||||
.params(new HttpParams())
|
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
|
||||||
.getRequest(new Callback<PolygonTaskBean>() {
|
polygonEntity.setTaskStatus(1);
|
||||||
@Override
|
}
|
||||||
public void onSuccess(PolygonTaskBean response, int id) {
|
new Thread(new Runnable() {
|
||||||
dismissLoadingDialog();
|
@Override
|
||||||
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集),
|
public void run() {
|
||||||
PolygonTaskBean.BodyBean listBean = response.getBody();
|
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), polygonEntity);
|
||||||
PoiEntity polygonEntity = new PoiEntity();
|
if (getActivity() != null) {
|
||||||
polygonEntity.setRecord_way(poiEntity.getRecord_way());
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
polygonEntity.setWork_type(poiEntity.getWork_type());
|
@Override
|
||||||
if (listBean != null) {
|
public void run() {
|
||||||
polygonEntity.setTaskId(listBean.getId());
|
initViewByTaskStatus(1);
|
||||||
polygonEntity.setName(listBean.getName());
|
ToastUtils.Message(getActivity(),"领取成功");
|
||||||
polygonEntity.setType(listBean.getType());
|
if (aBoolean) {
|
||||||
polygonEntity.setGeoWkt(listBean.getGeo());
|
initCompleteTask(HttpInterface.SUBMIT_POLYGON_TASK, polygonEntity);
|
||||||
polygonEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
} else {
|
||||||
String encodeStr = listBean.getGeo();
|
Message obtains = Message.obtain();
|
||||||
String geo = Geohash.getInstance().decode(encodeStr);
|
obtains.what = Constant.JOB_WORD_MONITOR;
|
||||||
// 生成对应的x和y poiEntity.setX
|
obtains.obj = true;
|
||||||
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
|
EventBus.getDefault().post(obtains);
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} else if (response.getCode() == 230) {
|
||||||
|
FlushTokenUtil.flushToken(getActivity());
|
||||||
|
} else {
|
||||||
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable e, int id) {
|
public void onError(Throwable e, int id) {
|
||||||
dismissLoadingDialog();
|
dismissLoadingDialog();
|
||||||
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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
Log.d("TAG", "onError: " + e.getMessage());
|
Log.d("TAG", "onError: " + e.getMessage());
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -672,7 +566,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.showToast(getActivity(),"无此任务");
|
ToastUtils.Message(getActivity(),"无此任务");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
@@ -703,7 +597,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.d("TAG", "run: " + response.getMessage());
|
Log.d("TAG", "run: " + response.getMessage());
|
||||||
ToastUtils.showToast(requireContext(), "已取消领取:" + poiEntity.getName());
|
|
||||||
initViewByTaskStatus(0);
|
initViewByTaskStatus(0);
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||||
@@ -717,7 +610,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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,9 +620,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -740,7 +633,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.showToast(getActivity(),"无此任务");
|
ToastUtils.Message(getActivity(),"无此任务");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
@@ -784,7 +677,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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,9 +687,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -807,23 +700,12 @@ 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.showToast(getActivity(),"无此任务");
|
ToastUtils.Message(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())
|
||||||
@@ -834,36 +716,18 @@ 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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,9 +737,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -886,7 +750,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.showToast(getActivity(),"无此任务");
|
ToastUtils.Message(getActivity(),"无此任务");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
@@ -915,12 +779,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
poiListEntity.setName(listBean.getName());
|
poiListEntity.setName(listBean.getName());
|
||||||
poiListEntity.setDescribe(listBean.getMemo());
|
poiListEntity.setDescribe(listBean.getMemo());
|
||||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||||
poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
|
||||||
poiListEntity.setAddress(listBean.getAddress());
|
poiListEntity.setAddress(listBean.getAddress());
|
||||||
poiListEntity.setType(listBean.getType());
|
poiListEntity.setType(listBean.getType());
|
||||||
poiListEntity.setIsExclusive(listBean.getIsExclusive());
|
poiListEntity.setIsExclusive(listBean.getIsExclusive());
|
||||||
poiListEntity.setRecord_way(poiEntity.getRecord_way());
|
|
||||||
poiListEntity.setWork_type(poiEntity.getWork_type());
|
|
||||||
if (listBean.getType() == 1) {
|
if (listBean.getType() == 1) {
|
||||||
if (listBean.getTelephone() == null || listBean.getTelephone().equals("") || listBean.getTelephone().equals("null")) {
|
if (listBean.getTelephone() == null || listBean.getTelephone().equals("") || listBean.getTelephone().equals("null")) {
|
||||||
poiListEntity.setTelPhone(null);
|
poiListEntity.setTelPhone(null);
|
||||||
@@ -942,7 +803,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
initViewByTaskStatus(1);//已领取
|
initViewByTaskStatus(1);//已领取
|
||||||
ToastUtils.showToast(requireContext(), "领取成功");
|
|
||||||
if (isSaver) {
|
if (isSaver) {
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.GATHER_GET_MAP;
|
obtain.what = Constant.GATHER_GET_MAP;
|
||||||
@@ -985,7 +845,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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -995,9 +855,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1015,7 +875,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, int matchTrack) {
|
private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) {
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||||
.getInstance()
|
.getInstance()
|
||||||
@@ -1028,6 +888,7 @@ 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) {
|
||||||
@@ -1038,12 +899,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
if (taskIdPoiEntity == null) {//数据库没有这条数据
|
if (taskIdPoiEntity == null) {//数据库没有这条数据
|
||||||
PoiEntity poiListEntity = new PoiEntity();
|
PoiEntity poiListEntity = new PoiEntity();
|
||||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||||
poiListEntity.setRecord_way(poiEntity.getRecord_way());
|
|
||||||
poiListEntity.setWork_type(poiEntity.getWork_type());
|
|
||||||
poiListEntity.setName(listBean.getName());
|
poiListEntity.setName(listBean.getName());
|
||||||
poiListEntity.setMemo(listBean.getMemo());
|
poiListEntity.setMemo(listBean.getMemo());
|
||||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||||
poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
|
||||||
poiListEntity.setAddress(listBean.getAddress());
|
poiListEntity.setAddress(listBean.getAddress());
|
||||||
poiListEntity.setType(listBean.getType());
|
poiListEntity.setType(listBean.getType());
|
||||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||||
@@ -1062,12 +920,10 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
initViewByTaskStatus(1);
|
initViewByTaskStatus(1);
|
||||||
ToastUtils.showToast(requireContext(), "领取成功");
|
|
||||||
if (isSaver) {
|
if (isSaver) {
|
||||||
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();
|
||||||
@@ -1088,7 +944,6 @@ 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();
|
||||||
@@ -1107,9 +962,8 @@ 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.showToast(getActivity(),response.getMessage());
|
ToastUtils.Message(getActivity(),response.getMessage());
|
||||||
}
|
}
|
||||||
dismissLoadingDialog();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1118,9 +972,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.showToast(getActivity(),"请求超时");
|
ToastUtils.Message(getActivity(),"请求超时");
|
||||||
} else {
|
} else {
|
||||||
ToastUtils.showToast(getActivity(),message);
|
ToastUtils.Message(getActivity(),message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ public class GatheringFragment 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.Message(getActivity(), "绑定失败!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,553 +0,0 @@
|
|||||||
package com.navinfo.outdoor.fragment;
|
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.SharedPreferences;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.CheckBox;
|
|
||||||
import android.widget.CompoundButton;
|
|
||||||
import android.widget.TextView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.elvishew.xlog.Logger;
|
|
||||||
import com.elvishew.xlog.XLog;
|
|
||||||
import com.github.lazylibrary.util.FileUtils;
|
|
||||||
import com.github.lazylibrary.util.MD5;
|
|
||||||
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
|
|
||||||
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
|
|
||||||
import com.kongzue.dialog.util.BaseDialog;
|
|
||||||
import com.kongzue.dialog.util.DialogSettings;
|
|
||||||
import com.kongzue.dialog.v3.BottomMenu;
|
|
||||||
import com.kongzue.dialog.v3.MessageDialog;
|
|
||||||
import com.lzy.okgo.model.HttpParams;
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.adapter.HasReceiveAdapter;
|
|
||||||
import com.navinfo.outdoor.adapter.StaySubmitAdapter;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.base.BaseFragment;
|
|
||||||
import com.navinfo.outdoor.bean.CommonRequestSend;
|
|
||||||
import com.navinfo.outdoor.bean.CommonResponse;
|
|
||||||
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.PoiDao;
|
|
||||||
import com.navinfo.outdoor.room.PoiDatabase;
|
|
||||||
import com.navinfo.outdoor.room.PoiEntity;
|
|
||||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
|
||||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
|
||||||
import com.navinfo.outdoor.util.PoiEntityDeleteUtil;
|
|
||||||
import com.navinfo.outdoor.util.PoiSaveUtils;
|
|
||||||
import com.navinfo.outdoor.util.TimestampUtil;
|
|
||||||
import com.navinfo.outdoor.util.ToastUtils;
|
|
||||||
import com.navinfo.outdoor.util.XLogUtils;
|
|
||||||
import com.umeng.umcrash.UMCrash;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
|
||||||
import org.greenrobot.eventbus.ThreadMode;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
public class HasReceiveFragment extends BaseFragment implements View.OnClickListener {
|
|
||||||
private HasReceiveAdapter hasReceiveAdapter;
|
|
||||||
private TextView tvStayType,tvNumber;
|
|
||||||
private List<PoiEntity> roadEntities;
|
|
||||||
private ArrayList<PoiEntity> poiEntities;
|
|
||||||
private CheckBox cbSelect;
|
|
||||||
private File logFile;
|
|
||||||
// private StringBuilder staySubmitBuilder;
|
|
||||||
private Logger logger;
|
|
||||||
|
|
||||||
public static HasReceiveFragment newInstance(Bundle bundle) {
|
|
||||||
HasReceiveFragment fragment = new HasReceiveFragment();
|
|
||||||
fragment.setArguments(bundle);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart() {
|
|
||||||
super.onStart();
|
|
||||||
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
|
|
||||||
EventBus.getDefault().register(this);
|
|
||||||
}
|
|
||||||
logger=XLogUtils.Companion.getInstance().getUploadLogWriter();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getLayout() {
|
|
||||||
return R.layout.fragment_has_receive;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
protected void initView() {
|
|
||||||
super.initView();
|
|
||||||
ConstraintLayout clStayType = findViewById(R.id.cl_has_receive_type);
|
|
||||||
clStayType.setOnClickListener(this);
|
|
||||||
cbSelect = findViewById(R.id.cb_select);
|
|
||||||
cbSelect.setOnClickListener(this);
|
|
||||||
TextView tvDelete = findViewById(R.id.tv_delete);
|
|
||||||
tvDelete.setOnClickListener(this);
|
|
||||||
tvStayType = findViewById(R.id.tv_stay_type);
|
|
||||||
Button btnStaySubmit = findViewById(R.id.btn_stay_submit);
|
|
||||||
tvNumber = findViewById(R.id.tv_number);
|
|
||||||
btnStaySubmit.setOnClickListener(this);
|
|
||||||
Button btnStayCancel = findViewById(R.id.btn_stay_cancel);
|
|
||||||
btnStayCancel.setOnClickListener(this);
|
|
||||||
RecyclerView stayXrv = findViewById(R.id.stay_xrv);
|
|
||||||
stayXrv.setLayoutManager(new LinearLayoutManager(getActivity()));
|
|
||||||
stayXrv.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));
|
|
||||||
hasReceiveAdapter = new HasReceiveAdapter(getContext());
|
|
||||||
stayXrv.setAdapter(hasReceiveAdapter);
|
|
||||||
//点击条目跳转
|
|
||||||
hasReceiveAdapter.setOnClickItem(new HasReceiveAdapter.onClickItem() {
|
|
||||||
@Override
|
|
||||||
public void item(int position, PoiEntity poiEntity) {
|
|
||||||
Message subObtain = Message.obtain();
|
|
||||||
subObtain.what = Constant.EVENT_WORK_HOME;
|
|
||||||
subObtain.obj = true;
|
|
||||||
EventBus.getDefault().post(subObtain);
|
|
||||||
Message obtain = Message.obtain();
|
|
||||||
obtain.what = Constant.EVENT_WHAT_HAS_RECEIVE_ITEM;
|
|
||||||
obtain.obj = poiEntity;
|
|
||||||
EventBus.getDefault().post(obtain);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//全选
|
|
||||||
cbSelect.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
||||||
if (Constant.isPresent) {
|
|
||||||
hasReceiveAdapter.setAllDataChecked(isChecked);
|
|
||||||
hasReceiveAdapter.notifyDataSetChanged();
|
|
||||||
} else {
|
|
||||||
cbSelect.setChecked(false);
|
|
||||||
ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
|
||||||
if (Constant.USHERED != null) {
|
|
||||||
cbSelect.setChecked(false);
|
|
||||||
refreshData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
|
||||||
public void onEvent(Message data) {
|
|
||||||
if (data.what == Constant.HAS_RECEIVE_ITEM) {
|
|
||||||
if ((boolean) data.obj) {
|
|
||||||
if (Constant.USHERED != null) {
|
|
||||||
refreshData();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// else if (data.what == Constant.EVENT_WHAT_UPLOAD_PROGRESS) {
|
|
||||||
// if (data.obj!=null&&hasReceiveAdapter!=null&&hasReceiveAdapter.getAllRoad()!=null) {
|
|
||||||
// for (int i = 0; i < hasReceiveAdapter.getAllRoad().size(); i++) {
|
|
||||||
// if (data.obj == hasReceiveAdapter.getAllRoad().get(i)) {
|
|
||||||
// hasReceiveAdapter.notifyItemChanged(i);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
|
||||||
super.onSaveInstanceState(outState);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop() {
|
|
||||||
super.onStop();
|
|
||||||
dismissLoadingDialog();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initRoadWord(int type) {
|
|
||||||
if (roadEntities == null) {
|
|
||||||
roadEntities = new ArrayList<>();
|
|
||||||
} else {
|
|
||||||
roadEntities.clear();
|
|
||||||
}
|
|
||||||
PoiDatabase roadDatabase = PoiDatabase.getInstance(getContext());
|
|
||||||
if (roadDatabase != null) {
|
|
||||||
PoiDao roadDao = roadDatabase.getPoiDao();
|
|
||||||
if (roadDao != null) {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
List<PoiEntity> roadAll = null;
|
|
||||||
if (type == 0) {
|
|
||||||
roadAll = roadDao.getHasReceivePoiByRecoded();
|
|
||||||
} else {
|
|
||||||
roadAll = roadDao.getHasReceivePoiType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
|
||||||
List<PoiEntity> finalRoadAll = roadAll;
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
roadEntities.clear();
|
|
||||||
roadEntities.addAll(finalRoadAll);
|
|
||||||
hasReceiveAdapter.setAllRoad(roadEntities);
|
|
||||||
hasReceiveAdapter.notifyDataSetChanged();
|
|
||||||
if (tvNumber != null) {
|
|
||||||
tvNumber.setText(hasReceiveAdapter.getAllRoad().size() + "条");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
UMCrash.generateCustomLog(e, "自定义");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "无法读取数据库,请尝试重启程序!");
|
|
||||||
UMCrash.generateCustomLog("无法读取数据库", "自定义");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "数据库创建失败,请关闭程序重新进入");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.cl_stay_type://1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
|
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
|
||||||
BottomMenu.show((AppCompatActivity) requireActivity(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
public void onClick(String text, int index) {
|
|
||||||
switch (index) {
|
|
||||||
case 0:
|
|
||||||
initRoadWord(0);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
initRoadWord(1);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
initRoadWord(2);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
initRoadWord(3);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
initRoadWord(4);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
initRoadWord(5);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
tvStayType.setText(text);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case R.id.tv_delete:
|
|
||||||
List<PoiEntity> checkedPoiEntityList = hasReceiveAdapter.getCheckedPoiEntity();
|
|
||||||
if (checkedPoiEntityList == null || checkedPoiEntityList.isEmpty()) {
|
|
||||||
ToastUtils.Message(getActivity(), "没有勾选任何数据!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logger.d("用户点击批量删除按钮+++++++++++++++++++++++");
|
|
||||||
if (Constant.isPresent) {
|
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
|
||||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
|
||||||
logger.d("用户点击确认批量删除按钮+++++++++++++++++++++++");
|
|
||||||
initRequest(hasReceiveAdapter.getCheckedPoiEntity());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.btn_stay_submit://提交
|
|
||||||
logger.d("用户点击批量上传提交按钮+++++++++++++++++++++++");
|
|
||||||
if (Constant.isPresent) {
|
|
||||||
if (poiEntities == null) {
|
|
||||||
poiEntities = new ArrayList<>();
|
|
||||||
} else {
|
|
||||||
poiEntities.clear();
|
|
||||||
}
|
|
||||||
List<PoiEntity> allRoad = hasReceiveAdapter.getAllRoad();
|
|
||||||
for (int i = 0; i < allRoad.size(); i++) {
|
|
||||||
if (allRoad.get(i).isChecked()) {
|
|
||||||
poiEntities.add(allRoad.get(i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (poiEntities.size() > 0) {
|
|
||||||
Constant.isPresent = false;
|
|
||||||
hasReceiveAdapter.setUpdateWork();
|
|
||||||
PoiSaveUtils.getInstance(getActivity()).uploadPoiEntityBatch(poiEntities);
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "请选择要提交的数据");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.btn_stay_cancel:
|
|
||||||
// 用户点击取消上传
|
|
||||||
PoiSaveUtils.getInstance(requireActivity()).cancelUploadPoiEntityBatch();
|
|
||||||
// 数据上传取消后重置上传状态
|
|
||||||
hasReceiveAdapter.setAllWorkType(0);
|
|
||||||
// 设置当前没有正在上传的数据
|
|
||||||
Constant.isPresent = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initRequest(List<PoiEntity> poiEntities) {
|
|
||||||
showLoadingDialog();
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (getActivity() != null) {
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
StringBuilder taskIds = new StringBuilder();
|
|
||||||
StringBuilder auditIds = new StringBuilder();
|
|
||||||
for (int i = 0; i < poiEntities.size(); i++) {
|
|
||||||
if (poiEntities.get(i).getTaskStatus() == 2) {
|
|
||||||
taskIds.append(poiEntities.get(i).getTaskId()).append(",");
|
|
||||||
} else if (poiEntities.get(i).getTaskStatus() == 3) {
|
|
||||||
auditIds.append(poiEntities.get(i).getBodyId()).append(",");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!taskIds.toString().equals("")) {
|
|
||||||
taskIds = new StringBuilder(taskIds.substring(0, taskIds.length() - 1));
|
|
||||||
}
|
|
||||||
if (!auditIds.toString().equals("")) {
|
|
||||||
auditIds = new StringBuilder(auditIds.substring(0, auditIds.length() - 1));
|
|
||||||
}
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("taskIds", taskIds.toString());
|
|
||||||
httpParams.put("auditIds", auditIds.toString());
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
|
||||||
.time(30)
|
|
||||||
.Builder(getActivity())
|
|
||||||
.url(HttpInterface.UNRECEIVED_POLYGON_TASK)
|
|
||||||
.params(httpParams)
|
|
||||||
.token(Constant.ACCESS_TOKEN)
|
|
||||||
.cls(UnPolygonTaskBean.class);
|
|
||||||
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(UnPolygonTaskBean response, int id) {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
// 启动线程删除对应的图片文件
|
|
||||||
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 {
|
|
||||||
hasReceiveAdapter.setAllCheckedDelete();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void refreshData() {
|
|
||||||
if (roadEntities == null) {
|
|
||||||
roadEntities = new ArrayList<>();
|
|
||||||
} else {
|
|
||||||
roadEntities.clear();
|
|
||||||
}
|
|
||||||
PoiDatabase roadDatabase = PoiDatabase.getInstance(getContext());
|
|
||||||
if (roadDatabase != null) {
|
|
||||||
PoiDao roadDao = roadDatabase.getPoiDao();
|
|
||||||
if (roadDao != null) {
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
List<PoiEntity> roadAll = roadDao.getHasReceivePoiByRecoded();
|
|
||||||
|
|
||||||
// 首先过滤数据中记录的领取失效时间超限的数据
|
|
||||||
Iterator iterator = roadAll.iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
PoiEntity poiEntity = (PoiEntity) iterator.next();
|
|
||||||
if (poiEntity.getUnReceivedTimeStamp()<=new Date().getTime()) {
|
|
||||||
// 删除该条数据,并且将此数据移除出当前列表
|
|
||||||
roadDao.deletePoiEntity(poiEntity);
|
|
||||||
iterator.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 再次请求在线已领取数据,做差分处理
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("datetime", System.currentTimeMillis());
|
|
||||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<List<Double>>>();
|
|
||||||
CommonResponse<List<Double>> response = commonRequestSend.getMethodCommonSync(requireActivity(), HttpInterface.GET_RECEIVED_LIST, httpParams, Constant.DEFAULT_TIME_OUT, new CommonResponse<List<Double>>().getClass());
|
|
||||||
if (response!=null) {
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
List<Double> ids = response.getBody();
|
|
||||||
|
|
||||||
// 使用id过滤已有的数据,如果数据不在ids中,需要删除该数据,过滤掉
|
|
||||||
Iterator iteratorAgain = roadAll.iterator();
|
|
||||||
a:while (iteratorAgain.hasNext()) {
|
|
||||||
PoiEntity poiEntity = (PoiEntity) iteratorAgain.next();
|
|
||||||
for (double id: ids) {
|
|
||||||
if (((int)id) == poiEntity.getTaskId()) {
|
|
||||||
continue a;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 数据库中移除该数据
|
|
||||||
roadDao.deletePoiEntity(poiEntity);
|
|
||||||
iteratorAgain.remove();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(requireActivity(), response.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getActivity() != null) {
|
|
||||||
getActivity().runOnUiThread(new Runnable() {
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
roadEntities.clear();
|
|
||||||
roadEntities.addAll(roadAll);
|
|
||||||
hasReceiveAdapter.setAllRoad(roadEntities);
|
|
||||||
hasReceiveAdapter.notifyDataSetChanged();
|
|
||||||
if (tvNumber != null) {
|
|
||||||
tvNumber.setText(hasReceiveAdapter.getAllRoad().size() + "条");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
ToastUtils.Message(requireActivity(), "初始化数据失败!");
|
|
||||||
XLog.e("获取数据失败:" + e.getMessage());
|
|
||||||
UMCrash.generateCustomLog(e, "自定义");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "无法读取数据库,请尝试重启程序!");
|
|
||||||
UMCrash.generateCustomLog("无法读取数据库", "自定义");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "数据库创建失败,请关闭程序重新进入");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDestroy() {
|
|
||||||
if (EventBus.getDefault().isRegistered(this))//加上判断
|
|
||||||
EventBus.getDefault().unregister(this);
|
|
||||||
super.onDestroy();
|
|
||||||
dismissLoadingDialog();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -23,14 +23,10 @@ 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;
|
||||||
@@ -38,6 +34,7 @@ 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;
|
||||||
@@ -109,9 +106,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
// if (((HomeActivity)getActivity()).getCurrentTabSelected() == 1) {
|
initRequest();
|
||||||
// initRequest();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -136,7 +131,6 @@ 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,20 +14,14 @@ 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;
|
||||||
@@ -35,8 +29,6 @@ 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;
|
||||||
@@ -51,19 +43,8 @@ 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
|
||||||
*/
|
*/
|
||||||
@@ -124,8 +105,6 @@ 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);
|
||||||
@@ -195,10 +174,7 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
|
|||||||
public void onError(Throwable e, int id) {
|
public void onError(Throwable e, int id) {
|
||||||
dismissLoadingDialog();
|
dismissLoadingDialog();
|
||||||
String message = e.getMessage();
|
String message = e.getMessage();
|
||||||
if (message == null) {
|
assert message != null;
|
||||||
ToastUtils.Message(getActivity(), "获取余额失败,请重试!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||||
ToastUtils.Message(getActivity(), "请求超时");
|
ToastUtils.Message(getActivity(), "请求超时");
|
||||||
} else {
|
} else {
|
||||||
@@ -274,85 +250,6 @@ 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);
|
||||||
@@ -363,7 +260,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);
|
||||||
requireActivity().finish();
|
Objects.requireNonNull(getActivity()).finish();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ 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;
|
||||||
@@ -70,7 +69,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -513,14 +512,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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File file = PhotoUtils.showPhotoFile("a", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File files = PhotoUtils.showPhotoFile("b", latLng);
|
||||||
intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath());
|
intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath());
|
||||||
startActivityForResult(intentPictures, 102);
|
startActivityForResult(intentPictures, 102);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -37,9 +37,6 @@ import java.util.Comparator;
|
|||||||
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.stream.Collectors;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图片-fragment
|
* 图片-fragment
|
||||||
@@ -110,36 +107,33 @@ public class PhotoFragment extends BaseFragment implements View.OnClickListener
|
|||||||
List<File> fileArrayList = new ArrayList<>();
|
List<File> fileArrayList = new ArrayList<>();
|
||||||
if (fileListByUUID.size() >= 2) {
|
if (fileListByUUID.size() >= 2) {
|
||||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||||
File file = fileListByUUID.get(i);
|
if (!fileListByUUID.get(i).getPath().contains("paper.txt")) {
|
||||||
// 过滤分包数据,如果不是txt和照片文件,则自动跳过
|
|
||||||
if (!file.getName().endsWith(".txt")&&!file.getName().endsWith(".webp")&&!file.getName().endsWith(".jpg")&&!file.getName().endsWith(".png")&&!file.getName().endsWith(".jpeg")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!fileListByUUID.get(i).getPath().endsWith("paper.txt")) {
|
|
||||||
fileArrayList.add(fileListByUUID.get(i));
|
fileArrayList.add(fileListByUUID.get(i));
|
||||||
} else {
|
} else {
|
||||||
fileTxt = fileListByUUID.get(i);
|
fileTxt = fileListByUUID.get(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(fileArrayList, new Comparator<File>() {
|
||||||
fileArrayList = fileArrayList.stream().sorted(new Comparator<File>() {
|
|
||||||
@Override
|
@Override
|
||||||
public int compare(File o1, File o2) {
|
public int compare(File o1, File o2) {
|
||||||
String o1Name = o1.getName().replace(".webp","").replace(".jpg", "").replace(".png", "").replace("jpeg", "");
|
String[] split = o1.getName().split(".webp");
|
||||||
String o2Name = o2.getName().replace(".webp","").replace(".jpg", "").replace(".png", "").replace("jpeg", "");
|
int i = Integer.parseInt(split[0]);
|
||||||
if (Integer.parseInt(o1Name)>Integer.parseInt(o2Name)) {
|
String[] split2 = o2.getName().split(".webp");
|
||||||
|
int i2 = Integer.parseInt(split2[0]);
|
||||||
|
if (i > i2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).collect(Collectors.toList());
|
});
|
||||||
|
|
||||||
if (fileArrayList.size() > 0) {
|
if (fileArrayList.size() > 0) {
|
||||||
for (int i = 0; i < fileArrayList.size(); i++) {
|
for (int i = 0; i < fileArrayList.size(); i++) {
|
||||||
if (fileArrayList.get(i).exists()) {
|
if (fileArrayList.get(i).getPath().contains(".webp") && !fileArrayList.get(i).getPath().contains("paper.txt")) {
|
||||||
fileBeans.add(new FileBean(fileArrayList.get(i), false));
|
if (fileArrayList.get(i).exists()) {
|
||||||
|
fileBeans.add(new FileBean(fileArrayList.get(i), false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ 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;
|
||||||
@@ -78,7 +77,7 @@ import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
|||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -344,7 +343,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
|||||||
initShowPoi();
|
initShowPoi();
|
||||||
//拍照长按删除
|
//拍照长按删除
|
||||||
onLongDel();
|
onLongDel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//拍照长按删除
|
//拍照长按删除
|
||||||
@@ -617,7 +615,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
|||||||
if (getPhoneBean.getCode() == 200) {
|
if (getPhoneBean.getCode() == 200) {
|
||||||
String code = getPhoneBean.getBody().getCode();
|
String code = getPhoneBean.getBody().getCode();
|
||||||
Integer telLength = getPhoneBean.getBody().getTelLength();
|
Integer telLength = getPhoneBean.getBody().getTelLength();
|
||||||
if (code!=null&&!Constant.CODE.equals(code)) {
|
if (!Constant.CODE.equals(code)) {
|
||||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "此地区区号为" + code + ",请手动修改", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "此地区区号为" + code + ",请手动修改", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@@ -817,35 +815,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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File filePanorama = PhotoUtils.showPhotoFile("a", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File fileName = PhotoUtils.showPhotoFile("b", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File fileInternal = PhotoUtils.showPhotoFile("c", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File fileCard = PhotoUtils.showPhotoFile("d", latLng);
|
||||||
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(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
File fileElse = PhotoUtils.showPhotoFile("e", latLng);
|
||||||
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, fileElse.getPath());
|
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, fileElse.getPath());
|
||||||
startActivityForResult(intentElse, 105);
|
startActivityForResult(intentElse, 105);
|
||||||
break;
|
break;
|
||||||
@@ -1003,7 +1001,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
|||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("auditId", body);
|
httpParams.put("auditId", body);
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
.time(600)
|
.time(0)
|
||||||
.Builder(getActivity())
|
.Builder(getActivity())
|
||||||
.url(HttpInterface.POI_TASK_UPLOAD_PIC)
|
.url(HttpInterface.POI_TASK_UPLOAD_PIC)
|
||||||
.cls(OtherUploadPicBean.class)
|
.cls(OtherUploadPicBean.class)
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ 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;
|
||||||
@@ -140,7 +139,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 (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
if (Constant.currentLocation != null) {
|
||||||
if (Constant.USHERED != null) {
|
if (Constant.USHERED != null) {
|
||||||
initWork(type, true);
|
initWork(type, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ 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;
|
||||||
@@ -39,6 +40,7 @@ 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;
|
||||||
@@ -46,25 +48,25 @@ 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.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.sothree.slidinguppanel.SlidingUpPanelLayout;
|
import com.navinfo.outdoor.util.UploadUtils;
|
||||||
|
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;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -75,6 +77,7 @@ 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录像
|
||||||
@@ -91,7 +94,6 @@ 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();
|
||||||
@@ -143,18 +145,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) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").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);
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).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) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").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("点击了返回当前页面的 确定 按钮,");
|
||||||
@@ -182,7 +184,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -201,7 +203,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +231,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) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").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("点击了长按删除图片的 按钮,");
|
||||||
@@ -247,8 +249,6 @@ 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);
|
||||||
//添加数据
|
//添加数据
|
||||||
@@ -258,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 = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).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");
|
||||||
@@ -286,7 +286,6 @@ 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 +358,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(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
||||||
isImageLoad = true;
|
isImageLoad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -399,7 +398,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,13 +413,6 @@ 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -445,22 +437,20 @@ 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 = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
double latitude = Constant.currentLocation.getLatitude();
|
||||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
double longitude = Constant.currentLocation.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 (matchTrack == 0) {
|
if (geometry > rearGeometry) {//用戶在终点开始作业
|
||||||
if (geometry > rearGeometry) {//用戶在终点开始作业
|
if (rearGeometry > 5000) {
|
||||||
if (rearGeometry > 5000) {
|
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
} else {//用户在起点开始作业
|
||||||
} else {//用户在起点开始作业
|
if (geometry > 5000) {
|
||||||
if (geometry > 5000) {
|
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Intent intents = new Intent(getActivity(), PicturesActivity.class);
|
Intent intents = new Intent(getActivity(), PicturesActivity.class);
|
||||||
@@ -469,8 +459,7 @@ 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());
|
||||||
intents.putExtra(Constant.MATCH_TRACK, matchTrack);
|
int gpsRssi = Constant.currentLocation.getGPSRssi();
|
||||||
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 {
|
||||||
@@ -480,7 +469,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(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
|
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.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) {//用戶在终点开始作业
|
||||||
@@ -500,7 +489,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 = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
int gpsRss = Constant.currentLocation.getGPSRssi();
|
||||||
if (gpsRss == 0) {
|
if (gpsRss == 0) {
|
||||||
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||||
} else {
|
} else {
|
||||||
@@ -510,30 +499,62 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
break;
|
break;
|
||||||
case R.id.btn_poi_video_upload:
|
case R.id.btn_poi_video_upload:
|
||||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
||||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
if (Constant.isPresent) {
|
||||||
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
|
if (fmPoiVideoPic.getTag() != null) {
|
||||||
initPoiSaveLocal(true);
|
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
|
||||||
|
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
||||||
|
if (!existsPic) {
|
||||||
|
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ZipUtil.zipFiles(videoFileList, fileZip, null);
|
||||||
|
long zipTrueSize = ZipUtils.getZipTrueSize(fileZip.getAbsolutePath());
|
||||||
|
if (zipTrueSize > 0) {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (showPoiEntity == null) {
|
||||||
|
showPoiEntity = new PoiEntity();
|
||||||
|
}
|
||||||
|
if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 5) {
|
||||||
|
initPoiSaveLocal(true);
|
||||||
|
} else {
|
||||||
|
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
|
||||||
|
Constant.isPresent = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fileZip.delete();
|
||||||
|
ToastUtils.Message(getActivity(), "压缩文件失败,请重新提交");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} else {
|
||||||
|
dismissLoadingDialog();
|
||||||
|
ToastUtils.Message(getActivity(), "请录像");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
poiVideoUpload(poiEntity);
|
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
||||||
}
|
}
|
||||||
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)
|
||||||
@@ -581,7 +602,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
if (never) {
|
if (never) {
|
||||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -592,10 +613,8 @@ 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("geo", poiEntity.getGeoWkt());
|
httpParams.put("workType", 1);
|
||||||
// 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())
|
||||||
@@ -612,46 +631,32 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void poiVideoUpload(PoiEntity poiEntity) {
|
private void poiVideoUpload(int poiVideoBody, File fileZip) {
|
||||||
if (poiEntity.getBodyId() == 0) {
|
if (poiVideoBody == 0) {
|
||||||
ToastUtils.Message(getActivity(), "请先保存本地在上传");
|
ToastUtils.Message(getActivity(), "请先保存本地在上传");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Constant.isPresent) {
|
if (fileZip == null) {
|
||||||
if (fmPoiVideoPic.getTag() != null) {
|
ToastUtils.Message(getActivity(), "未压缩完成");
|
||||||
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
|
return;
|
||||||
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
}
|
||||||
if (!existsPic) {
|
HttpParams httpParams = new HttpParams();
|
||||||
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
httpParams.put("auditId", poiVideoBody);
|
||||||
return;
|
long time = System.currentTimeMillis();
|
||||||
}
|
httpParams.put("datetime", time);
|
||||||
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
httpParams.put("file", fileZip);
|
||||||
@Override
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
public void onStart() {
|
.time(0)
|
||||||
dismissLoadingDialog();
|
.Builder(getActivity())
|
||||||
Constant.isPresent = false;
|
.url(HttpInterface.POI_VIDEO_UPLOAD_PIC)
|
||||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
.cls(OtherUploadPicBean.class)
|
||||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
.params(httpParams)
|
||||||
WaitDialog.dismiss(3000);
|
.token(Constant.ACCESS_TOKEN);
|
||||||
}
|
if (getActivity() != null) {
|
||||||
|
okGoBuilder.postRequest(UploadUtils.getInstance().getPoiVideoUploadCallback(getActivity(), showPoiEntity, fileZip));
|
||||||
@Override
|
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||||
public void onFinish() {
|
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
||||||
Constant.isPresent = true;
|
WaitDialog.dismiss(3000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
ToastUtils.Message(getActivity(), "请录像拍照");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -660,10 +665,8 @@ 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("geo", poiEntity.getGeoWkt());
|
httpParams.put("workType", 1);
|
||||||
// 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)
|
||||||
@@ -689,7 +692,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
|||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
poiVideoUpload(poiEntity);
|
poiVideoUpload(poiVideoBody, fileZip);
|
||||||
|
Constant.isPresent = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -733,9 +737,6 @@ 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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -752,7 +753,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 = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
|
||||||
//获取Editor对象
|
//获取Editor对象
|
||||||
SharedPreferences.Editor edit = poi.edit();
|
SharedPreferences.Editor edit = poi.edit();
|
||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
@@ -866,8 +867,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 = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
|
String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||||
String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
|
String district = Constant.currentLocation.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("-");
|
||||||
@@ -878,7 +879,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());
|
||||||
requireActivity().runOnUiThread(new Runnable() {
|
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
etRoadName.setText(sb);
|
etRoadName.setText(sb);
|
||||||
@@ -897,19 +898,13 @@ 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&&!fileListByUUID.isEmpty()) {
|
if (fileListByUUID != null) {
|
||||||
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&&lineStringByFileList.size()>1) {
|
if (lineStringByFileList != null) {
|
||||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||||
if (lineString != null) {
|
if (lineString != null) {
|
||||||
poiEntity.setDetail(lineString);
|
poiEntity.setDetail(lineString);
|
||||||
@@ -917,15 +912,15 @@ 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&&lineStringByFileList.size()>1) {
|
if (lineStringByFileList != null) {
|
||||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||||
if (lineString != null) {
|
if (lineString != null) {
|
||||||
poiEntity.setDetail(lineString);
|
poiEntity.setDetail(lineString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
||||||
poiEntity.setPhoto(fileListByUUID.size()+"");
|
poiEntity.setPhoto(photoStr);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ 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;
|
||||||
@@ -19,7 +18,6 @@ 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;
|
||||||
@@ -30,8 +28,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();
|
||||||
@@ -47,11 +44,9 @@ public class RecordFragment extends BaseFragment {
|
|||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
super.initView();
|
super.initView();
|
||||||
tabRecord = findViewById(R.id.tab_record);
|
TabLayout 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<>();
|
||||||
// 待作业
|
|
||||||
fragments.add(new HasReceiveFragment());
|
|
||||||
// 待提交
|
// 待提交
|
||||||
fragments.add(new StaySubmitFragment());
|
fragments.add(new StaySubmitFragment());
|
||||||
// 已提交
|
// 已提交
|
||||||
@@ -72,21 +67,15 @@ public class RecordFragment extends BaseFragment {
|
|||||||
tabRecord.setupWithViewPager(vpRecord);
|
tabRecord.setupWithViewPager(vpRecord);
|
||||||
Objects.requireNonNull(tabRecord.getTabAt(0)).setText(names[0]);
|
Objects.requireNonNull(tabRecord.getTabAt(0)).setText(names[0]);
|
||||||
Objects.requireNonNull(tabRecord.getTabAt(1)).setText(names[1]);
|
Objects.requireNonNull(tabRecord.getTabAt(1)).setText(names[1]);
|
||||||
Objects.requireNonNull(tabRecord.getTabAt(2)).setText(names[2]);
|
|
||||||
tabRecord.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
tabRecord.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onTabSelected(TabLayout.Tab tab) {
|
public void onTabSelected(TabLayout.Tab tab) {
|
||||||
if (tab.getPosition()==0){
|
if (tab.getPosition()==0){
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.HAS_RECEIVE_ITEM;
|
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||||
obtain.obj=true;
|
obtain.obj=true;
|
||||||
EventBus.getDefault().post(obtain);
|
EventBus.getDefault().post(obtain);
|
||||||
}else if (tab.getPosition()==1){
|
}else if (tab.getPosition()==1){
|
||||||
Message obtain = Message.obtain();
|
|
||||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
|
||||||
obtain.obj = true;
|
|
||||||
EventBus.getDefault().post(obtain);
|
|
||||||
}else if (tab.getPosition()==2){
|
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.HAS_SUBMIT_ITEM;
|
obtain.what = Constant.HAS_SUBMIT_ITEM;
|
||||||
obtain.obj = true;
|
obtain.obj = true;
|
||||||
@@ -116,42 +105,9 @@ 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) { // 底部Tab切换为"记录"tab
|
|
||||||
if (tabRecord.getSelectedTabPosition() == 0) {
|
|
||||||
Message obtain = Message.obtain();
|
|
||||||
obtain.what = Constant.HAS_RECEIVE_ITEM;
|
|
||||||
obtain.obj = true;
|
|
||||||
EventBus.getDefault().post(obtain);
|
|
||||||
} else if (tabRecord.getSelectedTabPosition() == 1) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -13,8 +13,6 @@ import android.widget.Button;
|
|||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.RadioGroup;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -26,6 +24,7 @@ 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;
|
||||||
@@ -41,13 +40,13 @@ 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.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;
|
||||||
@@ -55,18 +54,19 @@ 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.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;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
import org.greenrobot.eventbus.Subscribe;
|
import org.greenrobot.eventbus.Subscribe;
|
||||||
@@ -78,6 +78,7 @@ 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;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 寻宝-点击上传弹窗-道路
|
* 寻宝-点击上传弹窗-道路
|
||||||
@@ -94,11 +95,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
private LatLng latLng, rearLatLng;
|
private LatLng latLng, rearLatLng;
|
||||||
private StringBuilder roadBuilder;
|
private StringBuilder roadBuilder;
|
||||||
private boolean booleanExtra = true;
|
private boolean booleanExtra = true;
|
||||||
private RadioButton rbtnRoadOpen/*道路已开通*/, rbtnRoadPartOpen/*道路部分开通*/, rbtnRoadHasntOpen/*道路未开通*/, rbtnRoadHasntFind/*道路未找到*/, rbtnRoadOther/*其他*/;
|
|
||||||
private RadioGroup rgRoadStatus; // 道路状态的radioGroup
|
|
||||||
private EditText edtCheckedOther;
|
|
||||||
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();
|
||||||
@@ -144,18 +140,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) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").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);
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).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) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").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("点击了返回当前页面的 确定 按钮,");
|
||||||
@@ -181,7 +177,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -200,7 +196,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
obtain1.obj = isSliding;
|
obtain1.obj = isSliding;
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
}
|
}
|
||||||
requireActivity().getSupportFragmentManager().popBackStack();
|
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,34 +210,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
protected void initView() {
|
protected void initView() {
|
||||||
super.initView();
|
super.initView();
|
||||||
rbtnRoadOpen = findViewById(R.id.rbtn_road_open);
|
|
||||||
rbtnRoadPartOpen = findViewById(R.id.rbtn_road_part_open);
|
|
||||||
rbtnRoadHasntOpen = findViewById(R.id.rbtn_road_hasnt_open);
|
|
||||||
rbtnRoadHasntFind = findViewById(R.id.rbtn_road_hasnt_find);
|
|
||||||
rbtnRoadOther = findViewById(R.id.rbtn_road_other);
|
|
||||||
rgRoadStatus = findViewById(R.id.rg_road_status);
|
|
||||||
edtCheckedOther = findViewById(R.id.edt_checked_other);
|
|
||||||
|
|
||||||
rgRoadStatus.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
||||||
@Override
|
|
||||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
||||||
rgRoadStatus.setTag(findViewById(checkedId).getTag());
|
|
||||||
existence = Integer.parseInt((findViewById(checkedId).getTag()).toString());
|
|
||||||
if (showPoiEntity!=null) {
|
|
||||||
showPoiEntity.setExistence(existence);
|
|
||||||
}
|
|
||||||
switch (checkedId) {
|
|
||||||
case R.id.rbtn_road_other:
|
|
||||||
edtCheckedOther.setVisibility(View.VISIBLE);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
edtCheckedOther.setVisibility(View.GONE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
tvPictures = findViewById(R.id.tv_pictures);
|
tvPictures = findViewById(R.id.tv_pictures);
|
||||||
tvPictures.setOnClickListener(this);
|
tvPictures.setOnClickListener(this);
|
||||||
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
|
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
|
||||||
@@ -258,7 +226,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) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").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("点击长按删除 确定按钮,");
|
||||||
@@ -276,8 +244,6 @@ 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);
|
||||||
//数据展示
|
//数据展示
|
||||||
@@ -287,7 +253,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
super.initData();
|
super.initData();
|
||||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).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");
|
||||||
@@ -315,7 +281,6 @@ 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("")) {
|
||||||
@@ -380,22 +345,21 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (describe != null && !describe.equals("")) {
|
if (describe != null && !describe.equals("")) {
|
||||||
etDesc.setText(describe);
|
etDesc.setText(describe);
|
||||||
}
|
}
|
||||||
// String photoList = showPoiEntity.getPhoto();//存儲在數據庫中的數據
|
String photoList = showPoiEntity.getPhoto();//存儲在數據庫中的數據
|
||||||
// if (!StringUtils.isEmpty(photoList)) {
|
if (!StringUtils.isEmpty(photoList)) {
|
||||||
boolean isImageLoad = false;
|
boolean isImageLoad = false;
|
||||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||||
if (fileListByUUID.get(i).getPath().endsWith(".webp") || fileListByUUID.get(i).getPath().endsWith(".png")
|
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
|
||||||
|| 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(requireActivity()).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
||||||
isImageLoad = true;
|
isImageLoad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmRoadPic.setTag(fileListByUUID);
|
fmRoadPic.setTag(fileListByUUID);
|
||||||
// }
|
}
|
||||||
if (showPoiEntity.getTaskStatus() == 3) {
|
if (showPoiEntity.getTaskStatus() == 3) {
|
||||||
disables();
|
disables();
|
||||||
}
|
}
|
||||||
@@ -403,15 +367,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (showPoiEntity.getTaskId()>0) {
|
if (showPoiEntity.getTaskId()>0) {
|
||||||
etRoadName.setEnabled(false);
|
etRoadName.setEnabled(false);
|
||||||
}
|
}
|
||||||
if (rgRoadStatus!=null) {
|
|
||||||
for (int i = 0; i < rgRoadStatus.getChildCount(); i++) {
|
|
||||||
RadioButton childAt = (RadioButton) rgRoadStatus.getChildAt(i);
|
|
||||||
if (Integer.parseInt(childAt.getTag().toString())==showPoiEntity.getExistence()) {
|
|
||||||
childAt.setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,8 +379,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (!StringUtils.isEmpty(photo)) {
|
if (!StringUtils.isEmpty(photo)) {
|
||||||
File videoFile = new File(photo);
|
File videoFile = new File(photo);
|
||||||
videoFileList.add(new File(photo));
|
videoFileList.add(new File(photo));
|
||||||
if (videoFile.getName().endsWith(".webp") || videoFile.getName().endsWith(".png")
|
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
|
||||||
|| videoFile.getName().endsWith(".jpg")|| videoFile.getName().endsWith(".jpeg")) {
|
|
||||||
if (videoFile.exists() && !isImageLoad) {
|
if (videoFile.exists() && !isImageLoad) {
|
||||||
// 使用glide加载视频的第一帧
|
// 使用glide加载视频的第一帧
|
||||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
|
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
|
||||||
@@ -445,14 +399,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
tvPictures.setEnabled(false);
|
tvPictures.setEnabled(false);
|
||||||
etDesc.setEnabled(false);
|
etDesc.setEnabled(false);
|
||||||
btnRoadSave.setEnabled(false);
|
btnRoadSave.setEnabled(false);
|
||||||
|
|
||||||
rgRoadStatus.setEnabled(false);
|
|
||||||
rbtnRoadOpen.setEnabled(false);
|
|
||||||
rbtnRoadPartOpen.setEnabled(false);
|
|
||||||
rbtnRoadHasntOpen.setEnabled(false);
|
|
||||||
rbtnRoadHasntFind.setEnabled(false);
|
|
||||||
rbtnRoadOther.setEnabled(false);
|
|
||||||
edtCheckedOther.setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -473,8 +419,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
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);
|
||||||
if (videoFile.getName().endsWith(".webp") || videoFile.getName().endsWith(".png")
|
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
|
||||||
|| videoFile.getName().endsWith(".jpg")|| videoFile.getName().endsWith(".jpeg")) {
|
|
||||||
if (videoFile.exists() && !isImageLoad) {
|
if (videoFile.exists() && !isImageLoad) {
|
||||||
// 使用glide加载视频的第一帧
|
// 使用glide加载视频的第一帧
|
||||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
|
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivRoadPicture, 500);
|
||||||
@@ -485,13 +430,6 @@ 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));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,80 +454,29 @@ 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 = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
double latitude = Constant.currentLocation.getLatitude();
|
||||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
double longitude = Constant.currentLocation.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 (matchTrack == 0) { // 普通拍照模式
|
if (geometry > rearGeometry) {//用戶在终点开始作业
|
||||||
if (geometry > rearGeometry) {//用戶在终点开始作业
|
if (rearGeometry > 5000) {
|
||||||
if (rearGeometry > 5000) {
|
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
} else {//用户在起点开始作业
|
||||||
} else {//用户在起点开始作业
|
if (geometry > 5000) {
|
||||||
if (geometry > 5000) {
|
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置亮度和摄像机刷新率
|
|
||||||
// CustomDialog.show((AppCompatActivity) getActivity(), R.layout.camera_setting_pre, new CustomDialog.OnBindView() {
|
|
||||||
// @Override
|
|
||||||
// public void onBind(CustomDialog dialog, View v) {
|
|
||||||
// SharedPreferences sharedPreferences = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE);
|
|
||||||
// int brightness = sharedPreferences.getInt("brightness", 40);
|
|
||||||
// EditText edtBrightness = v.findViewById(R.id.edt_camera_setting_brightness);
|
|
||||||
// edtBrightness.setText(brightness+"");
|
|
||||||
//
|
|
||||||
// int framness = sharedPreferences.getInt("framness", 30);
|
|
||||||
// EditText edtFramness = v.findViewById(R.id.edt_camera_setting_framness);
|
|
||||||
// edtFramness.setText(framness+"");
|
|
||||||
//
|
|
||||||
// Button btnConfirm = v.findViewById(R.id.btn_camera_setting_confirm);
|
|
||||||
// btnConfirm.setOnClickListener(new View.OnClickListener() {
|
|
||||||
// @Override
|
|
||||||
// public void onClick(View v) {
|
|
||||||
// SharedPreferences.Editor editor = getActivity().getSharedPreferences("pic", Context.MODE_PRIVATE).edit();
|
|
||||||
// if (!edtBrightness.getText().toString().isEmpty()) {
|
|
||||||
// int b = Integer.parseInt(edtBrightness.getText().toString());
|
|
||||||
// editor.putInt("brightness", b);
|
|
||||||
// }
|
|
||||||
// if (!edtFramness.getText().toString().isEmpty()) {
|
|
||||||
// int f = Integer.parseInt(edtFramness.getText().toString());
|
|
||||||
// editor.putInt("framness", f);
|
|
||||||
// }
|
|
||||||
// editor.commit();
|
|
||||||
// Toast.makeText(getActivity(), "设置完成", Toast.LENGTH_SHORT).show();
|
|
||||||
//
|
|
||||||
// Intent intent = new Intent(getContext(), PicturesActivity.class);
|
|
||||||
// File finalFile = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
|
||||||
// intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath());
|
|
||||||
// intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
|
||||||
// intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
|
||||||
// intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
|
||||||
// int gpsRssi = LocationLifeCycle.getInstance().getMainLocation().getGPSRssi();
|
|
||||||
// if (gpsRssi == 0) {
|
|
||||||
// intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
|
||||||
// } else {
|
|
||||||
// intent.putExtra(Constant.INTENT_BOOLEAN, true);
|
|
||||||
// }
|
|
||||||
// startActivityForResult(intent, 0x101);
|
|
||||||
// dialog.doDismiss();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }).setFullScreen(true);
|
|
||||||
Intent intent = new Intent(getContext(), PicturesActivity.class);
|
Intent intent = new Intent(getContext(), PicturesActivity.class);
|
||||||
File finalFile = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
File finalFile = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||||
intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath());
|
intent.putExtra(Constant.INTENT_JPG_PATH, finalFile.getAbsolutePath());
|
||||||
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());
|
||||||
intent.putExtra(Constant.MATCH_TRACK, matchTrack);
|
int gpsRssi = Constant.currentLocation.getGPSRssi();
|
||||||
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 {
|
||||||
@@ -598,33 +485,63 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
startActivityForResult(intent, 0x101);
|
startActivityForResult(intent, 0x101);
|
||||||
break;
|
break;
|
||||||
case R.id.road_upload:
|
case R.id.road_upload:
|
||||||
// 如果该数据没有被保存,需要先调用保存功能自动保存数据
|
|
||||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
||||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
if (Constant.isPresent) {
|
||||||
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
|
if (fmRoadPic.getTag() != null) {
|
||||||
initPoiSaveLocal(true);
|
List<File> videoFileList = (List<File>) fmRoadPic.getTag();
|
||||||
|
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
||||||
|
if (!existsPic) {
|
||||||
|
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ZipUtil.zipFiles(videoFileList, fileZip, null);//压缩
|
||||||
|
long zipTrueSize = ZipUtils.getZipTrueSize(fileZip.getAbsolutePath());
|
||||||
|
if (zipTrueSize > 0) {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (showPoiEntity == null) {
|
||||||
|
showPoiEntity = new PoiEntity();
|
||||||
|
}
|
||||||
|
if (showPoiEntity.getTaskStatus() == 1 || showPoiEntity.getTaskStatus() == 2 || showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 5) {
|
||||||
|
initPoiSaveLocal(true);
|
||||||
|
} else {
|
||||||
|
poiVideoUpload(showPoiEntity.getBodyId(), fileZip);
|
||||||
|
Constant.isPresent = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (getActivity() != null) {
|
||||||
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
fileZip.delete();
|
||||||
|
ToastUtils.Message(getActivity(), "压缩文件失败,请重新提交");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
} else {
|
||||||
|
dismissLoadingDialog();
|
||||||
|
ToastUtils.Message(getActivity(), "请录像");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
poiVideoUpload(poiEntity);
|
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@@ -642,20 +559,23 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
|
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (existence == 0&&showPoiEntity.getGeoWkt()!=null) {
|
poiEntity.setTaskStatus(2);
|
||||||
DataSaveUtils.checkRoadPoiPicture(showPoiEntity, (List<File>) fmRoadPic.getTag(), new DataSaveUtils.RoadPercentCheckCallback() {
|
new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void callback(double percent) {
|
public void run() {
|
||||||
if (percent<=0.1) {
|
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||||
ToastUtils.Message(getActivity(), "手动拍摄的道路任务覆盖度小于10%时,不能选择‘道路正常开通’");
|
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||||
return;
|
@Override
|
||||||
|
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(), "没有申请权限,请手动申请");
|
||||||
}
|
}
|
||||||
@@ -666,44 +586,19 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
if (never) {
|
if (never) {
|
||||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), 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("geo", poiEntity.getGeoWkt());
|
httpParams.put("workType", 0);
|
||||||
// httpParams.put("workType", 0);
|
|
||||||
httpParams.put("memo", poiEntity.getMemo());
|
httpParams.put("memo", poiEntity.getMemo());
|
||||||
// 增加对应九天平台的参数
|
|
||||||
httpParams.put("existence", existence);
|
|
||||||
httpParams.put("description", edtCheckedOther!=null&&edtCheckedOther.isShown()? edtCheckedOther.getText().toString().trim(): "");
|
|
||||||
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
.time(30)
|
.time(30)
|
||||||
.Builder(getActivity())
|
.Builder(getActivity())
|
||||||
@@ -719,46 +614,32 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void poiVideoUpload(PoiEntity poiEntity) {
|
private void poiVideoUpload(int body, File fileZip) {
|
||||||
if (poiEntity.getBodyId() == 0) {
|
if (body == 0) {
|
||||||
ToastUtils.Message(getActivity(), "请先保存本地在上传");
|
ToastUtils.Message(getActivity(), "请先保存本地上传");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Constant.isPresent) {
|
if (fileZip == null) {
|
||||||
if (fmRoadPic.getTag() != null) {
|
ToastUtils.Message(getActivity(), "未压缩完成");
|
||||||
List<File> videoFileList = (List<File>) fmRoadPic.getTag();
|
return;
|
||||||
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
}
|
||||||
if (!existsPic) {
|
HttpParams httpParams = new HttpParams();
|
||||||
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
httpParams.put("auditId", body);
|
||||||
return;
|
long time = System.currentTimeMillis();
|
||||||
}
|
httpParams.put("datetime", time);
|
||||||
DataSaveUtils.getInstance().uploadFiles(getActivity(), poiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
httpParams.put("file", fileZip);
|
||||||
@Override
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
public void onStart() {
|
.time(0)
|
||||||
dismissLoadingDialog();
|
.Builder(getActivity())
|
||||||
Constant.isPresent = false;
|
.url(HttpInterface.ROAD_TASK_UPLOAD_PIC)
|
||||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
.cls(OtherUploadPicBean.class)
|
||||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
.params(httpParams)
|
||||||
WaitDialog.dismiss(3000);
|
.token(Constant.ACCESS_TOKEN);
|
||||||
}
|
if (getActivity() != null) {
|
||||||
|
okGoBuilder.postRequest(UploadUtils.getInstance().getRoadUploadCallback(getActivity(), showPoiEntity, fileZip));
|
||||||
@Override
|
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||||
public void onFinish() {
|
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
||||||
Constant.isPresent = true;
|
WaitDialog.dismiss(3000);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError() {
|
|
||||||
Constant.isPresent = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
dismissLoadingDialog();
|
|
||||||
ToastUtils.Message(getActivity(), "请录像拍照");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -769,12 +650,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("geo", poiEntity.getGeoWkt());
|
httpParams.put("workType", 0);
|
||||||
// httpParams.put("workType", 0);
|
|
||||||
httpParams.put("memo", poiEntity.getMemo());
|
httpParams.put("memo", poiEntity.getMemo());
|
||||||
// 增加对应九天平台的参数
|
|
||||||
httpParams.put("existence", existence);
|
|
||||||
httpParams.put("description", edtCheckedOther!=null&&edtCheckedOther.isShown()? edtCheckedOther.getText().toString().trim(): "");
|
|
||||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||||
.time(30)
|
.time(30)
|
||||||
.Builder(getActivity())
|
.Builder(getActivity())
|
||||||
@@ -799,7 +676,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
getActivity().runOnUiThread(new Runnable() {
|
getActivity().runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
poiVideoUpload(poiEntity);
|
poiVideoUpload(roadBody, fileZip);
|
||||||
|
Constant.isPresent = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -864,7 +742,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 = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
|
||||||
//获取Editor对象
|
//获取Editor对象
|
||||||
SharedPreferences.Editor edit = poi.edit();
|
SharedPreferences.Editor edit = poi.edit();
|
||||||
//根据要保存的数据的类型,调用对应的put方法,
|
//根据要保存的数据的类型,调用对应的put方法,
|
||||||
@@ -974,8 +852,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 = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
|
String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||||
String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
|
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
|
||||||
StringBuffer sb = new StringBuffer("道路录像上报");
|
StringBuffer sb = new StringBuffer("道路录像上报");
|
||||||
if (city != null && !"".equals(city)) {
|
if (city != null && !"".equals(city)) {
|
||||||
sb.append("-");
|
sb.append("-");
|
||||||
@@ -1007,20 +885,13 @@ 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&&!fileListByUUID.isEmpty()) {
|
if (fileListByUUID != null) {
|
||||||
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&&lineStringByFileList.size()>1) {
|
if (lineStringByFileList != null) {
|
||||||
String encodeList = Geohash.getInstance().encodeList(lineStringByFileList);
|
String encodeList = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||||
if (encodeList != null) {
|
if (encodeList != null) {
|
||||||
poiEntity.setDetail(encodeList);
|
poiEntity.setDetail(encodeList);
|
||||||
@@ -1028,15 +899,15 @@ 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&&lineStringByFileList.size()>1) {
|
if (lineStringByFileList != null) {
|
||||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||||
if (lineString != null) {
|
if (lineString != null) {
|
||||||
poiEntity.setDetail(lineString);
|
poiEntity.setDetail(lineString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
||||||
poiEntity.setPhoto(fileListByUUID.size()+"");
|
poiEntity.setPhoto(photoStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return poiEntity;
|
return poiEntity;
|
||||||
@@ -1062,4 +933,4 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
|||||||
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
|
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ 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;
|
||||||
@@ -41,17 +40,14 @@ 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;
|
||||||
@@ -60,13 +56,6 @@ 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
|
||||||
@@ -79,7 +68,6 @@ 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();
|
||||||
@@ -93,7 +81,6 @@ 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
|
||||||
@@ -115,11 +102,9 @@ 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(requireContext(), DividerItemDecoration.VERTICAL));
|
stayXrv.addItemDecoration(new DividerItemDecoration(Objects.requireNonNull(getContext()), DividerItemDecoration.VERTICAL));
|
||||||
staySubmitAdapter = new StaySubmitAdapter(getContext());
|
staySubmitAdapter = new StaySubmitAdapter(getContext());
|
||||||
stayXrv.setAdapter(staySubmitAdapter);
|
stayXrv.setAdapter(staySubmitAdapter);
|
||||||
//点击条目跳转
|
//点击条目跳转
|
||||||
@@ -156,7 +141,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
if (Constant.currentLocation != null) {
|
||||||
if (Constant.USHERED != null) {
|
if (Constant.USHERED != null) {
|
||||||
cbSelect.setChecked(false);
|
cbSelect.setChecked(false);
|
||||||
refreshData();
|
refreshData();
|
||||||
@@ -167,7 +152,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
|||||||
@Override
|
@Override
|
||||||
protected void initData() {
|
protected void initData() {
|
||||||
super.initData();
|
super.initData();
|
||||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).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");
|
||||||
@@ -191,11 +176,11 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
@Subscribe
|
||||||
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 (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
if (Constant.currentLocation != null) {
|
||||||
if (Constant.USHERED != null) {
|
if (Constant.USHERED != null) {
|
||||||
if (cbSelect != null) {
|
if (cbSelect != null) {
|
||||||
cbSelect.setChecked(false);
|
cbSelect.setChecked(false);
|
||||||
@@ -204,14 +189,6 @@ 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,7 +265,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) requireActivity(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
|
BottomMenu.show((AppCompatActivity) Objects.requireNonNull(getContext()), 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) {
|
||||||
@@ -317,21 +294,14 @@ 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) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||||
@SuppressLint("SetTextI18n")
|
@SuppressLint("SetTextI18n")
|
||||||
@Override
|
@Override
|
||||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||||
logger.d("用户点击确认批量删除按钮+++++++++++++++++++++++");
|
initRequest(staySubmitAdapter.getAllRoad());
|
||||||
initRequest(staySubmitAdapter.getCheckedPoiEntity());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -341,7 +311,6 @@ 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<>();
|
||||||
@@ -365,22 +334,23 @@ 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> poiEntities) {
|
private void initRequest(List<PoiEntity> allRoad) {
|
||||||
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
|
||||||
@@ -415,34 +385,7 @@ 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 {
|
||||||
|
|||||||
@@ -1,954 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -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 = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).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,7 +120,6 @@ 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())
|
||||||
@@ -164,7 +163,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) {
|
||||||
requireActivity().finish();
|
Objects.requireNonNull(getActivity()).finish();
|
||||||
withdrawalRecordBuilder.append(TimestampUtil.time()).append("点击了返回,");
|
withdrawalRecordBuilder.append(TimestampUtil.time()).append("点击了返回,");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,6 @@ public abstract class DialogCallback<T> extends JsonCallback<T> {
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(Response<T> response) { }
|
public void onSuccess(Response<T> response) { }
|
||||||
|
|
||||||
public DialogCallback() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public DialogCallback( Class<T> tClass) {
|
public DialogCallback( Class<T> tClass) {
|
||||||
super(tClass);
|
super(tClass);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,14 @@
|
|||||||
package com.navinfo.outdoor.http;
|
package com.navinfo.outdoor.http;
|
||||||
|
|
||||||
public class HttpInterface {
|
public class HttpInterface {
|
||||||
// 开发
|
public static final String IP2 = "http://172.23.139.129:9999/m4";//测试接口
|
||||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发地址
|
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//测试接口-外网
|
||||||
public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-数据上传
|
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/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 IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//生产地址
|
|
||||||
// public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/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/";//登录
|
||||||
public static final String PRICE_PATH = "/price/";//提现
|
public static final String PRICE_PATH = "/price/";//提现
|
||||||
public static final String TASK_PATH = "/task/";//任务
|
public static final String TASK_PATH = "/task/";//任务
|
||||||
public static final String UPDATE_PHONE_NUM_PATH = "/user/user/{userId}/updateUserPhone"; // 修改手机号
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
public static final String TEST_GUIDANCE_IP = "http://172.21.98.90:9999/m4";//引导页完成接口
|
public static final String TEST_GUIDANCE_IP = "http://172.21.98.90:9999/m4";//引导页完成接口
|
||||||
@@ -64,7 +55,6 @@ public class HttpInterface {
|
|||||||
public static String EXAM_CONTENT = null;//发现 -能力测评获取试题接口
|
public static String EXAM_CONTENT = null;//发现 -能力测评获取试题接口
|
||||||
//172.23.139.4:8002/findAndMessage/1/submitExam
|
//172.23.139.4:8002/findAndMessage/1/submitExam
|
||||||
public static String EXAM_SUBMIT = null;//发现 -能力测评提交试卷 post
|
public static String EXAM_SUBMIT = null;//发现 -能力测评提交试卷 post
|
||||||
public static String RECOMMAND_TASK = null;//TreasureFragment获取最新的推荐任务信息 post
|
|
||||||
|
|
||||||
/* 登录
|
/* 登录
|
||||||
* Path=/m4/userlogin/
|
* Path=/m4/userlogin/
|
||||||
@@ -74,7 +64,7 @@ public class HttpInterface {
|
|||||||
///m4/user/user/register
|
///m4/user/user/register
|
||||||
public static String USER_REGISTER = IP + USER_PATH + "user/register";//注册接口
|
public static String USER_REGISTER = IP + USER_PATH + "user/register";//注册接口
|
||||||
///m4/user/ phone/message
|
///m4/user/ phone/message
|
||||||
public static String USER_MESSAGE = IP + USER_PATH + "phone/message";//获取验证码 type 1:注册获取 2:更新 3: 修改手机号
|
public static String USER_MESSAGE = IP + USER_PATH + "phone/message";//获取验证码 type 1:注册获取 2:更新
|
||||||
///m4/user/user/forgetPassword
|
///m4/user/user/forgetPassword
|
||||||
public static String USER_FORGET_PASSWORD = IP + USER_PATH + "user/forgetPassword";//忘记密码
|
public static String USER_FORGET_PASSWORD = IP + USER_PATH + "user/forgetPassword";//忘记密码
|
||||||
|
|
||||||
@@ -144,12 +134,6 @@ public class HttpInterface {
|
|||||||
public static String SUBMIT_POLYGON_TASK = null;//面状任务开始采集
|
public static String SUBMIT_POLYGON_TASK = null;//面状任务开始采集
|
||||||
//dtxbmaps.navinfo.com/dtxb_test/m4/msgList/InfoPush/28/push?type=0
|
//dtxbmaps.navinfo.com/dtxb_test/m4/msgList/InfoPush/28/push?type=0
|
||||||
public static String MESSAGE_INFO_PUSH = null;//消息通知
|
public static String MESSAGE_INFO_PUSH = null;//消息通知
|
||||||
public static String MESSAGE_LATEST_PUSH = null;//最新的推荐任务推送信息获取
|
|
||||||
public static String UPDATE_PHONE_NUM_URL = null;//消息通知
|
|
||||||
public static String CREATE_UPLOAD_TASK = null;//创建断点续传任务
|
|
||||||
public static String UPLOAD_SPLITE_TASK = null;//执行断点续传
|
|
||||||
public static String UPLOAD_TASK_FINISH = null;//断点续传完成
|
|
||||||
public static String GET_RECEIVED_LIST = null;//获取当前用户所有已领取的任务ID
|
|
||||||
|
|
||||||
public static String CONTACT_US = "";//联系我们
|
public static String CONTACT_US = "";//联系我们
|
||||||
public static String ABOUT_MAP = "";//关于 -关于地图寻宝
|
public static String ABOUT_MAP = "";//关于 -关于地图寻宝
|
||||||
@@ -172,7 +156,6 @@ public class HttpInterface {
|
|||||||
USER_DETAIL_BY_USER_ID = IP + USER_PATH + "user/" + userId + "/getUserDetailByUserid/" + userId; //获取用户信息
|
USER_DETAIL_BY_USER_ID = IP + USER_PATH + "user/" + userId + "/getUserDetailByUserid/" + userId; //获取用户信息
|
||||||
//172.21.98.90:9999/m4/user/userGuide/1/insertUserGuide
|
//172.21.98.90:9999/m4/user/userGuide/1/insertUserGuide
|
||||||
INSERT_USER_GUIDE = IP + USER_PATH + "userGuide/" + userId + "/insertUserGuide";//引导页完成接口
|
INSERT_USER_GUIDE = IP + USER_PATH + "userGuide/" + userId + "/insertUserGuide";//引导页完成接口
|
||||||
RECOMMAND_TASK = IP + USER_PATH + "user/" + userId + "/lastRecommandTask";//获取用户推荐信息
|
|
||||||
|
|
||||||
/* 发现
|
/* 发现
|
||||||
* Path=/m4/msgList/
|
* Path=/m4/msgList/
|
||||||
@@ -188,7 +171,6 @@ public class HttpInterface {
|
|||||||
//172.23.139.4:8002/findAndMessage/1/submitExam
|
//172.23.139.4:8002/findAndMessage/1/submitExam
|
||||||
EXAM_SUBMIT = IP + MSG_LIST_PATH + "findAndMessage/" + userId + "/submitExam";//发现 -能力测评提交试卷 post
|
EXAM_SUBMIT = IP + MSG_LIST_PATH + "findAndMessage/" + userId + "/submitExam";//发现 -能力测评提交试卷 post
|
||||||
MESSAGE_INFO_PUSH = IP + MSG_LIST_PATH + "InfoPush/" + userId + "/push";//寻宝-消息通知
|
MESSAGE_INFO_PUSH = IP + MSG_LIST_PATH + "InfoPush/" + userId + "/push";//寻宝-消息通知
|
||||||
MESSAGE_LATEST_PUSH = IP + MSG_LIST_PATH + "UserMessage/" + userId + "/getLatestMessage";//寻宝首页-获取最新推送推荐任务
|
|
||||||
|
|
||||||
/* 提现 金额
|
/* 提现 金额
|
||||||
* Path=/m4/price/
|
* Path=/m4/price/
|
||||||
@@ -215,22 +197,34 @@ 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
|
||||||
@@ -240,23 +234,5 @@ public class HttpInterface {
|
|||||||
UNRECEIVED_POLYGON_TASK = IP + TASK_PATH + "task/" + userId + "/unReceivedTask";//所有類型结束领取
|
UNRECEIVED_POLYGON_TASK = IP + TASK_PATH + "task/" + userId + "/unReceivedTask";//所有類型结束领取
|
||||||
COMPLETE = IP + TASK_PATH + "polygonTask/" + userId + "/complete";//面状任务结束领取
|
COMPLETE = IP + TASK_PATH + "polygonTask/" + userId + "/complete";//面状任务结束领取
|
||||||
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);// 修改手机号
|
|
||||||
CREATE_UPLOAD_TASK = IP + TASK_PATH + "task/"+ userId+"/createUploadTask";// 创建断点续传任务
|
|
||||||
UPLOAD_TASK_FINISH = IP + TASK_PATH + "task/"+ userId+"/uploadTaskFinish";// 断点续传完成
|
|
||||||
GET_RECEIVED_LIST = IP + TASK_PATH + "task/"+ userId+"/getReceivedList";// 断点续传完成
|
|
||||||
|
|
||||||
//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,7 +3,6 @@ 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;
|
||||||
@@ -293,13 +292,6 @@ 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,403 +0,0 @@
|
|||||||
package com.navinfo.outdoor.receiver;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.app.NotificationChannel;
|
|
||||||
import android.app.NotificationManager;
|
|
||||||
import android.app.PendingIntent;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
import androidx.core.app.NotificationCompat;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.bumptech.glide.Glide;
|
|
||||||
import com.elvishew.xlog.XLog;
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.activity.HomeActivity;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.tencent.android.tpush.NotificationAction;
|
|
||||||
import com.tencent.android.tpush.XGPushBaseReceiver;
|
|
||||||
import com.tencent.android.tpush.XGPushClickedResult;
|
|
||||||
import com.tencent.android.tpush.XGPushRegisterResult;
|
|
||||||
import com.tencent.android.tpush.XGPushShowedResult;
|
|
||||||
import com.tencent.android.tpush.XGPushTextMessage;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
|
|
||||||
public class MessageReceiver extends XGPushBaseReceiver {
|
|
||||||
public static final String UPDATE_LISTVIEW_ACTION = "com.qq.xgdemo.activity.UPDATE_LISTVIEW";
|
|
||||||
public static final String TEST_ACTION = "com.qq.xgdemo.activity.TEST_ACTION";
|
|
||||||
public static final String LogTag = "xg.test";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息透传处理
|
|
||||||
* @param context
|
|
||||||
* @param message 解析自定义的 JSON
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onTextMessage(Context context, XGPushTextMessage message) {
|
|
||||||
// String text = "onTextMessage:" + message.toString();
|
|
||||||
// // 获取自定义key-value
|
|
||||||
// String customContent = message.getCustomContent();
|
|
||||||
// if (customContent != null && customContent.length() != 0) {
|
|
||||||
// try {
|
|
||||||
// JSONObject obj = new JSONObject(customContent);
|
|
||||||
// // key1为前台配置的key
|
|
||||||
// if (!obj.isNull("key")) {
|
|
||||||
// String value = obj.getString("key");
|
|
||||||
// XLog.d("get custom value:" + value);
|
|
||||||
// }
|
|
||||||
// // ...
|
|
||||||
// } catch (JSONException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// // APP自主处理消息的过程...
|
|
||||||
// XLog.d(text);
|
|
||||||
// show(context, text);
|
|
||||||
|
|
||||||
// 获取透传信息内容
|
|
||||||
String msgContent = message.getContent();
|
|
||||||
// 使用json解析msgContent
|
|
||||||
try {
|
|
||||||
JSONObject msgJson = new JSONObject(msgContent);
|
|
||||||
// 获取当前json的id,如果id大于等于0,则根据Content内容尝试展示提示信息
|
|
||||||
int id = msgJson.optInt("id", -1);
|
|
||||||
if (id >= 0) {
|
|
||||||
// 读取该推送的截止时间,如果当前时间比截止时间晚,则不需要展示
|
|
||||||
long endTime = msgJson.optLong("endTime", 0);
|
|
||||||
if (endTime > 0 && System.currentTimeMillis()/1000 > endTime) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int type = msgJson.optInt("type", -1);
|
|
||||||
if (type == 0) { // 显示推荐任务
|
|
||||||
String imgUrl = msgJson.optString("img", "");
|
|
||||||
String wkt = msgJson.optString("geom", "");
|
|
||||||
int zoom = msgJson.optInt("zoom", 17);
|
|
||||||
// 获取推荐任务的大图
|
|
||||||
try {
|
|
||||||
Bitmap bigBitmap = Glide.with(context).asBitmap().load(imgUrl).submit().get(16000, TimeUnit.MILLISECONDS);
|
|
||||||
if (bigBitmap==null) {
|
|
||||||
bigBitmap = BitmapFactory.decodeResource(context.getResources(), R.mipmap.ic_launcher);
|
|
||||||
}
|
|
||||||
if (bigBitmap!=null) {
|
|
||||||
// 显示notifycation
|
|
||||||
createNotificationForBigImage(context,
|
|
||||||
msgJson.optString("title", "推荐任务"),
|
|
||||||
msgJson.optString("content", "为你准备的推荐任务"),
|
|
||||||
bigBitmap, wkt, zoom, id);
|
|
||||||
}
|
|
||||||
} catch (ExecutionException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (TimeoutException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
} else if (type == 1) { // 显示普通通知
|
|
||||||
String title = msgJson.optString("title", "通知");
|
|
||||||
String content = msgJson.optString("content", "");
|
|
||||||
// 展示普通notification
|
|
||||||
createNotificationForNormal(context, title, content, id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// id小于0,说明当前没有可推送的任务
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNotificationForNormal(Context context, String contentTitle, String contentText, int id) {
|
|
||||||
String mNormalChannelId = "normalNotification";
|
|
||||||
String mNormalChannelName = "普通通知";
|
|
||||||
NotificationManager mManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
NotificationChannel channel = new NotificationChannel(mNormalChannelId, mNormalChannelName, NotificationManager.IMPORTANCE_DEFAULT);
|
|
||||||
mManager.createNotificationChannel(channel);
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(context, HomeActivity.class);
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_INTENT_FROM, "normalNotification");
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_TITLE, contentTitle);
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_CONTENT, contentText);
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, id, intent, PendingIntent.FLAG_CANCEL_CURRENT);
|
|
||||||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, mNormalChannelId)
|
|
||||||
.setContentTitle(contentTitle)
|
|
||||||
.setContentText(contentText)
|
|
||||||
.setStyle(new NotificationCompat.BigTextStyle().bigText(contentText))
|
|
||||||
.setSmallIcon(R.mipmap.ic_launcher)
|
|
||||||
.setSilent(false)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.addAction(R.mipmap.ic_launcher, "去看看", pendingIntent)
|
|
||||||
.setAutoCancel(true);
|
|
||||||
mManager.notify(2, mBuilder.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createNotificationForBigImage(Context context, String contentTitle, String contentText, Bitmap bigPic,
|
|
||||||
String wkt, int zoom, int id) {
|
|
||||||
String mBigImageChannelId = "recommendTaskId";
|
|
||||||
String mBigImageChannelName = "推荐任务";
|
|
||||||
NotificationManager mManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
NotificationChannel channel = new NotificationChannel(mBigImageChannelId, mBigImageChannelName, NotificationManager.IMPORTANCE_DEFAULT);
|
|
||||||
mManager.createNotificationChannel(channel);
|
|
||||||
}
|
|
||||||
Intent intent = new Intent(context, HomeActivity.class);
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_INTENT_FROM, "recommandTask");
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_TASK_GEOM, wkt);
|
|
||||||
intent.putExtra(Constant.NOTIFYCATION_TASK_ZOOM, zoom);
|
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(context, id, intent, 0);
|
|
||||||
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context, mBigImageChannelId)
|
|
||||||
.setContentTitle(contentTitle)
|
|
||||||
.setContentText(contentText)
|
|
||||||
.setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bigPic))
|
|
||||||
.setSmallIcon(R.mipmap.ic_launcher)
|
|
||||||
.setSilent(false)
|
|
||||||
.setLargeIcon(bigPic)
|
|
||||||
.setAutoCancel(true)
|
|
||||||
.setContentIntent(pendingIntent)
|
|
||||||
.addAction(R.mipmap.ic_launcher, "去看看", pendingIntent);
|
|
||||||
mManager.notify(1, mBuilder.build());
|
|
||||||
// 用户点击该提醒后跳转到主界面,并自动定位到指定位置
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知展示
|
|
||||||
* @param context
|
|
||||||
* @param notifiShowedRlt 包含通知的内容
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onNotificationShowedResult(Context context, XGPushShowedResult notifiShowedRlt) {
|
|
||||||
if (context == null || notifiShowedRlt == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
XLog.d("onNotificationShowedResult:"+notifiShowedRlt.getContent());
|
|
||||||
// XGNotification notific = new XGNotification();
|
|
||||||
// notific.setMsg_id(notifiShowedRlt.getMsgId());
|
|
||||||
// notific.setTitle(notifiShowedRlt.getTitle());
|
|
||||||
// notific.setContent(notifiShowedRlt.getContent());
|
|
||||||
// // notificationActionType==1为Activity,2为url,3为intent
|
|
||||||
// notific.setNotificationActionType(notifiShowedRlt
|
|
||||||
// .getNotificationActionType());
|
|
||||||
// // Activity,url,intent都可以通过getActivity()获得
|
|
||||||
// notific.setActivity(notifiShowedRlt.getActivity());
|
|
||||||
// notific.setUpdate_time(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
|
|
||||||
// .format(Calendar.getInstance().getTime()));
|
|
||||||
// NotificationService.getInstance(context).save(notific);
|
|
||||||
//
|
|
||||||
// Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
// if (notifiShowedRlt.getTitle().equals(Constants.LOCAL_NOTIFICATION_TITLE)) {
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_LOCAL_NOTIFICATION);
|
|
||||||
// } else {
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_NOTIFICATION);
|
|
||||||
// }
|
|
||||||
// context.sendBroadcast(testIntent);
|
|
||||||
//
|
|
||||||
// Intent viewIntent = new Intent(UPDATE_LISTVIEW_ACTION);
|
|
||||||
// context.sendBroadcast(viewIntent);
|
|
||||||
// show(context, "您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString());
|
|
||||||
// XLog.d("您有1条新消息, " + "通知被展示 , " + notifiShowedRlt.toString() + ", PushChannel:" + notifiShowedRlt.getPushChannel());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onRegisterResult(Context context, int errorCode, XGPushRegisterResult message) {
|
|
||||||
if (context == null || message == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
// 在这里拿token
|
|
||||||
String token = message.getToken();
|
|
||||||
text = "注册成功1. token:" + token;
|
|
||||||
Constant.PUSH_TOKEN =token;
|
|
||||||
} else {
|
|
||||||
text = message + "注册失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
XLog.d(text);
|
|
||||||
show(context, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 反注册回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onUnregisterResult(Context context, int errorCode) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "反注册成功";
|
|
||||||
} else {
|
|
||||||
text = "反注册失败" + errorCode;
|
|
||||||
}
|
|
||||||
XLog.d(text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置标签回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param tagName 设置的 TAG
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onSetTagResult(Context context, int errorCode, String tagName) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "\"" + tagName + "\"设置成功";
|
|
||||||
} else {
|
|
||||||
text = "\"" + tagName + "\"设置失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
XLog.d(text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
// Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_SET_TAG);
|
|
||||||
// context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除标签的回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param tagName 设置的 TAG
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDeleteTagResult(Context context, int errorCode, String tagName) {
|
|
||||||
if (context == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (errorCode == XGPushBaseReceiver.SUCCESS) {
|
|
||||||
text = "\"" + tagName + "\"删除成功";
|
|
||||||
} else {
|
|
||||||
text = "\"" + tagName + "\"删除失败,错误码:" + errorCode;
|
|
||||||
}
|
|
||||||
XLog.d(text);
|
|
||||||
show(context, text);
|
|
||||||
|
|
||||||
// Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_DEL_TAG);
|
|
||||||
// context.sendBroadcast(testIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置账号回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param account 设置的账号
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onSetAccountResult(Context context, int errorCode, String account) {
|
|
||||||
// Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_SET_ACCOUNT);
|
|
||||||
// context.sendBroadcast(testIntent);
|
|
||||||
XLog.d("onSetAccountResult:"+errorCode+"-"+account);
|
|
||||||
show(context, errorCode+":"+account);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除账号回调
|
|
||||||
* @param context
|
|
||||||
* @param errorCode 0 为成功,其它为错误码
|
|
||||||
* @param account 设置的账号
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onDeleteAccountResult(Context context, int errorCode, String account) {
|
|
||||||
// Intent testIntent = new Intent(TEST_ACTION);
|
|
||||||
// testIntent.putExtra("step", Constants.TEST_DEL_ACCOUNT);
|
|
||||||
// context.sendBroadcast(testIntent);
|
|
||||||
XLog.d("onDeleteAccountResult:"+errorCode+"-"+account);
|
|
||||||
show(context, errorCode+":"+account);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSetAttributeResult(Context context, int i, String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeleteAttributeResult(Context context, int i, String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onQueryTagsResult(Context context, int errorCode, String data, String operateName) {
|
|
||||||
XLog.i("action - onQueryTagsResult, errorCode:" + errorCode + ", operateName:" + operateName + ", data: " + data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知点击回调 actionType=1为该消息被清除,actionType=0为该消息被点击
|
|
||||||
* @param context
|
|
||||||
* @param message 包含被点击通知的内容
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void onNotificationClickedResult(Context context, XGPushClickedResult message) {
|
|
||||||
if (context == null || message == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String text = "";
|
|
||||||
if (message.getActionType() == NotificationAction.clicked.getType()) {
|
|
||||||
// 通知在通知栏被点击啦。。。。。
|
|
||||||
// APP自己处理点击的相关动作
|
|
||||||
// 这个动作可以在activity的onResume也能监听,请看第3点相关内容
|
|
||||||
text = "通知被打开 :" + message;
|
|
||||||
} else if (message.getActionType() == NotificationAction.delete.getType()) {
|
|
||||||
// 通知被清除啦。。。。
|
|
||||||
// APP自己处理通知被清除后的相关动作
|
|
||||||
text = "通知被清除 :" + message;
|
|
||||||
}
|
|
||||||
Toast.makeText(context, "广播接收到通知被点击:" + message.toString(),
|
|
||||||
Toast.LENGTH_SHORT).show();
|
|
||||||
// 获取自定义key-value
|
|
||||||
String customContent = message.getCustomContent();
|
|
||||||
if (customContent != null && customContent.length() != 0) {
|
|
||||||
try {
|
|
||||||
JSONObject obj = new JSONObject(customContent);
|
|
||||||
// key1为前台配置的key
|
|
||||||
if (!obj.isNull("key")) {
|
|
||||||
String value = obj.getString("key");
|
|
||||||
XLog.d("get custom value:" + value);
|
|
||||||
}
|
|
||||||
// ...
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// APP自主处理的过程。。。
|
|
||||||
XLog.d(text);
|
|
||||||
show(context, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void show(Context context, String text) {
|
|
||||||
// Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package com.navinfo.outdoor.room;
|
|
||||||
|
|
||||||
import androidx.room.Dao;
|
|
||||||
import androidx.room.Delete;
|
|
||||||
import androidx.room.Insert;
|
|
||||||
import androidx.room.OnConflictStrategy;
|
|
||||||
import androidx.room.Query;
|
|
||||||
import androidx.room.Update;
|
|
||||||
|
|
||||||
import com.navinfo.outdoor.bean.LocationRecorder;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 访问数据库操作的接口
|
|
||||||
*/
|
|
||||||
@Dao
|
|
||||||
public interface LocationRecorderDao {
|
|
||||||
/*
|
|
||||||
* 查询
|
|
||||||
*/
|
|
||||||
@Query("SELECT * FROM LocationRecorder")
|
|
||||||
List<LocationRecorder> getAllLocationRecorder();
|
|
||||||
|
|
||||||
@Query("SELECT * FROM LocationRecorder where time >= :startTime and time<=:endTime order by time")
|
|
||||||
List<LocationRecorder> getLocationRecorderByTime(long startTime, long endTime);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加
|
|
||||||
*/
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
|
||||||
void insertLocationRecorder(LocationRecorder... locationRecorders);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新
|
|
||||||
*/
|
|
||||||
@Update
|
|
||||||
void updateLocationRecorder(LocationRecorder... locationRecorders);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
@Delete
|
|
||||||
void deleteLocationRecorder(LocationRecorder... locationRecorders);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 根据条件删除
|
|
||||||
*/
|
|
||||||
@Query("DELETE FROM LocationRecorder where time >= :startTime and time<=:endTime ")
|
|
||||||
void deleteForTime(long startTime, long endTime);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全部删除
|
|
||||||
*/
|
|
||||||
@Query("DELETE FROM LocationRecorder")
|
|
||||||
void deleteAllLocationRecorder();
|
|
||||||
}
|
|
||||||
@@ -22,13 +22,9 @@ public interface PoiDao {
|
|||||||
|
|
||||||
@Query("SELECT * FROM poi where taskStatus > 1 and taskStatus!=100 and type!=6 ")
|
@Query("SELECT * FROM poi where taskStatus > 1 and taskStatus!=100 and type!=6 ")
|
||||||
List<PoiEntity> getAllPoiByRecoded();
|
List<PoiEntity> getAllPoiByRecoded();
|
||||||
@Query("SELECT * FROM poi where taskStatus = 1 and type!=6 ")
|
|
||||||
List<PoiEntity> getHasReceivePoiByRecoded();
|
|
||||||
|
|
||||||
@Query("SELECT * FROM poi where type=:type and taskStatus > 1 and taskStatus!=100")
|
@Query("SELECT * FROM poi where type=:type and taskStatus > 1 and taskStatus!=100")
|
||||||
List<PoiEntity> getAllPoiType(int type);
|
List<PoiEntity> getAllPoiType(int type);
|
||||||
@Query("SELECT * FROM poi where type=:type and taskStatus = 1 and taskStatus!=100")
|
|
||||||
List<PoiEntity> getHasReceivePoiType(int type);
|
|
||||||
|
|
||||||
@Query("SELECT * FROM poi where taskStatus =5")
|
@Query("SELECT * FROM poi where taskStatus =5")
|
||||||
List<PoiEntity> getAllPoiStatus();
|
List<PoiEntity> getAllPoiStatus();
|
||||||
@@ -37,8 +33,6 @@ public interface PoiDao {
|
|||||||
// @Query("SELECT * FROM poi WHERE taskStatus=:taskStatus and type=:type and (:isExclusive=-1 or isExclusive=:isExclusive) ")
|
// @Query("SELECT * FROM poi WHERE taskStatus=:taskStatus and type=:type and (:isExclusive=-1 or isExclusive=:isExclusive) ")
|
||||||
List<PoiEntity> getAllTaskStatus(int taskStatus, int taskStatus1, int type, int type1, int isExclusive, int isExclusive1);
|
List<PoiEntity> getAllTaskStatus(int taskStatus, int taskStatus1, int type, int type1, int isExclusive, int isExclusive1);
|
||||||
|
|
||||||
@Query("SELECT * FROM poi WHERE taskStatus=:taskStatus and type=:type")
|
|
||||||
List<PoiEntity> getPoiEntityByTaskStatus(int taskStatus, int type);
|
|
||||||
|
|
||||||
@Query("SELECT * FROM poi where id=:id")
|
@Query("SELECT * FROM poi where id=:id")
|
||||||
PoiEntity getPoiEntity(String id);
|
PoiEntity getPoiEntity(String id);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
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;
|
||||||
@@ -10,9 +9,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.util.SdkFolderCreate;
|
import com.navinfo.outdoor.util.SdkFolderCreate;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -30,7 +27,7 @@ import java.io.File;
|
|||||||
* 如果需要在主线程调用则使用allowMainThreadQueries进行说明。
|
* 如果需要在主线程调用则使用allowMainThreadQueries进行说明。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 7, exportSchema = false)
|
@Database(entities = {PoiEntity.class,ChargingPileEntity.class}, version = 2, 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;
|
||||||
@@ -53,11 +50,6 @@ public abstract class PoiDatabase extends RoomDatabase {
|
|||||||
getDbName=dbFolder.getAbsolutePath()+"/"+DB_NAME;
|
getDbName=dbFolder.getAbsolutePath()+"/"+DB_NAME;
|
||||||
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_3_4)
|
|
||||||
.addMigrations(migration_4_5)
|
|
||||||
.addMigrations(migration_5_6)
|
|
||||||
.addMigrations(migration_6_7)
|
|
||||||
//.fallbackToDestructiveMigration()//数据库更新时删除数据重新创建 改动特别大的时候在用
|
//.fallbackToDestructiveMigration()//数据库更新时删除数据重新创建 改动特别大的时候在用
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
@@ -73,71 +65,23 @@ public abstract class PoiDatabase extends RoomDatabase {
|
|||||||
private static Migration migration_2_3 = new Migration(2, 3) {
|
private static Migration migration_2_3 = new Migration(2, 3) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
database.execSQL("CREATE TABLE LocationRecorder (" +
|
database.execSQL("ALTER TABLE poi ADD stage TEXT DEFAULT ''");
|
||||||
"time INTEGER PRIMARY KEY NOT NULL ," +
|
|
||||||
"tencentLocationX REAL NOT NULL ," +
|
|
||||||
"tencentLocationY REAL NOT NULL ," +
|
|
||||||
"gpsLocationX REAL NOT NULL ," +
|
|
||||||
"gpsLocationY REAL NOT NULL ," +
|
|
||||||
"rssi INTEGER NOT NULL ," +
|
|
||||||
"bearing REAL NOT NULL," +
|
|
||||||
"satelliteCount INTEGER NOT NULL ," +
|
|
||||||
"imgFileName TEXT)");//添加轨迹记录功能
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// 增加POI字段
|
|
||||||
private static Migration migration_3_4 = new Migration(3, 4) {
|
private static Migration migration_3_4 = new Migration(3, 4) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
try {
|
database.execSQL("ALTER TABLE poi ADD views INTEGER NOT NULL DEFAULT 0");
|
||||||
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) {
|
private static Migration migration_4_5 = new Migration(4, 5) {
|
||||||
@Override
|
@Override
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
try {
|
database.execSQL("ALTER TABLE poi ADD partner INTEGER NOT NULL DEFAULT 0");
|
||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private static Migration migration_6_7 = new Migration(6, 7) {
|
|
||||||
@Override
|
|
||||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
|
||||||
try {
|
|
||||||
database.execSQL("ALTER TABLE poi ADD COLUMN unReceivedTime TEXT DEFAULT 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();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.navinfo.outdoor.room;
|
package com.navinfo.outdoor.room;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.room.ColumnInfo;
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -12,9 +10,6 @@ import com.navinfo.outdoor.util.PhotoInfoConverter;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -48,19 +43,13 @@ 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 "面状任务" 11-“交通枢纽” 12-“区域设施” 13-“建筑物内部”
|
private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
|
||||||
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,提交中 2,已上传
|
private int work_type;//0,待提交 1,提交中
|
||||||
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; //上传结果
|
|
||||||
private String unReceivedTime; // 任务领取后自动释放的时间
|
|
||||||
|
|
||||||
public int getRecord_way() {
|
public int getRecord_way() {
|
||||||
return record_way;
|
return record_way;
|
||||||
@@ -149,10 +138,6 @@ public class PoiEntity implements Serializable {
|
|||||||
|
|
||||||
public void setTaskStatus(int taskStatus) {
|
public void setTaskStatus(int taskStatus) {
|
||||||
this.taskStatus = taskStatus;
|
this.taskStatus = taskStatus;
|
||||||
if (this.taskStatus==100) { // 当数据上传成功后,重置其bodyId和taskId
|
|
||||||
setBodyId(0);
|
|
||||||
setTaskId(0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@@ -291,71 +276,6 @@ 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取经过处理后的接受任务失效时间的时间戳
|
|
||||||
* */
|
|
||||||
public long getUnReceivedTimeStamp() {
|
|
||||||
if (getUnReceivedTime() == null || "".equals(getUnReceivedTime())) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
long time = 0;
|
|
||||||
try {
|
|
||||||
time = df.parse(getUnReceivedTime()).getTime();
|
|
||||||
} catch (ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUnReceivedTime() {
|
|
||||||
return unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUnReceivedTime(String unReceivedTime) {
|
|
||||||
this.unReceivedTime = unReceivedTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "PoiEntity{" +
|
return "PoiEntity{" +
|
||||||
@@ -376,7 +296,6 @@ public class PoiEntity implements Serializable {
|
|||||||
", x='" + x + '\'' +
|
", x='" + x + '\'' +
|
||||||
", y='" + y + '\'' +
|
", y='" + y + '\'' +
|
||||||
", detail='" + detail + '\'' +
|
", detail='" + detail + '\'' +
|
||||||
", unReceivedTime='" + unReceivedTime + '\'' +
|
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.navinfo.outdoor.service
|
|
||||||
|
|
||||||
import android.app.Service
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.IBinder
|
|
||||||
|
|
||||||
class ForegroundCoreService : Service() {
|
|
||||||
override fun onBind(intent: Intent?): IBinder? = null
|
|
||||||
private val mForegroundNF:ForegroundNF by lazy {ForegroundNF(this)}
|
|
||||||
override fun onCreate() {
|
|
||||||
super.onCreate()
|
|
||||||
mForegroundNF.startForegroundNotification()
|
|
||||||
}
|
|
||||||
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
|
|
||||||
if(null == intent){
|
|
||||||
//服务被系统kill掉之后重启进来的
|
|
||||||
return START_NOT_STICKY
|
|
||||||
}
|
|
||||||
mForegroundNF.startForegroundNotification()
|
|
||||||
return super.onStartCommand(intent, flags, startId)
|
|
||||||
}
|
|
||||||
override fun onDestroy() {
|
|
||||||
mForegroundNF.stopForegroundNotification()
|
|
||||||
super.onDestroy()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package com.navinfo.outdoor.service
|
|
||||||
|
|
||||||
import android.app.Notification
|
|
||||||
import android.app.NotificationChannel
|
|
||||||
import android.app.NotificationManager
|
|
||||||
import android.app.PendingIntent
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.ContextWrapper
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Build
|
|
||||||
import androidx.core.app.NotificationCompat
|
|
||||||
import com.navinfo.outdoor.R
|
|
||||||
import com.navinfo.outdoor.activity.HomeActivity
|
|
||||||
|
|
||||||
//初始化前台通知,停止前台通知
|
|
||||||
class ForegroundNF(private val service: ForegroundCoreService) : ContextWrapper(service) {
|
|
||||||
companion object {
|
|
||||||
private const val START_ID = 101
|
|
||||||
private const val CHANNEL_ID = "app_foreground_service"
|
|
||||||
private const val CHANNEL_NAME = "前台保活服务"
|
|
||||||
}
|
|
||||||
private var mNotificationManager: NotificationManager? = null
|
|
||||||
|
|
||||||
private var mCompatBuilder: NotificationCompat.Builder?=null
|
|
||||||
|
|
||||||
private val compatBuilder: NotificationCompat.Builder?
|
|
||||||
get() {
|
|
||||||
if (mCompatBuilder == null) {
|
|
||||||
val notificationIntent = Intent(this, HomeActivity::class.java)
|
|
||||||
notificationIntent.action = Intent.ACTION_MAIN
|
|
||||||
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER)
|
|
||||||
notificationIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
|
|
||||||
//动作意图
|
|
||||||
val pendingIntent = PendingIntent.getActivity(
|
|
||||||
this, (Math.random() * 10 + 10).toInt(),
|
|
||||||
notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT
|
|
||||||
)
|
|
||||||
val notificationBuilder: NotificationCompat.Builder = NotificationCompat.Builder(this,CHANNEL_ID)
|
|
||||||
//标题
|
|
||||||
notificationBuilder.setContentTitle("地图寻宝3")
|
|
||||||
//通知内容
|
|
||||||
notificationBuilder.setContentText("地图寻宝3正在运行中")
|
|
||||||
//状态栏显示的小图标
|
|
||||||
notificationBuilder.setSmallIcon(R.mipmap.ic_launcher)
|
|
||||||
//通知内容打开的意图
|
|
||||||
notificationBuilder.setContentIntent(pendingIntent)
|
|
||||||
mCompatBuilder = notificationBuilder
|
|
||||||
}
|
|
||||||
return mCompatBuilder
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
createNotificationChannel()
|
|
||||||
}
|
|
||||||
|
|
||||||
//创建通知渠道
|
|
||||||
private fun createNotificationChannel() {
|
|
||||||
mNotificationManager =
|
|
||||||
getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
|
||||||
//针对8.0+系统
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
||||||
val channel = NotificationChannel(
|
|
||||||
CHANNEL_ID,
|
|
||||||
CHANNEL_NAME,
|
|
||||||
NotificationManager.IMPORTANCE_LOW
|
|
||||||
)
|
|
||||||
channel.lockscreenVisibility = Notification.VISIBILITY_PUBLIC
|
|
||||||
channel.setShowBadge(false)
|
|
||||||
mNotificationManager?.createNotificationChannel(channel)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//开启前台通知
|
|
||||||
fun startForegroundNotification() {
|
|
||||||
service.startForeground(START_ID, compatBuilder?.build())
|
|
||||||
}
|
|
||||||
|
|
||||||
//停止前台服务并清除通知
|
|
||||||
fun stopForegroundNotification() {
|
|
||||||
mNotificationManager?.cancelAll()
|
|
||||||
service.stopForeground(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -417,14 +417,12 @@ public class AWMp4ParserHelper {
|
|||||||
if (strings != null) {
|
if (strings != null) {
|
||||||
for (int i = 0; i < strings.size(); i++) {
|
for (int i = 0; i < strings.size(); i++) {
|
||||||
String[] split = strings.get(i).split(",");
|
String[] split = strings.get(i).split(",");
|
||||||
if (split.length>3) {
|
LatLng latLng = new LatLng();
|
||||||
LatLng latLng = new LatLng();
|
latLng.setLatitude(Double.valueOf(split[2]));
|
||||||
latLng.setLatitude(Double.valueOf(split[2]));
|
latLng.setLongitude(Double.valueOf(split[3]));
|
||||||
latLng.setLongitude(Double.valueOf(split[3]));
|
latLags.add(latLng);
|
||||||
latLags.add(latLng);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (latLags.size() == 1) {
|
if (strings.size() == 1) {
|
||||||
LatLng latLng = latLags.get(0);
|
LatLng latLng = latLags.get(0);
|
||||||
latLags.add(latLng);
|
latLags.add(latLng);
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,92 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,486 +0,0 @@
|
|||||||
package com.navinfo.outdoor.util;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
import android.graphics.BitmapFactory;
|
|
||||||
import android.os.Message;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
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.MD5;
|
|
||||||
import com.github.lazylibrary.util.ZipUtil;
|
|
||||||
import com.hjq.permissions.OnPermissionCallback;
|
|
||||||
import com.hjq.permissions.Permission;
|
|
||||||
import com.hjq.permissions.XXPermissions;
|
|
||||||
import com.kongzue.dialog.v3.TipDialog;
|
|
||||||
import com.kongzue.dialog.v3.WaitDialog;
|
|
||||||
import com.lzy.okgo.OkGo;
|
|
||||||
import com.lzy.okgo.model.HttpParams;
|
|
||||||
import com.lzy.okgo.model.Response;
|
|
||||||
import com.navinfo.outdoor.activity.PicturesActivity;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.navinfo.outdoor.api.UserApplication;
|
|
||||||
import com.navinfo.outdoor.bean.CommonRequestSend;
|
|
||||||
import com.navinfo.outdoor.bean.CommonResponse;
|
|
||||||
import com.navinfo.outdoor.bean.LocationRecorder;
|
|
||||||
import com.navinfo.outdoor.bean.PoiSaveBean;
|
|
||||||
import com.navinfo.outdoor.http.Callback;
|
|
||||||
import com.navinfo.outdoor.http.DialogCallback;
|
|
||||||
import com.navinfo.outdoor.http.HttpInterface;
|
|
||||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
|
||||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
|
||||||
import com.navinfo.outdoor.room.LocationRecorderDao;
|
|
||||||
import com.navinfo.outdoor.room.PoiDatabase;
|
|
||||||
import com.navinfo.outdoor.room.PoiEntity;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|
||||||
import com.umeng.commonsdk.debug.UMLog;
|
|
||||||
import com.umeng.umcrash.UMCrash;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
|
||||||
import org.locationtech.jts.geom.Geometry;
|
|
||||||
import org.locationtech.jts.geom.LineString;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.text.ParseException;
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableEmitter;
|
|
||||||
import io.reactivex.ObservableOnSubscribe;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.Observer;
|
|
||||||
import io.reactivex.Single;
|
|
||||||
import io.reactivex.SingleObserver;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Action;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
|
|
||||||
public class DataSaveUtils {
|
|
||||||
private static DataSaveUtils instance;
|
|
||||||
private static Logger logger;
|
|
||||||
|
|
||||||
public static DataSaveUtils getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new DataSaveUtils();
|
|
||||||
logger = XLogUtils.Companion.getInstance().getUploadLogWriter();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface UploadCallback {
|
|
||||||
public void onStart();
|
|
||||||
public void onFinish();
|
|
||||||
public void onError();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Single<PoiEntity> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
|
|
||||||
poiEntity.setUploadResult("");
|
|
||||||
int auditId = poiEntity.getBodyId();
|
|
||||||
File zipFile = new File(poiPicList.get(0).getParentFile(), auditId+".zip");
|
|
||||||
return Observable.create(new ObservableOnSubscribe<File>() {
|
|
||||||
@Override
|
|
||||||
public void subscribe(ObservableEmitter<File> emitter) throws Exception {
|
|
||||||
if (!zipFile.exists()) {
|
|
||||||
// 首先检查图片中是否存在已损坏的图片
|
|
||||||
List<File> corruptImage = filterCorruptImages(poiPicList);
|
|
||||||
logger.d("存在损坏的照片:"+poiEntity.getId()+":"+poiEntity.getName()+list2Str(corruptImage));
|
|
||||||
// 开始压缩文件
|
|
||||||
ZipUtil.zipFiles(poiPicList, zipFile, "", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
emitter.onNext(zipFile);
|
|
||||||
emitter.onComplete();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(Schedulers.computation())
|
|
||||||
// 切分数据,发送开始上传请求
|
|
||||||
.map(new Function<File, Map<Integer, File>>() {
|
|
||||||
@Override
|
|
||||||
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, splitFileSize);
|
|
||||||
poiEntity.setUploadMax(splitFiles.size());
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
List<Long> chunkSizeList = new ArrayList<>();
|
|
||||||
long slipeFileSizeCount = 0;
|
|
||||||
for (File f: splitFiles) {
|
|
||||||
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);
|
|
||||||
if (response!=null) {
|
|
||||||
// 请求成功,获取需要上传的分包index
|
|
||||||
String body = response.getBody();
|
|
||||||
if (response.getCode() == 213) { // 该数据已经上传成功,自动切换该数据为已上传状态
|
|
||||||
poiEntity.setTaskStatus(100);
|
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
|
||||||
ToastUtils.Message(mContext, "数据:"+poiEntity.getName()+"已成功上传!");
|
|
||||||
poiEntity.setUploadProgress(splitFiles.size()); // 上传进度为当前文件个数
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
}
|
|
||||||
if (body==null) {
|
|
||||||
throw new Exception(response.getMessage());
|
|
||||||
}
|
|
||||||
if (body.isEmpty()) { // 服务返回空数据,说明该数据的所有分包数据都上传完成,没有需要上传的分包了
|
|
||||||
poiEntity.setUploadProgress(splitFiles.size()); // 上传进度为当前文件个数
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
String[] needUploadStrIndex = body.split(",");
|
|
||||||
// 批量转换String为int
|
|
||||||
int[] needUploadIndex = new int[needUploadStrIndex.length];
|
|
||||||
for (int i = 0; i < needUploadStrIndex.length; i++) {
|
|
||||||
needUploadIndex[i] = Integer.parseInt(needUploadStrIndex[i]);
|
|
||||||
}
|
|
||||||
poiEntity.setUploadProgress(splitFiles.size()-needUploadIndex.length); // 上传进度为当前文件个数
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
// 根据返回的index,将需要上传的切分包数据流转到下一个流程
|
|
||||||
Map<Integer, File> needUploadFileMap = new HashMap<>();
|
|
||||||
for (int index: needUploadIndex) {
|
|
||||||
if (index<splitFiles.size()) {
|
|
||||||
needUploadFileMap.put(index, splitFiles.get(index));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 遍历已存在的切割文件,如果不需要上传,则删除该分包数据
|
|
||||||
for (int i = 0; i < splitFiles.size(); i++) {
|
|
||||||
if (!needUploadFileMap.keySet().contains(i)) {
|
|
||||||
splitFiles.get(i).delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return needUploadFileMap;
|
|
||||||
} else {
|
|
||||||
return new HashMap<>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.flatMap(new Function<Map<Integer, File>, ObservableSource<Map.Entry<Integer, File>>>() {
|
|
||||||
@Override
|
|
||||||
public ObservableSource<Map.Entry<Integer, File>> apply(Map<Integer, File> filesMap) throws Exception {
|
|
||||||
// 将每个切分的文件file作为发送者重新发送出去
|
|
||||||
return Observable.fromIterable(filesMap.entrySet());
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.doOnNext(new Consumer<Map.Entry<Integer, File>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map.Entry<Integer, File> fileEntry) throws Exception {
|
|
||||||
// 执行上传流程
|
|
||||||
CommonResponse response = uploadSplitTask(mContext, auditId, fileEntry.getKey(), fileEntry.getValue());
|
|
||||||
if (response.getCode() != 200) {
|
|
||||||
poiEntity.setUploadResult("第"+fileEntry.getKey()+"个分包数据上传失败");
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
throw new Exception(response.getMessage());
|
|
||||||
} else {
|
|
||||||
poiEntity.setUploadProgress(poiEntity.getUploadProgress()+1); // 上传进度为当前文件个数
|
|
||||||
sendRefreshItem(poiEntity);
|
|
||||||
UMLog.mutlInfo(3, "已上传分包"+fileEntry.getKey());
|
|
||||||
// 上传成功,则删除该分包数据
|
|
||||||
if (fileEntry.getValue().exists()) {
|
|
||||||
fileEntry.getValue().delete();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.toList()
|
|
||||||
.observeOn(Schedulers.io())
|
|
||||||
// 调用执行成功的接口
|
|
||||||
.doOnSuccess(new Consumer<List<Map.Entry<Integer, File>>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(List<Map.Entry<Integer, File>> entries) throws Exception {
|
|
||||||
// 最终成功,调用finish接口
|
|
||||||
poiEntity.setUploadResult("附件上传完成");
|
|
||||||
CommonResponse response = uploadTaskFinish(mContext, auditId);
|
|
||||||
if (response.getCode() == 200) { // 更新成功,再次更新本地数据库
|
|
||||||
poiEntity.setTaskStatus(100);
|
|
||||||
poiEntity.setUploadProgress(poiEntity.getUploadMax());
|
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
|
||||||
// 同时删除关联的照片文件和压缩包文件
|
|
||||||
if (zipFile.getParentFile().exists()&&!zipFile.getParentFile().getName().endsWith("picture")) {
|
|
||||||
// 删除对应的文件夹
|
|
||||||
FileUtils.deleteFile(zipFile.getParentFile().getAbsolutePath());
|
|
||||||
}
|
|
||||||
// if (zipFile.exists()) {
|
|
||||||
// zipFile.delete();
|
|
||||||
// }
|
|
||||||
// if (poiPicList!=null&&!poiPicList.isEmpty()) {
|
|
||||||
// for (File picFile: poiPicList
|
|
||||||
// ) {
|
|
||||||
// picFile.delete();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
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) {
|
|
||||||
getUploadSpliteFilesObservble(mContext ,poiEntity, poiPicList)
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new SingleObserver<PoiEntity>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
callback.onStart();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(PoiEntity poiEntity) {
|
|
||||||
ToastUtils.Message(mContext, "分包数据上传完成!");
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
|
||||||
// 提醒用户数据上传完成
|
|
||||||
obtain1.obj = "数据:" + poiEntity.getName() + " 上传成功";
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
callback.onFinish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
ToastUtils.Message(mContext, e.getMessage());
|
|
||||||
Message obtain1 = Message.obtain();
|
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
|
||||||
// 提醒用户数据上传完成
|
|
||||||
obtain1.obj = e.getMessage();
|
|
||||||
EventBus.getDefault().post(obtain1);
|
|
||||||
callback.onError();
|
|
||||||
callback.onFinish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 创建分包上传任务
|
|
||||||
* */
|
|
||||||
private CommonResponse createUploadTask(Activity mContext, int auditId, long fileSize, List<Long> chunkSize) {
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("auditId", auditId);
|
|
||||||
httpParams.put("fileSize", fileSize);
|
|
||||||
httpParams.put("chunkSize", list2Str(chunkSize));
|
|
||||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<String>>();
|
|
||||||
CommonResponse response = commonRequestSend.getMethodCommonSync(mContext, HttpInterface.CREATE_UPLOAD_TASK, httpParams, Constant.DEFAULT_TIME_OUT, new CommonResponse<String>().getClass());
|
|
||||||
if (response!=null) {
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(mContext, response.getMessage());
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 上传分包数据
|
|
||||||
* */
|
|
||||||
private CommonResponse uploadSplitTask(Activity mContext, int auditId, int chunkIndex, File splitFile) {
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("auditId", auditId);
|
|
||||||
httpParams.put("chunkIndex", chunkIndex);
|
|
||||||
httpParams.put("md5", MD5.md5sum(splitFile.getAbsolutePath()).toLowerCase());
|
|
||||||
httpParams.put("file", splitFile);
|
|
||||||
|
|
||||||
// List<File> fileList = new ArrayList<>();
|
|
||||||
// fileList.add(splitFile);
|
|
||||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<String>>();
|
|
||||||
CommonResponse response = commonRequestSend.postMethodCommonSync(mContext, HttpInterface.UPLOAD_SPLITE_TASK, httpParams, Constant.DEFAULT_TIME_OUT, null, new CommonResponse<String>().getClass());
|
|
||||||
if (response!=null) {
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(mContext, response.getMessage());
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 分包数据上传完成
|
|
||||||
* */
|
|
||||||
private CommonResponse uploadTaskFinish(Activity mContext, int auditId) {
|
|
||||||
HttpParams httpParams = new HttpParams();
|
|
||||||
httpParams.put("auditId", auditId);
|
|
||||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<String>>();
|
|
||||||
CommonResponse response = commonRequestSend.getMethodCommonSync(mContext, HttpInterface.UPLOAD_TASK_FINISH, httpParams, Constant.DEFAULT_TIME_OUT, new CommonResponse<String>().getClass());
|
|
||||||
if (response!=null) {
|
|
||||||
if (response.getCode() == 200) {
|
|
||||||
return response;
|
|
||||||
} else {
|
|
||||||
ToastUtils.Message(mContext, response.getMessage());
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable savePoiEntity(Context mContext, PoiEntity poiEntity) {
|
|
||||||
return getPermission(mContext)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.map(new Function() {
|
|
||||||
@Override
|
|
||||||
public PoiEntity apply(Object o) {
|
|
||||||
return poiEntity;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 判断当前POI状态,根据状态处理随后的流程
|
|
||||||
.map(new Function<PoiEntity, PoiEntity>() {
|
|
||||||
@Override
|
|
||||||
public PoiEntity apply(PoiEntity entity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public Observable getPermission(Context mContext) {
|
|
||||||
return Observable.create(
|
|
||||||
new ObservableOnSubscribe<Object>() {
|
|
||||||
@Override
|
|
||||||
public void subscribe(ObservableEmitter<Object> emitter) throws Exception {
|
|
||||||
XXPermissions.with(mContext)
|
|
||||||
//读写权限
|
|
||||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
|
||||||
.request(new OnPermissionCallback() {
|
|
||||||
@Override
|
|
||||||
public void onGranted(List<String> permissions, boolean all) {
|
|
||||||
if (all) {
|
|
||||||
emitter.onNext("permission Ok");
|
|
||||||
} else {
|
|
||||||
emitter.onError(new Throwable("未获取文件访问权限,请确认!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDenied(List<String> permissions, boolean never) {
|
|
||||||
if (never) {
|
|
||||||
emitter.onError(new Throwable("未获取文件访问权限,请确认!"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String list2Str(List chunkSize) {
|
|
||||||
StringBuilder result = new StringBuilder("");
|
|
||||||
for (Object chunk: chunkSize) {
|
|
||||||
result.append(chunk).append(",");
|
|
||||||
}
|
|
||||||
if (result.length()>0) {
|
|
||||||
return result.substring(0, result.length()-1);
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package com.navinfo.outdoor.util
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.navinfo.outdoor.api.Constant
|
|
||||||
import java.io.File
|
|
||||||
import java.io.FileNotFoundException
|
|
||||||
import java.io.IOException
|
|
||||||
import java.io.RandomAccessFile
|
|
||||||
import java.lang.Exception
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Author: LiaoZhongKai
|
|
||||||
* @Date: 2021/7/28 19:42
|
|
||||||
* @Description:
|
|
||||||
*/
|
|
||||||
object FileSpliteMergeUtils {
|
|
||||||
const val TAG = "FileUtils"
|
|
||||||
//默认切割文件的大小
|
|
||||||
private const val DEFAULT_CUT_SIZE: Long = Constant.DEFAULT_CUT_SIZE//5MB
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分割文件
|
|
||||||
* [sourceFile] 需要分割的源文件
|
|
||||||
* [cutSize] 每个文件的大小
|
|
||||||
* @return 分段文件集合
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
fun splitFile(sourceFile: File,cutSize: Long = DEFAULT_CUT_SIZE): List<File>{
|
|
||||||
//分段片文件集合
|
|
||||||
val singleFileList = mutableListOf<File>()
|
|
||||||
|
|
||||||
val totalLength = sourceFile.length()
|
|
||||||
//分段数量
|
|
||||||
val count = if(totalLength % cutSize == 0L) totalLength/cutSize else totalLength/cutSize +1
|
|
||||||
Log.d(TAG,"split file count:$count")
|
|
||||||
val mRandomAccFile = RandomAccessFile(sourceFile,"r")
|
|
||||||
try {
|
|
||||||
// val length = mRandomAccFile.length()
|
|
||||||
// val singleSize = length/count//源文件分割后每个文件的大小
|
|
||||||
var offSet = 0L
|
|
||||||
|
|
||||||
for (i in 0 until count){//最后一个文件单独处理,因为它的大小可能不等于singleSize
|
|
||||||
val begin = offSet
|
|
||||||
// 如果当前index对应的数据没有超过文件大小,则使用cutSize,否则使用文件实际剩余大小
|
|
||||||
var end = begin + cutSize
|
|
||||||
if (totalLength<=end) {
|
|
||||||
end = totalLength;
|
|
||||||
}
|
|
||||||
val file = createSingleFile(sourceFile,i)
|
|
||||||
offSet = writeFile(mRandomAccFile,file,begin,end)
|
|
||||||
singleFileList.add(file)
|
|
||||||
}
|
|
||||||
// if (length - offSet > 0){//最后一个文件
|
|
||||||
// val file = createSingleFile(sourceFile,count-1)
|
|
||||||
// writeFile(mRandomAccFile,file,offSet,length)
|
|
||||||
// singleFileList.add(file)
|
|
||||||
// }
|
|
||||||
|
|
||||||
}catch (e: FileNotFoundException){
|
|
||||||
e.printStackTrace()
|
|
||||||
}catch (e: IOException){
|
|
||||||
e.printStackTrace()
|
|
||||||
}finally {
|
|
||||||
try {
|
|
||||||
mRandomAccFile.close()
|
|
||||||
}catch (e: IOException){
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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{
|
|
||||||
val path = sourceFile.absolutePath.substringBeforeLast(".")
|
|
||||||
// val suffix = sourceFile.name.substringAfterLast(".")
|
|
||||||
val suffix = "tmp";
|
|
||||||
val file = File("${path}_${index}.${suffix}")
|
|
||||||
if (file.exists()){
|
|
||||||
file.delete()
|
|
||||||
}
|
|
||||||
Log.d(TAG,"sourceFilePath:${sourceFile.absolutePath}")
|
|
||||||
file.createNewFile()
|
|
||||||
Log.d(TAG,"single file path:${file.absolutePath}")
|
|
||||||
return file
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun writeFile(inFile: RandomAccessFile,single: File,begin: Long,end: Long): Long{
|
|
||||||
var endPointer = 0L
|
|
||||||
val out = RandomAccessFile(single,"rw")
|
|
||||||
var index = 0
|
|
||||||
try {
|
|
||||||
val byte = ByteArray((end-begin).toInt())
|
|
||||||
inFile.seek(begin)
|
|
||||||
while (inFile.read(byte).also { index = it } != -1&&inFile.filePointer <= end){
|
|
||||||
out.write(byte,0,index)
|
|
||||||
endPointer = inFile.filePointer
|
|
||||||
}
|
|
||||||
}catch (e: Exception){
|
|
||||||
e.printStackTrace()
|
|
||||||
}finally {
|
|
||||||
out.close()
|
|
||||||
}
|
|
||||||
return endPointer
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 合并文件
|
|
||||||
* [files] 需要合并的文件集合
|
|
||||||
* [outputFilePath] 输出文件的路径 eg:D:/test
|
|
||||||
* [outputFileName] 输出文件的名称 eg:crawler.json
|
|
||||||
*/
|
|
||||||
@JvmStatic
|
|
||||||
fun mergeFile(files: List<File>,outputFilePath: String,outputFileName: String){
|
|
||||||
|
|
||||||
val parentFile = File(outputFilePath)
|
|
||||||
val targetFile = File(outputFilePath+File.separator+outputFileName)
|
|
||||||
if (!parentFile.exists()){
|
|
||||||
parentFile.mkdirs()
|
|
||||||
}
|
|
||||||
if (!targetFile.exists()){
|
|
||||||
targetFile.createNewFile()
|
|
||||||
}
|
|
||||||
|
|
||||||
val outRaf = RandomAccessFile(targetFile,"rw")
|
|
||||||
try {
|
|
||||||
files.forEach { file ->
|
|
||||||
val reader = RandomAccessFile(file,"r")
|
|
||||||
val byte = ByteArray(1024)
|
|
||||||
var index = 0
|
|
||||||
while (reader.read(byte).also { index = it } != -1){
|
|
||||||
outRaf.write(byte,0,index)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
files.forEach {
|
|
||||||
if (it.exists()){
|
|
||||||
it.delete()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.d(TAG,"merge output file path:${targetFile.absolutePath}")
|
|
||||||
}catch (e: IOException){
|
|
||||||
e.printStackTrace()
|
|
||||||
}catch (e: FileNotFoundException){
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
outRaf.close()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -7,38 +7,22 @@ import android.content.Intent;
|
|||||||
import android.location.Address;
|
import android.location.Address;
|
||||||
import android.location.Criteria;
|
import android.location.Criteria;
|
||||||
import android.location.Geocoder;
|
import android.location.Geocoder;
|
||||||
import android.location.GnssStatus;
|
|
||||||
import android.location.GpsSatellite;
|
import android.location.GpsSatellite;
|
||||||
import android.location.GpsStatus;
|
import android.location.GpsStatus;
|
||||||
import android.location.Location;
|
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.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;
|
||||||
@@ -47,50 +31,35 @@ public class GPSUtils {
|
|||||||
|
|
||||||
private Location mLocation = null;
|
private Location mLocation = null;
|
||||||
|
|
||||||
private Context mContext;
|
private Activity mContext;
|
||||||
|
|
||||||
private static GPSUtils instance;
|
public GPSUtils(Activity context) {
|
||||||
|
|
||||||
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)) {
|
||||||
com.github.lazylibrary.util.ToastUtils.showToast(context, "请开启GPS导航...");
|
ToastUtils.Message(context,"请开启GPS导航...");
|
||||||
Map<String, String> mapData = new HashMap<>();
|
// 返回开启GPS导航设置界面
|
||||||
mapData.put("code", "101");
|
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||||
EventBus.getDefault().post(mapData);
|
context.startActivityForResult(intent, 0);
|
||||||
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.addGpsStatusListener(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);
|
||||||
@@ -104,15 +73,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(true);
|
criteria.setSpeedRequired(false);
|
||||||
// 设置是否允许运营商收费
|
// 设置是否允许运营商收费
|
||||||
criteria.setCostAllowed(true);
|
criteria.setCostAllowed(false);
|
||||||
// 设置是否需要方位信息
|
// 设置是否需要方位信息
|
||||||
criteria.setBearingRequired(true);
|
criteria.setBearingRequired(false);
|
||||||
// 设置是否需要海拔信息
|
// 设置是否需要海拔信息
|
||||||
criteria.setAltitudeRequired(true);
|
criteria.setAltitudeRequired(false);
|
||||||
// 设置对电源的需求
|
// 设置对电源的需求
|
||||||
criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
|
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||||
return criteria;
|
return criteria;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,26 +130,11 @@ public class GPSUtils {
|
|||||||
|
|
||||||
//位置信息变化时触发
|
//位置信息变化时触发
|
||||||
public void onLocationChanged(Location location) {
|
public void onLocationChanged(Location location) {
|
||||||
if (mContext == null) {
|
|
||||||
mLocationManager.removeUpdates(this);
|
|
||||||
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状态变化时触发
|
||||||
@@ -229,47 +183,50 @@ public class GPSUtils {
|
|||||||
|
|
||||||
|
|
||||||
// 状态监听
|
// 状态监听
|
||||||
GnssStatus.Callback listener = new GnssStatus.Callback() {
|
GpsStatus.Listener listener = new GpsStatus.Listener() {
|
||||||
@Override
|
public void onGpsStatusChanged(int event) {
|
||||||
public void onStarted() {
|
switch (event) {
|
||||||
super.onStarted();
|
// 第一次定位
|
||||||
Log.i(TAG, "定位启动");
|
case GpsStatus.GPS_EVENT_FIRST_FIX:
|
||||||
}
|
Log.i(TAG, "第一次定位");
|
||||||
|
break;
|
||||||
@Override
|
// 卫星状态改变
|
||||||
public void onStopped() {
|
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
|
||||||
super.onStopped();
|
Log.i(TAG, "卫星状态改变");
|
||||||
Log.i(TAG, "定位结束");
|
GpsStatus gpsStatus = mLocationManager.getGpsStatus(null);
|
||||||
}
|
// 获取卫星颗数的默认最大值
|
||||||
|
int maxSatellites = gpsStatus.getMaxSatellites();
|
||||||
@Override
|
// 创建一个迭代器保存所有卫星
|
||||||
public void onFirstFix(int ttffMillis) {
|
Iterator<GpsSatellite> iters = gpsStatus.getSatellites()
|
||||||
super.onFirstFix(ttffMillis);
|
.iterator();
|
||||||
Log.i(TAG, "第一次定位");
|
int count = 0;
|
||||||
}
|
while (iters.hasNext() && count <= maxSatellites) {
|
||||||
|
GpsSatellite s = iters.next();
|
||||||
@Override
|
count++;
|
||||||
public void onSatelliteStatusChanged(@NonNull GnssStatus status) {
|
}
|
||||||
super.onSatelliteStatusChanged(status);
|
if (onClickGPSStatus != null) {
|
||||||
if (mContext == null) {
|
onClickGPSStatus.onGpsCount(count);
|
||||||
mLocationManager.unregisterGnssStatusCallback(this);
|
}
|
||||||
return;
|
break;
|
||||||
}
|
//定位启动
|
||||||
Log.i(TAG, "卫星状态改变");
|
case GpsStatus.GPS_EVENT_STARTED:
|
||||||
if (status != null) {
|
Log.i(TAG, "定位启动");
|
||||||
sateliteCount = status.getSatelliteCount();
|
break;
|
||||||
} else {
|
//定位结束
|
||||||
sateliteCount = 0;
|
case GpsStatus.GPS_EVENT_STOPPED:
|
||||||
|
Log.i(TAG, "定位结束");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
public OnClickGPSStatus onClickGPSStatus;
|
||||||
|
|
||||||
public int getSateliteCount() {
|
public void setOnClickGPSStatus(OnClickGPSStatus onClickGPSStatus) {
|
||||||
return sateliteCount;
|
this.onClickGPSStatus = onClickGPSStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unRegisterAllListener() {
|
public interface OnClickGPSStatus {
|
||||||
mLocationManager.unregisterGnssStatusCallback(listener);
|
void onGpsCount(int count);
|
||||||
mLocationManager.removeUpdates(locationListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.navinfo.outdoor.util;
|
package com.navinfo.outdoor.util;
|
||||||
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.security.InvalidAlgorithmParameterException;
|
import java.security.InvalidAlgorithmParameterException;
|
||||||
|
|||||||
@@ -3,18 +3,17 @@ package com.navinfo.outdoor.util;
|
|||||||
import android.graphics.Point;
|
import android.graphics.Point;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.navinfo.outdoor.activity.MyCoordinate;
|
|
||||||
import com.navinfo.outdoor.room.PoiEntity;
|
import com.navinfo.outdoor.room.PoiEntity;
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||||
import org.locationtech.jts.geom.Coordinate;
|
import com.vividsolutions.jts.geom.Coordinate;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import com.vividsolutions.jts.geom.Geometry;
|
||||||
import org.locationtech.jts.geom.GeometryFactory;
|
import com.vividsolutions.jts.geom.GeometryFactory;
|
||||||
import org.locationtech.jts.geom.LineString;
|
import com.vividsolutions.jts.geom.LineString;
|
||||||
import org.locationtech.jts.geom.MultiLineString;
|
import com.vividsolutions.jts.geom.MultiLineString;
|
||||||
import org.locationtech.jts.geom.MultiPoint;
|
import com.vividsolutions.jts.geom.MultiPoint;
|
||||||
import org.locationtech.jts.geom.MultiPolygon;
|
import com.vividsolutions.jts.geom.MultiPolygon;
|
||||||
import org.locationtech.jts.geom.Polygon;
|
import com.vividsolutions.jts.geom.Polygon;
|
||||||
import org.locationtech.jts.io.WKTReader;
|
import com.vividsolutions.jts.io.WKTReader;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -264,8 +263,8 @@ public class GeometryTools {
|
|||||||
/**
|
/**
|
||||||
* 创建点
|
* 创建点
|
||||||
*/
|
*/
|
||||||
public org.locationtech.jts.geom.Point createPoint(Coordinate chord) {
|
public com.vividsolutions.jts.geom.Point createPoint(Coordinate chord) {
|
||||||
org.locationtech.jts.geom.Point point = null;
|
com.vividsolutions.jts.geom.Point point = null;
|
||||||
GeometryFactory factory = new GeometryFactory();
|
GeometryFactory factory = new GeometryFactory();
|
||||||
point = factory.createPoint(chord);
|
point = factory.createPoint(chord);
|
||||||
return point;
|
return point;
|
||||||
@@ -287,7 +286,7 @@ public class GeometryTools {
|
|||||||
try {
|
try {
|
||||||
geometers = reader.read(geometry);
|
geometers = reader.read(geometry);
|
||||||
if (geometers != null) {
|
if (geometers != null) {
|
||||||
org.locationtech.jts.geom.Point point = geometers.getInteriorPoint();
|
com.vividsolutions.jts.geom.Point point = geometers.getInteriorPoint();
|
||||||
LatLng geoInteriorPoint = new LatLng(point.getY(), point.getX());
|
LatLng geoInteriorPoint = new LatLng(point.getY(), point.getX());
|
||||||
if (geometers.getGeometryType().equalsIgnoreCase("Point")) {
|
if (geometers.getGeometryType().equalsIgnoreCase("Point")) {
|
||||||
Coordinate coordinate = geometers.getCoordinate();
|
Coordinate coordinate = geometers.getCoordinate();
|
||||||
@@ -571,42 +570,6 @@ public class GeometryTools {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* 获取线型
|
|
||||||
* @param list
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static LineString getLineStringByPointList(List<org.locationtech.jts.geom.Point> list) {
|
|
||||||
|
|
||||||
if (list != null && list.size() > 1) {
|
|
||||||
int size = list.size();
|
|
||||||
Coordinate[] coors = new Coordinate[size];
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
org.locationtech.jts.geom.Point point = list.get(i);
|
|
||||||
coors[i] = new Coordinate(point.getX(), point.getY());
|
|
||||||
}
|
|
||||||
return getLineStrinGeo(coors);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* 获取线型
|
|
||||||
* @param list
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static LineString getLineStringByMyCoordinate(List<MyCoordinate> list) {
|
|
||||||
|
|
||||||
if (list != null && list.size() > 1) {
|
|
||||||
int size = list.size();
|
|
||||||
Coordinate[] coors = new Coordinate[size];
|
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
coors[i] = new Coordinate(list.get(i).getX(), list.get(i).getY());
|
|
||||||
}
|
|
||||||
return getLineStrinGeo(coors);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 获取线型
|
* 获取线型
|
||||||
* @param coors
|
* @param coors
|
||||||
@@ -978,7 +941,7 @@ public class GeometryTools {
|
|||||||
if (wkts == null || wkts.size() == 0 || LatLng == null) {
|
if (wkts == null || wkts.size() == 0 || LatLng == null) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
org.locationtech.jts.geom.Point point = createPoint(new Coordinate(LatLng.getLongitude(), LatLng.getLatitude()));
|
com.vividsolutions.jts.geom.Point point = createPoint(new Coordinate(LatLng.getLongitude(), LatLng.getLatitude()));
|
||||||
for (int i = 0; i < wkts.size(); i++) {
|
for (int i = 0; i < wkts.size(); i++) {
|
||||||
Geometry geometry = createGeometry(wkts.get(i));
|
Geometry geometry = createGeometry(wkts.get(i));
|
||||||
if (geometry != null && geometry.getGeometryType().equals("Polygon")) {
|
if (geometry != null && geometry.getGeometryType().equals("Polygon")) {
|
||||||
@@ -1224,5 +1187,4 @@ public class GeometryTools {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,210 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package com.navinfo.outdoor.util;
|
|
||||||
|
|
||||||
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
public class LogFileNameGenerate extends 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a file name which represent a specific date.
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String generateFileName(int logLevel, long timestamp) {
|
|
||||||
SimpleDateFormat sdf = mLocalDateFormat.get();
|
|
||||||
sdf.setTimeZone(TimeZone.getDefault());
|
|
||||||
return "default-"+sdf.format(new Date(timestamp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
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;
|
||||||
LocationLifeCycle.getInstance().getLocationChangedListenerList().add(onLocationChangedListener);
|
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().add(onLocationChangedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deactivate() {
|
public void deactivate() {
|
||||||
if (locationChangedListener!=null) {
|
if (locationChangedListener!=null) {
|
||||||
LocationLifeCycle.getInstance().getLocationChangedListenerList().remove(locationChangedListener);
|
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().remove(locationChangedListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,759 +0,0 @@
|
|||||||
package com.navinfo.outdoor.util;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.RadioGroup;
|
|
||||||
import android.widget.TextView;
|
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
|
||||||
|
|
||||||
import com.elvishew.xlog.XLog;
|
|
||||||
import com.kongzue.dialog.v3.CustomDialog;
|
|
||||||
import com.navinfo.outdoor.R;
|
|
||||||
import com.navinfo.outdoor.activity.NaviCarActivity;
|
|
||||||
import com.navinfo.outdoor.activity.NaviRideActivity;
|
|
||||||
import com.navinfo.outdoor.activity.NaviWalkActivity;
|
|
||||||
import com.navinfo.outdoor.api.Constant;
|
|
||||||
import com.tencent.map.navi.CalcRouteCallback;
|
|
||||||
import com.tencent.map.navi.INaviView;
|
|
||||||
import com.tencent.map.navi.TencentNaviCallback;
|
|
||||||
import com.tencent.map.navi.TencentNaviManager;
|
|
||||||
import com.tencent.map.navi.TencentRideNaviListener;
|
|
||||||
import com.tencent.map.navi.TencentRouteSearchCallback;
|
|
||||||
import com.tencent.map.navi.TencentWalkNaviListener;
|
|
||||||
import com.tencent.map.navi.car.CarNaviView;
|
|
||||||
import com.tencent.map.navi.car.CarRouteSearchOptions;
|
|
||||||
import com.tencent.map.navi.car.TencentCarNaviManager;
|
|
||||||
import com.tencent.map.navi.data.AttachedLocation;
|
|
||||||
import com.tencent.map.navi.data.CalcRouteResult;
|
|
||||||
import com.tencent.map.navi.data.IdleRangeInfo;
|
|
||||||
import com.tencent.map.navi.data.NaviPoi;
|
|
||||||
import com.tencent.map.navi.data.NaviTts;
|
|
||||||
import com.tencent.map.navi.data.NavigationData;
|
|
||||||
import com.tencent.map.navi.data.ParallelRoadStatus;
|
|
||||||
import com.tencent.map.navi.data.RouteColors;
|
|
||||||
import com.tencent.map.navi.data.RouteData;
|
|
||||||
import com.tencent.map.navi.data.TrafficItem;
|
|
||||||
import com.tencent.map.navi.ride.RideNaviView;
|
|
||||||
import com.tencent.map.navi.ride.RideRouteSearchOptions;
|
|
||||||
import com.tencent.map.navi.ride.TencentRideNaviManager;
|
|
||||||
import com.tencent.map.navi.ui.car.CarNaviInfoPanel;
|
|
||||||
import com.tencent.map.navi.walk.TencentWalkNaviManager;
|
|
||||||
import com.tencent.map.navi.walk.WalkNaviView;
|
|
||||||
import com.tencent.map.ui.NaviView;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdateFactory;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLngBounds;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
|
||||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class NaviUtils {
|
|
||||||
private static NaviUtils instance;
|
|
||||||
private Context mContext;
|
|
||||||
private TencentMap tencentMap;
|
|
||||||
private TencentNaviManager naviManager = null;
|
|
||||||
private NaviTts naviTts = new NaviTts();
|
|
||||||
public static NaviUtils getInstance() {
|
|
||||||
if (instance == null) {
|
|
||||||
instance = new NaviUtils();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void selectNaviType(AppCompatActivity mContext, SelectNaviTypeListener selectNaviTypeListener) {
|
|
||||||
CustomDialog selectNaviTypeDialog = CustomDialog.build(mContext, R.layout.dialog_select_navi_type, new CustomDialog.OnBindView() {
|
|
||||||
@Override
|
|
||||||
public void onBind(CustomDialog dialog, View v) {
|
|
||||||
RadioGroup rgNaviType = v.findViewById(R.id.rg_navi_type);
|
|
||||||
RadioButton rbtnCar = v.findViewById(R.id.navi_type_car);
|
|
||||||
RadioButton rbtnRide = v.findViewById(R.id.navi_type_ride);
|
|
||||||
RadioButton rbtnWalk = v.findViewById(R.id.navi_type_walk);
|
|
||||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
|
||||||
rbtnCar.setChecked(true);
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
|
||||||
rbtnRide.setChecked(true);
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.WALK) {
|
|
||||||
rbtnWalk.setChecked(true);
|
|
||||||
}
|
|
||||||
TextView tvConfirm = v.findViewById(R.id.btn_navi_type_select_confirm);
|
|
||||||
TextView tvCancel = v.findViewById(R.id.btn_navi_type_select_cancel);
|
|
||||||
tvCancel.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (dialog.isShow) {
|
|
||||||
dialog.doDismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
tvConfirm.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
if (!rbtnCar.isChecked()&&!rbtnRide.isChecked()&&!rbtnWalk.isChecked()) {
|
|
||||||
ToastUtils.Message(mContext, "请选择导航方式!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (rbtnCar.isChecked()) {
|
|
||||||
Constant.currentNaviType = Constant.NAV_TYPE.CAR;
|
|
||||||
} else if (rbtnRide.isChecked()) {
|
|
||||||
Constant.currentNaviType = Constant.NAV_TYPE.RIDE;
|
|
||||||
} else if (rbtnWalk.isChecked()) {
|
|
||||||
Constant.currentNaviType = Constant.NAV_TYPE.WALK;
|
|
||||||
}
|
|
||||||
if (Constant.currentNaviType!=null) {
|
|
||||||
selectNaviTypeListener.selectNaviType(Constant.currentNaviType);
|
|
||||||
}
|
|
||||||
if (dialog.isShow) {
|
|
||||||
dialog.doDismiss();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.setCancelable(false);
|
|
||||||
selectNaviTypeDialog.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, NaviView naviView) {
|
|
||||||
if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车
|
|
||||||
CarNaviView carNaviView = (CarNaviView) naviView;
|
|
||||||
if (naviManager==null||!naviManager.isNavigating()) {
|
|
||||||
naviManager = new TencentCarNaviManager(mContext);
|
|
||||||
}
|
|
||||||
carNaviView.setVisibility(View.VISIBLE);
|
|
||||||
naviManager.addNaviView(carNaviView);
|
|
||||||
CarNaviInfoPanel carNaviInfoPanel = carNaviView.showNaviInfoPanel();
|
|
||||||
carNaviInfoPanel.setOnNaviInfoListener(new CarNaviInfoPanel.OnNaviInfoListener() {
|
|
||||||
@Override
|
|
||||||
public void onBackClick() {
|
|
||||||
((TencentCarNaviManager)naviManager).stopNavi();
|
|
||||||
SystemTTS.getInstance(mContext).playText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((TencentCarNaviManager)naviManager).addTencentNaviCallback(new TencentNaviCallback() {
|
|
||||||
@Override
|
|
||||||
public void onStartNavi() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopNavi() {
|
|
||||||
naviTts.setText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onOffRoute() {
|
|
||||||
// 请求重新规划路径
|
|
||||||
XLog.d("Car已偏航");
|
|
||||||
naviTts.setText("您已偏航,重新计算路径信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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
|
|
||||||
public void onRecalculateRouteSuccessInFence(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRecalculateRouteFailure(int i, int i1, String s) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRecalculateSuccess(CalcRouteResult calcRouteResult) {
|
|
||||||
XLog.d("Car重新计算路径信息成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRecalculateFailure(CalcRouteResult calcRouteResult) {
|
|
||||||
XLog.d("Car重新计算路径信息失败");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRecalculateRouteStarted(int i) {
|
|
||||||
XLog.d("Car开始重新计算路径信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRecalculateRouteCanceled() {
|
|
||||||
XLog.d("Car取消重新计算路径信息");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArrivedDestination() {
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPassedWayPoint(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateRoadType(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateParallelRoadStatus(ParallelRoadStatus parallelRoadStatus) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateAttachedLocation(AttachedLocation attachedLocation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFollowRouteClick(String s, ArrayList<LatLng> arrayList) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int onVoiceBroadcast(NaviTts naviTts) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnterIdleSection(IdleRangeInfo idleRangeInfo) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行
|
|
||||||
RideNaviView rideNaviView = (RideNaviView) naviView;
|
|
||||||
if (naviManager==null||!naviManager.isNavigating()) {
|
|
||||||
naviManager = new TencentRideNaviManager(mContext);
|
|
||||||
}
|
|
||||||
rideNaviView.setVisibility(View.VISIBLE);
|
|
||||||
((TencentRideNaviManager)naviManager).addTencentNaviListener(rideNaviView);
|
|
||||||
CarNaviInfoPanel carNaviInfoPanel = rideNaviView.showNaviInfoPanel();
|
|
||||||
carNaviInfoPanel.setOnNaviInfoListener(new CarNaviInfoPanel.OnNaviInfoListener() {
|
|
||||||
@Override
|
|
||||||
public void onBackClick() {
|
|
||||||
((TencentRideNaviManager)naviManager).stopNavi();
|
|
||||||
SystemTTS.getInstance(mContext).playText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((TencentRideNaviManager) naviManager).addTencentNaviListener(new TencentRideNaviListener() {
|
|
||||||
@Override
|
|
||||||
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
|
|
||||||
public void onDirectionUpdateBySensor(float v) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartNavi() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopNavi() {
|
|
||||||
naviTts.setText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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
|
|
||||||
public int onVoiceBroadcast(NaviTts naviTts) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArrivedDestination() {
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateAttachedLocation(AttachedLocation attachedLocation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsRssiChanged(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateNavigationData(NavigationData navigationData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsWeakNotify() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStrongNotify() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStatusChanged(boolean b) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateCurrentRoute(RouteData routeData) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChangeRes(boolean b) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
WalkNaviView walkNaviView = (WalkNaviView) naviView;
|
|
||||||
if (naviManager==null||!naviManager.isNavigating()) {
|
|
||||||
naviManager = new TencentWalkNaviManager(mContext);
|
|
||||||
}
|
|
||||||
walkNaviView.setVisibility(View.VISIBLE);
|
|
||||||
((TencentWalkNaviManager)naviManager).addTencentNaviListener(walkNaviView);
|
|
||||||
CarNaviInfoPanel carNaviInfoPanel = walkNaviView.showNaviInfoPanel();
|
|
||||||
carNaviInfoPanel.setOnNaviInfoListener(new CarNaviInfoPanel.OnNaviInfoListener() {
|
|
||||||
@Override
|
|
||||||
public void onBackClick() {
|
|
||||||
((TencentWalkNaviManager)naviManager).stopNavi();
|
|
||||||
SystemTTS.getInstance(mContext).playText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
((TencentWalkNaviManager) naviManager).addTencentNaviListener(new TencentWalkNaviListener() {
|
|
||||||
@Override
|
|
||||||
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
|
|
||||||
public void onDirectionUpdateBySensor(float v) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStartNavi() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStopNavi() {
|
|
||||||
naviTts.setText("结束导航");
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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
|
|
||||||
public int onVoiceBroadcast(NaviTts naviTts) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onArrivedDestination() {
|
|
||||||
mContext.finish();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateAttachedLocation(AttachedLocation attachedLocation) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsRssiChanged(int i) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateNavigationData(NavigationData navigationData) {
|
|
||||||
XLog.d("Walk更新导航信息");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsWeakNotify() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStrongNotify() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onGpsStatusChanged(boolean b) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdateCurrentRoute(RouteData routeData) {
|
|
||||||
XLog.d("Walk更新当前route信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+routeData.getRoutePoints().get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChangeRes(boolean b) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.tencentMap = naviView.getMap();
|
|
||||||
this.mContext = mContext;
|
|
||||||
|
|
||||||
// 开启语音播报
|
|
||||||
naviManager.setInternalTtsEnabled(true);
|
|
||||||
naviManager.setIsDefaultRes(true);
|
|
||||||
naviManager.setUseExtraLocationData(true);
|
|
||||||
return naviManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取路径规划
|
|
||||||
* */
|
|
||||||
// private NaviPoi currentStart, currentEnd;
|
|
||||||
// private Constant.NAV_TYPE currentNaviType;
|
|
||||||
public void searchRoute(Constant.NAV_TYPE nav_type, TencentNaviManager naviManager,
|
|
||||||
NaviPoi start, NaviPoi end) throws Exception {
|
|
||||||
// currentStart = start;
|
|
||||||
// currentEnd = end;
|
|
||||||
// currentNaviType = nav_type;
|
|
||||||
if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车模式
|
|
||||||
TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager;
|
|
||||||
CarRouteSearchOptions options = CarRouteSearchOptions.create();
|
|
||||||
NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude());
|
|
||||||
carNaviManager.searchRoute(newStart, end, new ArrayList<>(), options, routeSearchCallback);
|
|
||||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行模式
|
|
||||||
TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager;
|
|
||||||
RideRouteSearchOptions options = RideRouteSearchOptions.create();
|
|
||||||
rideNaviManager.searchRoute(start, end, options, routeSearchCallback);
|
|
||||||
} else { // 步行模式
|
|
||||||
TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager;
|
|
||||||
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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 仅进行路径规划,无需导航
|
|
||||||
* */
|
|
||||||
public TencentNaviManager searchRouteOnly(Activity mContext, Constant.NAV_TYPE nav_type, NaviPoi start, NaviPoi end, TencentRouteSearchCallback routeSearchCallback) throws Exception {
|
|
||||||
TencentNaviManager naviManager = null;
|
|
||||||
if (nav_type == Constant.NAV_TYPE.CAR) {
|
|
||||||
naviManager = new TencentCarNaviManager(mContext);
|
|
||||||
CarRouteSearchOptions options = CarRouteSearchOptions.create();
|
|
||||||
((TencentCarNaviManager)naviManager).searchRoute(start, end, new ArrayList<>(), options, routeSearchCallback);
|
|
||||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) {
|
|
||||||
naviManager = new TencentRideNaviManager(mContext);
|
|
||||||
RideRouteSearchOptions options = RideRouteSearchOptions.create();
|
|
||||||
((TencentRideNaviManager)naviManager).searchRoute(start, end, options, routeSearchCallback);
|
|
||||||
} else {
|
|
||||||
naviManager = new TencentWalkNaviManager(mContext);
|
|
||||||
((TencentWalkNaviManager)naviManager).searchRoute(start, end, routeSearchCallback);
|
|
||||||
}
|
|
||||||
return naviManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 算路回调
|
|
||||||
*/
|
|
||||||
private Polyline currentRouteLine; // 当前绘制的道路线
|
|
||||||
private TencentRouteSearchCallback routeSearchCallback = new TencentRouteSearchCallback() {
|
|
||||||
@Override
|
|
||||||
public void onRouteSearchFailure(int i, String s) {
|
|
||||||
//i错误码提示:1001为网络错误,1002为无网络,2001为返回数据无效(或空),2002为起终点参数错误,2003为途经点参数错误,2004为吸附失败,2005为算路失败,2999为服务器内部错误
|
|
||||||
Log.e("route","error:"+i);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRouteSearchSuccess(ArrayList<RouteData> arrayList) {
|
|
||||||
// 添加道路Route到地图,默认选取第一条
|
|
||||||
currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
|
|
||||||
zoomToRoute(mContext, arrayList.get(0), tencentMap);
|
|
||||||
try {
|
|
||||||
// 自动开始导航
|
|
||||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
|
||||||
if (!((TencentCarNaviManager)naviManager).isNavigating()) {
|
|
||||||
((TencentCarNaviManager)naviManager).startNavi(0);
|
|
||||||
// ((TencentCarNaviManager)naviManager).startSimulateNavi(0);
|
|
||||||
}
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
|
||||||
if (!((TencentRideNaviManager)naviManager).isNavigating()) {
|
|
||||||
((TencentRideNaviManager)naviManager).startNavi(0);
|
|
||||||
// ((TencentRideNaviManager)naviManager).startSimulateNavi(0);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!((TencentWalkNaviManager)naviManager).isNavigating()) {
|
|
||||||
((TencentWalkNaviManager)naviManager).startNavi(0);
|
|
||||||
// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
// addMarkerStart(start.getLatitude(),start.getLongitude());
|
|
||||||
// addMarkerDestination(dest.getLatitude(),dest.getLongitude());
|
|
||||||
// addMarkerPass(wayPoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCalcRouteSuccess(CalcRouteResult calcRouteResult) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCalcRouteFailure(CalcRouteResult calcRouteResult) {
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private void addMarkerStart(double latitude, double longitude) {
|
|
||||||
LatLng startPoint = new LatLng(latitude, longitude);
|
|
||||||
tencentMap.addMarker(new MarkerOptions(startPoint)
|
|
||||||
.icon(BitmapDescriptorFactory.fromAsset("navi_marker_start.png"))
|
|
||||||
.anchor(0.5f, 1));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMarkerDestination(double latitude, double longitude) {
|
|
||||||
|
|
||||||
LatLng destinationPoint = new LatLng(latitude, longitude);
|
|
||||||
tencentMap.addMarker(new MarkerOptions(destinationPoint)
|
|
||||||
.icon(BitmapDescriptorFactory.fromAsset("navi_marker_end.png"))
|
|
||||||
.anchor(0.5f, 1));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addMarkerPass(ArrayList<NaviPoi> wayPoints) {
|
|
||||||
|
|
||||||
for (NaviPoi wayPoint : wayPoints) {
|
|
||||||
LatLng destinationPoint = new LatLng(wayPoint.getLatitude(), wayPoint.getLongitude());
|
|
||||||
tencentMap.addMarker(new MarkerOptions(destinationPoint)
|
|
||||||
.icon(BitmapDescriptorFactory.fromAsset("navi_marker_pass.png"))
|
|
||||||
.anchor(0.5f, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Polyline addRoutes(RouteData routeData, TencentMap map) {
|
|
||||||
if (currentRouteLine!=null&&!currentRouteLine.isRemoved()) {
|
|
||||||
currentRouteLine.remove();
|
|
||||||
currentRouteLine = null;
|
|
||||||
}
|
|
||||||
ArrayList<TrafficItem> traffics = getTrafficItemsFromList(routeData.getTrafficIndexList());
|
|
||||||
List<LatLng> mRoutePoints = routeData.getRoutePoints();
|
|
||||||
// 点的个数
|
|
||||||
int pointSize = mRoutePoints.size();
|
|
||||||
// 路段总数 三个index是一个路况单元,分别为:路况级别,起点,终点
|
|
||||||
int trafficSize = traffics.size();
|
|
||||||
// 路段index所对应的颜色值数组
|
|
||||||
int[] trafficColors = new int[pointSize];
|
|
||||||
// 路段index数组
|
|
||||||
int[] trafficColorsIndex = new int[pointSize];
|
|
||||||
int pointStart = 0;
|
|
||||||
int pointEnd = 0;
|
|
||||||
int trafficColor = 0;
|
|
||||||
int index = 0;
|
|
||||||
for (int j = 0; j < trafficSize; j++) {
|
|
||||||
pointStart = traffics.get(j).getFromIndex();
|
|
||||||
// 规避错乱数据
|
|
||||||
if (pointStart < pointEnd) {
|
|
||||||
pointStart = pointEnd;
|
|
||||||
}
|
|
||||||
pointEnd = traffics.get(j).getToIndex();
|
|
||||||
trafficColor = getTrafficColorByCode(traffics.get(j).getTraffic());
|
|
||||||
|
|
||||||
for (int k = pointStart; k < pointEnd || k == pointSize - 1; k++) {
|
|
||||||
trafficColors[index] = trafficColor;
|
|
||||||
trafficColorsIndex[index] = index;
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PolylineOptions options = new PolylineOptions()
|
|
||||||
.addAll(routeData.getRoutePoints())
|
|
||||||
.width(15)
|
|
||||||
.arrow(true)
|
|
||||||
.colors(trafficColors, trafficColorsIndex)
|
|
||||||
.zIndex(10);
|
|
||||||
if (map == null) {
|
|
||||||
map = tencentMap;
|
|
||||||
}
|
|
||||||
Polyline polyline = map.addPolyline(options);
|
|
||||||
return polyline;
|
|
||||||
}
|
|
||||||
public void zoomToRoute(Context mContext, RouteData routeData, TencentMap map) {
|
|
||||||
int marginLeft = mContext.getResources().getDimensionPixelSize(R.dimen.navigation_line_margin_left);
|
|
||||||
int marginTop = mContext.getResources().getDimensionPixelSize(R.dimen.navigation_line_margin_top);
|
|
||||||
int marginRight = mContext.getResources().getDimensionPixelSize(R.dimen.navigation_line_margin_right);
|
|
||||||
int marginBottom = mContext.getResources().getDimensionPixelSize(R.dimen.navigation_line_margin_bottom);
|
|
||||||
LatLngBounds.Builder builder = new LatLngBounds.Builder();
|
|
||||||
|
|
||||||
builder.include(routeData.getRoutePoints());
|
|
||||||
LatLngBounds bounds = builder.build();
|
|
||||||
if (map == null) {
|
|
||||||
map = tencentMap;
|
|
||||||
}
|
|
||||||
map.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(bounds, marginLeft, marginRight, marginTop, marginBottom));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private int getTrafficColorByCode(int type) {
|
|
||||||
int color = 0xFFFFFFFF;
|
|
||||||
switch (type) {
|
|
||||||
case 0:
|
|
||||||
// 路况标签-畅通
|
|
||||||
// 绿色
|
|
||||||
color = RouteColors.COLOR_MAIN_DAY_SMOOTH;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// 路况标签-缓慢
|
|
||||||
// 黄色
|
|
||||||
color = RouteColors.COLOR_MAIN_DAY_SLOW;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// 路况标签-拥堵
|
|
||||||
// 红色
|
|
||||||
color = RouteColors.COLOR_MAIN_DAY_VERY_SLOW;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
// 路况标签-无路况
|
|
||||||
color = RouteColors.COLOR_MAIN_DAY_UNKNOWN;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
// 路况标签-特别拥堵(猪肝红)
|
|
||||||
color = RouteColors.COLOR_MAIN_DAY_JAM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<TrafficItem> getTrafficItemsFromList(ArrayList<Integer> indexList) {
|
|
||||||
ArrayList<TrafficItem> trafficItems = new ArrayList<>();
|
|
||||||
for (int i = 0; i < indexList.size(); i = i + 3) {
|
|
||||||
TrafficItem item = new TrafficItem();
|
|
||||||
item.setTraffic(indexList.get(i));
|
|
||||||
item.setFromIndex(indexList.get(i + 1));
|
|
||||||
item.setToIndex(indexList.get(i + 2));
|
|
||||||
trafficItems.add(item);
|
|
||||||
}
|
|
||||||
return trafficItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopNavi() {
|
|
||||||
if (naviManager!=null&&naviManager.isNavigating()) {
|
|
||||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
|
||||||
((TencentCarNaviManager)naviManager).stopNavi();
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
|
||||||
((TencentRideNaviManager)naviManager).stopNavi();
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.WALK) {
|
|
||||||
((TencentWalkNaviManager)naviManager).stopNavi();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始路径规划
|
|
||||||
* */
|
|
||||||
public void startNav(Activity mContext, LatLng startLatlng, LatLng endLatlng) {
|
|
||||||
if (LocationLifeCycle.getInstance().getMainLocation() == null) {
|
|
||||||
ToastUtils.Message(mContext, "无法获取当前位置,请检查是否授权应用获取位置权限!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (startLatlng == null || endLatlng == null) {
|
|
||||||
ToastUtils.Message(mContext, "无法获取个人位置或数据位置信息,请重新打开此数据尝试!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 跳转到指定的Activity
|
|
||||||
Class toClass = null;
|
|
||||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
|
||||||
toClass = NaviCarActivity.class;
|
|
||||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
|
||||||
toClass = NaviRideActivity.class;
|
|
||||||
} else {
|
|
||||||
toClass = NaviWalkActivity.class;
|
|
||||||
}
|
|
||||||
Intent naviIntent = new Intent(mContext, toClass);
|
|
||||||
// 使用当前数据起点作为导航的终点,规划路径
|
|
||||||
naviIntent.putExtra("start", startLatlng);
|
|
||||||
naviIntent.putExtra("end", endLatlng);
|
|
||||||
mContext.startActivity(naviIntent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private TencentNaviManager getNaviManager() {
|
|
||||||
if (naviManager!=null) {
|
|
||||||
return naviManager;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
public interface SelectNaviTypeListener {
|
|
||||||
void selectNaviType(Constant.NAV_TYPE nav_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,318 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
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,9 +45,7 @@ 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());
|
||||||
if (file.exists()) {
|
file.delete();
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (poiEntity.getId() != null) {
|
if (poiEntity.getId() != null) {
|
||||||
@@ -61,9 +59,7 @@ public class PoiEntityDeleteUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < chargingPileFileList.size(); i++) {
|
for (int i = 0; i < chargingPileFileList.size(); i++) {
|
||||||
if (chargingPileFileList.get(i).exists()) {
|
chargingPileFileList.get(i).delete();
|
||||||
chargingPileFileList.get(i).delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
PoiDatabase.getInstance(context).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
PoiDatabase.getInstance(context).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
||||||
}
|
}
|
||||||
@@ -75,14 +71,10 @@ 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++) {
|
||||||
if (fileListByUUID.get(i).exists()) {
|
fileListByUUID.get(i).delete();
|
||||||
fileListByUUID.get(i).delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
|
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
|
||||||
if (filePath.exists()) {
|
filePath.delete();
|
||||||
filePath.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,9 +83,7 @@ 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());
|
||||||
if (file.exists()) {
|
file.delete();
|
||||||
file.delete();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ 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.ZipUtil;
|
||||||
import com.github.lazylibrary.util.FileUtils;
|
|
||||||
import com.github.lazylibrary.util.ToastUtils;
|
|
||||||
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;
|
||||||
@@ -22,27 +21,16 @@ import com.navinfo.outdoor.room.ChargingPileEntity;
|
|||||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||||
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.umeng.commonsdk.debug.UMLog;
|
|
||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
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.Map;
|
import java.util.Objects;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
|
||||||
import io.reactivex.ObservableSource;
|
|
||||||
import io.reactivex.Observer;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
import io.reactivex.functions.Function;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -52,11 +40,8 @@ public class PoiSaveUtils {
|
|||||||
private Activity mContext;
|
private Activity mContext;
|
||||||
private Gson gson;
|
private Gson gson;
|
||||||
private static PoiSaveUtils instance;
|
private static PoiSaveUtils instance;
|
||||||
private int anInt = 0; // 上传成功的个数
|
private int anInt = 0;
|
||||||
private int bInt = 0; // 上传失败的个数
|
private int bInt = 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,188 +59,76 @@ public class PoiSaveUtils {
|
|||||||
* 批量上传数据到服务端
|
* 批量上传数据到服务端
|
||||||
*/
|
*/
|
||||||
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
|
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
|
||||||
if (poiEntityList != null&&!poiEntityList.isEmpty()) {
|
if (poiEntityList != null) {
|
||||||
logger.d("开始批量上传-------------------------共"+poiEntityList.size()+"个");
|
new Thread(new Runnable() {
|
||||||
// 因为道路任务和POI录像任务需要分包提交,因此和其他要素分开,分别放在两个管道里
|
@Override
|
||||||
List<Map.Entry<Integer, PoiEntity>> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
public void run() {
|
||||||
List<Map.Entry<Integer, PoiEntity>> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
anInt = 0;
|
||||||
List<Map.Entry<Integer, PoiEntity>> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
bInt = 0;
|
||||||
for (int i = 0; i < poiEntityList.size(); i++) {
|
Log.d("PoiSaveUtils", "开始上传");
|
||||||
PoiEntity poiEntity = poiEntityList.get(i);
|
for (int i = 0; i < poiEntityList.size(); i++) {
|
||||||
logger.d("准备数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
PoiEntity poiEntity = poiEntityList.get(i);
|
||||||
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
Log.d("PoiSaveUtils", "poiEntity.getType():"+poiEntity.getType());
|
||||||
continue;
|
if (poiEntity.getType() == 2) { // 如果是充电站数据,首先检查子充电桩的状态
|
||||||
}
|
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||||
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
if (saveChargingPileByChargingStation(poiEntity)) {
|
||||||
if (poiEntity.getType()==2) {
|
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
||||||
chargePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
// 开始上传流程
|
||||||
} else if (poiEntity.getType() == 3 || poiEntity.getType() == 4 || poiEntity.getType() == 11 || poiEntity.getType() == 12 || poiEntity.getType() == 13) {
|
if (saveChargingPileUploadChargingStation(poiEntity)) {
|
||||||
spliteFilePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
uploadPoiNet(poiEntity);
|
||||||
} else {
|
}else {
|
||||||
otherPoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
poiEntity.setChecked(false);
|
||||||
}
|
poiEntity.setWork_type(0);
|
||||||
}
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
|
}
|
||||||
Observable chargePoiObserable = Observable.fromIterable(chargePoiEntityList)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
|
||||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
|
||||||
logger.d("开始上传充电站数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
|
||||||
if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
|
|
||||||
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
|
||||||
// 开始上传流程
|
|
||||||
if (saveChargingPileUploadChargingStation(poiEntity)) {
|
|
||||||
uploadPoiNet(integerPoiEntityEntry);
|
|
||||||
}else {
|
}else {
|
||||||
poiEntityUploadFailed(poiEntity, "充电桩数据上传失败!");
|
poiEntity.setChecked(false);
|
||||||
|
poiEntity.setWork_type(0);
|
||||||
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
}
|
}
|
||||||
}else {
|
|
||||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
poiEntity.setChecked(false);
|
||||||
|
poiEntity.setWork_type(0);
|
||||||
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
}
|
}
|
||||||
}
|
} else {//其他类型
|
||||||
})
|
|
||||||
.onErrorResumeNext(Observable.empty());
|
|
||||||
// 处理普通数据
|
|
||||||
Observable otherObserable = Observable.fromIterable(otherPoiEntityList)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
|
||||||
@Override
|
|
||||||
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(integerPoiEntityEntry);
|
uploadPoiNet(poiEntity);
|
||||||
}else {
|
}else {
|
||||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
poiEntity.setChecked(false);
|
||||||
|
poiEntity.setWork_type(0);
|
||||||
|
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
.onErrorResumeNext(Observable.empty());
|
mContext.runOnUiThread(new Runnable() {
|
||||||
// 处理需要分包上传数据的POI录像和道路数据
|
|
||||||
Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
public void run() {
|
||||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
|
||||||
logger.d("开始上传分包数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
|
||||||
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
|
||||||
//走上传流程:
|
|
||||||
if (poiEntity == null) {
|
|
||||||
poiEntityUploadFailed(poiEntity, "当前数据为null!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int bodyId = poiEntity.getBodyId();
|
|
||||||
if (bodyId == 0) {
|
|
||||||
poiEntityUploadFailed(poiEntity, "bodyId为0");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}else {
|
|
||||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.concatMap(new Function<Map.Entry<Integer, PoiEntity>, ObservableSource<PoiEntity>>() {
|
|
||||||
@Override
|
|
||||||
public ObservableSource<PoiEntity> apply(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
|
||||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
|
||||||
List<File> photoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
|
||||||
if (photoFileList == null||photoFileList.size()<2/*如果文件压缩包内小于2个文件,说明拍摄的照片丢失了*/) {
|
|
||||||
poiEntityUploadFailed(poiEntity, "照片数据获取为空!");
|
|
||||||
return Observable.empty();
|
|
||||||
}
|
|
||||||
return DataSaveUtils.getInstance().getUploadSpliteFilesObservble(mContext, poiEntity, photoFileList)
|
|
||||||
.toObservable();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.doOnNext(new Consumer<PoiEntity>() {
|
|
||||||
@Override
|
|
||||||
public void accept(PoiEntity poiEntity) throws Exception {
|
|
||||||
poiEntityUploadSuccess(poiEntity, "上传成功");
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.doOnError(new Consumer<Throwable>() {
|
|
||||||
@Override
|
|
||||||
public void accept(Throwable throwable) throws Exception {
|
|
||||||
bInt++;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.onErrorResumeNext(Observable.empty());
|
|
||||||
Observable.concat(
|
|
||||||
otherObserable, spliteFileObserable, chargePoiObserable
|
|
||||||
).subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.onErrorResumeNext(Observable.empty())
|
|
||||||
.subscribe(new Observer() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(Disposable d) {
|
|
||||||
anInt = 0;
|
|
||||||
bInt = 0;
|
|
||||||
uploadCount = chargePoiEntityList.size()+spliteFilePoiEntityList.size()+otherPoiEntityList.size();
|
|
||||||
Log.d("PoiSaveUtils", "开始上传");
|
|
||||||
ToastUtils.showToast(mContext, "开始批量上传数据,本次共需上传"+uploadCount+"条数据");
|
|
||||||
mDisposable = d;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(Object o) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(Throwable e) {
|
|
||||||
ToastUtils.showToast(mContext, e.getMessage());
|
|
||||||
Constant.isPresent = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
Message obtain = Message.obtain();
|
Message obtain = Message.obtain();
|
||||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||||
obtain.obj = true;
|
obtain.obj = true;
|
||||||
EventBus.getDefault().post(obtain);
|
EventBus.getDefault().post(obtain);
|
||||||
Message obtain1 = Message.obtain();
|
if (anInt + bInt > 0) {
|
||||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
Message obtain1 = Message.obtain();
|
||||||
obtain1.obj = "批量提交数据,共选中"+uploadCount+"条数据,成功:" + anInt + "条, 失败:" + bInt+"条";
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
EventBus.getDefault().post(obtain1);
|
obtain1.obj = "批量提交 成功:" + anInt + ", 失败:" + bInt;
|
||||||
Constant.isPresent = true;
|
EventBus.getDefault().post(obtain1);
|
||||||
|
} else {
|
||||||
|
Message obtain1 = Message.obtain();
|
||||||
|
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||||
|
obtain1.obj = "批量提交 失败";
|
||||||
|
EventBus.getDefault().post(obtain1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理poi数据上传失败
|
|
||||||
* */
|
|
||||||
private void poiEntityUploadFailed(PoiEntity poiEntity, String errorInfo) {
|
|
||||||
poiEntity.setUploadResult(errorInfo);
|
|
||||||
bInt++;
|
|
||||||
poiEntity.setWork_type(-1);
|
|
||||||
poiEntity.setUploadProgress(0);
|
|
||||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 保存数据到服务
|
* 保存数据到服务
|
||||||
*/
|
*/
|
||||||
@@ -288,16 +161,14 @@ 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) {
|
||||||
@@ -345,22 +216,17 @@ public class PoiSaveUtils {
|
|||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public interface UploadListener {
|
|
||||||
// public void uploadCallback();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最终上传POI数据到服务
|
* 最终上传POI数据到服务
|
||||||
*/
|
*/
|
||||||
public void uploadPoiNet(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) {
|
public void uploadPoiNet(PoiEntity poiEntity) {
|
||||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
|
||||||
if (poiEntity == null) {
|
if (poiEntity == null) {
|
||||||
poiEntityUploadFailed(poiEntity, "poiEntity为null");
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int bodyId = poiEntity.getBodyId();
|
int bodyId = poiEntity.getBodyId();
|
||||||
if (bodyId == 0) {
|
if (bodyId == 0) {
|
||||||
poiEntityUploadFailed(poiEntity, "bodyId为0");
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ArrayList<File> photoFile = new ArrayList<>();
|
ArrayList<File> photoFile = new ArrayList<>();
|
||||||
@@ -373,108 +239,77 @@ 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.size()<2) {
|
if (videoFileList != null && !videoFileList.isEmpty()) {
|
||||||
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
||||||
if (!existsPic) {
|
if (!existsPic) {
|
||||||
bInt++;
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 需要上传的文件都存在,开始调用分片上传接口上传附件数据
|
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
||||||
DataSaveUtils.getInstance().uploadFiles(mContext, poiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
ZipUtil.zipFiles(videoFileList, fileZip, null);
|
||||||
@Override
|
photoFile.add(fileZip);
|
||||||
public void onStart() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
anInt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError() {
|
|
||||||
// 上传失败
|
|
||||||
bInt++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
|
||||||
// ZipUtil.zipFiles(videoFileList, fileZip, null);
|
|
||||||
// photoFile.add(fileZip);
|
|
||||||
} else {
|
} else {
|
||||||
bInt++;
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if (photoFile.size() > 0) {
|
if (photoFile.size() > 0) {
|
||||||
// long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath());
|
long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath());
|
||||||
// if (zipTrueSize > 0) {
|
if (zipTrueSize > 0) {
|
||||||
// initList(HttpInterface.POI_VIDEO_UPLOAD_PIC, photoFile, poiEntity);
|
initList(HttpInterface.POI_VIDEO_UPLOAD_PIC, photoFile, poiEntity);
|
||||||
// } else {
|
} else {
|
||||||
// for (int i = 0; i < photoFile.size(); i++) {
|
for (int i = 0; i < photoFile.size(); i++) {
|
||||||
// photoFile.get(i).delete();
|
photoFile.get(i).delete();
|
||||||
// }
|
}
|
||||||
// bInt++;
|
bInt++;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
} 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.size()<2) {
|
if (videoFileList != null && !videoFileList.isEmpty()) {
|
||||||
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
||||||
if (!existsPic) {
|
if (!existsPic) {
|
||||||
bInt++;
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 需要上传的文件都存在,开始调用分片上传接口上传附件数据
|
File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
||||||
DataSaveUtils.getInstance().uploadFiles(mContext, poiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
ZipUtil.zipFiles(videoFileList, fileZip, null);
|
||||||
@Override
|
photoFile.add(fileZip);
|
||||||
public void onStart() {
|
} else {
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFinish() {
|
|
||||||
anInt++;
|
|
||||||
Log.d("TAGSS", "uploadPoiNet: 成功" + anInt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError() {
|
|
||||||
// 上传失败
|
|
||||||
bInt++;
|
|
||||||
Log.d("TAGSS", poiEntity.getBodyId()+"uploadPoiNet: 失败" + bInt);
|
|
||||||
UMLog.aq(1, poiEntity.getBodyId()+"uploadPoiNet: 失败", "文件上传失败");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
// File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
|
||||||
// ZipUtil.zipFiles(videoFileList, fileZip, null);
|
|
||||||
// photoFile.add(fileZip);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Log.d("TAGSS", "videoFileList: 失败" + bInt);
|
Log.d("TAGSS", "videoFileList: 失败" + bInt);
|
||||||
bInt++;
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (photoFile.size() > 0) {
|
||||||
else if (poiEntity.getType() == 5) {
|
long zipTrueSize = ZipUtils.getZipTrueSize(photoFile.get(0).getAbsolutePath());
|
||||||
|
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()
|
||||||
.time(600)
|
.time(0)
|
||||||
.Builder(mContext)
|
.Builder(mContext)
|
||||||
.url(url)
|
.url(url)
|
||||||
.params(httpParams)
|
.params(httpParams)
|
||||||
@@ -483,46 +318,56 @@ public class PoiSaveUtils {
|
|||||||
.postFileSynchronization();
|
.postFileSynchronization();
|
||||||
if (execute == null) {
|
if (execute == null) {
|
||||||
Log.d("TAGSS", "execute: 失败" + bInt);
|
Log.d("TAGSS", "execute: 失败" + bInt);
|
||||||
poiEntityUploadFailed(poiEntity, "服务返回结果为null");
|
poiEntity.setChecked(false);
|
||||||
|
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);
|
||||||
poiEntityUploadFailed(poiEntity, "服务返回code码不为200"+execute.code());
|
poiEntity.setChecked(false);
|
||||||
|
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);
|
||||||
poiEntityUploadFailed(poiEntity, "服务返回body为null");
|
poiEntity.setChecked(false);
|
||||||
|
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++) {
|
||||||
if (!list.isEmpty()&&list.get(0).getParentFile().exists()&&!list.get(0).getParentFile().getName().endsWith("picture")) {
|
list.get(i).delete();
|
||||||
// 删除对应的文件夹
|
|
||||||
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);
|
||||||
poiEntity.setUploadProgress(poiEntity.getUploadMax());
|
anInt++;
|
||||||
poiEntityUploadSuccess(poiEntity, "");
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
poiEntityUploadFailed(poiEntity, "错误:"+otherUploadPicBean.getMessage());
|
poiEntity.setChecked(false);
|
||||||
|
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);
|
||||||
poiEntityUploadFailed(poiEntity, "Json转换失败");
|
bInt++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -531,16 +376,6 @@ 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
|
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
|
||||||
*/
|
*/
|
||||||
@@ -599,8 +434,8 @@ public class PoiSaveUtils {
|
|||||||
if (execute.code() != 200) {
|
if (execute.code() != 200) {
|
||||||
return execute.code();
|
return execute.code();
|
||||||
}
|
}
|
||||||
String string = execute.body().string();
|
if (execute.body().string() != null) {
|
||||||
if (string != null) {
|
String string = execute.body().string();
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(string, ChargingPileSaveBean.class);
|
ChargingPileSaveBean chargingPileSaveBean = gson.fromJson(string, ChargingPileSaveBean.class);
|
||||||
if (chargingPileSaveBean.getCode() != 200) {
|
if (chargingPileSaveBean.getCode() != 200) {
|
||||||
@@ -662,7 +497,7 @@ public class PoiSaveUtils {
|
|||||||
HttpParams httpParams = new HttpParams();
|
HttpParams httpParams = new HttpParams();
|
||||||
httpParams.put("auditId", chargingPileEntity.getBodyId());
|
httpParams.put("auditId", chargingPileEntity.getBodyId());
|
||||||
Response execute = OkGoBuilder.getInstance()
|
Response execute = OkGoBuilder.getInstance()
|
||||||
.time(600)
|
.time(0)
|
||||||
.Builder(mContext)
|
.Builder(mContext)
|
||||||
.url(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
.url(HttpInterface.CS_TASK_UP_LOAD_PIC)
|
||||||
.token(Constant.ACCESS_TOKEN)
|
.token(Constant.ACCESS_TOKEN)
|
||||||
@@ -703,21 +538,11 @@ 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()&&!picFile.getName().endsWith(".txt")/*至少包含1张照片*/) {
|
if (picFile!=null&&picFile.exists()) {
|
||||||
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表
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,7 +283,6 @@ public class PreserveUtils {
|
|||||||
|
|
||||||
// 充电站数据已经保存在服务上,批量保存充电桩数据
|
// 充电站数据已经保存在服务上,批量保存充电桩数据
|
||||||
saveChargingPileByChargingStation(mContext, poiEntity);
|
saveChargingPileByChargingStation(mContext, poiEntity);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
mContext.runOnUiThread(new Runnable() {
|
mContext.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -300,17 +299,14 @@ public class PreserveUtils {
|
|||||||
obtain1.what = Constant.NEST_WORD_REGISTER;
|
obtain1.what = Constant.NEST_WORD_REGISTER;
|
||||||
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
} else if (chargingStationBean.getCode() == 230) {
|
} else if (chargingStationBean.getCode() == 230) {
|
||||||
FlushTokenUtil.flushToken(mContext);
|
FlushTokenUtil.flushToken(mContext);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
} else {
|
} else {
|
||||||
Message obtain1 = Message.obtain();
|
Message obtain1 = Message.obtain();
|
||||||
obtain1.what = Constant.NEST_WORD_REGISTER;
|
obtain1.what = Constant.NEST_WORD_REGISTER;
|
||||||
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -320,7 +316,6 @@ public class PreserveUtils {
|
|||||||
obtain1.what = Constant.NEST_WORD_REGISTER;
|
obtain1.what = Constant.NEST_WORD_REGISTER;
|
||||||
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
obtain1.obj = "充电站:" + poiEntity.getName() + " 保存本地失败";
|
||||||
EventBus.getDefault().post(obtain1);
|
EventBus.getDefault().post(obtain1);
|
||||||
Constant.submitIdSet.remove(poiEntity.getId());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user