Compare commits
90
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cbcaf38b65 | ||
|
|
aaaef022ea | ||
|
|
b6ea2b74e0 | ||
|
|
8bb3d566c9 | ||
|
|
d59e2e65ab | ||
|
|
89b6c8e01d | ||
|
|
6153bb607c | ||
|
|
7a83b510e9 | ||
|
|
480ff37026 | ||
|
|
f385fb8e6c | ||
|
|
c40ccaece4 | ||
|
|
8a77853888 | ||
|
|
e0618ee747 | ||
|
|
c80562f731 | ||
|
|
85f76408ea | ||
|
|
981ed24a27 | ||
|
|
1c0e462ea9 | ||
|
|
dc41a9bba8 | ||
|
|
d6b917fb72 | ||
|
|
4ff0f5cd2a | ||
|
|
a039b44271 | ||
|
|
aff6dea97d | ||
|
|
f4ce86f37b | ||
|
|
b9bb75063b | ||
|
|
b329f9dc54 | ||
|
|
b8719ccfaa | ||
|
|
5853e3f940 | ||
|
|
82605b895e | ||
|
|
81ec86bb04 | ||
|
|
4ea20cb0cf | ||
|
|
7c6ac78f53 | ||
|
|
edd91c8ad3 | ||
|
|
f28f9031a5 | ||
|
|
53ce6e1c2e | ||
|
|
8a3ccbd0f5 | ||
|
|
038947fc42 | ||
|
|
5a1b0edd82 | ||
|
|
9d8185a958 | ||
|
|
eb7adc487d | ||
|
|
f4685039e4 | ||
|
|
ac2beb5370 | ||
|
|
6fcb464311 | ||
|
|
26f6627be0 | ||
|
|
6a5b6a5f19 | ||
|
|
477f4981e8 | ||
|
|
ae2f4705d9 | ||
|
|
34316889ce | ||
|
|
94c9253372 | ||
|
|
070d196f45 | ||
|
|
61c1c53696 | ||
|
|
3b1624f49a | ||
|
|
8755b70705 | ||
|
|
ba57256471 | ||
|
|
6399dc3abc | ||
|
|
12b870ea79 | ||
|
|
a66647d735 | ||
|
|
4317bc87d8 | ||
|
|
37e4c59041 | ||
|
|
506299b3a3 | ||
|
|
c5e4a216bc | ||
|
|
baebb9e5cf | ||
|
|
2b6163fe45 | ||
|
|
96bb6a35e6 | ||
|
|
54358b2ef0 | ||
|
|
88dd96f572 | ||
|
|
f7943db1c0 | ||
|
|
11289fb08a | ||
|
|
3e6f8997fb | ||
|
|
2126781230 | ||
|
|
12b7d95982 | ||
|
|
bee9fb9d59 | ||
|
|
b2e5d6dd87 | ||
|
|
3f8ee91230 | ||
|
|
b6a6c85da7 | ||
|
|
8392b7ba7e | ||
|
|
43960c0740 | ||
|
|
c4d927d40b | ||
|
|
d5090bcd3d | ||
|
|
3c24038fd2 | ||
|
|
bd22ede488 | ||
|
|
8b8866d3fb | ||
|
|
f8ad72023f | ||
|
|
7fb65d4a64 | ||
|
|
9063a5a99e | ||
|
|
862e828c46 | ||
|
|
2ec9f49272 | ||
|
|
390d3d435c | ||
|
|
f04b2a5892 | ||
|
|
7299e1e993 | ||
|
|
c56322abb9 |
+3
-1
@@ -13,4 +13,6 @@
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
app/release/
|
||||
app/release/
|
||||
app/build/
|
||||
ocr/build/
|
||||
Generated
+30
@@ -56,5 +56,35 @@
|
||||
<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>
|
||||
</project>
|
||||
+86
-23
@@ -1,21 +1,63 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
plugins {
|
||||
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 {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion '29.0.2'
|
||||
compileSdkVersion 31
|
||||
// buildToolsVersion '29.0.2'
|
||||
//ndkVersion '23.0.7123448'
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
minSdkVersion 23
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 43
|
||||
versionName "8.230130"
|
||||
versionCode 118
|
||||
versionName "8.231110-通用测试版"
|
||||
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 {
|
||||
checkReleaseBuilds false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
@@ -36,8 +78,8 @@ android {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility JavaVersion.VERSION_11
|
||||
targetCompatibility JavaVersion.VERSION_11
|
||||
}
|
||||
ndkVersion '21.3.6528147'
|
||||
packagingOptions {
|
||||
@@ -48,6 +90,13 @@ android {
|
||||
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 {
|
||||
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
|
||||
@@ -66,17 +115,19 @@ android {
|
||||
//}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"])
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.6.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.1.0'
|
||||
implementation 'androidx.navigation:navigation-ui:2.1.0'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation project(path: ':ocr')
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
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
|
||||
implementation 'com.umeng.umsdk:apm:1.2.0'
|
||||
//友盟基础库依赖(必须)
|
||||
@@ -90,18 +141,17 @@ dependencies {
|
||||
implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
|
||||
implementation 'com.gyf.immersionbar:immersionbar-components:3.0.0'
|
||||
|
||||
|
||||
//网络框架
|
||||
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.readystatesoftware.chuck:library:1.1.0'
|
||||
|
||||
//retrofit+rxJava
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||
//转换器,请求结果转换成Model
|
||||
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
// //retrofit+rxJava
|
||||
// implementation 'com.squareup.retrofit2:retrofit:2.5.0'
|
||||
// implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
|
||||
// //转换器,请求结果转换成Model
|
||||
// implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
|
||||
//配合RxJava 使用
|
||||
implementation 'io.reactivex.rxjava2:rxjava:2.2.7'
|
||||
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
|
||||
@@ -117,6 +167,8 @@ dependencies {
|
||||
implementation 'com.github.bumptech.glide:glide:4.8.0'
|
||||
//弹窗 https://github.com/kongzue/DialogV3
|
||||
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下拉刷新控件
|
||||
implementation project(':xrecyclerview')
|
||||
//拍照功能 https://github.com/natario1/CameraView
|
||||
@@ -139,7 +191,7 @@ dependencies {
|
||||
// implementation 'com.tencent.map.geolocation:TencentLocationSdk-openplatform:7.4.9'
|
||||
|
||||
// 权限请求框架:https://github.com/getActivity/XXPermissions
|
||||
implementation 'com.github.getActivity:XXPermissions:11.6'
|
||||
implementation 'com.github.getActivity:XXPermissions:18.0'
|
||||
|
||||
//room 数据库
|
||||
def room_version = "2.2.0-alpha01"
|
||||
@@ -159,8 +211,8 @@ dependencies {
|
||||
implementation 'cn.jzvd:jiaozivideoplayer:7.4.2'
|
||||
//图片压缩 https://github.com/Hu12037102/ImageCompress
|
||||
implementation 'com.github.Hu12037102:ImageCompress:2.3.0'
|
||||
//webp 转换
|
||||
implementation 'com.wanghong.webpnative:webpnative:0.1.0'
|
||||
// //webp 转换
|
||||
// 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 日志记录
|
||||
@@ -169,4 +221,15 @@ dependencies {
|
||||
// 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.
@@ -3,6 +3,23 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
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.READ_CALENDAR" /> <!-- <uses-permission android:name="android.permission.WRITE_CALENDAR" /> -->
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||
@@ -17,10 +34,6 @@
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_BOOT_COMPLETED"
|
||||
tools:node="remove" /> <!-- 移除自启动能力 -->
|
||||
<!-- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> -->
|
||||
<!-- <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得到精确位置 -->
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- 通过网络得到粗略位置 -->
|
||||
@@ -36,6 +49,11 @@
|
||||
<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.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
|
||||
android:name="android.hardware.camera"
|
||||
android:required="true" />
|
||||
@@ -65,21 +83,26 @@
|
||||
<!-- android:name="android.app.lib_name"-->
|
||||
<!-- android:value="" />-->
|
||||
<!-- </activity>-->
|
||||
<activity android:name=".activity.RegardMapActivity" />
|
||||
<activity android:name=".activity.StatementActivity" />
|
||||
<activity android:name=".activity.RegardMapActivity"
|
||||
android:exported="true"/>
|
||||
<activity android:name=".activity.StatementActivity"
|
||||
android:exported="true"/>
|
||||
<activity
|
||||
android:name=".activity.PicturesActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
|
||||
android:launchMode="singleTop" />
|
||||
android:launchMode="singleTop"
|
||||
android:exported="true"/>
|
||||
<activity
|
||||
android:name=".activity.PictureActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
|
||||
android:launchMode="singleTop" />
|
||||
android:launchMode="singleTop"
|
||||
android:exported="true"/>
|
||||
<activity
|
||||
android:name=".activity.PhotographActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|navigation"
|
||||
android:launchMode="singleTop" />
|
||||
android:launchMode="singleTop"
|
||||
android:exported="true"/>
|
||||
|
||||
<meta-data
|
||||
android:name="android.webkit.WebView.EnableSafeBrowsing"
|
||||
@@ -88,7 +111,8 @@
|
||||
<!-- android:value="EWWBZ-2PB62-6JXUL-CEX7G-N7UE6-XRB4V" /> -->
|
||||
<meta-data
|
||||
android:name="TencentMapSDK"
|
||||
android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" /> <!-- 今日头屏幕适配 -->
|
||||
android:value="7UEBZ-TWAYK-5JFJM-A5SJI-FA4U6-3IBMX" />
|
||||
<!-- 今日头屏幕适配 -->
|
||||
<meta-data
|
||||
android:name="design_width_in_dp"
|
||||
android:value="360" />
|
||||
@@ -96,9 +120,15 @@
|
||||
android:name="design_height_in_dp"
|
||||
android:value="640" />
|
||||
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="com.baidu.lbsapi.API_KEY"-->
|
||||
<!-- android:value="tqrlve3Njjz0GEu73BhSjxyyzIhTjCQz" >-->
|
||||
<!-- </meta-data>-->
|
||||
|
||||
<activity
|
||||
android:name=".activity.MainActivity"
|
||||
android:screenOrientation="portrait">
|
||||
android:screenOrientation="portrait"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
@@ -117,7 +147,9 @@
|
||||
android:screenOrientation="portrait" /> <!-- |screenSize -->
|
||||
<activity
|
||||
android:name=".activity.HomeActivity"
|
||||
android:exported="true"
|
||||
android:configChanges="keyboardHidden|orientation|screenSize"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.WebActivity"
|
||||
@@ -133,9 +165,17 @@
|
||||
<activity
|
||||
android:name=".activity.VideoActivity"
|
||||
android:screenOrientation="portrait" /> <!-- 自动拍照界面 -->
|
||||
<!-- 自动捕捉道路任务 -->
|
||||
<activity
|
||||
android:name=".activity.AutoTakePictureActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="landscape" />
|
||||
<!-- 自动捕捉POI录像任务 -->
|
||||
<activity
|
||||
android:name=".activity.AutoTakePicture4PoiActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
<!-- <activity-->
|
||||
<!-- android:name=".activity.AutoTakePicture4PoiVideoActivity"-->
|
||||
<!-- android:screenOrientation="landscape" />-->
|
||||
<activity
|
||||
android:name=".activity.UserActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
@@ -145,13 +185,13 @@
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.NaviCarActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="sensor" />
|
||||
<activity
|
||||
android:name=".activity.NaviRideActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="sensor" />
|
||||
<activity
|
||||
android:name=".activity.NaviWalkActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
android:screenOrientation="sensor" />
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
@@ -202,6 +242,107 @@
|
||||
android:name="com.umeng.message.UmengMessageIntentReceiverService"
|
||||
android:exported="false"
|
||||
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>
|
||||
|
||||
</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,25 +1,13 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import com.elvishew.xlog.LogConfiguration;
|
||||
import com.elvishew.xlog.LogLevel;
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.elvishew.xlog.flattener.ClassicFlattener;
|
||||
import com.elvishew.xlog.printer.AndroidPrinter;
|
||||
import com.elvishew.xlog.printer.ConsolePrinter;
|
||||
import com.elvishew.xlog.printer.Printer;
|
||||
import com.elvishew.xlog.printer.file.FilePrinter;
|
||||
import com.elvishew.xlog.printer.file.backup.BackupStrategy2;
|
||||
import com.elvishew.xlog.printer.file.backup.FileSizeBackupStrategy2;
|
||||
import com.elvishew.xlog.printer.file.backup.NeverBackupStrategy;
|
||||
import com.elvishew.xlog.printer.file.clean.FileLastModifiedCleanStrategy;
|
||||
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator;
|
||||
import com.elvishew.xlog.printer.file.naming.LevelFileNameGenerator;
|
||||
import com.github.lazylibrary.util.ShellUtils;
|
||||
import com.google.gson.Gson;
|
||||
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.navinfo.ocr.OCRManager;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
@@ -30,7 +18,10 @@ import com.navinfo.outdoor.fragment.RecordFragment;
|
||||
import com.navinfo.outdoor.fragment.TreasureFragment;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.service.ForegroundCoreService;
|
||||
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;
|
||||
|
||||
@@ -38,6 +29,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import android.content.Context;
|
||||
@@ -51,11 +43,13 @@ import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.navinfo.outdoor.util.WhiteListHelper;
|
||||
import com.teprinciple.mailsender.Mail;
|
||||
import com.teprinciple.mailsender.MailSender;
|
||||
import com.umeng.message.UmengNotificationClickHandler;
|
||||
@@ -91,6 +85,7 @@ public class HomeActivity extends BaseActivity {
|
||||
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 boolean isBack = false;
|
||||
private WhiteListHelper whiteListHelper;
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
@@ -102,7 +97,6 @@ public class HomeActivity extends BaseActivity {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.activity_home;
|
||||
@@ -111,34 +105,38 @@ public class HomeActivity extends BaseActivity {
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
DialogSettings.init();
|
||||
if (Constant.USHERED != null) {
|
||||
Constant.initRootFolder(Constant.USHERED);
|
||||
// 检测用户是否为虚拟定位
|
||||
boolean result = handler.sendEmptyMessageDelayed(0x101, 1000*60*(int)(10*Math.random()));
|
||||
Log.d("HomeActivity", "作弊检查:"+result);
|
||||
|
||||
LogConfiguration logConfiguration = new LogConfiguration.Builder()
|
||||
// .enableStackTrace(5)
|
||||
.enableBorder()
|
||||
.tag("OutDoor").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);
|
||||
// 注册位置更新的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 {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@@ -152,6 +150,45 @@ public class HomeActivity extends BaseActivity {
|
||||
super.onResume();
|
||||
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() {
|
||||
@@ -195,7 +232,7 @@ public class HomeActivity extends BaseActivity {
|
||||
Log.i("TAGEE", "click dismissNotification: " + msg.getRaw().toString());
|
||||
}
|
||||
};
|
||||
UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
||||
// UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -243,14 +280,14 @@ public class HomeActivity extends BaseActivity {
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else if (tab.getPosition() == 1) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||
obtain.obj = true;
|
||||
obtain.what = Constant.SWITCH_RECORFER_ITEM; // 发送消息给Recorder界面,根据子tab的选项请求数据
|
||||
EventBus.getDefault().post(obtain);
|
||||
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||
obtain1.obj = true;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
// 待提交页面暂时不需要获取,当用户在记录tab下点击已提交后,再去请求 #2023-0216
|
||||
// Message obtain1 = Message.obtain();
|
||||
// obtain1.what = Constant.HAS_SUBMIT_ITEM;
|
||||
// obtain1.obj = true;
|
||||
// EventBus.getDefault().post(obtain1);
|
||||
} else if (tab.getPosition() == 3) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.HOME_MINE;
|
||||
@@ -383,6 +420,7 @@ public class HomeActivity extends BaseActivity {
|
||||
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()
|
||||
) {
|
||||
@@ -405,6 +443,7 @@ public class HomeActivity extends BaseActivity {
|
||||
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")
|
||||
@@ -523,6 +562,14 @@ public class HomeActivity extends BaseActivity {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getCurrentTabSelected() {
|
||||
if (mTab!=null) {
|
||||
return mTab.getSelectedTabPosition();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private String getUid(Context context) {
|
||||
String uid = "";
|
||||
try {
|
||||
@@ -556,5 +603,6 @@ public class HomeActivity extends BaseActivity {
|
||||
PoiDatabase.destroy();
|
||||
// 清空登录信息
|
||||
Constant.clearLoginInfo();
|
||||
getLifecycle().removeObserver(LocationLifeCycle.getInstance());
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,6 @@ import com.navinfo.outdoor.util.APKVersionCodeUtils;
|
||||
import com.navinfo.outdoor.util.Base64;
|
||||
import com.navinfo.outdoor.util.Md5Util;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.umeng.umcrash.UMCrash;
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
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.os.Build;
|
||||
import android.os.CountDownTimer;
|
||||
@@ -19,7 +23,17 @@ import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
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.Permission;
|
||||
@@ -31,6 +45,7 @@ import com.lzy.okgo.model.HttpParams;
|
||||
import com.lzy.okgo.model.Progress;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
import com.kongzue.dialog.util.DialogSettings;
|
||||
import com.navinfo.outdoor.bean.ApkVersionBean;
|
||||
@@ -41,9 +56,7 @@ import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.http.UploadCallBack;
|
||||
import com.navinfo.outdoor.util.APKVersionCodeUtils;
|
||||
import com.navinfo.outdoor.util.Base64;
|
||||
import com.navinfo.outdoor.util.Md5Util;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
|
||||
|
||||
@@ -60,7 +73,6 @@ import java.util.List;
|
||||
* 以及自启动 (获取token 获取用户信息)
|
||||
*/
|
||||
public class MainActivity extends BaseActivity {
|
||||
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
@@ -115,13 +127,13 @@ public class MainActivity extends BaseActivity {
|
||||
// 申请多个权限
|
||||
//.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.REQUEST_INSTALL_PACKAGES)
|
||||
// 位置权限
|
||||
.permission(Permission.ACCESS_FINE_LOCATION)
|
||||
.permission(Permission.ACCESS_MEDIA_LOCATION)
|
||||
// .permission(Permission.ACCESS_MEDIA_LOCATION)
|
||||
//.permission(Permission.ACCESS_BACKGROUND_LOCATION)
|
||||
.permission(Permission.ACCESS_COARSE_LOCATION)
|
||||
//读写权限
|
||||
@@ -130,11 +142,34 @@ public class MainActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onGranted(List<String> permissions, boolean 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) {
|
||||
HttpInterface.initAppPath(Constant.USHERED);
|
||||
Constant.initRootFolder(Constant.USHERED);
|
||||
HttpInterface.initHttpInter(Constant.USHERED);
|
||||
//
|
||||
// 检查版本
|
||||
initCheckVersion();
|
||||
} else {
|
||||
initTime();
|
||||
|
||||
@@ -1,19 +1,30 @@
|
||||
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;
|
||||
@@ -25,12 +36,20 @@ public class NaviCarActivity extends BaseActivity {
|
||||
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, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -41,6 +60,6 @@ public class NaviCarActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.ViewModel;
|
||||
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.tencent.map.navi.TencentNaviManager;
|
||||
|
||||
public class NaviCarViewModel extends ViewModel {
|
||||
private TencentNaviManager naviManager;
|
||||
public void setNaviManager(TencentNaviManager naviManager) {
|
||||
this.naviManager = naviManager;
|
||||
}
|
||||
|
||||
public TencentNaviManager getNaviManager() {
|
||||
return naviManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCleared() {
|
||||
super.onCleared();
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
@@ -11,14 +12,17 @@ import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.car.CarNaviView;
|
||||
import com.tencent.map.navi.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_car;
|
||||
return R.layout.activity_navi_ride;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,12 +31,21 @@ public class NaviRideActivity extends BaseActivity {
|
||||
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().getSerializableExtra("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getSerializableExtra("end");
|
||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
||||
try {
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -43,6 +56,7 @@ public class NaviRideActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
((TencentRideNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(rideNaviView);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import androidx.lifecycle.LifecycleObserver;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
@@ -10,15 +11,18 @@ import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.tencent.map.navi.TencentNaviManager;
|
||||
import com.tencent.map.navi.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_car;
|
||||
return R.layout.activity_navi_walk;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27,12 +31,20 @@ public class NaviWalkActivity extends BaseActivity {
|
||||
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().getSerializableExtra("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getSerializableExtra("end");
|
||||
LatLng startLatlng = (LatLng) getIntent().getExtras().get("start");
|
||||
LatLng endLatlng = (LatLng) getIntent().getExtras().get("end");
|
||||
try {
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviManager, new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
NaviUtils.getInstance().searchRoute(Constant.currentNaviType, naviCarViewModel.getNaviManager(), new NaviPoi(startLatlng.latitude, startLatlng.longitude), new NaviPoi(endLatlng.latitude, endLatlng.longitude));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -43,6 +55,7 @@ public class NaviWalkActivity extends BaseActivity {
|
||||
super.onDestroy();
|
||||
getLifecycle().removeObserver(lifecycleObserver);
|
||||
// 如果当前正在导航,自动停止
|
||||
NaviUtils.getInstance().stopNavi();
|
||||
naviCarViewModel.getNaviManager().removeAllNaviViews();
|
||||
((TencentWalkNaviManager)naviCarViewModel.getNaviManager()).removeTencentNaviListener(walkNaviView);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.otaliastudios.cameraview.CameraException;
|
||||
@@ -476,10 +477,10 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
||||
tencentMap.animateCamera(cameraUpdateOut);
|
||||
break;
|
||||
case R.id.iv_location://定位:
|
||||
if (Constant.currentLocation != null) {
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
|
||||
new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), //中心点坐标,地图目标经纬度
|
||||
tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
@@ -680,21 +681,21 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMessageMainThread(Message msg) {
|
||||
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
|
||||
if (tencentMap != null && !isMapSlide) {
|
||||
TencentLocation tencentLocation = (TencentLocation) msg.obj;
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
|
||||
tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||
0, //目标倾斜角
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma);
|
||||
}
|
||||
}
|
||||
}
|
||||
// @Subscribe(threadMode = ThreadMode.MAIN)
|
||||
// public void onEventMessageMainThread(Message msg) {
|
||||
// if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
|
||||
// if (tencentMap != null && !isMapSlide) {
|
||||
// TencentLocation tencentLocation = (TencentLocation) msg.obj;
|
||||
// CameraUpdate cameraSigma =
|
||||
// CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
// new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
|
||||
// tencentMap.getCameraPosition().zoom, //目标缩放级别
|
||||
// 0, //目标倾斜角
|
||||
// 0)); //目标旋转角 0~360° (正北方为0)
|
||||
// tencentMap.animateCamera(cameraSigma);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 记录视频拍摄的时间及经纬度
|
||||
@@ -722,17 +723,17 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene
|
||||
sb.append(",");
|
||||
sb.append(currentVideoTime);// 记录视频时间
|
||||
sb.append(",");
|
||||
sb.append(Constant.currentLocation.getLatitude());
|
||||
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLatitude());
|
||||
sb.append(",");
|
||||
sb.append(Constant.currentLocation.getLongitude());
|
||||
sb.append(LocationLifeCycle.getInstance().getMainLocation().getLongitude());
|
||||
sb.append(",");
|
||||
if (Constant.currentLocation.getBearing() != 0) {
|
||||
sb.append(Constant.currentLocation.getBearing());
|
||||
if (LocationLifeCycle.getInstance().getTencentLocation().getBearing() != 0) {
|
||||
sb.append(LocationLifeCycle.getInstance().getMainLocation().getBearing());
|
||||
} else {
|
||||
sb.append(Constant.currentLocation.getDirection());
|
||||
sb.append(LocationLifeCycle.getInstance().getTencentLocation().getDirection());
|
||||
}
|
||||
sb.append("\r\n");
|
||||
LatLng latLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
|
||||
LatLng latLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude());
|
||||
BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.circle);
|
||||
Marker marker = tencentMap.addMarker(new MarkerOptions(latLng)
|
||||
.icon(pileDescriptor)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,241 @@
|
||||
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,6 +8,7 @@ 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;
|
||||
@@ -22,6 +23,7 @@ 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;
|
||||
@@ -38,6 +40,18 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
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);
|
||||
@@ -65,6 +79,26 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
}).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) {
|
||||
@@ -119,20 +153,15 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
poiEntity.setChecked(!poiEntity.isChecked());
|
||||
}
|
||||
});
|
||||
if (allRoad.get(position).isChecked()) {
|
||||
if (poiEntity.getWork_type() == 0) {
|
||||
holder.tvText.setText("待提交");
|
||||
} else if (poiEntity.getWork_type() == 1) {
|
||||
holder.tvText.setText("提交中");
|
||||
allRoad.get(position).setChecked(true);
|
||||
}
|
||||
} else {
|
||||
if (poiEntity.getWork_type() == 1) {
|
||||
holder.tvText.setText("提交中");
|
||||
allRoad.get(position).setChecked(true);
|
||||
} else {
|
||||
holder.tvText.setText("待提交");
|
||||
}
|
||||
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
|
||||
@@ -142,6 +171,23 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
}
|
||||
}
|
||||
});
|
||||
// 显示进度
|
||||
if (poiEntity.getWork_type()!=0&&poiEntity.getUploadMax()>0&&poiEntity.getUploadProgress()!=poiEntity.getUploadMax()) {
|
||||
holder.layerProgress.setVisibility(View.VISIBLE);
|
||||
holder.pbUpload.setMax(poiEntity.getUploadMax());
|
||||
holder.pbUpload.setProgress(poiEntity.getUploadProgress());
|
||||
holder.tvUploadProgress.setText(poiEntity.getUploadProgress()+"/"+poiEntity.getUploadMax());
|
||||
} else {
|
||||
holder.layerProgress.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
// 显示上传状态
|
||||
if (poiEntity.getUploadResult()!=null&&!poiEntity.getUploadResult().trim().equals("")) {
|
||||
holder.tvUploadResult.setVisibility(View.VISIBLE);
|
||||
holder.tvUploadResult.setText(poiEntity.getUploadResult());
|
||||
holder.layerProgress.setVisibility(View.GONE); // 上传结果存在,不需要显示进度条
|
||||
} else {
|
||||
holder.tvUploadResult.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,6 +198,9 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
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);
|
||||
@@ -159,6 +208,10 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.umeng.umcrash.UMCrash;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,8 @@ public class Constant {
|
||||
public static String LOG_FOLDER = ROOT_FOLDER + "/log";
|
||||
public static String GPS_LOG_FOLDER = ROOT_FOLDER + "/gps_log";
|
||||
public static int TelLength = 0;
|
||||
public static String PUSH_TOKEN = null;
|
||||
public static Map<String, Boolean> mockGPSMap; // 是否模拟定位,如果模拟定位,该map不为空
|
||||
|
||||
public static void initRootFolder(String userId) {
|
||||
BASE_FOLDER = ROOT_FOLDER + "/" + userId;
|
||||
@@ -149,6 +152,15 @@ public class Constant {
|
||||
public static final int EVENT_MESSAGE = 55;//提示消息
|
||||
public static final int CAPACITY_EVALUATION=59;//能力测试的返回
|
||||
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 int NUMBER = 200; //任务个数
|
||||
public static int LIMIT_TYPE = -1; //权限类型,普通任务-0,专属任务-1
|
||||
@@ -159,7 +171,6 @@ public class Constant {
|
||||
/*
|
||||
用户当前位置
|
||||
*/
|
||||
public static TencentLocation currentLocation;
|
||||
public static LatLng markerLacing;
|
||||
public static JobSearchBean jobSearchBean;//数
|
||||
public static MapView treasureMap;
|
||||
@@ -169,10 +180,12 @@ public class Constant {
|
||||
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_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_TYPE = "type";//poiEntity 的type
|
||||
public static final String INTENT_GEO_WKT = "geowkt";//poiEntity 的geowkt
|
||||
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 TencentMap.OnMarkerClickListener markerClickListener = null;
|
||||
|
||||
@@ -232,14 +245,13 @@ public class Constant {
|
||||
public static String getRssiDesStr(int rssi) {
|
||||
if (rssi == 0) {
|
||||
return "无信号";
|
||||
} else if (rssi == 1) {
|
||||
} else if (rssi <= 3) {
|
||||
return "弱";
|
||||
} else if (rssi == 2) {
|
||||
} else if (rssi <= 8) {
|
||||
return "中";
|
||||
} else if (rssi == 3) {
|
||||
} else {
|
||||
return "强";
|
||||
}
|
||||
return "无信号"; // 默认为无信号
|
||||
}
|
||||
|
||||
public static Set<String> submitIdSet = new HashSet<>();
|
||||
@@ -275,4 +287,10 @@ public class Constant {
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
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,13 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.StrictMode;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.elvishew.xlog.LogLevel;
|
||||
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.cache.CacheEntity;
|
||||
import com.lzy.okgo.cache.CacheMode;
|
||||
@@ -21,23 +21,14 @@ import com.lzy.okgo.cookie.CookieJarImpl;
|
||||
import com.lzy.okgo.cookie.store.DBCookieStore;
|
||||
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
|
||||
import com.lzy.okgo.model.HttpHeaders;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.HomeActivity;
|
||||
import com.navinfo.outdoor.activity.WebActivity;
|
||||
import com.navinfo.outdoor.bean.NotificationBean;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.util.TalentLocationUtils;
|
||||
import com.navinfo.outdoor.util.CrashHandler;
|
||||
import com.tencent.android.tpush.XGIOperateCallback;
|
||||
import com.tencent.android.tpush.XGPushConfig;
|
||||
import com.tencent.android.tpush.XGPushManager;
|
||||
import com.tencent.map.navi.TencentNavi;
|
||||
import com.tencent.navi.surport.utils.DeviceUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMapInitializer;
|
||||
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.UMCrashCallback;
|
||||
|
||||
@@ -53,7 +44,7 @@ import okhttp3.OkHttpClient;
|
||||
public class UserApplication extends Application {
|
||||
public static UserApplication userApplication;
|
||||
public static ExecutorService fixedThreadPool;
|
||||
public static PushAgent instance;
|
||||
// public static PushAgent instance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
@@ -61,7 +52,6 @@ public class UserApplication extends Application {
|
||||
userApplication = this;
|
||||
initUMSDK();
|
||||
initOkGo();
|
||||
TalentLocationUtils.getInstance(this).startLocation(this);
|
||||
//创建一个线程池
|
||||
fixedThreadPool = Executors.newSingleThreadExecutor(); // 使用单线程线程池
|
||||
|
||||
@@ -74,6 +64,27 @@ public class UserApplication extends Application {
|
||||
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() {
|
||||
@@ -91,49 +102,49 @@ public class UserApplication extends Application {
|
||||
return "注册友盟异常查看功能";
|
||||
}
|
||||
});
|
||||
instance = PushAgent.getInstance(this);
|
||||
instance.register(new IUmengRegisterCallback() {
|
||||
@Override
|
||||
public void onSuccess(String s) {
|
||||
//注册成功会返回deviceToken deviceToken是推送消息的唯一标志
|
||||
Constant.DEVICE_TOKEN = s;
|
||||
Log.i("TAGEE", "Success 注册成功:deviceToken:--> " + Constant.DEVICE_TOKEN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String s, String s1) {
|
||||
Log.e("TAGEE", "Failure 注册失败:--> " + "code:" + s + ", desc:" + s1);
|
||||
}
|
||||
});
|
||||
instance.onAppStart();
|
||||
UmengMessageHandler msgHandler = new UmengMessageHandler() {
|
||||
//处理通知栏消息
|
||||
@Override
|
||||
public void dealWithNotificationMessage(Context context, UMessage msg) {
|
||||
super.dealWithNotificationMessage(context, msg);
|
||||
Log.i("TAGEE", "dealWithNotificationMessage:" + msg.getRaw().toString());
|
||||
Constant.NOTIFICATION=msg.getRaw().toString();
|
||||
}
|
||||
|
||||
//自定义通知样式,此方法可以修改通知样式等
|
||||
@Override
|
||||
public Notification getNotification(Context context, UMessage msg) {
|
||||
Log.i("TAGEE", "getNotification: "+msg.getRaw().toString());
|
||||
return super.getNotification(context, msg);
|
||||
}
|
||||
|
||||
//处理透传消息
|
||||
@Override
|
||||
public void dealWithCustomMessage(Context context, UMessage msg) {
|
||||
super.dealWithCustomMessage(context, msg);
|
||||
Log.i("TAGEE", "dealWithCustomMessage:" + msg.getRaw().toString());
|
||||
}
|
||||
};
|
||||
instance.setMessageHandler(msgHandler);
|
||||
// instance = PushAgent.getInstance(this);
|
||||
// instance.register(new IUmengRegisterCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(String s) {
|
||||
// //注册成功会返回deviceToken deviceToken是推送消息的唯一标志
|
||||
// Constant.DEVICE_TOKEN = s;
|
||||
// Log.i("TAGEE", "Success 注册成功:deviceToken:--> " + Constant.DEVICE_TOKEN);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onFailure(String s, String s1) {
|
||||
// Log.e("TAGEE", "Failure 注册失败:--> " + "code:" + s + ", desc:" + s1);
|
||||
// }
|
||||
// });
|
||||
// instance.onAppStart();
|
||||
// UmengMessageHandler msgHandler = new UmengMessageHandler() {
|
||||
// //处理通知栏消息
|
||||
// @Override
|
||||
// public void dealWithNotificationMessage(Context context, UMessage msg) {
|
||||
// super.dealWithNotificationMessage(context, msg);
|
||||
// Log.i("TAGEE", "dealWithNotificationMessage:" + msg.getRaw().toString());
|
||||
// Constant.NOTIFICATION=msg.getRaw().toString();
|
||||
// }
|
||||
//
|
||||
// //自定义通知样式,此方法可以修改通知样式等
|
||||
// @Override
|
||||
// public Notification getNotification(Context context, UMessage msg) {
|
||||
// Log.i("TAGEE", "getNotification: "+msg.getRaw().toString());
|
||||
// return super.getNotification(context, msg);
|
||||
// }
|
||||
//
|
||||
// //处理透传消息
|
||||
// @Override
|
||||
// public void dealWithCustomMessage(Context context, UMessage msg) {
|
||||
// super.dealWithCustomMessage(context, msg);
|
||||
// Log.i("TAGEE", "dealWithCustomMessage:" + msg.getRaw().toString());
|
||||
// }
|
||||
// };
|
||||
// instance.setMessageHandler(msgHandler);
|
||||
//App处于前台时不显示通知
|
||||
//instance.setNotificationOnForeground(false);
|
||||
//设置显示通知的数量
|
||||
instance.setDisplayNotificationNumber(0);
|
||||
// instance.setDisplayNotificationNumber(0);
|
||||
//服务端控制声音
|
||||
//instance.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SERVER);
|
||||
//通知免打扰时段
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
package com.navinfo.outdoor.base;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.provider.Settings;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -17,10 +23,14 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
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.navinfo.outdoor.R;
|
||||
@@ -30,7 +40,11 @@ import com.gyf.immersionbar.ImmersionBar;
|
||||
import com.navinfo.outdoor.util.NetWorkUtils;
|
||||
import com.umeng.message.PushAgent;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
@@ -54,6 +68,10 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
initView();
|
||||
initData();
|
||||
initListener();
|
||||
requestPermission();
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCustomDensity(Application application, Activity activity) {
|
||||
@@ -143,6 +161,9 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
super.onDestroy();
|
||||
dismissLoadingDialog();
|
||||
Collector.removeActivity(this);
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,4 +178,92 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(sticky = true)
|
||||
public void onEventMainThrean(Map<String, String> data) {
|
||||
if (data.get("code") == "101") {
|
||||
// 返回开启GPS导航设置界面
|
||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
startActivityForResult(intent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static final int REQUEST_PERMISSION = 1;
|
||||
|
||||
protected boolean allPermissionsGranted;
|
||||
|
||||
|
||||
private void requestPermission() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
String[] permissions = new String[]{
|
||||
Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
};
|
||||
allPermissionsGranted = true;
|
||||
for (String perm : permissions) {
|
||||
if ((PermissionChecker.checkSelfPermission(this, perm) != PermissionChecker.PERMISSION_GRANTED)) {
|
||||
allPermissionsGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allPermissionsGranted) {
|
||||
ActivityCompat.requestPermissions(BaseActivity.this, permissions, REQUEST_PERMISSION);
|
||||
} else {
|
||||
requestAllFilesAccess();
|
||||
}
|
||||
} else {
|
||||
allPermissionsGranted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
|
||||
@NonNull int[] grantResults) {
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
if (requestCode == REQUEST_PERMISSION) {
|
||||
allPermissionsGranted = true;
|
||||
for (int grantRes : grantResults) {
|
||||
if (grantRes != PackageManager.PERMISSION_GRANTED) {
|
||||
allPermissionsGranted = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allPermissionsGranted) {
|
||||
requestAllFilesAccess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Android 11 跳转到设置获取SD卡根目录写入权限
|
||||
*/
|
||||
private void requestAllFilesAccess() {
|
||||
if (!Consts.AUTH_REQUIRE_SDCARD) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !Environment.isExternalStorageManager()) {
|
||||
allPermissionsGranted = false;
|
||||
|
||||
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(BaseActivity.this,
|
||||
R.style.Theme_AppCompat_Light_Dialog_Alert);
|
||||
alertBuilder.setMessage("需授权访问SD卡文件");
|
||||
alertBuilder.setCancelable(false);
|
||||
alertBuilder.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Intent intent = new Intent(Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
alertBuilder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
});
|
||||
alertBuilder.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import androidx.annotation.NonNull;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MapManager;
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||
import com.tencent.tencentmap.mapsdk.maps.CameraUpdate;
|
||||
@@ -31,14 +32,15 @@ public abstract class BaseDrawerFragment extends BaseFragment {
|
||||
protected PoiEntity showPoiEntity;
|
||||
public SlidingUpPanelLayout slidingPaneLayout;
|
||||
public TencentMap tencentMap;
|
||||
protected int matchTrack;
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
tencentMap = MapManager.getInstance().getTencentMap();
|
||||
super.initData();
|
||||
if (Constant.currentLocation!=null){
|
||||
int mockGps = Constant.currentLocation.isMockGps();
|
||||
int gpsRssi = Constant.currentLocation.getGPSRssi();//无信号,信号弱,信号中,信号强
|
||||
if (LocationLifeCycle.getInstance().getTencentLocation()!=null){
|
||||
int mockGps = LocationLifeCycle.getInstance().getTencentLocation().isMockGps();
|
||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();//无信号,信号弱,信号中,信号强
|
||||
//1为是,0为否,-1为无法判断
|
||||
if (mockGps == 1) {
|
||||
onBackPressed();
|
||||
@@ -138,6 +140,7 @@ public abstract class BaseDrawerFragment extends BaseFragment {
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("poiEntity", null);
|
||||
edit.putString("chargingPileEntity", null);
|
||||
edit.putInt("roadVideoType", -1);
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.commit();
|
||||
}
|
||||
@@ -173,4 +176,14 @@ public abstract class BaseDrawerFragment extends BaseFragment {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏抽屉界面
|
||||
* */
|
||||
public void changeSlidingLayout(int isVisible, SlidingUpPanelLayout.PanelState panelState) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constant.EVENT_WHAT_CHANGE_SLIDING_STATE;
|
||||
msg.arg1 = isVisible;
|
||||
msg.obj = panelState;
|
||||
EventBus.getDefault().post(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,8 @@ import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import 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.http.HttpInterface;
|
||||
import com.navinfo.outdoor.util.BackHandlerHelper;
|
||||
import com.navinfo.outdoor.util.FragmentBackHandler;
|
||||
import com.navinfo.outdoor.util.NetWorkUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -82,7 +75,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
|
||||
}
|
||||
|
||||
protected <T extends View> T findViewById(@IdRes int id) {
|
||||
return Objects.requireNonNull(getView()).findViewById(id);
|
||||
return requireView().findViewById(id);
|
||||
}
|
||||
|
||||
protected void debounce(View view) {
|
||||
@@ -99,7 +92,7 @@ public abstract class BaseFragment extends Fragment implements FragmentBackHandl
|
||||
if (alertDialog != null) {
|
||||
alertDialog.dismiss();
|
||||
}
|
||||
alertDialog = new AlertDialog.Builder(Objects.requireNonNull(getActivity())).create();
|
||||
alertDialog = new AlertDialog.Builder(requireActivity()).create();
|
||||
Objects.requireNonNull(alertDialog.getWindow()).setBackgroundDrawable(new ColorDrawable());
|
||||
alertDialog.setCancelable(false);
|
||||
alertDialog.setOnKeyListener((dialog, keyCode, event) -> {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.navinfo.outdoor.base
|
||||
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Bundle
|
||||
import android.provider.Settings
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.github.lazylibrary.util.StringUtils
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.navinfo.outdoor.R
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
|
||||
open class BaseViewBindingActivity: AppCompatActivity() {
|
||||
private var alertDialog: AlertDialog? = null
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
// setScreenRoate(true);
|
||||
//初始化,默认透明状态栏和黑色导航栏
|
||||
ImmersionBar.with(this).init()
|
||||
Collector.addActivity(this)
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun showLoadingDialog() {
|
||||
showLoadingDialog(null)
|
||||
}
|
||||
|
||||
fun showLoadingDialog(msg: String?) {
|
||||
alertDialog?.dismiss()
|
||||
alertDialog = AlertDialog.Builder(this).create()
|
||||
alertDialog!!.window?.setBackgroundDrawable(ColorDrawable())
|
||||
alertDialog!!.setCancelable(false)
|
||||
alertDialog!!.setOnKeyListener(DialogInterface.OnKeyListener { dialog: DialogInterface?, keyCode: Int, event: KeyEvent? -> keyCode == KeyEvent.KEYCODE_SEARCH || keyCode == KeyEvent.KEYCODE_BACK })
|
||||
//loading样式
|
||||
val view: View = LayoutInflater.from(this).inflate(R.layout.loading, null)
|
||||
val tv = view.findViewById<TextView>(R.id.progressBar_tx)
|
||||
if (!StringUtils.isBlank(msg)) {
|
||||
tv.text = msg
|
||||
}
|
||||
alertDialog!!.setView(view)
|
||||
alertDialog!!.setCanceledOnTouchOutside(false)
|
||||
alertDialog!!.show()
|
||||
}
|
||||
|
||||
fun setLoadingDialogText(s: String?) {
|
||||
//给loading 添加文字
|
||||
val view = alertDialog!!.findViewById<TextView>(R.id.progressBar_tx)
|
||||
view!!.text = s
|
||||
}
|
||||
|
||||
fun dismissLoadingDialog() {
|
||||
if (null != alertDialog && alertDialog!!.isShowing()) {
|
||||
alertDialog!!.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
dismissLoadingDialog()
|
||||
Collector.removeActivity(this)
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(sticky = true)
|
||||
open fun onEventMainThrean(data: Map<String?, String>) {
|
||||
if (data["code"] === "101") {
|
||||
// 返回开启GPS导航设置界面
|
||||
val intent = Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)
|
||||
startActivityForResult(intent, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,6 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
builder.writeTimeout(time, TimeUnit.SECONDS);
|
||||
//全局的连接超时时间
|
||||
builder.connectTimeout(time, TimeUnit.SECONDS);
|
||||
builder.callTimeout(time, TimeUnit.SECONDS);
|
||||
OkGo.getInstance().init(UserApplication.getUserApplication()).setOkHttpClient(builder.build())
|
||||
//全局统一缓存模式,默认不使用缓存,可以不传
|
||||
.setCacheMode(CacheMode.NO_CACHE)
|
||||
|
||||
@@ -115,6 +115,8 @@ public class JobSearchBean implements Serializable {
|
||||
private String memo;
|
||||
private String telephone;
|
||||
|
||||
private int publish; // 是否已发布,如果是未发布的数据,则用半透明形式展示
|
||||
|
||||
public int getCanReceived() {
|
||||
return canReceived;
|
||||
}
|
||||
@@ -210,6 +212,14 @@ public class JobSearchBean implements Serializable {
|
||||
public void setTelephone(String telephone) {
|
||||
this.telephone = telephone;
|
||||
}
|
||||
|
||||
public int getPublish() {
|
||||
return publish;
|
||||
}
|
||||
|
||||
public void setPublish(int publish) {
|
||||
this.publish = publish;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -52,6 +52,8 @@ public class PolygonTaskBean {
|
||||
private String name;
|
||||
private int isExclusive;
|
||||
|
||||
private String unReceivedTime; // 任务领取后自动释放的时间
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -91,5 +93,17 @@ public class PolygonTaskBean {
|
||||
public void setIsExclusive(int 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,7 +43,17 @@ public class ReceivedBean {
|
||||
private String name;
|
||||
private Integer isExclusive;
|
||||
private String memo;
|
||||
|
||||
public String getUnReceivedTime() {
|
||||
return unReceivedTime;
|
||||
}
|
||||
|
||||
public void setUnReceivedTime(String unReceivedTime) {
|
||||
this.unReceivedTime = unReceivedTime;
|
||||
}
|
||||
|
||||
private String endDate;
|
||||
private String unReceivedTime;
|
||||
|
||||
public String getMemo() {
|
||||
return memo;
|
||||
|
||||
@@ -58,6 +58,8 @@ public class ReceivedPoiBean {
|
||||
private String endDate;
|
||||
private String telephone;
|
||||
|
||||
private String unReceivedTime;
|
||||
|
||||
public String getTelephone() {
|
||||
return telephone;
|
||||
}
|
||||
@@ -129,5 +131,13 @@ public class ReceivedPoiBean {
|
||||
public void setIsExclusive(int isExclusive) {
|
||||
this.isExclusive = isExclusive;
|
||||
}
|
||||
|
||||
public String getUnReceivedTime() {
|
||||
return unReceivedTime;
|
||||
}
|
||||
|
||||
public void setUnReceivedTime(String unReceivedTime) {
|
||||
this.unReceivedTime = unReceivedTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -21,7 +22,7 @@ import java.util.List;
|
||||
* */
|
||||
public class RoadMatchEntity implements Serializable {
|
||||
private int id; // 唯一id
|
||||
private JobSearchBean.BodyBean.ListBean dataDetail; // 具体的内容信息
|
||||
private PoiEntity dataDetail; // 具体的内容信息
|
||||
private double angle=0; // 起点匹配方向
|
||||
private double length=0; //geometry的长度
|
||||
private String geometry; // 数据的geometry,此处应该为lineString
|
||||
@@ -46,12 +47,12 @@ public class RoadMatchEntity implements Serializable {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public JobSearchBean.BodyBean.ListBean getDataDetail() {
|
||||
public PoiEntity getDataDetail() {
|
||||
return dataDetail;
|
||||
}
|
||||
|
||||
public void setDataDetail(JobSearchBean.BodyBean.ListBean dataDetail) {
|
||||
this.dataDetail = dataDetail;
|
||||
public void setDataDetail(PoiEntity poiEntity) {
|
||||
this.dataDetail = poiEntity;
|
||||
}
|
||||
|
||||
public double getAngle() {
|
||||
|
||||
@@ -56,6 +56,15 @@ public class TaskByNetBean {
|
||||
private int isExclusive;
|
||||
private String memo;
|
||||
private String endDate;
|
||||
private String unReceivedTime;
|
||||
|
||||
public String getUnReceivedTime() {
|
||||
return unReceivedTime;
|
||||
}
|
||||
|
||||
public void setUnReceivedTime(String unReceivedTime) {
|
||||
this.unReceivedTime = unReceivedTime;
|
||||
}
|
||||
|
||||
public String getMemo() {
|
||||
return memo;
|
||||
|
||||
@@ -3,16 +3,19 @@ package com.navinfo.outdoor.fragment;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
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.activity.RegardMapActivity;
|
||||
import com.navinfo.outdoor.activity.WebActivity;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -20,7 +23,9 @@ import java.util.Objects;
|
||||
* 我的-关于页面的fragment
|
||||
*/
|
||||
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) {
|
||||
AboutFragment fragment = new AboutFragment();
|
||||
fragment.setArguments(bundle);
|
||||
@@ -46,13 +51,103 @@ public class AboutFragment extends BaseFragment implements View.OnClickListener
|
||||
RelativeLayout rlPrivilege = findViewById(R.id.rl_privilege);
|
||||
ImageView ivAboutFinish = findViewById(R.id.iv_about_finish);
|
||||
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
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.iv_about_finish:
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
requireActivity().finish();
|
||||
break;
|
||||
case R.id.rl_about:
|
||||
Intent regardIntent = new Intent(getActivity(), RegardMapActivity.class);
|
||||
|
||||
@@ -0,0 +1,954 @@
|
||||
package com.navinfo.outdoor.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.StringUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
|
||||
import com.kongzue.dialog.util.BaseDialog;
|
||||
import com.kongzue.dialog.util.DialogSettings;
|
||||
import com.kongzue.dialog.v3.MessageDialog;
|
||||
import com.kongzue.dialog.v3.WaitDialog;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.PicturesActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.bean.PoiVideoBean;
|
||||
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.ui.view.SpinnerUtils;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
import com.navinfo.outdoor.util.DataSaveUtils;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PoiSaveUtils;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 寻宝-上报弹窗-区域设施
|
||||
*/
|
||||
public class AreaHubFragment extends BaseDrawerFragment implements View.OnClickListener {
|
||||
private EditText etDesc;
|
||||
private Spinner spnRoadName;
|
||||
private ImageView ivPoiVideoPicture;
|
||||
private Button btnRoadSave;
|
||||
private File fileZip, logFile;
|
||||
private FrameLayout fmPoiVideoPic;
|
||||
private LatLng latLng;
|
||||
private Marker markerPoiVideo;
|
||||
private TextView tvCombo, tvShort;
|
||||
private StringBuilder poiVideoBuilder;
|
||||
private LatLng rearLatLng;
|
||||
private boolean booleanExtra = true;
|
||||
|
||||
public static AreaHubFragment newInstance(Bundle bundle) {
|
||||
AreaHubFragment fragment = new AreaHubFragment();
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.traffic_hub_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
View header = mView.findViewById(R.id.traffic_hub_header);
|
||||
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
initBack();
|
||||
}
|
||||
});
|
||||
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), FragmentManagement.class);
|
||||
intent.putExtra("tag", 8);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
moveLatlng(latLng, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
initBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initBack() {
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskStatus() == 5) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
|
||||
filePath.delete();
|
||||
}
|
||||
}
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
isSliding = arguments.getBoolean("isSliding", true);
|
||||
}
|
||||
if (isSliding) {
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.TREASURE_FRAGMENT;
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
isSliding = arguments.getBoolean("isSliding", true);
|
||||
}
|
||||
if (isSliding) {
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.TREASURE_FRAGMENT;
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
|
||||
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
|
||||
if (slidingPaneLayout != null) {
|
||||
slidingPaneLayout.setScrollableView(nestedScrollView);
|
||||
}
|
||||
spnRoadName = findViewById(R.id.spn_poi_video_name);
|
||||
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
|
||||
etDesc = findViewById(R.id.et_desc);
|
||||
//点击拍照
|
||||
tvShort = findViewById(R.id.tv_short);
|
||||
tvShort.setOnClickListener(this);
|
||||
//自动连拍
|
||||
tvCombo = findViewById(R.id.tv_combo);
|
||||
tvCombo.setOnClickListener(this);
|
||||
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
|
||||
fmPoiVideoPic.setOnClickListener(this);
|
||||
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
ivPoiVideoPicture.setImageDrawable(null);
|
||||
fmPoiVideoPic.setTag(null);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
btnRoadSave = findViewById(R.id.btn_poi_video_save);
|
||||
btnRoadSave.setOnClickListener(this);
|
||||
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
|
||||
btnPoiVideoUpload.setOnClickListener(this);
|
||||
//添加数据
|
||||
initShowPoi();
|
||||
((TextView)findViewById(R.id.tv1)).setText("区域设施");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
|
||||
String pictures_time = sharedPreferences.getString("pictures_time", null);
|
||||
if (pictures_time == null) {
|
||||
sharedEdit.putString("pictures_time", newFormat);
|
||||
sharedEdit.apply();
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
|
||||
} else {
|
||||
if (pictures_time.equals(newFormat)) {
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
|
||||
} else {
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
|
||||
}
|
||||
}
|
||||
poiVideoBuilder = new StringBuilder();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
|
||||
if (Constant.USHERED != null) {
|
||||
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
private void initShowPoi() {
|
||||
// 添加信息:
|
||||
assert getArguments() != null;
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
SpinnerUtils spinnerUtils = new SpinnerUtils();
|
||||
String[] items = {"园区外围(含门)", "园区引导图", "园区底商"};
|
||||
if (StringUtils.isEmpty(name)) {// 如果从数据获取的名称为空,则设置name显示为默认的第一个选项
|
||||
name = items[0];
|
||||
}
|
||||
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
spnRoadName.setTag(items[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
}, name, items);
|
||||
String geoWkt = showPoiEntity.getGeoWkt();
|
||||
if (geoWkt != null) {
|
||||
String geo = Geohash.getInstance().decode(geoWkt);
|
||||
Geometry geometry = GeometryTools.createGeometry(geo);
|
||||
switch (geometry.getGeometryType()) {
|
||||
case "Point": //点
|
||||
latLng = GeometryTools.createLatLng(geo);
|
||||
break;
|
||||
case "LineString": //线
|
||||
case "Polygon": //面
|
||||
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
|
||||
assert latLineString != null;
|
||||
latLng = latLineString.get(0);//起點
|
||||
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
|
||||
break;
|
||||
}
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
} else {
|
||||
String detail = showPoiEntity.getDetail();
|
||||
if (detail != null) {
|
||||
String geo = Geohash.getInstance().decode(detail);
|
||||
Geometry geometry = GeometryTools.createGeometry(geo);
|
||||
switch (geometry.getGeometryType()) {
|
||||
case "Point": //点
|
||||
latLng = GeometryTools.createLatLng(geo);
|
||||
break;
|
||||
case "LineString": //线
|
||||
case "Polygon": //面
|
||||
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
|
||||
assert latLineString != null;
|
||||
latLng = latLineString.get(0);
|
||||
break;
|
||||
}
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
} else {
|
||||
String x = showPoiEntity.getX();
|
||||
String y = showPoiEntity.getY();
|
||||
if (x != null && y != null) {
|
||||
latLng = new LatLng();
|
||||
latLng.setLongitude(Double.parseDouble(x));
|
||||
latLng.setLatitude(Double.parseDouble(y));
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
String memo = showPoiEntity.getMemo();//任务描述
|
||||
if (memo != null && !memo.equals("")) {
|
||||
etDesc.setText(memo);
|
||||
}
|
||||
showPoiEntity.setType(12);
|
||||
String photoList = showPoiEntity.getPhoto();
|
||||
if (!StringUtils.isEmpty(photoList)) {
|
||||
boolean isImageLoad = false;
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
|
||||
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
if (showPoiEntity.getTaskStatus() == 3) {
|
||||
disables();//禁用所有可操作的控件
|
||||
}
|
||||
// 如果是推送的POI录像,不允许修改名称
|
||||
if (showPoiEntity.getTaskId()>0) {
|
||||
spnRoadName.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disables() {
|
||||
spnRoadName.setEnabled(false);
|
||||
ivPoiVideoPicture.setEnabled(false);
|
||||
tvShort.setEnabled(false);
|
||||
tvCombo.setEnabled(false);
|
||||
etDesc.setEnabled(false);
|
||||
btnRoadSave.setEnabled(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.PICTURE_VIDEO_WORD) {
|
||||
if ((boolean) data.obj) {
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID.size() == 1) {
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
ivPoiVideoPicture.setImageDrawable(null);
|
||||
fmPoiVideoPic.setTag(null);
|
||||
} else {
|
||||
boolean isImageLoad = false;
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
File videoFile = fileListByUUID.get(i);
|
||||
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
|
||||
if (videoFile.exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.fm_poi_video_picture:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID.size() > 1) {
|
||||
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
|
||||
photoAlbumIntent.putExtra("tag", 36);
|
||||
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
|
||||
startActivity(photoAlbumIntent);
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "请拍摄");
|
||||
}
|
||||
break;
|
||||
case R.id.btn_poi_video_save:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
|
||||
initPoiSaveLocal(false);
|
||||
break;
|
||||
case R.id.tv_short://点击拍摄
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
|
||||
double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
||||
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
|
||||
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
|
||||
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
|
||||
if (matchTrack == 0) {
|
||||
if (geometry > rearGeometry) {//用戶在终点开始作业
|
||||
if (rearGeometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent intents = new Intent(getActivity(), PicturesActivity.class);
|
||||
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
|
||||
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRssi == 0) {
|
||||
intents.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
intents.putExtra(Constant.INTENT_BOOLEAN, true);
|
||||
}
|
||||
startActivityForResult(intents, 0x101);
|
||||
break;
|
||||
case R.id.tv_combo://自动连拍:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
|
||||
LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
|
||||
double geom = GeometryTools.distanceToDouble(startLng, latLng);
|
||||
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
|
||||
if (geom > rearGeom) {//用戶在终点开始作业
|
||||
if (rearGeom > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geom > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Intent intent = new Intent(getActivity(), PicturesActivity.class);
|
||||
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
|
||||
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRss == 0) {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, true);
|
||||
}
|
||||
startActivityForResult(intent, 0x102);
|
||||
break;
|
||||
case R.id.btn_poi_video_upload:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
|
||||
initPoiSaveLocal(true);
|
||||
} else {
|
||||
poiVideoUpload(poiEntity);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void initPoiSaveLocal(boolean isLocal) {
|
||||
if (spnRoadName.getTag() == null) {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称,无法保存!");
|
||||
return;
|
||||
}
|
||||
XXPermissions.with(getContext())
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
.request(new OnPermissionCallback() {
|
||||
@Override
|
||||
public void onGranted(List<String> permissions, boolean all) {
|
||||
if (all) {
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
|
||||
Toast.makeText(getActivity(), "POI录像任务必须拍照!", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
|
||||
if (poiCheckResult.getCode() == 1) {
|
||||
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
|
||||
return;
|
||||
}
|
||||
poiEntity.setTaskStatus(2);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isLocal) {
|
||||
poiVideoSave(poiEntity);
|
||||
} else {
|
||||
poiVideoSaveNet(poiEntity);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied(List<String> permissions, boolean never) {
|
||||
if (never) {
|
||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void poiVideoSaveNet(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(HttpInterface.INSIDE_API_LIST)
|
||||
.cls(PoiVideoBean.class)
|
||||
.params(httpParams)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
if (getActivity() != null) {
|
||||
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
|
||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
|
||||
WaitDialog.dismiss(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void poiVideoUpload(PoiEntity poiEntity) {
|
||||
if (poiEntity.getBodyId() == 0) {
|
||||
ToastUtils.Message(getActivity(), "请先保存本地在上传");
|
||||
return;
|
||||
}
|
||||
if (Constant.isPresent) {
|
||||
if (fmPoiVideoPic.getTag() != null) {
|
||||
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
|
||||
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
||||
if (!existsPic) {
|
||||
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
||||
return;
|
||||
}
|
||||
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
dismissLoadingDialog();
|
||||
Constant.isPresent = false;
|
||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
||||
WaitDialog.dismiss(3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Constant.isPresent = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dismissLoadingDialog();
|
||||
ToastUtils.Message(getActivity(), "请录像拍照");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
||||
}
|
||||
}
|
||||
|
||||
private void poiVideoSave(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
showLoadingDialog();
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(HttpInterface.INSIDE_API_LIST)
|
||||
.cls(PoiVideoBean.class)
|
||||
.params(httpParams)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
|
||||
@Override
|
||||
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (poiVideoBean.getCode() == 200) {
|
||||
Integer poiVideoBody = poiVideoBean.getBody();
|
||||
if (poiVideoBody != null && poiVideoBody != 0) {
|
||||
poiEntity.setBodyId(poiVideoBody);
|
||||
poiEntity.setTaskStatus(3);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiVideoUpload(poiEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
|
||||
}
|
||||
} else if (poiVideoBean.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(), "请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0x101 && resultCode == 0x111) {
|
||||
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
|
||||
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
|
||||
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
|
||||
assert videoPath != null;
|
||||
File videoFile = new File(videoPath);
|
||||
if (videoFile.exists()) {
|
||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
|
||||
// 更新当前POI的置信度
|
||||
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
|
||||
/* 防止程序崩溃后数据丢失*/
|
||||
public void initPoiVideoSharePre() {
|
||||
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("poiEntity", newPoiEntity);
|
||||
edit.putInt("roadVideoType", 3);
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.apply();
|
||||
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (EventBus.getDefault().isRegistered(this))//加上判断
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroy();
|
||||
if (markerPoiVideo != null) {
|
||||
markerPoiVideo.remove();
|
||||
}
|
||||
if (poiVideoBuilder != null) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
|
||||
poiVideoBuilder.append("\r\n");
|
||||
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
|
||||
if (poiEntity == null) {
|
||||
ToastUtils.Message(getActivity(), "无此任务");
|
||||
return;
|
||||
}
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(), "无此任务");
|
||||
return;
|
||||
}
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskIds", poiEntity.getTaskId());
|
||||
httpParams.put("auditIds", "");
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(url)
|
||||
.params(httpParams)
|
||||
.cls(UnPolygonTaskBean.class)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
|
||||
@Override
|
||||
public void onSuccess(UnPolygonTaskBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
|
||||
filePath.delete();
|
||||
}
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(), "请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
|
||||
String roadName = spnRoadName.getTag().toString();
|
||||
poiEntity.setName(roadName);
|
||||
// if (!roadName.equals("")) {
|
||||
// poiEntity.setName(roadName);
|
||||
// } else {
|
||||
// @SuppressLint("SimpleDateFormat")
|
||||
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
// Calendar calendars = Calendar.getInstance();
|
||||
// calendars.setTimeInMillis(System.currentTimeMillis());
|
||||
// String formats = formatter.format(calendars.getTime());
|
||||
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
|
||||
// StringBuilder sb = new StringBuilder("poi录像上报");
|
||||
// if (city != null && !"".equals(city)) {
|
||||
// sb.append("-");
|
||||
// sb.append(city);
|
||||
// }
|
||||
// if (district != null && !"".equals(district)) {
|
||||
// sb.append(district);
|
||||
// }
|
||||
// sb.append("-").append(formats);
|
||||
// poiEntity.setName(sb.toString());
|
||||
// requireActivity().runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// etRoadName.setText(sb);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
String desc = etDesc.getText().toString().trim();
|
||||
if (!desc.equals("")) {
|
||||
poiEntity.setMemo(desc);
|
||||
}
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setType(12);
|
||||
if (latLng != null) {
|
||||
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
|
||||
poiEntity.setGeoWkt(encode);
|
||||
poiEntity.setX(String.valueOf(latLng.longitude));
|
||||
poiEntity.setY(String.valueOf(latLng.latitude));
|
||||
}
|
||||
if (showPoiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
if (booleanExtra) {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
}
|
||||
}
|
||||
}
|
||||
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
||||
poiEntity.setPhoto(fileListByUUID.size()+"");
|
||||
|
||||
}
|
||||
}
|
||||
return poiEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
|
||||
PoiCheckResult poiCheckResult = new PoiCheckResult();
|
||||
if (entity.getPhoto() == null) {
|
||||
poiCheckResult.setCode(1);
|
||||
poiCheckResult.setMsg("请拍摄");
|
||||
return poiCheckResult;
|
||||
}
|
||||
return poiCheckResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -50,9 +50,9 @@ import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PhotoUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.TencentMap;
|
||||
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:
|
||||
chargingPileBuilder.append("点击了全景照片进行拍照,");
|
||||
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
|
||||
File panoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File panoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, panoramaFile.getPath());
|
||||
startActivityForResult(intentPanorama, 101);
|
||||
break;
|
||||
case R.id.rl_coding:
|
||||
chargingPileBuilder.append("点击了充电桩编码进行拍照,");
|
||||
Intent intentCoding = new Intent(getActivity(), PhotographActivity.class);
|
||||
File codingFile = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File codingFile = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentCoding.putExtra(Constant.INTENT_PHOTO_PATH, codingFile.getPath());
|
||||
startActivityForResult(intentCoding, 102);
|
||||
break;
|
||||
case R.id.rl_equipment:
|
||||
chargingPileBuilder.append("点击了设备标牌进行拍照,");
|
||||
Intent intentEquipment = new Intent(getActivity(), PhotographActivity.class);
|
||||
File equipmentFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File equipmentFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentEquipment.putExtra(Constant.INTENT_PHOTO_PATH, equipmentFile.getPath());
|
||||
startActivityForResult(intentEquipment, 103);
|
||||
break;
|
||||
case R.id.rl_facility:
|
||||
chargingPileBuilder.append("点击了设备标牌进行拍照,");
|
||||
Intent intentFacility = new Intent(getActivity(), PhotographActivity.class);
|
||||
File facilityFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File facilityFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentFacility.putExtra(Constant.INTENT_PHOTO_PATH, facilityFile.getPath());
|
||||
startActivityForResult(intentFacility, 104);
|
||||
break;
|
||||
case R.id.rl_scutcheon:
|
||||
chargingPileBuilder.append("点击了设备标牌进行拍照,");
|
||||
Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class);
|
||||
File scutcheonFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File scutcheonFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
|
||||
startActivityForResult(intentScutcheon, 105);
|
||||
break;
|
||||
case R.id.rl_device:
|
||||
chargingPileBuilder.append("点击了设备标牌进行拍照,");
|
||||
Intent intentDevice = new Intent(getActivity(), PhotographActivity.class);
|
||||
File deviceFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File deviceFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentDevice.putExtra(Constant.INTENT_PHOTO_PATH, deviceFile.getPath());
|
||||
startActivityForResult(intentDevice, 106);
|
||||
break;
|
||||
case R.id.rl_usable:
|
||||
chargingPileBuilder.append("点击了可用状态进行拍照,");
|
||||
Intent intentUsable = new Intent(getActivity(), PhotographActivity.class);
|
||||
File usableFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File usableFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentUsable.putExtra(Constant.INTENT_PHOTO_PATH, usableFile.getPath());
|
||||
startActivityForResult(intentUsable, 107);
|
||||
break;
|
||||
case R.id.rl_available:
|
||||
chargingPileBuilder.append("点击了可用专题进行拍照,");
|
||||
Intent intentAvailable = new Intent(getActivity(), PhotographActivity.class);
|
||||
File availableFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File availableFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentAvailable.putExtra(Constant.INTENT_PHOTO_PATH, availableFile.getPath());
|
||||
startActivityForResult(intentAvailable, 108);
|
||||
break;
|
||||
case R.id.rl_parking:
|
||||
chargingPileBuilder.append("点击了停车位编号进行拍照,");
|
||||
Intent intentParking = new Intent(getActivity(), PhotographActivity.class);
|
||||
File parkingFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File parkingFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentParking.putExtra(Constant.INTENT_PHOTO_PATH, parkingFile.getPath());
|
||||
startActivityForResult(intentParking, 109);
|
||||
break;
|
||||
case R.id.rl_number:
|
||||
chargingPileBuilder.append("点击了停车位编号进行拍照,");
|
||||
Intent intentNumber = new Intent(getActivity(), PhotographActivity.class);
|
||||
File numberFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File numberFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentNumber.putExtra(Constant.INTENT_PHOTO_PATH, numberFile.getPath());
|
||||
startActivityForResult(intentNumber, 110);
|
||||
break;
|
||||
|
||||
@@ -52,6 +52,7 @@ import com.navinfo.outdoor.adapter.ChargingPileAdapter;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
@@ -1052,35 +1053,35 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
case R.id.rl_panorama:
|
||||
chargingStationBuilder.append(TimestampUtil.time()).append("点击了全景照片进行拍照 ,");
|
||||
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
|
||||
File PanoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File PanoramaFile = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, PanoramaFile.getPath());
|
||||
startActivityForResult(intentPanorama, 101);
|
||||
break;
|
||||
case R.id.rl_name:
|
||||
chargingStationBuilder.append(TimestampUtil.time()).append("点击了名称照片进行拍照 ,");
|
||||
Intent intentName = new Intent(getActivity(), PhotographActivity.class);
|
||||
File nameFile = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File nameFile = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentName.putExtra(Constant.INTENT_PHOTO_PATH, nameFile.getPath());
|
||||
startActivityForResult(intentName, 102);
|
||||
break;
|
||||
case R.id.rl_internal_photos:
|
||||
chargingStationBuilder.append(TimestampUtil.time()).append("点击了服务说明进行拍照 ,");
|
||||
Intent intentInternal = new Intent(getActivity(), PhotographActivity.class);
|
||||
File internalFile = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File internalFile = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, internalFile.getPath());
|
||||
startActivityForResult(intentInternal, 103);
|
||||
break;
|
||||
case R.id.rl_else:
|
||||
chargingStationBuilder.append(TimestampUtil.time()).append("点击了充电站指引牌进行拍照 ,");
|
||||
Intent intentElse = new Intent(getActivity(), PhotographActivity.class);
|
||||
File elseFile = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File elseFile = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, elseFile.getPath());
|
||||
startActivityForResult(intentElse, 104);
|
||||
break;
|
||||
case R.id.rl_scutcheon:
|
||||
chargingStationBuilder.append(TimestampUtil.time()).append("点击了停车收费标牌进行拍照 ,");
|
||||
Intent intentScutcheon = new Intent(getActivity(), PhotographActivity.class);
|
||||
File scutcheonFile = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File scutcheonFile = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentScutcheon.putExtra(Constant.INTENT_PHOTO_PATH, scutcheonFile.getPath());
|
||||
startActivityForResult(intentScutcheon, 105);
|
||||
break;
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -16,12 +17,14 @@ import android.widget.Toast;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.ToastUtils;
|
||||
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.lzy.okgo.model.HttpParams;
|
||||
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;
|
||||
@@ -44,12 +47,9 @@ import com.navinfo.outdoor.room.PoiEntity;
|
||||
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.NaviUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.tencent.lbssearch.httpresponse.Poi;
|
||||
import com.tencent.map.navi.car.TencentCarNaviManager;
|
||||
import com.tencent.map.navi.data.NaviPoi;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
@@ -60,6 +60,7 @@ import java.math.RoundingMode;
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -73,6 +74,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
private File logFile;
|
||||
private StringBuilder gatherGetBuilder;
|
||||
private TextView tvStartNav;
|
||||
private TextView tvMatchTrack; // 手动匹配轨迹照片
|
||||
|
||||
public static GatherGetFragment newInstance(Bundle bundle) {
|
||||
GatherGetFragment fragment = new GatherGetFragment();
|
||||
@@ -83,7 +85,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
@@ -115,7 +117,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
//主界面获取焦点
|
||||
private void getFocus() {
|
||||
Objects.requireNonNull(getView()).setFocusableInTouchMode(true);
|
||||
requireView().setFocusableInTouchMode(true);
|
||||
getView().requestFocus();
|
||||
getView().setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
@@ -153,6 +155,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
TextView tvDistance = findViewById(R.id.tv_distance);
|
||||
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);
|
||||
btnDelete.setOnClickListener(this);
|
||||
btnCancelGet = findViewById(R.id.btn_cancel_get);//取消领取
|
||||
@@ -204,18 +207,59 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
public void selectNaviType(Constant.NAV_TYPE nav_type) {
|
||||
// 显示导航类型选择的对话框
|
||||
Constant.currentNaviType = nav_type;
|
||||
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
|
||||
NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 已选择导航方式
|
||||
NaviUtils.getInstance().startNav(getActivity(), new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
|
||||
NaviUtils.getInstance().startNav(getActivity(), new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()), new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX())));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 连续点击tvTitle显示匹配轨迹的按钮
|
||||
tvTitle.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (tvMatchTrack.isShown()) {
|
||||
return;
|
||||
}
|
||||
if (poiEntity.getType() != 3 && poiEntity.getType() != 4) {
|
||||
return;
|
||||
}
|
||||
settingHookClickCount++;
|
||||
if(lastClickTime > 0){
|
||||
long secondClickTime = System.currentTimeMillis();//距离上次开机时间
|
||||
long dtime = secondClickTime - lastClickTime;
|
||||
if(dtime <800){
|
||||
if (settingHookClickCount>8) {
|
||||
Toast.makeText(requireActivity(), "打开轨迹自动匹配功能", Toast.LENGTH_SHORT).show();
|
||||
tvMatchTrack.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
if (settingHookClickCount>5) {
|
||||
Toast.makeText(requireActivity(), "再点击"+(9-settingHookClickCount)+"下打开设置功能", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
} else{
|
||||
lastClickTime = 0;
|
||||
settingHookClickCount = 1;
|
||||
}
|
||||
}
|
||||
lastClickTime = System.currentTimeMillis();
|
||||
}
|
||||
});
|
||||
|
||||
tvMatchTrack.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// 与领取任务功能类似,不再检查当前位置与任务之间的距离
|
||||
initGather(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private int settingHookClickCount = 1;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -284,7 +328,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
EventBus.getDefault().post(obtains);
|
||||
break;
|
||||
case R.id.btn_cancel_get://结束领取
|
||||
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了结束领取的按钮 ,");
|
||||
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了取消领取的按钮 ,");
|
||||
if (poiEntity != null) {
|
||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, poiEntity);
|
||||
}
|
||||
@@ -300,9 +344,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (type == 2) {//充电站的领取类型
|
||||
chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, false, 1);
|
||||
} else if (type == 3) {//poi录像的领取类型
|
||||
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, false, 1);
|
||||
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, false, 1, 0);
|
||||
} else if (type == 4) {//道路的领取类型
|
||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1);
|
||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, false, 1, 0);
|
||||
} else if (type == 5) {//其他的领取类型
|
||||
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, false, 1);
|
||||
}
|
||||
@@ -311,28 +355,28 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
case R.id.btn_gather://立即采集
|
||||
gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了立即采集的按钮 ,");
|
||||
if (poiEntity.getTaskStatus() < 2) {
|
||||
double latitude = Constant.currentLocation.getLatitude();
|
||||
double longitude = Constant.currentLocation.getLongitude();
|
||||
double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
||||
LatLng startLatLng = new LatLng(latitude, longitude); //用户当前位置
|
||||
LatLng endLatLng = new LatLng(Double.parseDouble(poiEntity.getY()), Double.parseDouble(poiEntity.getX()));
|
||||
double geometry = GeometryTools.distanceToDouble(startLatLng, endLatLng);
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(),"作业不在领取范围内,无法采集");
|
||||
ToastUtils.showToast(getActivity(),"作业不在领取范围内,无法采集");
|
||||
return;
|
||||
} else {
|
||||
if (geometry > 50) {
|
||||
//Voice.sprat("注意在附近50米范围内进行采集",0);
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "注意在任务附近50米范围内进行采集", "确定").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
initGather();
|
||||
initGather(0);
|
||||
//Voice.sprat("注意在附近50米范围内进行采集",1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
initGather();
|
||||
initGather(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,13 +386,13 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
if (poiEntity != null) {
|
||||
int type = poiEntity.getType();
|
||||
if (type == 6) {
|
||||
initSubmitPolygonTask(HttpInterface.COMPLETE, poiEntity);
|
||||
initSubmitPolygonTask(HttpInterface.COMPLETE+"/"+poiEntity.getTaskId(), poiEntity);
|
||||
} else {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiEntity.setTaskStatus(0);
|
||||
@@ -363,7 +407,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
|
||||
private void initGather() {
|
||||
private void initGather(int matchTrack/*是否为根据轨迹手动匹配*/) {
|
||||
if (poiEntity != null) {
|
||||
int type = poiEntity.getType();
|
||||
if (type == 6) {
|
||||
@@ -378,9 +422,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (type == 2) {//充电站的领取类型
|
||||
chargingTaskByWork(HttpInterface.RECEIVED_CTASK, poiEntity, true, 5);
|
||||
} else if (type == 3) {//poi录像的领取类型
|
||||
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, true, 5);
|
||||
taskByNet(HttpInterface.RECEIVED_POI_VIDEO_TASK, poiEntity, true, 5, matchTrack);
|
||||
} else if (type == 4) {//道路的领取类型
|
||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5);
|
||||
taskByNet(HttpInterface.RECEIVED_ROAD_TASK, poiEntity, true, 5, matchTrack);
|
||||
} else if (type == 5) {//其他的领取类型
|
||||
receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity, true, 5);
|
||||
}
|
||||
@@ -413,10 +457,13 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
if (taskIdPoiEntity == null) {
|
||||
PoiEntity chargingStationEntity = new PoiEntity();
|
||||
chargingStationEntity.setTaskId(poiEntity.getTaskId());
|
||||
chargingStationEntity.setRecord_way(poiEntity.getRecord_way());
|
||||
chargingStationEntity.setWork_type(poiEntity.getWork_type());
|
||||
chargingStationEntity.setStation_type(stationBean.getSptype());
|
||||
chargingStationEntity.setName(stationBean.getName());
|
||||
chargingStationEntity.setDescribe(stationBean.getMemo());
|
||||
chargingStationEntity.setCreateTime(stationBean.getEndDate());
|
||||
chargingStationEntity.setUnReceivedTime(stationBean.getUnReceivedTime());
|
||||
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
|
||||
chargingStationEntity.setAddress(stationBean.getAddress());
|
||||
if (stationBean.getTelephone() == null || stationBean.getTelephone().equals("") || stationBean.getTelephone().equals("null")) {
|
||||
@@ -453,6 +500,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void run() {
|
||||
initViewByTaskStatus(1);
|
||||
ToastUtils.showToast(requireContext(), "领取成功");
|
||||
if (isSaver) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_MAP;
|
||||
@@ -495,7 +543,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,9 +553,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
Log.d("TAG", "onError: " + e.getMessage());
|
||||
}
|
||||
@@ -519,78 +567,103 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
*/
|
||||
private void initPolygonTask(String url, PoiEntity poiEntity, boolean aBoolean) {
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(),"无此任务");
|
||||
ToastUtils.showToast(getActivity(),"无此任务");
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(url + "/" + poiEntity.getTaskId())
|
||||
.cls(PolygonTaskBean.class)
|
||||
.token(Constant.ACCESS_TOKEN)
|
||||
.params(new HttpParams())
|
||||
.getRequest(new Callback<PolygonTaskBean>() {
|
||||
// 如果当前存在未关闭的面状任务,提示用户无法领取,先关闭已领取的面状任务
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<PoiEntity> recivePolygonPoi = new ArrayList<>();
|
||||
// 如果点击立即采集,则面状任务taskstatus可能是2,如果点击领取任务,则可能是1,所以需要查询两个状态的数据
|
||||
List<PoiEntity> recivePolygonPoi1 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(1, 6);
|
||||
List<PoiEntity> recivePolygonPoi2 = PoiDatabase.getInstance(requireContext()).getPoiDao().getPoiEntityByTaskStatus(2, 6);
|
||||
recivePolygonPoi.addAll(recivePolygonPoi1);
|
||||
recivePolygonPoi.addAll(recivePolygonPoi2);
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void onSuccess(PolygonTaskBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集),
|
||||
PolygonTaskBean.BodyBean listBean = response.getBody();
|
||||
PoiEntity polygonEntity = new PoiEntity();
|
||||
if (listBean != null) {
|
||||
polygonEntity.setTaskId(listBean.getId());
|
||||
polygonEntity.setName(listBean.getName());
|
||||
polygonEntity.setType(listBean.getType());
|
||||
polygonEntity.setGeoWkt(listBean.getGeo());
|
||||
String encodeStr = listBean.getGeo();
|
||||
String geo = Geohash.getInstance().decode(encodeStr);
|
||||
// 生成对应的x和y poiEntity.setX
|
||||
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
|
||||
polygonEntity.setTaskStatus(1);
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), polygonEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initViewByTaskStatus(1);
|
||||
ToastUtils.Message(getActivity(),"领取成功");
|
||||
if (aBoolean) {
|
||||
initCompleteTask(HttpInterface.SUBMIT_POLYGON_TASK, polygonEntity);
|
||||
} else {
|
||||
Message obtains = Message.obtain();
|
||||
obtains.what = Constant.JOB_WORD_MONITOR;
|
||||
obtains.obj = true;
|
||||
EventBus.getDefault().post(obtains);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
public void run() {
|
||||
if (recivePolygonPoi!=null&&!recivePolygonPoi.isEmpty()) {
|
||||
ToastUtils.showToast(requireActivity(),"您当前存在已领取的其他面状任务,请先关闭该任务后再领取!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
Log.d("TAG", "onError: " + e.getMessage());
|
||||
showLoadingDialog();
|
||||
OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(url + "/" + poiEntity.getTaskId())
|
||||
.cls(PolygonTaskBean.class)
|
||||
.token(Constant.ACCESS_TOKEN)
|
||||
.params(new HttpParams())
|
||||
.getRequest(new Callback<PolygonTaskBean>() {
|
||||
@Override
|
||||
public void onSuccess(PolygonTaskBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200) {// 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集),
|
||||
PolygonTaskBean.BodyBean listBean = response.getBody();
|
||||
PoiEntity polygonEntity = new PoiEntity();
|
||||
polygonEntity.setRecord_way(poiEntity.getRecord_way());
|
||||
polygonEntity.setWork_type(poiEntity.getWork_type());
|
||||
if (listBean != null) {
|
||||
polygonEntity.setTaskId(listBean.getId());
|
||||
polygonEntity.setName(listBean.getName());
|
||||
polygonEntity.setType(listBean.getType());
|
||||
polygonEntity.setGeoWkt(listBean.getGeo());
|
||||
polygonEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
||||
String encodeStr = listBean.getGeo();
|
||||
String geo = Geohash.getInstance().decode(encodeStr);
|
||||
// 生成对应的x和y poiEntity.setX
|
||||
GeometryTools.obitainPoiEntityXY(geo, polygonEntity);
|
||||
polygonEntity.setTaskStatus(1);
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), polygonEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initViewByTaskStatus(1);
|
||||
ToastUtils.showToast(getActivity(),"领取成功");
|
||||
if (aBoolean) {
|
||||
initCompleteTask(HttpInterface.SUBMIT_POLYGON_TASK, polygonEntity);
|
||||
} else {
|
||||
Message obtains = Message.obtain();
|
||||
obtains.what = Constant.JOB_WORD_MONITOR;
|
||||
obtains.obj = true;
|
||||
EventBus.getDefault().post(obtains);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
Log.d("TAG", "onError: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -599,7 +672,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
*/
|
||||
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(),"无此任务");
|
||||
ToastUtils.showToast(getActivity(),"无此任务");
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
@@ -630,6 +703,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void run() {
|
||||
Log.d("TAG", "run: " + response.getMessage());
|
||||
ToastUtils.showToast(requireContext(), "已取消领取:" + poiEntity.getName());
|
||||
initViewByTaskStatus(0);
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
@@ -643,7 +717,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,9 +727,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -666,7 +740,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
*/
|
||||
private void initCompleteTask(String url, PoiEntity poiEntity) {
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(),"无此任务");
|
||||
ToastUtils.showToast(getActivity(),"无此任务");
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
@@ -710,7 +784,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -720,9 +794,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -733,12 +807,23 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
*/
|
||||
private void initSubmitPolygonTask(String url, PoiEntity poiEntity) {
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(),"无此任务");
|
||||
ToastUtils.showToast(getActivity(),"无此任务");
|
||||
return;
|
||||
}
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("id", poiEntity.getTaskId());
|
||||
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()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
@@ -749,18 +834,36 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
.getRequest(new Callback<UnPolygonTaskBean>() {
|
||||
@Override
|
||||
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();
|
||||
if (response.getCode() == 200) {
|
||||
ToastUtils.showToast(getActivity(), "结束采集成功!");
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
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();
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -770,9 +873,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -783,7 +886,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
*/
|
||||
private void receivedTaskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) {
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(),"无此任务");
|
||||
ToastUtils.showToast(getActivity(),"无此任务");
|
||||
return;
|
||||
}
|
||||
showLoadingDialog();
|
||||
@@ -812,9 +915,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setDescribe(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setIsExclusive(listBean.getIsExclusive());
|
||||
poiListEntity.setRecord_way(poiEntity.getRecord_way());
|
||||
poiListEntity.setWork_type(poiEntity.getWork_type());
|
||||
if (listBean.getType() == 1) {
|
||||
if (listBean.getTelephone() == null || listBean.getTelephone().equals("") || listBean.getTelephone().equals("null")) {
|
||||
poiListEntity.setTelPhone(null);
|
||||
@@ -836,6 +942,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void run() {
|
||||
initViewByTaskStatus(1);//已领取
|
||||
ToastUtils.showToast(requireContext(), "领取成功");
|
||||
if (isSaver) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_MAP;
|
||||
@@ -878,7 +985,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -888,9 +995,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -908,7 +1015,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
/**
|
||||
* @param url 不同任务类型对应的url
|
||||
*/
|
||||
private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId) {
|
||||
private void taskByNet(String url, PoiEntity poiEntity, boolean isSaver, int statusId, int matchTrack) {
|
||||
showLoadingDialog();
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
@@ -921,7 +1028,6 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
okGoBuilder.getRequest(new Callback<TaskByNetBean>() {
|
||||
@Override
|
||||
public void onSuccess(TaskByNetBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200) {
|
||||
TaskByNetBean.BodyBean listBean = response.getBody();
|
||||
if (listBean != null) {
|
||||
@@ -932,9 +1038,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
if (taskIdPoiEntity == null) {//数据库没有这条数据
|
||||
PoiEntity poiListEntity = new PoiEntity();
|
||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||
poiListEntity.setRecord_way(poiEntity.getRecord_way());
|
||||
poiListEntity.setWork_type(poiEntity.getWork_type());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setMemo(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||
@@ -953,10 +1062,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void run() {
|
||||
initViewByTaskStatus(1);
|
||||
ToastUtils.showToast(requireContext(), "领取成功");
|
||||
if (isSaver) {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_MAP;
|
||||
obtain.obj = poiListEntity;
|
||||
obtain.arg1 = matchTrack;
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else {
|
||||
Message obtain = Message.obtain();
|
||||
@@ -977,6 +1088,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.GATHER_GET_MAP;
|
||||
obtain.obj = taskIdPoiEntity;
|
||||
obtain.arg1 = matchTrack;
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else {
|
||||
Message obtain = Message.obtain();
|
||||
@@ -995,8 +1107,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),response.getMessage());
|
||||
ToastUtils.showToast(getActivity(),response.getMessage());
|
||||
}
|
||||
dismissLoadingDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1005,9 +1118,9 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(),"请求超时");
|
||||
ToastUtils.showToast(getActivity(),"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(),message);
|
||||
ToastUtils.showToast(getActivity(),message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,553 @@
|
||||
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,10 +23,14 @@ import com.kongzue.dialog.util.DialogSettings;
|
||||
import com.kongzue.dialog.v3.MessageDialog;
|
||||
import com.lzy.okgo.OkGo;
|
||||
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.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.HomeActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.bean.CommonResponse;
|
||||
import com.navinfo.outdoor.bean.HasSubmitBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
@@ -34,7 +38,6 @@ import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
@@ -106,7 +109,9 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
initRequest();
|
||||
// if (((HomeActivity)getActivity()).getCurrentTabSelected() == 1) {
|
||||
// initRequest();
|
||||
// }
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -131,6 +136,7 @@ public class HasSubmitFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void initOtherSubMitWork() {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("type", 5);
|
||||
|
||||
@@ -14,14 +14,20 @@ import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
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.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.LoginActivity;
|
||||
import com.navinfo.outdoor.activity.PicturesActivity;
|
||||
import com.navinfo.outdoor.activity.UserActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
@@ -29,6 +35,8 @@ import com.navinfo.outdoor.bean.GetPriceBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
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.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
@@ -43,8 +51,19 @@ import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
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
|
||||
*/
|
||||
@@ -105,6 +124,8 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
|
||||
rlContact.setOnClickListener(this);
|
||||
RelativeLayout rlSet = findViewById(R.id.rl_set);
|
||||
rlSet.setOnClickListener(this);
|
||||
RelativeLayout rlClearCache = findViewById(R.id.rl_clear_cache);
|
||||
rlClearCache.setOnClickListener(this);
|
||||
RelativeLayout rlAbout = findViewById(R.id.rl_about);
|
||||
rlAbout.setOnClickListener(this);
|
||||
Button btnQuit = findViewById(R.id.btn_quit);
|
||||
@@ -253,6 +274,85 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
|
||||
intentContact.putExtra("tag", 21);
|
||||
startActivity(intentContact);
|
||||
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: //关于
|
||||
mainBuilder.append(TimestampUtil.time()).append(",").append("点击了item 跳转到关于页面 ,");
|
||||
Intent intentAbout = new Intent(getActivity(), FragmentManagement.class);
|
||||
@@ -263,7 +363,7 @@ public class MineFragment extends BaseFragment implements View.OnClickListener {
|
||||
mainBuilder.append(TimestampUtil.time()).append(",").append("点击了退出登录的按钮 ,");
|
||||
Intent intent = new Intent(getContext(), LoginActivity.class);
|
||||
startActivity(intent);
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
requireActivity().finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,7 @@ import com.navinfo.outdoor.activity.PhotographActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
@@ -512,14 +513,14 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
case R.id.rl_picture:
|
||||
otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第一个照片进行拍照 ,");
|
||||
Intent intentPicture = new Intent(getActivity(), PhotographActivity.class);
|
||||
File file = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File file = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentPicture.putExtra(Constant.INTENT_PHOTO_PATH, file.getPath());
|
||||
startActivityForResult(intentPicture, 101);
|
||||
break;
|
||||
case R.id.rl_pictures:
|
||||
otherBuilder.append(TimestampUtil.time()).append(",").append("点击了第二个照片进行拍照 ,");
|
||||
Intent intentPictures = new Intent(getActivity(), PhotographActivity.class);
|
||||
File files = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File files = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentPictures.putExtra(Constant.INTENT_PHOTO_PATH, files.getPath());
|
||||
startActivityForResult(intentPictures, 102);
|
||||
break;
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
@@ -816,35 +817,35 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
case R.id.rl_panorama:
|
||||
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了全景图的进行拍照,");
|
||||
Intent intentPanorama = new Intent(getActivity(), PhotographActivity.class);
|
||||
File filePanorama = PhotoUtils.showPhotoFile("a", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File filePanorama = PhotoUtils.showPhotoFile("a", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentPanorama.putExtra(Constant.INTENT_PHOTO_PATH, filePanorama.getPath());
|
||||
startActivityForResult(intentPanorama, 101);
|
||||
break;
|
||||
case R.id.rl_name:
|
||||
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名称的进行拍照,");
|
||||
Intent intentName = new Intent(getActivity(), PhotographActivity.class);
|
||||
File fileName = PhotoUtils.showPhotoFile("b", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File fileName = PhotoUtils.showPhotoFile("b", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentName.putExtra(Constant.INTENT_PHOTO_PATH, fileName.getPath());
|
||||
startActivityForResult(intentName, 102);
|
||||
break;
|
||||
case R.id.rl_internal_photos:
|
||||
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了内部照片的进行拍照,");
|
||||
Intent intentInternal = new Intent(getActivity(), PhotographActivity.class);
|
||||
File fileInternal = PhotoUtils.showPhotoFile("c", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File fileInternal = PhotoUtils.showPhotoFile("c", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentInternal.putExtra(Constant.INTENT_PHOTO_PATH, fileInternal.getPath());
|
||||
startActivityForResult(intentInternal, 103);
|
||||
break;
|
||||
case R.id.rl_card:
|
||||
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了名片的进行拍照,");
|
||||
Intent intentCard = new Intent(getActivity(), PhotographActivity.class);
|
||||
File fileCard = PhotoUtils.showPhotoFile("d", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File fileCard = PhotoUtils.showPhotoFile("d", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentCard.putExtra(Constant.INTENT_PHOTO_PATH, fileCard.getPath());
|
||||
startActivityForResult(intentCard, 104);
|
||||
break;
|
||||
case R.id.rl_else:
|
||||
poiBuilder.append(TimestampUtil.time()).append(",").append("点击了其他的进行拍照,");
|
||||
Intent intentElse = new Intent(getActivity(), PhotographActivity.class);
|
||||
File fileElse = PhotoUtils.showPhotoFile("e", new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
|
||||
File fileElse = PhotoUtils.showPhotoFile("e", new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()));
|
||||
intentElse.putExtra(Constant.INTENT_PHOTO_PATH, fileElse.getPath());
|
||||
startActivityForResult(intentElse, 105);
|
||||
break;
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.umeng.commonsdk.debug.D;
|
||||
@@ -139,7 +140,7 @@ public class PoiTaskFragment extends BaseFragment implements View.OnClickListene
|
||||
assert getArguments() != null;
|
||||
type = getArguments().getInt("type", 0);
|
||||
listBeans = new ArrayList<>();
|
||||
if (Constant.currentLocation != null) {
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
||||
if (Constant.USHERED != null) {
|
||||
initWork(type, true);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import androidx.core.widget.NestedScrollView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.StringUtils;
|
||||
import com.github.lazylibrary.util.ZipUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
@@ -40,7 +39,6 @@ import com.navinfo.outdoor.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.PicturesActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.bean.OtherUploadPicBean;
|
||||
import com.navinfo.outdoor.bean.PoiVideoBean;
|
||||
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
@@ -48,7 +46,6 @@ import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||
import com.navinfo.outdoor.room.PoiDao;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
@@ -56,12 +53,12 @@ import com.navinfo.outdoor.util.DataSaveUtils;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.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.navinfo.outdoor.util.UploadUtils;
|
||||
import com.navinfo.outdoor.util.ZipUtils;
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
@@ -78,7 +75,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 寻宝-上报弹窗-poi录像
|
||||
@@ -95,6 +91,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
private StringBuilder poiVideoBuilder;
|
||||
private LatLng rearLatLng;
|
||||
private boolean booleanExtra = true;
|
||||
private TextView tvDrawLine; // 绘制辅助线
|
||||
|
||||
public static PoiVideoFragment newInstance(Bundle bundle) {
|
||||
PoiVideoFragment fragment = new PoiVideoFragment();
|
||||
@@ -146,18 +143,18 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskStatus() == 5) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
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);
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
@@ -185,7 +182,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -204,7 +201,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -232,7 +229,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
|
||||
@@ -250,6 +247,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
});
|
||||
btnRoadSave = findViewById(R.id.btn_poi_video_save);
|
||||
btnRoadSave.setOnClickListener(this);
|
||||
tvDrawLine = findViewById(R.id.tv_draw_line_poi_video);
|
||||
tvDrawLine.setOnClickListener(this::onClick);
|
||||
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
|
||||
btnPoiVideoUpload.setOnClickListener(this);
|
||||
//添加数据
|
||||
@@ -259,7 +258,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
@@ -287,6 +286,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
// 添加信息:
|
||||
assert getArguments() != null;
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
matchTrack = getArguments().getInt("matchTrack", 0);
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null && !name.equals("")) {
|
||||
@@ -359,7 +359,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
|
||||
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
||||
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
}
|
||||
ivPoiVideoPicture.setImageDrawable(null);
|
||||
fmPoiVideoPic.setTag(null);
|
||||
} else {
|
||||
} else {
|
||||
boolean isImageLoad = false;
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
File videoFile = fileListByUUID.get(i);
|
||||
@@ -414,6 +414,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
initPoiVideoSharePre();
|
||||
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
|
||||
// 显示原有抽屉画面
|
||||
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||
if (data.arg1 == 1) {
|
||||
List<LatLng> drawPoints = (List<LatLng>) data.obj;
|
||||
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -438,20 +445,22 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
break;
|
||||
case R.id.tv_short://点击拍摄
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
|
||||
double latitude = Constant.currentLocation.getLatitude();
|
||||
double longitude = Constant.currentLocation.getLongitude();
|
||||
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 (geometry > rearGeometry) {//用戶在终点开始作业
|
||||
if (rearGeometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
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);
|
||||
@@ -460,7 +469,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRssi = Constant.currentLocation.getGPSRssi();
|
||||
intents.putExtra(Constant.MATCH_TRACK, matchTrack);
|
||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRssi == 0) {
|
||||
intents.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
@@ -470,7 +480,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
break;
|
||||
case R.id.tv_combo://自动连拍:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
|
||||
LatLng startLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()); //用户当前位置
|
||||
LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
|
||||
double geom = GeometryTools.distanceToDouble(startLng, latLng);
|
||||
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
|
||||
if (geom > rearGeom) {//用戶在终点开始作业
|
||||
@@ -490,7 +500,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRss = Constant.currentLocation.getGPSRssi();
|
||||
int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRss == 0) {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
@@ -505,12 +515,25 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
initPoiSaveLocal(true);
|
||||
} else {
|
||||
poiVideoUpload(poiEntity);
|
||||
Constant.isPresent = false;
|
||||
}
|
||||
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) {
|
||||
XXPermissions.with(getContext())
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
@@ -558,7 +581,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
if (never) {
|
||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
|
||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -569,8 +592,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 1);
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
@@ -635,8 +660,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 1);
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
showLoadingDialog();
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
@@ -663,7 +690,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
@Override
|
||||
public void run() {
|
||||
poiVideoUpload(poiEntity);
|
||||
Constant.isPresent = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -707,6 +733,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
|
||||
// 更新当前POI的置信度
|
||||
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -723,7 +752,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
@@ -837,8 +866,8 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
Calendar calendars = Calendar.getInstance();
|
||||
calendars.setTimeInMillis(System.currentTimeMillis());
|
||||
String formats = formatter.format(calendars.getTime());
|
||||
String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
|
||||
String city = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
|
||||
String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
|
||||
StringBuilder sb = new StringBuilder("poi录像上报");
|
||||
if (city != null && !"".equals(city)) {
|
||||
sb.append("-");
|
||||
@@ -849,7 +878,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
}
|
||||
sb.append("-").append(formats);
|
||||
poiEntity.setName(sb.toString());
|
||||
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
etRoadName.setText(sb);
|
||||
@@ -868,13 +897,19 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setChecked(false);
|
||||
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) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID != null) {
|
||||
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
if (booleanExtra) {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
|
||||
if (lineStringByFileList != null) {
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
@@ -882,7 +917,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
}
|
||||
} else {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
|
||||
if (lineStringByFileList != null) {
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.Message;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
@@ -18,6 +19,7 @@ import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.util.NoSlideViewPager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -28,7 +30,8 @@ import java.util.Objects;
|
||||
*/
|
||||
public class RecordFragment extends BaseFragment {
|
||||
|
||||
private final String[] names = {"待提交", "已提交"};
|
||||
private final String[] names = {"已领取", "待提交", "已提交"};
|
||||
private TabLayout tabRecord;
|
||||
|
||||
public static RecordFragment newInstance(Bundle bundle) {
|
||||
RecordFragment fragment = new RecordFragment();
|
||||
@@ -44,9 +47,11 @@ public class RecordFragment extends BaseFragment {
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
TabLayout tabRecord = findViewById(R.id.tab_record);
|
||||
tabRecord = findViewById(R.id.tab_record);
|
||||
NoSlideViewPager vpRecord = findViewById(R.id.vp_record);
|
||||
ArrayList<Fragment> fragments = new ArrayList<>();
|
||||
// 待作业
|
||||
fragments.add(new HasReceiveFragment());
|
||||
// 待提交
|
||||
fragments.add(new StaySubmitFragment());
|
||||
// 已提交
|
||||
@@ -67,15 +72,21 @@ public class RecordFragment extends BaseFragment {
|
||||
tabRecord.setupWithViewPager(vpRecord);
|
||||
Objects.requireNonNull(tabRecord.getTabAt(0)).setText(names[0]);
|
||||
Objects.requireNonNull(tabRecord.getTabAt(1)).setText(names[1]);
|
||||
Objects.requireNonNull(tabRecord.getTabAt(2)).setText(names[2]);
|
||||
tabRecord.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
if (tab.getPosition()==0){
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||
obtain.what = Constant.HAS_RECEIVE_ITEM;
|
||||
obtain.obj=true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
}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();
|
||||
obtain.what = Constant.HAS_SUBMIT_ITEM;
|
||||
obtain.obj = true;
|
||||
@@ -105,9 +116,42 @@ public class RecordFragment extends BaseFragment {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,6 @@ import androidx.core.widget.NestedScrollView;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.StringUtils;
|
||||
import com.github.lazylibrary.util.ZipUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
@@ -34,24 +33,21 @@ 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.CustomDialog;
|
||||
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.AutoTakePictureActivity;
|
||||
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.util.DataSaveUtils;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
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.navinfo.outdoor.util.UploadUtils;
|
||||
import com.navinfo.outdoor.bean.OtherUploadPicBean;
|
||||
import com.navinfo.outdoor.bean.RoadSaveBean;
|
||||
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
@@ -59,13 +55,12 @@ import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||
import com.navinfo.outdoor.room.PoiDao;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.ZipUtils;
|
||||
import com.sothree.slidinguppanel.SlidingUpPanelLayout;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
@@ -83,7 +78,6 @@ import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/*
|
||||
* 寻宝-点击上传弹窗-道路
|
||||
@@ -104,6 +98,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
private RadioGroup rgRoadStatus; // 道路状态的radioGroup
|
||||
private EditText edtCheckedOther;
|
||||
private int existence = 0; // 是否存在
|
||||
private TextView tvDrawLine; // 绘制辅助线
|
||||
|
||||
public static RoadFragment newInstance(Bundle bundle) {
|
||||
RoadFragment fragment = new RoadFragment();
|
||||
@@ -149,18 +144,18 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskStatus() == 5) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getActivity()), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
@@ -186,7 +181,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -205,7 +200,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
Objects.requireNonNull(getActivity()).getSupportFragmentManager().popBackStack();
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -263,7 +258,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击长按删除 确定按钮,");
|
||||
@@ -281,6 +276,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
});
|
||||
btnRoadSave = findViewById(R.id.btn_road_save);
|
||||
btnRoadSave.setOnClickListener(this);
|
||||
tvDrawLine = findViewById(R.id.tv_draw_line_road);
|
||||
tvDrawLine.setOnClickListener(this::onClick);
|
||||
Button roadUpload = findViewById(R.id.road_upload);
|
||||
roadUpload.setOnClickListener(this);
|
||||
//数据展示
|
||||
@@ -290,7 +287,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
@@ -318,6 +315,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
// 添加信息:
|
||||
assert getArguments() != null;
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
matchTrack = getArguments().getInt("matchTrack", 0);
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
if (name != null && !name.equals("")) {
|
||||
@@ -391,7 +389,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
|| fileListByUUID.get(i).getPath().endsWith(".jpg")|| fileListByUUID.get(i).getPath().endsWith(".jpeg")) {
|
||||
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
Glide.with(Objects.requireNonNull(getActivity())).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
||||
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivRoadPicture);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
@@ -408,7 +406,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
if (rgRoadStatus!=null) {
|
||||
for (int i = 0; i < rgRoadStatus.getChildCount(); i++) {
|
||||
RadioButton childAt = (RadioButton) rgRoadStatus.getChildAt(i);
|
||||
if (childAt.getTag().equals(showPoiEntity.getExistence())) {
|
||||
if (Integer.parseInt(childAt.getTag().toString())==showPoiEntity.getExistence()) {
|
||||
childAt.setChecked(true);
|
||||
break;
|
||||
}
|
||||
@@ -487,6 +485,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
fmRoadPic.setTag(fileListByUUID);
|
||||
}
|
||||
initRoadSharePre();
|
||||
} else if (data.what == Constant.EVENT_WHAT_FINISH_DRAW_LINE) {
|
||||
// 显示原有抽屉画面
|
||||
changeSlidingLayout(View.VISIBLE, SlidingUpPanelLayout.PanelState.COLLAPSED);
|
||||
if (data.arg1 == 1) {
|
||||
List<LatLng> drawPoints = (List<LatLng>) data.obj;
|
||||
showPoiEntity.setDrawLine(GeometryTools.getLineString(drawPoints));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -511,20 +516,22 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
break;
|
||||
case R.id.tv_pictures:
|
||||
roadBuilder.append(TimestampUtil.time()).append(",").append("点击了自动拍照的按钮 ,");
|
||||
double latitude = Constant.currentLocation.getLatitude();
|
||||
double longitude = Constant.currentLocation.getLongitude();
|
||||
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 (geometry > rearGeometry) {//用戶在终点开始作业
|
||||
if (rearGeometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
if (matchTrack == 0) { // 普通拍照模式
|
||||
if (geometry > rearGeometry) {//用戶在终点开始作业
|
||||
if (rearGeometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,7 +570,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
// intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
// intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
// intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
// int gpsRssi = Constant.currentLocation.getGPSRssi();
|
||||
// int gpsRssi = LocationLifeCycle.getInstance().getMainLocation().getGPSRssi();
|
||||
// if (gpsRssi == 0) {
|
||||
// intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
// } else {
|
||||
@@ -581,7 +588,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRssi = Constant.currentLocation.getGPSRssi();
|
||||
intent.putExtra(Constant.MATCH_TRACK, matchTrack);
|
||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRssi == 0) {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
@@ -597,13 +605,26 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
initPoiSaveLocal(true);
|
||||
} else {
|
||||
poiVideoUpload(poiEntity);
|
||||
Constant.isPresent = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case R.id.tv_draw_line_road:
|
||||
// 开始绘制辅助线,隐藏当前界面,展示地图,用户点击绘制线
|
||||
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) {
|
||||
XXPermissions.with(getContext())
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
@@ -621,23 +642,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
|
||||
return;
|
||||
}
|
||||
poiEntity.setTaskStatus(2);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
Objects.requireNonNull(getActivity()).runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isLocal) {
|
||||
roadSaveBetWork(poiEntity);
|
||||
} else {
|
||||
roadSaveWork(poiEntity);
|
||||
}
|
||||
if (existence == 0&&showPoiEntity.getGeoWkt()!=null) {
|
||||
DataSaveUtils.checkRoadPoiPicture(showPoiEntity, (List<File>) fmRoadPic.getTag(), new DataSaveUtils.RoadPercentCheckCallback() {
|
||||
@Override
|
||||
public void callback(double percent) {
|
||||
if (percent<=0.1) {
|
||||
ToastUtils.Message(getActivity(), "手动拍摄的道路任务覆盖度小于10%时,不能选择‘道路正常开通’");
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
doSaveRoadData(poiEntity, isLocal);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
doSaveRoadData(poiEntity, isLocal);
|
||||
}
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
|
||||
}
|
||||
@@ -648,18 +666,39 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
if (never) {
|
||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(Objects.requireNonNull(getActivity()), permissions);
|
||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void doSaveRoadData(PoiEntity poiEntity, boolean isLocal) {
|
||||
poiEntity.setTaskStatus(2);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isLocal) {
|
||||
roadSaveBetWork(poiEntity);
|
||||
} else {
|
||||
roadSaveWork(poiEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void roadSaveWork(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 0);
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 0);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
// 增加对应九天平台的参数
|
||||
httpParams.put("existence", existence);
|
||||
@@ -710,7 +749,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
Constant.isPresent = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -730,7 +769,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 0);
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 0);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
// 增加对应九天平台的参数
|
||||
httpParams.put("existence", existence);
|
||||
@@ -760,7 +800,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
@Override
|
||||
public void run() {
|
||||
poiVideoUpload(poiEntity);
|
||||
Constant.isPresent = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -825,7 +864,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
@@ -935,8 +974,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
Calendar calendars = Calendar.getInstance();
|
||||
calendars.setTimeInMillis(System.currentTimeMillis());
|
||||
String formats = formatter.format(calendars.getTime());
|
||||
String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||
String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
|
||||
String city = LocationLifeCycle.getInstance().getTencentLocation().getCity();//返回当前位置的城市.
|
||||
String district = LocationLifeCycle.getInstance().getTencentLocation().getDistrict();//返回当前位置的区县.
|
||||
StringBuffer sb = new StringBuffer("道路录像上报");
|
||||
if (city != null && !"".equals(city)) {
|
||||
sb.append("-");
|
||||
@@ -968,13 +1007,20 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setType(4);
|
||||
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) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID != null) {
|
||||
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
|
||||
fmRoadPic.setTag(fileListByUUID);
|
||||
if (booleanExtra) {//true
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
|
||||
if (lineStringByFileList != null) {
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String encodeList = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (encodeList != null) {
|
||||
poiEntity.setDetail(encodeList);
|
||||
@@ -982,7 +1028,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
}
|
||||
} else {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
|
||||
if (lineStringByFileList != null) {
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
|
||||
@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.elvishew.xlog.Logger;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
|
||||
import com.kongzue.dialog.interfaces.OnMenuItemClickListener;
|
||||
@@ -40,14 +41,17 @@ import com.navinfo.outdoor.room.PoiDao;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.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;
|
||||
@@ -56,6 +60,13 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
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
|
||||
@@ -68,6 +79,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
private CheckBox cbSelect;
|
||||
private File logFile;
|
||||
private StringBuilder staySubmitBuilder;
|
||||
private Logger logger;
|
||||
|
||||
public static StaySubmitFragment newInstance(Bundle bundle) {
|
||||
StaySubmitFragment fragment = new StaySubmitFragment();
|
||||
@@ -81,6 +93,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
logger=XLogUtils.Companion.getInstance().getUploadLogWriter();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -102,9 +115,11 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
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(Objects.requireNonNull(getContext()), DividerItemDecoration.VERTICAL));
|
||||
stayXrv.addItemDecoration(new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL));
|
||||
staySubmitAdapter = new StaySubmitAdapter(getContext());
|
||||
stayXrv.setAdapter(staySubmitAdapter);
|
||||
//点击条目跳转
|
||||
@@ -141,7 +156,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (Constant.currentLocation != null) {
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
||||
if (Constant.USHERED != null) {
|
||||
cbSelect.setChecked(false);
|
||||
refreshData();
|
||||
@@ -152,7 +167,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
@@ -176,11 +191,11 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@Subscribe(threadMode = ThreadMode.MAIN_ORDERED)
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.STAY_SUBMIT_ITEM) {
|
||||
if ((boolean) data.obj) {
|
||||
if (Constant.currentLocation != null) {
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) {
|
||||
if (Constant.USHERED != null) {
|
||||
if (cbSelect != null) {
|
||||
cbSelect.setChecked(false);
|
||||
@@ -189,6 +204,14 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (data.what == Constant.EVENT_WHAT_UPLOAD_PROGRESS) {
|
||||
if (data.obj!=null&&staySubmitAdapter!=null&&staySubmitAdapter.getAllRoad()!=null) {
|
||||
for (int i = 0; i < staySubmitAdapter.getAllRoad().size(); i++) {
|
||||
if (data.obj == staySubmitAdapter.getAllRoad().get(i)) {
|
||||
staySubmitAdapter.notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,7 +288,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
case R.id.cl_stay_type://1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
|
||||
staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了待提交的类型 ,");
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
BottomMenu.show((AppCompatActivity) Objects.requireNonNull(getContext()), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
|
||||
BottomMenu.show((AppCompatActivity) requireActivity(), new String[]{"全部", "poi", "充电站", "poi录像", "道路录像", "其他"}, new OnMenuItemClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onClick(String text, int index) {
|
||||
@@ -294,14 +317,21 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
});
|
||||
break;
|
||||
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("点击了删除按钮 ,");
|
||||
if (Constant.isPresent) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) Objects.requireNonNull(getContext()), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
initRequest(staySubmitAdapter.getAllRoad());
|
||||
logger.d("用户点击确认批量删除按钮+++++++++++++++++++++++");
|
||||
initRequest(staySubmitAdapter.getCheckedPoiEntity());
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@@ -311,6 +341,7 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
break;
|
||||
case R.id.btn_stay_submit://提交
|
||||
staySubmitBuilder.append(TimestampUtil.time()).append(",").append("点击了提交的按钮 ,");
|
||||
logger.d("用户点击批量上传提交按钮+++++++++++++++++++++++");
|
||||
if (Constant.isPresent) {
|
||||
if (poiEntities == null) {
|
||||
poiEntities = new ArrayList<>();
|
||||
@@ -334,23 +365,22 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
ToastUtils.Message(getActivity(), "有正在提交的数据,等提交成功后,方可操作");
|
||||
}
|
||||
break;
|
||||
case R.id.btn_stay_cancel:
|
||||
// 用户点击取消上传
|
||||
PoiSaveUtils.getInstance(requireActivity()).cancelUploadPoiEntityBatch();
|
||||
// 数据上传取消后重置上传状态
|
||||
staySubmitAdapter.setAllWorkType(0);
|
||||
// 设置当前没有正在上传的数据
|
||||
Constant.isPresent = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void initRequest(List<PoiEntity> allRoad) {
|
||||
private void initRequest(List<PoiEntity> poiEntities) {
|
||||
showLoadingDialog();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
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) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
@@ -385,7 +415,34 @@ public class StaySubmitFragment extends BaseFragment implements View.OnClickList
|
||||
public void onSuccess(UnPolygonTaskBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
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) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,954 @@
|
||||
package com.navinfo.outdoor.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.widget.NestedScrollView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.StringUtils;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.kongzue.dialog.interfaces.OnDialogButtonClickListener;
|
||||
import com.kongzue.dialog.util.BaseDialog;
|
||||
import com.kongzue.dialog.util.DialogSettings;
|
||||
import com.kongzue.dialog.v3.MessageDialog;
|
||||
import com.kongzue.dialog.v3.WaitDialog;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.FragmentManagement;
|
||||
import com.navinfo.outdoor.activity.PicturesActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.bean.PoiVideoBean;
|
||||
import com.navinfo.outdoor.bean.UnPolygonTaskBean;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
import com.navinfo.outdoor.http.OkGoBuilder;
|
||||
import com.navinfo.outdoor.room.ChargingPileEntity;
|
||||
import com.navinfo.outdoor.room.InsertAndUpdateUtils;
|
||||
import com.navinfo.outdoor.room.PoiDatabase;
|
||||
import com.navinfo.outdoor.room.PoiEntity;
|
||||
import com.navinfo.outdoor.ui.view.SpinnerUtils;
|
||||
import com.navinfo.outdoor.util.AWMp4ParserHelper;
|
||||
import com.navinfo.outdoor.util.DataSaveUtils;
|
||||
import com.navinfo.outdoor.util.FlushTokenUtil;
|
||||
import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.PoiSaveUtils;
|
||||
import com.navinfo.outdoor.util.PreserveUtils;
|
||||
import com.navinfo.outdoor.util.TimestampUtil;
|
||||
import com.navinfo.outdoor.util.ToastUtils;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptorFactory;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.Marker;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.MarkerOptions;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 寻宝-上报弹窗-交通枢纽
|
||||
*/
|
||||
public class TrafficHubFragment extends BaseDrawerFragment implements View.OnClickListener {
|
||||
private EditText etDesc;
|
||||
private Spinner spnRoadName;
|
||||
private ImageView ivPoiVideoPicture;
|
||||
private Button btnRoadSave;
|
||||
private File fileZip, logFile;
|
||||
private FrameLayout fmPoiVideoPic;
|
||||
private LatLng latLng;
|
||||
private Marker markerPoiVideo;
|
||||
private TextView tvCombo, tvShort;
|
||||
private StringBuilder poiVideoBuilder;
|
||||
private LatLng rearLatLng;
|
||||
private boolean booleanExtra = true;
|
||||
|
||||
public static TrafficHubFragment newInstance(Bundle bundle) {
|
||||
TrafficHubFragment fragment = new TrafficHubFragment();
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayout() {
|
||||
return R.layout.traffic_hub_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (!EventBus.getDefault().isRegistered(this)) {//加上判断
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
View header = mView.findViewById(R.id.traffic_hub_header);
|
||||
header.findViewById(R.id.iv_final).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
initBack();
|
||||
}
|
||||
});
|
||||
header.findViewById(R.id.tv_explain).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(getActivity(), FragmentManagement.class);
|
||||
intent.putExtra("tag", 8);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
moveLatlng(latLng, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onBackPressed() {
|
||||
initBack();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void initBack() {
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getTaskStatus() == 5) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, showPoiEntity);
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else if (showPoiEntity.getTaskStatus() == 0 || showPoiEntity.getTaskStatus() == 1) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireActivity(), "提示", "当前在任务作业中,是否退出", "确定", "取消").setOnOkButtonClickListener(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了返回当前页面的 确定 按钮,");
|
||||
if (showPoiEntity != null) {
|
||||
if (showPoiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(showPoiEntity.getId());
|
||||
filePath.delete();
|
||||
}
|
||||
}
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
isSliding = arguments.getBoolean("isSliding", true);
|
||||
}
|
||||
if (isSliding) {
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.TREASURE_FRAGMENT;
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
Bundle arguments = getArguments();
|
||||
if (arguments != null) {
|
||||
isSliding = arguments.getBoolean("isSliding", true);
|
||||
}
|
||||
if (isSliding) {
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.TREASURE_FRAGMENT;
|
||||
obtain1.obj = isSliding;
|
||||
EventBus.getDefault().post(obtain1);
|
||||
}
|
||||
requireActivity().getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
super.initView();
|
||||
setSlidingUpPanelLayout(Constant.SLIDING_LAYOUT);
|
||||
NestedScrollView nestedScrollView = findViewById(R.id.nested_scroll_view);
|
||||
if (slidingPaneLayout != null) {
|
||||
slidingPaneLayout.setScrollableView(nestedScrollView);
|
||||
}
|
||||
spnRoadName = findViewById(R.id.spn_poi_video_name);
|
||||
ivPoiVideoPicture = findViewById(R.id.iv_poi_video_picture);
|
||||
etDesc = findViewById(R.id.et_desc);
|
||||
//点击拍照
|
||||
tvShort = findViewById(R.id.tv_short);
|
||||
tvShort.setOnClickListener(this);
|
||||
//自动连拍
|
||||
tvCombo = findViewById(R.id.tv_combo);
|
||||
tvCombo.setOnClickListener(this);
|
||||
fmPoiVideoPic = findViewById(R.id.fm_poi_video_picture);
|
||||
fmPoiVideoPic.setOnClickListener(this);
|
||||
fmPoiVideoPic.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View v) {
|
||||
DialogSettings.style = DialogSettings.STYLE.STYLE_IOS;
|
||||
MessageDialog.show((AppCompatActivity) requireContext(), "提示", "是否删除", "确定", "取消").setOkButton(new OnDialogButtonClickListener() {
|
||||
@Override
|
||||
public boolean onClick(BaseDialog baseDialog, View v) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了长按删除图片的 按钮,");
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
ivPoiVideoPicture.setImageDrawable(null);
|
||||
fmPoiVideoPic.setTag(null);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
btnRoadSave = findViewById(R.id.btn_poi_video_save);
|
||||
btnRoadSave.setOnClickListener(this);
|
||||
Button btnPoiVideoUpload = findViewById(R.id.btn_poi_video_upload);
|
||||
btnPoiVideoUpload.setOnClickListener(this);
|
||||
//添加数据
|
||||
initShowPoi();
|
||||
((TextView)findViewById(R.id.tv1)).setText("交通枢纽");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
|
||||
String pictures_time = sharedPreferences.getString("pictures_time", null);
|
||||
if (pictures_time == null) {
|
||||
sharedEdit.putString("pictures_time", newFormat);
|
||||
sharedEdit.apply();
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
|
||||
} else {
|
||||
if (pictures_time.equals(newFormat)) {
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + pictures_time + ".txt");
|
||||
} else {
|
||||
logFile = new File(Constant.LOG_FOLDER + "/" + newFormat + ".txt");
|
||||
}
|
||||
}
|
||||
poiVideoBuilder = new StringBuilder();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("PoiVideoActivity-onCreate-initData ,");
|
||||
if (Constant.USHERED != null) {
|
||||
poiVideoBuilder.append("userId:").append(Constant.USHERED).append(",");
|
||||
}
|
||||
}
|
||||
|
||||
private void initShowPoi() {
|
||||
// 添加信息:
|
||||
assert getArguments() != null;
|
||||
showPoiEntity = (PoiEntity) getArguments().getSerializable("poiEntity");
|
||||
if (showPoiEntity != null) {
|
||||
String name = showPoiEntity.getName();//名称
|
||||
SpinnerUtils spinnerUtils = new SpinnerUtils();
|
||||
String[] items = {"交通枢纽全景", "引导图", "出发、到达层", "上客、落客区", "停车场", "其他"};
|
||||
if (StringUtils.isEmpty(name)) { // 如果从数据获取的名称为空,则设置name显示为默认的第一个选项
|
||||
name = items[0];
|
||||
}
|
||||
spinnerUtils.initSpinner(getActivity(), spnRoadName, new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
spnRoadName.setTag(items[position]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
}, name, items);
|
||||
String geoWkt = showPoiEntity.getGeoWkt();
|
||||
if (geoWkt != null) {
|
||||
String geo = Geohash.getInstance().decode(geoWkt);
|
||||
Geometry geometry = GeometryTools.createGeometry(geo);
|
||||
switch (geometry.getGeometryType()) {
|
||||
case "Point": //点
|
||||
latLng = GeometryTools.createLatLng(geo);
|
||||
break;
|
||||
case "LineString": //线
|
||||
case "Polygon": //面
|
||||
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
|
||||
assert latLineString != null;
|
||||
latLng = latLineString.get(0);//起點
|
||||
rearLatLng = latLineString.get(latLineString.size() - 1);//終點
|
||||
break;
|
||||
}
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
} else {
|
||||
String detail = showPoiEntity.getDetail();
|
||||
if (detail != null) {
|
||||
String geo = Geohash.getInstance().decode(detail);
|
||||
Geometry geometry = GeometryTools.createGeometry(geo);
|
||||
switch (geometry.getGeometryType()) {
|
||||
case "Point": //点
|
||||
latLng = GeometryTools.createLatLng(geo);
|
||||
break;
|
||||
case "LineString": //线
|
||||
case "Polygon": //面
|
||||
List<LatLng> latLineString = GeometryTools.getLatLags(geo);
|
||||
assert latLineString != null;
|
||||
latLng = latLineString.get(0);
|
||||
break;
|
||||
}
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
} else {
|
||||
String x = showPoiEntity.getX();
|
||||
String y = showPoiEntity.getY();
|
||||
if (x != null && y != null) {
|
||||
latLng = new LatLng();
|
||||
latLng.setLongitude(Double.parseDouble(x));
|
||||
latLng.setLatitude(Double.parseDouble(y));
|
||||
BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_show);
|
||||
markerPoiVideo = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).anchor(0.5f, 1.0f));
|
||||
markerPoiVideo.setZIndex(4);
|
||||
moveLatlng(latLng, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
String memo = showPoiEntity.getMemo();//任务描述
|
||||
if (memo != null && !memo.equals("")) {
|
||||
etDesc.setText(memo);
|
||||
}
|
||||
showPoiEntity.setType(11);
|
||||
String photoList = showPoiEntity.getPhoto();
|
||||
if (!StringUtils.isEmpty(photoList)) {
|
||||
boolean isImageLoad = false;
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
if (fileListByUUID.get(i).getPath().contains(".webp") && !fileListByUUID.get(i).getPath().contains("paper.txt")) {
|
||||
if (fileListByUUID.get(i).exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
Glide.with(requireActivity()).load(fileListByUUID.get(i)).into(ivPoiVideoPicture);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
if (showPoiEntity.getTaskStatus() == 3) {
|
||||
disables();//禁用所有可操作的控件
|
||||
}
|
||||
// 如果是推送的POI录像,不允许修改名称
|
||||
if (showPoiEntity.getTaskId()>0) {
|
||||
spnRoadName.setEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void disables() {
|
||||
spnRoadName.setEnabled(false);
|
||||
ivPoiVideoPicture.setEnabled(false);
|
||||
tvShort.setEnabled(false);
|
||||
tvCombo.setEnabled(false);
|
||||
etDesc.setEnabled(false);
|
||||
btnRoadSave.setEnabled(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.PICTURE_VIDEO_WORD) {
|
||||
if ((boolean) data.obj) {
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
} else if (data.what == Constant.PHOTO_FINISH_VIDEO) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID.size() == 1) {
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
ivPoiVideoPicture.setImageDrawable(null);
|
||||
fmPoiVideoPic.setTag(null);
|
||||
} else {
|
||||
boolean isImageLoad = false;
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
File videoFile = fileListByUUID.get(i);
|
||||
if (videoFile.getPath().contains(".webp") && !videoFile.getPath().contains("paper.txt")) {
|
||||
if (videoFile.exists() && !isImageLoad) {
|
||||
// 使用glide加载视频的第一帧
|
||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
|
||||
isImageLoad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
switch (v.getId()) {
|
||||
case R.id.fm_poi_video_picture:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了图片查看列表 ,");
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID.size() > 1) {
|
||||
Intent photoAlbumIntent = new Intent(getActivity(), FragmentManagement.class);
|
||||
photoAlbumIntent.putExtra("tag", 36);
|
||||
photoAlbumIntent.putExtra("showPoiEntity", showPoiEntity);
|
||||
startActivity(photoAlbumIntent);
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "请拍摄");
|
||||
}
|
||||
break;
|
||||
case R.id.btn_poi_video_save:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了保存本地的按钮 ,");
|
||||
initPoiSaveLocal(false);
|
||||
break;
|
||||
case R.id.tv_short://点击拍摄
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了拍摄的按钮 ,");
|
||||
double latitude = LocationLifeCycle.getInstance().getMainLocation().getLatitude();
|
||||
double longitude = LocationLifeCycle.getInstance().getMainLocation().getLongitude();
|
||||
LatLng startLatLng = new LatLng(latitude, longitude);// 用户当前位置
|
||||
double geometry = GeometryTools.distanceToDouble(startLatLng, latLng);// 起點 于用戶的距離
|
||||
double rearGeometry = GeometryTools.distanceToDouble(startLatLng, rearLatLng);// 終點于用戶的距離
|
||||
if (matchTrack == 0) {
|
||||
if (geometry > rearGeometry) {//用戶在终点开始作业
|
||||
if (rearGeometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geometry > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
Intent intents = new Intent(getActivity(), PicturesActivity.class);
|
||||
File filePath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||
intents.putExtra(Constant.INTENT_JPG_PATH, filePath.getAbsolutePath());
|
||||
intents.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intents.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intents.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRssi = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRssi == 0) {
|
||||
intents.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
intents.putExtra(Constant.INTENT_BOOLEAN, true);
|
||||
}
|
||||
startActivityForResult(intents, 0x101);
|
||||
break;
|
||||
case R.id.tv_combo://自动连拍:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了自动连拍的按钮 ,");
|
||||
LatLng startLng = new LatLng(LocationLifeCycle.getInstance().getMainLocation().getLatitude(), LocationLifeCycle.getInstance().getMainLocation().getLongitude()); //用户当前位置
|
||||
double geom = GeometryTools.distanceToDouble(startLng, latLng);
|
||||
double rearGeom = GeometryTools.distanceToDouble(startLng, rearLatLng);
|
||||
if (geom > rearGeom) {//用戶在终点开始作业
|
||||
if (rearGeom > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
} else {//用户在起点开始作业
|
||||
if (geom > 5000) {
|
||||
ToastUtils.Message(getActivity(), "用户距离作业终点五公里以内才能拍摄");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Intent intent = new Intent(getActivity(), PicturesActivity.class);
|
||||
File fileJpgPath = AWMp4ParserHelper.getInstance().obtainWebpFilePath(new File(Constant.PICTURE_FOLDER, showPoiEntity.getId()).getAbsolutePath());
|
||||
intent.putExtra(Constant.INTENT_JPG_PATH, fileJpgPath.getAbsolutePath());
|
||||
intent.putExtra(Constant.INTENT_TYPE, showPoiEntity.getType());
|
||||
intent.putExtra(Constant.INTENT_GEO_WKT, showPoiEntity.getGeoWkt());
|
||||
intent.putExtra(Constant.INTENT_DETAIL, showPoiEntity.getDetail());
|
||||
int gpsRss = LocationLifeCycle.getInstance().getTencentLocation().getGPSRssi();
|
||||
if (gpsRss == 0) {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, false);
|
||||
} else {
|
||||
intent.putExtra(Constant.INTENT_BOOLEAN, true);
|
||||
}
|
||||
startActivityForResult(intent, 0x102);
|
||||
break;
|
||||
case R.id.btn_poi_video_upload:
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("点击了上传的按钮 ,");
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
if (poiEntity.getTaskStatus() == 1 || poiEntity.getTaskStatus() == 2 || poiEntity.getTaskStatus() == 0 || poiEntity.getTaskStatus() == 5) {
|
||||
initPoiSaveLocal(true);
|
||||
} else {
|
||||
poiVideoUpload(poiEntity);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void initPoiSaveLocal(boolean isLocal) {
|
||||
if (spnRoadName.getTag() == null) {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(getActivity(), "没有POI名称,无法保存!");
|
||||
return;
|
||||
}
|
||||
XXPermissions.with(getContext())
|
||||
.permission(Permission.MANAGE_EXTERNAL_STORAGE)
|
||||
.request(new OnPermissionCallback() {
|
||||
@Override
|
||||
public void onGranted(List<String> permissions, boolean all) {
|
||||
if (all) {
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
if (poiEntity.getPhoto() == null||poiEntity.getPhoto().isEmpty()) {
|
||||
Toast.makeText(getActivity(), "POI录像任务必须拍照!", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
PoiCheckResult poiCheckResult = checkPoiEntity(poiEntity);
|
||||
if (poiCheckResult.getCode() == 1) {
|
||||
ToastUtils.Message(getActivity(), poiCheckResult.getMsg());
|
||||
return;
|
||||
}
|
||||
poiEntity.setTaskStatus(2);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isLocal) {
|
||||
poiVideoSave(poiEntity);
|
||||
} else {
|
||||
poiVideoSaveNet(poiEntity);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "没有申请权限,请手动申请");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDenied(List<String> permissions, boolean never) {
|
||||
if (never) {
|
||||
ToastUtils.Message(getActivity(), "被永久拒绝授权,请手动授予权限");
|
||||
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
||||
XXPermissions.startPermissionActivity(requireActivity(), permissions);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void poiVideoSaveNet(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(HttpInterface.INSIDE_API_LIST)
|
||||
.cls(PoiVideoBean.class)
|
||||
.params(httpParams)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
if (getActivity() != null) {
|
||||
okGoBuilder.getRequest(PreserveUtils.getInstance().getPoiVideoPreserveCallback(getActivity(), poiEntity));
|
||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务已保存本地,请稍后");
|
||||
WaitDialog.dismiss(1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void poiVideoUpload(PoiEntity poiEntity) {
|
||||
if (poiEntity.getBodyId() == 0) {
|
||||
ToastUtils.Message(getActivity(), "请先保存本地在上传");
|
||||
return;
|
||||
}
|
||||
if (Constant.isPresent) {
|
||||
if (fmPoiVideoPic.getTag() != null) {
|
||||
List<File> videoFileList = (List<File>) fmPoiVideoPic.getTag();
|
||||
boolean existsPic = PoiSaveUtils.getInstance(getActivity()).checkPicExists(videoFileList);
|
||||
if (!existsPic) {
|
||||
ToastUtils.Message(getActivity(), "本地不存在照片文件,无法上传数据,请确认!");
|
||||
return;
|
||||
}
|
||||
DataSaveUtils.getInstance().uploadFiles(getActivity(), showPoiEntity, videoFileList, new DataSaveUtils.UploadCallback() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
dismissLoadingDialog();
|
||||
Constant.isPresent = false;
|
||||
getActivity().getSupportFragmentManager().popBackStack();//回退
|
||||
WaitDialog.show((AppCompatActivity) getActivity(), "任务正在后台上传中,请稍候...");
|
||||
WaitDialog.dismiss(3000);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
Constant.isPresent = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError() {
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
dismissLoadingDialog();
|
||||
ToastUtils.Message(getActivity(), "请录像拍照");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "该任务正在提交中");
|
||||
}
|
||||
}
|
||||
|
||||
private void poiVideoSave(PoiEntity poiEntity) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("geo", poiEntity.getGeoWkt());
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
showLoadingDialog();
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(HttpInterface.INSIDE_API_LIST)
|
||||
.cls(PoiVideoBean.class)
|
||||
.params(httpParams)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
okGoBuilder.getRequest(new Callback<PoiVideoBean>() {
|
||||
@Override
|
||||
public void onSuccess(PoiVideoBean poiVideoBean, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (poiVideoBean.getCode() == 200) {
|
||||
Integer poiVideoBody = poiVideoBean.getBody();
|
||||
if (poiVideoBody != null && poiVideoBody != 0) {
|
||||
poiEntity.setBodyId(poiVideoBody);
|
||||
poiEntity.setTaskStatus(3);
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(getContext(), poiEntity);
|
||||
if (getActivity() != null) {
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
poiVideoUpload(poiEntity);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
|
||||
}
|
||||
} else if (poiVideoBean.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), poiVideoBean.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(), "请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == 0x101 && resultCode == 0x111) {
|
||||
if (data != null && data.hasExtra(Constant.INTENT_PICTURES_PATH)) {
|
||||
String videoPath = data.getStringExtra(Constant.INTENT_PICTURES_PATH);
|
||||
booleanExtra = data.getBooleanExtra(Constant.INTENT_BOOLEAN, true);
|
||||
assert videoPath != null;
|
||||
File videoFile = new File(videoPath);
|
||||
if (videoFile.exists()) {
|
||||
AWMp4ParserHelper.getInstance().loadFirstWithGlide(getActivity(), Uri.fromFile(videoFile).toString(), ivPoiVideoPicture, 500);
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
}
|
||||
|
||||
// 更新当前POI的置信度
|
||||
showPoiEntity.setScore(data.getIntExtra(Constant.INTENT_PICTURES_CREDIBLE, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
initPoiVideoSharePre();
|
||||
}
|
||||
|
||||
/* 防止程序崩溃后数据丢失*/
|
||||
public void initPoiVideoSharePre() {
|
||||
//获取SharedPreferences对象,方法中两个参数的意思为:第一个name
|
||||
//表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
|
||||
//一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
|
||||
//方法注释得知,建议以0或者MODE_PRIVATE为默认值。
|
||||
SharedPreferences poi = requireActivity().getSharedPreferences(Constant.DATA_FILE, 0);
|
||||
//获取Editor对象
|
||||
SharedPreferences.Editor edit = poi.edit();
|
||||
//根据要保存的数据的类型,调用对应的put方法,
|
||||
PoiEntity poiEntity = initPoiEntityByUI(showPoiEntity);
|
||||
String newPoiEntity = new Gson().toJson(poiEntity);
|
||||
//以键值对的形式添加新值。
|
||||
edit.putString("poiEntity", newPoiEntity);
|
||||
edit.putInt("roadVideoType", 1);
|
||||
//提交新值。必须执行,否则前面的操作都无效。
|
||||
edit.apply();
|
||||
Log.d("TAG", "initRoadSharePre: " + newPoiEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onPause ,");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onStop ,");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
if (EventBus.getDefault().isRegistered(this))//加上判断
|
||||
EventBus.getDefault().unregister(this);
|
||||
super.onDestroy();
|
||||
if (markerPoiVideo != null) {
|
||||
markerPoiVideo.remove();
|
||||
}
|
||||
if (poiVideoBuilder != null) {
|
||||
poiVideoBuilder.append(TimestampUtil.time()).append(",").append("onDestroy ");
|
||||
poiVideoBuilder.append("\r\n");
|
||||
FileUtils.writeFile(logFile.getAbsolutePath(), poiVideoBuilder.toString(), true);
|
||||
}
|
||||
}
|
||||
|
||||
private void initEndReceiveTask(String url, PoiEntity poiEntity) {
|
||||
if (poiEntity == null) {
|
||||
ToastUtils.Message(getActivity(), "无此任务");
|
||||
return;
|
||||
}
|
||||
if (poiEntity.getTaskId() == 0) {
|
||||
ToastUtils.Message(getActivity(), "无此任务");
|
||||
return;
|
||||
}
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("taskIds", poiEntity.getTaskId());
|
||||
httpParams.put("auditIds", "");
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
.url(url)
|
||||
.params(httpParams)
|
||||
.cls(UnPolygonTaskBean.class)
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
okGoBuilder.getRequest(new Callback<UnPolygonTaskBean>() {
|
||||
@Override
|
||||
public void onSuccess(UnPolygonTaskBean response, int id) {
|
||||
dismissLoadingDialog();
|
||||
if (response.getCode() == 200) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
|
||||
filePath.delete();
|
||||
}
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.JOB_WORD_MONITOR;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(getActivity());
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
dismissLoadingDialog();
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(getActivity(), "请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiEntity initPoiEntityByUI(PoiEntity poiEntity) {
|
||||
String roadName = spnRoadName.getTag().toString();
|
||||
poiEntity.setName(roadName);
|
||||
// if (!roadName.equals("")) {
|
||||
// poiEntity.setName(roadName);
|
||||
// } else {
|
||||
// @SuppressLint("SimpleDateFormat")
|
||||
// DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH-mm-ss");
|
||||
// Calendar calendars = Calendar.getInstance();
|
||||
// calendars.setTimeInMillis(System.currentTimeMillis());
|
||||
// String formats = formatter.format(calendars.getTime());
|
||||
// String city = Constant.currentLocation.getCity();//返回当前位置的城市.
|
||||
// String district = Constant.currentLocation.getDistrict();//返回当前位置的区县.
|
||||
// StringBuilder sb = new StringBuilder("poi录像上报");
|
||||
// if (city != null && !"".equals(city)) {
|
||||
// sb.append("-");
|
||||
// sb.append(city);
|
||||
// }
|
||||
// if (district != null && !"".equals(district)) {
|
||||
// sb.append(district);
|
||||
// }
|
||||
// sb.append("-").append(formats);
|
||||
// poiEntity.setName(sb.toString());
|
||||
// requireActivity().runOnUiThread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// etRoadName.setText(sb);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
String desc = etDesc.getText().toString().trim();
|
||||
if (!desc.equals("")) {
|
||||
poiEntity.setMemo(desc);
|
||||
}
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(System.currentTimeMillis());
|
||||
String format = formatter.format(calendar.getTime());
|
||||
poiEntity.setCreateTime(format);
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setType(11);
|
||||
if (latLng != null) {
|
||||
String encode = Geohash.getInstance().encode(latLng.latitude, latLng.longitude);
|
||||
poiEntity.setGeoWkt(encode);
|
||||
poiEntity.setX(String.valueOf(latLng.longitude));
|
||||
poiEntity.setY(String.valueOf(latLng.latitude));
|
||||
}
|
||||
if (showPoiEntity.getId() != null) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(showPoiEntity.getId());
|
||||
if (fileListByUUID != null&&!fileListByUUID.isEmpty()) {
|
||||
fmPoiVideoPic.setTag(fileListByUUID);
|
||||
if (booleanExtra) {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getLinePhotoByList(fileListByUUID);
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
List<LatLng> lineStringByFileList = AWMp4ParserHelper.getInstance().getGpsLineByList(fileListByUUID);
|
||||
if (lineStringByFileList != null&&lineStringByFileList.size()>1) {
|
||||
String lineString = Geohash.getInstance().encodeList(lineStringByFileList);
|
||||
if (lineString != null) {
|
||||
poiEntity.setDetail(lineString);
|
||||
}
|
||||
}
|
||||
}
|
||||
// String photoStr = AWMp4ParserHelper.getInstance().getVideoFileListStr(fileListByUUID);
|
||||
poiEntity.setPhoto(fileListByUUID.size()+"");
|
||||
|
||||
}
|
||||
}
|
||||
return poiEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiCheckResult checkPoiEntity(PoiEntity entity) {
|
||||
PoiCheckResult poiCheckResult = new PoiCheckResult();
|
||||
if (entity.getPhoto() == null) {
|
||||
poiCheckResult.setCode(1);
|
||||
poiCheckResult.setMsg("请拍摄");
|
||||
return poiCheckResult;
|
||||
}
|
||||
return poiCheckResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ChargingPileEntity initChargingPileEntityByUI(ChargingPileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PoiCheckResult checkChargingPileEntity(ChargingPileEntity entity) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -92,7 +92,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
|
||||
@Override
|
||||
protected void initData() {
|
||||
super.initData();
|
||||
SharedPreferences sharedPreferences = Objects.requireNonNull(getActivity()).getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences sharedPreferences = requireActivity().getSharedPreferences(Constant.MESSAGE_TYPE, Context.MODE_PRIVATE);
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
@@ -120,6 +120,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
|
||||
showLoadingDialog();
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("pageNum", withPage);
|
||||
httpParams.put("pageSize", 20);
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(getActivity())
|
||||
@@ -163,7 +164,7 @@ public class WithdrawalRecordFragment extends BaseFragment implements View.OnCli
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (v.getId() == R.id.iv_withdraw) {
|
||||
Objects.requireNonNull(getActivity()).finish();
|
||||
requireActivity().finish();
|
||||
withdrawalRecordBuilder.append(TimestampUtil.time()).append("点击了返回,");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
package com.navinfo.outdoor.http;
|
||||
|
||||
public class HttpInterface {
|
||||
// public static final String IP = "http://172.23.138.133:9999/m4";//测试接口-IP
|
||||
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
|
||||
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
|
||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||
// 开发
|
||||
public static final String IP = "http://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/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 MSG_LIST_PATH = "/msgList/";//发现
|
||||
public static final String USER_LOGIN_PATH = "/userlogin/";//登录
|
||||
@@ -57,6 +64,7 @@ public class HttpInterface {
|
||||
public static String EXAM_CONTENT = null;//发现 -能力测评获取试题接口
|
||||
//172.23.139.4:8002/findAndMessage/1/submitExam
|
||||
public static String EXAM_SUBMIT = null;//发现 -能力测评提交试卷 post
|
||||
public static String RECOMMAND_TASK = null;//TreasureFragment获取最新的推荐任务信息 post
|
||||
|
||||
/* 登录
|
||||
* Path=/m4/userlogin/
|
||||
@@ -136,10 +144,12 @@ public class HttpInterface {
|
||||
public static String SUBMIT_POLYGON_TASK = null;//面状任务开始采集
|
||||
//dtxbmaps.navinfo.com/dtxb_test/m4/msgList/InfoPush/28/push?type=0
|
||||
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 ABOUT_MAP = "";//关于 -关于地图寻宝
|
||||
@@ -162,6 +172,7 @@ public class HttpInterface {
|
||||
USER_DETAIL_BY_USER_ID = IP + USER_PATH + "user/" + userId + "/getUserDetailByUserid/" + userId; //获取用户信息
|
||||
//172.21.98.90:9999/m4/user/userGuide/1/insertUserGuide
|
||||
INSERT_USER_GUIDE = IP + USER_PATH + "userGuide/" + userId + "/insertUserGuide";//引导页完成接口
|
||||
RECOMMAND_TASK = IP + USER_PATH + "user/" + userId + "/lastRecommandTask";//获取用户推荐信息
|
||||
|
||||
/* 发现
|
||||
* Path=/m4/msgList/
|
||||
@@ -177,6 +188,7 @@ public class HttpInterface {
|
||||
//172.23.139.4:8002/findAndMessage/1/submitExam
|
||||
EXAM_SUBMIT = IP + MSG_LIST_PATH + "findAndMessage/" + userId + "/submitExam";//发现 -能力测评提交试卷 post
|
||||
MESSAGE_INFO_PUSH = IP + MSG_LIST_PATH + "InfoPush/" + userId + "/push";//寻宝-消息通知
|
||||
MESSAGE_LATEST_PUSH = IP + MSG_LIST_PATH + "UserMessage/" + userId + "/getLatestMessage";//寻宝首页-获取最新推送推荐任务
|
||||
|
||||
/* 提现 金额
|
||||
* Path=/m4/price/
|
||||
@@ -203,34 +215,22 @@ public class HttpInterface {
|
||||
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=测试备注
|
||||
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
|
||||
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
|
||||
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}
|
||||
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
|
||||
RECEIVED_ROAD_TASK = IP + TASK_PATH + "roadtask/" + userId + "/receivedRoadtask";//道路任务获取
|
||||
//172.23.139.4:8003/poivideotask/1/receivedPoivideotask/8569
|
||||
RECEIVED_POI_VIDEO_TASK = IP + TASK_PATH + "poivideotask/" + userId + "/receivedPoivideotask";//poi录像任务获取
|
||||
// 172.23.139.4:8003/poivideotask/1/submitPoivideotask
|
||||
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
|
||||
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
|
||||
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=四维
|
||||
TASK_NAME = IP + TASK_PATH + "task/" + userId + "/taskName";//poi-查重
|
||||
//172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1
|
||||
@@ -242,7 +242,21 @@ public class HttpInterface {
|
||||
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_SPLITE_TASK = IP + TASK_PATH + "task/"+ userId+"/uploadSplitTask";// 执行断点续传
|
||||
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,6 +3,7 @@ package com.navinfo.outdoor.http;
|
||||
import android.app.Activity;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.github.lazylibrary.util.DES;
|
||||
import com.github.lazylibrary.util.MD5;
|
||||
import com.google.gson.Gson;
|
||||
@@ -292,6 +293,13 @@ public class OkGoBuilder<T> {
|
||||
// 请求的 tag, 主要用于取消对应的请求
|
||||
.params(params)
|
||||
.addFileParams("file", files)
|
||||
.uploadInterceptor(new ProgressRequestBody.UploadInterceptor() {
|
||||
@Override
|
||||
public void uploadProgress(Progress progress) {
|
||||
XLog.d(progress.speed);
|
||||
XLog.d(progress.currentSize);
|
||||
}
|
||||
})
|
||||
.tag(this)
|
||||
.execute();
|
||||
} catch (IOException e) {
|
||||
|
||||
@@ -0,0 +1,403 @@
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,9 +22,13 @@ public interface PoiDao {
|
||||
|
||||
@Query("SELECT * FROM poi where taskStatus > 1 and taskStatus!=100 and type!=6 ")
|
||||
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")
|
||||
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")
|
||||
List<PoiEntity> getAllPoiStatus();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.room;
|
||||
|
||||
import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.Database;
|
||||
@@ -9,6 +10,7 @@ import androidx.room.RoomDatabase;
|
||||
import androidx.room.migration.Migration;
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.bean.LocationRecorder;
|
||||
import com.navinfo.outdoor.util.SdkFolderCreate;
|
||||
@@ -28,7 +30,7 @@ import java.io.File;
|
||||
* 如果需要在主线程调用则使用allowMainThreadQueries进行说明。
|
||||
*/
|
||||
|
||||
@Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 3, exportSchema = false)
|
||||
@Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 7, exportSchema = false)
|
||||
public abstract class PoiDatabase extends RoomDatabase {
|
||||
private static final String DB_NAME = "navinfo.db";
|
||||
private static volatile PoiDatabase instance;
|
||||
@@ -52,6 +54,10 @@ public abstract class PoiDatabase extends RoomDatabase {
|
||||
return Room.databaseBuilder(context, PoiDatabase.class, Constant.POI_DAO+"/"+DB_NAME)
|
||||
.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()//数据库更新时删除数据重新创建 改动特别大的时候在用
|
||||
.build();
|
||||
}
|
||||
@@ -80,6 +86,57 @@ public abstract class PoiDatabase extends RoomDatabase {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// 增加POI字段
|
||||
private static Migration migration_3_4 = new Migration(3, 4) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
try {
|
||||
database.execSQL("ALTER TABLE poi ADD COLUMN uploadProgress INTEGER NOT NULL DEFAULT 'null'");//添加了一个上传进度
|
||||
database.execSQL("ALTER TABLE poi ADD COLUMN score INTEGER NOT NULL DEFAULT 'null'");//添加了一个置信度
|
||||
database.execSQL("ALTER TABLE poi ADD COLUMN drawLine TEXT DEFAULT 'null'");//添加了一个用户绘制线型
|
||||
} catch (Exception e) {
|
||||
XLog.e(e.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 增加POI字段
|
||||
private static Migration migration_4_5 = new Migration(4, 5) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
try {
|
||||
database.execSQL("ALTER TABLE poi ADD COLUMN uploadMax INTEGER NOT NULL DEFAULT 'null'");//添加了一个上传总数
|
||||
database.execSQL("ALTER TABLE poi ADD COLUMN uploadResult TEXT DEFAULT 'null'");//添加了一个上传结果
|
||||
} catch (Exception e) {
|
||||
XLog.e(e.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static Migration migration_5_6 = new Migration(5, 6) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||
try {
|
||||
database.execSQL("UPDATE poi set uploadProgress = 0 where uploadProgress = 'null'");
|
||||
database.execSQL("UPDATE poi set score = 0 where score = 'null'");
|
||||
database.execSQL("UPDATE poi set uploadMax = 0 where uploadMax = 'null'");
|
||||
} catch (Exception e) {
|
||||
XLog.e(e.toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
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 ChargingPileDao getChargingPileDao();//充电桩
|
||||
public abstract LocationRecorderDao getRecorderDao();
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package com.navinfo.outdoor.room;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.room.ColumnInfo;
|
||||
import androidx.room.Entity;
|
||||
import androidx.room.Ignore;
|
||||
import androidx.room.PrimaryKey;
|
||||
import androidx.room.TypeConverters;
|
||||
|
||||
@@ -10,6 +12,9 @@ import com.navinfo.outdoor.util.PhotoInfoConverter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -43,13 +48,19 @@ public class PoiEntity implements Serializable {
|
||||
private String detail;//需要保存的数据的wkt
|
||||
private String dist;//距离用户位置
|
||||
private int taskStatus;//任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集).5 立即采集,100 上传成功
|
||||
private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
|
||||
private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" 11-“交通枢纽” 12-“区域设施” 13-“建筑物内部”
|
||||
private int station_type;//1."充电站"2 "充换电站"3 "充电桩组"4 "换电站"5 "门牌", "公交:6 情报:7
|
||||
private int isLocalData;//是否是本地数据 0,服务 1,本地
|
||||
private int isExclusive;//任务类型 0.普通任务,1.专属任务 2挑战任务, 3奖励任务
|
||||
private int bodyId;//保存本地的bodyId
|
||||
private int work_type;//0,待提交 1,提交中
|
||||
private int work_type;//0,待提交 1,提交中 2,已上传
|
||||
private int record_way; //等同于 canReceived : 1是可领取 0是不可领取
|
||||
private int uploadProgress; // 上传进度
|
||||
private int uploadMax; // 上传数据总量-这里一般使用需要上传的文件数量作为总数,因此上传进度为已上传的文件数
|
||||
private int score; // 置信度
|
||||
private String drawLine; // 用户绘制的线型
|
||||
private String uploadResult; //上传结果
|
||||
private String unReceivedTime; // 任务领取后自动释放的时间
|
||||
|
||||
public int getRecord_way() {
|
||||
return record_way;
|
||||
@@ -280,6 +291,71 @@ public class PoiEntity implements Serializable {
|
||||
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
|
||||
public String toString() {
|
||||
return "PoiEntity{" +
|
||||
@@ -300,6 +376,7 @@ public class PoiEntity implements Serializable {
|
||||
", x='" + x + '\'' +
|
||||
", y='" + y + '\'' +
|
||||
", detail='" + detail + '\'' +
|
||||
", unReceivedTime='" + unReceivedTime + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.navinfo.outdoor.ui.view;
|
||||
|
||||
import android.content.Context;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Spinner;
|
||||
|
||||
public class SpinnerUtils {
|
||||
public void initSpinner(Context mContext, Spinner spinner, AdapterView.OnItemSelectedListener selectedListener, String selectItem, String... items) {
|
||||
if (spinner == null) {
|
||||
return;
|
||||
}
|
||||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(mContext, android.R.layout.simple_dropdown_item_1line,
|
||||
android.R.id.text1, items);
|
||||
spinner.setAdapter(adapter);
|
||||
for (int i = 0; i < items.length; i++) {
|
||||
if (items[i]!=null) {
|
||||
if (items[i].equals(selectItem)) {
|
||||
spinner.setSelection(i);
|
||||
spinner.setTag(items[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (selectItem!=null) {
|
||||
// 如果是楼层选项,则被选中要素为“楼层选择”
|
||||
if (items[i].startsWith("楼层选择")&&selectItem.endsWith("层")) {
|
||||
spinner.setSelection(i);
|
||||
spinner.setTag(selectItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 增加监听
|
||||
spinner.setOnItemSelectedListener(selectedListener);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,92 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.app.AlarmManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Looper;
|
||||
import android.os.SystemClock;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
|
||||
public class CrashHandler implements Thread.UncaughtExceptionHandler {
|
||||
|
||||
private static volatile CrashHandler INSTANCE;
|
||||
|
||||
private CrashHandler() {
|
||||
}
|
||||
|
||||
public static CrashHandler getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (CrashHandler.class) {
|
||||
if (INSTANCE == null) {
|
||||
synchronized (CrashHandler.class) {
|
||||
INSTANCE = new CrashHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Thread.UncaughtExceptionHandler mDefaultHandler;
|
||||
|
||||
/**
|
||||
* 初始化默认异常捕获
|
||||
*/
|
||||
public void init() {
|
||||
// 获取默认异常处理器
|
||||
mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
// 将当前类设为默认异常处理器
|
||||
Thread.setDefaultUncaughtExceptionHandler(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
if (handleException(e)) {
|
||||
Toast.makeText(UserApplication.getUserApplication(), "抱歉,出现不可预知错误,请联系工作人员!", Toast.LENGTH_SHORT).show();
|
||||
// 已经处理,APP重启
|
||||
restartApp();
|
||||
} else {
|
||||
// 如果不处理,则调用系统默认处理异常,弹出系统强制关闭的对话框
|
||||
if (mDefaultHandler != null) {
|
||||
mDefaultHandler.uncaughtException(t, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean handleException(Throwable e) {
|
||||
if (e == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Writer writer = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(writer);
|
||||
e.printStackTrace(pw);
|
||||
pw.close();
|
||||
String result = writer.toString();
|
||||
// 打印出错误日志
|
||||
XLog.e(result);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1s后让APP重启
|
||||
*/
|
||||
private void restartApp() {
|
||||
Intent intent = UserApplication.getUserApplication().getPackageManager()
|
||||
.getLaunchIntentForPackage(UserApplication.getUserApplication().getPackageName());
|
||||
PendingIntent restartIntent = PendingIntent.getActivity(UserApplication.getUserApplication(), 0, intent, 0);
|
||||
AlarmManager mgr = (AlarmManager) UserApplication.getUserApplication().getSystemService(Context.ALARM_SERVICE);
|
||||
// 1秒钟后重启应用
|
||||
mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 1000, restartIntent);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,15 @@ package com.navinfo.outdoor.util;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.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;
|
||||
@@ -18,27 +22,38 @@ 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;
|
||||
@@ -59,10 +74,12 @@ 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;
|
||||
}
|
||||
@@ -73,13 +90,17 @@ public class DataSaveUtils {
|
||||
public void onError();
|
||||
}
|
||||
|
||||
public Single<List<Map.Entry<Integer, File>>> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
|
||||
public Single<PoiEntity> getUploadSpliteFilesObservble(Activity mContext, PoiEntity poiEntity, List<File> poiPicList) {
|
||||
poiEntity.setUploadResult("");
|
||||
int auditId = poiEntity.getBodyId();
|
||||
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);
|
||||
}
|
||||
@@ -94,12 +115,25 @@ public class DataSaveUtils {
|
||||
.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, Constant.DEFAULT_CUT_SIZE);
|
||||
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
|
||||
@@ -108,11 +142,15 @@ public class DataSaveUtils {
|
||||
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()) {
|
||||
if (body.isEmpty()) { // 服务返回空数据,说明该数据的所有分包数据都上传完成,没有需要上传的分包了
|
||||
poiEntity.setUploadProgress(splitFiles.size()); // 上传进度为当前文件个数
|
||||
sendRefreshItem(poiEntity);
|
||||
return new HashMap<>();
|
||||
}
|
||||
String[] needUploadStrIndex = body.split(",");
|
||||
@@ -121,6 +159,8 @@ public class DataSaveUtils {
|
||||
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) {
|
||||
@@ -153,8 +193,12 @@ public class DataSaveUtils {
|
||||
// 执行上传流程
|
||||
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()) {
|
||||
@@ -171,39 +215,51 @@ public class DataSaveUtils {
|
||||
@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.exists()) {
|
||||
zipFile.delete();
|
||||
}
|
||||
if (poiPicList!=null&&!poiPicList.isEmpty()) {
|
||||
for (File picFile: poiPicList
|
||||
) {
|
||||
picFile.delete();
|
||||
}
|
||||
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)
|
||||
getUploadSpliteFilesObservble(mContext ,poiEntity, poiPicList)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new SingleObserver<List<Map.Entry<Integer, File>>>() {
|
||||
.subscribe(new SingleObserver<PoiEntity>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
callback.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<Map.Entry<Integer, File>> entries) {
|
||||
public void onSuccess(PoiEntity poiEntity) {
|
||||
ToastUtils.Message(mContext, "分包数据上传完成!");
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||
@@ -248,6 +304,16 @@ public class DataSaveUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* EventBus通知列表当前的上传进度
|
||||
* */
|
||||
private void sendRefreshItem(PoiEntity poiEntity) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constant.EVENT_WHAT_UPLOAD_PROGRESS;
|
||||
msg.obj = poiEntity;
|
||||
EventBus.getDefault().post(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传分包数据
|
||||
* */
|
||||
@@ -349,4 +415,72 @@ public class DataSaveUtils {
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private List<File> filterCorruptImages(List<File> files) {
|
||||
List<File> corruptImage = new ArrayList<>();
|
||||
Iterator<File> iterator = files.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
File file = iterator.next();
|
||||
if (file.getName().endsWith(".json")||file.getName().endsWith(".txt")) {
|
||||
continue;
|
||||
}
|
||||
if (file.length()==0) {
|
||||
corruptImage.add(file);
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
Bitmap bitmap = BitmapFactory.decodeFile(file.getPath());
|
||||
if (bitmap == null) {
|
||||
corruptImage.add(file);
|
||||
iterator.remove();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
corruptImage.add(file);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
return corruptImage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查道路POI的照片数据,轨迹与道路任务长度比率必须大于0.1
|
||||
* */
|
||||
public static void checkRoadPoiPicture(PoiEntity poiEntity, List<File> fileList, RoadPercentCheckCallback callback) {
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
double lengthPercent = 0.0;
|
||||
// 获取任务数据长度
|
||||
String geoWkt = poiEntity.getGeoWkt();
|
||||
if (geoWkt!=null) {
|
||||
String geoDecode = Geohash.getInstance().decode(geoWkt);
|
||||
Geometry originGeometry = GeometryTools.createGeometry(geoDecode);
|
||||
|
||||
// 获取轨迹对应的geometry
|
||||
if (fileList!=null&&!fileList.isEmpty()) {
|
||||
File txtFile = new File(fileList.get(0).getParentFile(), "paper.txt");
|
||||
// 读取第一条数据和最后一条数据,获取时间,然后根据数据查询轨迹数据
|
||||
List<String> txtStringList = FileUtils.readFileToList(txtFile.getAbsolutePath(), "utf-8");
|
||||
// 读取位置信息
|
||||
List<LatLng> latLngList = new ArrayList<>(txtStringList.size());
|
||||
for (String line: txtStringList) {
|
||||
String[] itemArray = line.split(",");
|
||||
// 获取数据的经纬度
|
||||
latLngList.add(new LatLng(Double.parseDouble(itemArray[2]), Double.parseDouble(itemArray[3])));
|
||||
}
|
||||
// 构建轨迹的geometry
|
||||
LineString trackLine = GeometryTools.getLineStainGeo(latLngList);
|
||||
lengthPercent = trackLine.getLength()/originGeometry.getLength();
|
||||
}
|
||||
}
|
||||
callback.callback(lengthPercent);
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
public interface RoadPercentCheckCallback{
|
||||
void callback(double percent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import java.lang.Exception
|
||||
object FileSpliteMergeUtils {
|
||||
const val TAG = "FileUtils"
|
||||
//默认切割文件的大小
|
||||
// private const val DEFAULT_CUT_SIZE: Long = 5*1024*1024//5MB
|
||||
private const val DEFAULT_CUT_SIZE: Long = Constant.DEFAULT_CUT_SIZE//5MB
|
||||
|
||||
/**
|
||||
@@ -70,6 +69,32 @@ object FileSpliteMergeUtils {
|
||||
}
|
||||
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(".")
|
||||
@@ -90,18 +115,18 @@ object FileSpliteMergeUtils {
|
||||
val out = RandomAccessFile(single,"rw")
|
||||
var index = 0
|
||||
try {
|
||||
val byte = ByteArray(1024)
|
||||
val byte = ByteArray((end-begin).toInt())
|
||||
inFile.seek(begin)
|
||||
while (inFile.read(byte).also { index = it } != -1 && inFile.filePointer <= end){
|
||||
while (inFile.read(byte).also { index = it } != -1&&inFile.filePointer <= end){
|
||||
out.write(byte,0,index)
|
||||
endPointer = inFile.filePointer
|
||||
}
|
||||
endPointer = inFile.filePointer
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
}finally {
|
||||
out.close()
|
||||
}
|
||||
return endPointer - index // 减去最后一次读取的字节数,因为while循环中会先读取文件,导致filePointer字段向后移动index,但是后面的判断条件导致循环跳出,所以要将下次读取的offset向前移动
|
||||
return endPointer
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,18 +14,31 @@ import android.location.Location;
|
||||
import android.location.LocationListener;
|
||||
import android.location.LocationManager;
|
||||
import android.location.LocationProvider;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
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.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressLint("MissingPermission")
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public class GPSUtils {
|
||||
|
||||
private LocationManager mLocationManager;
|
||||
@@ -34,35 +47,50 @@ public class GPSUtils {
|
||||
|
||||
private Location mLocation = null;
|
||||
|
||||
private Activity mContext;
|
||||
private Context mContext;
|
||||
|
||||
public GPSUtils(Activity context) {
|
||||
private static GPSUtils instance;
|
||||
|
||||
private int sateliteCount; // 卫星颗数
|
||||
|
||||
public static GPSUtils getInstance(Context mContext) {
|
||||
if (instance == null) {
|
||||
instance = new GPSUtils(mContext);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private GPSUtils(Context context) {
|
||||
this.mContext = context;
|
||||
mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
|
||||
|
||||
// 判断GPS是否正常启动
|
||||
if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
|
||||
ToastUtils.Message(context,"请开启GPS导航...");
|
||||
// 返回开启GPS导航设置界面
|
||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
|
||||
context.startActivityForResult(intent, 0);
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(context, "请开启GPS导航...");
|
||||
Map<String, String> mapData = new HashMap<>();
|
||||
mapData.put("code", "101");
|
||||
EventBus.getDefault().post(mapData);
|
||||
return;
|
||||
}
|
||||
// 为获取地理位置信息时设置查询条件
|
||||
String bestProvider = mLocationManager.getBestProvider(getCriteria(), true);
|
||||
// 获取位置信息
|
||||
// 如果不设置查询要求,getLastKnownLocation方法传人的参数为LocationManager.GPS_PROVIDER
|
||||
if (bestProvider!=null) {
|
||||
// 获取位置信息
|
||||
// 如果不设置查询要求,getLastKnownLocation方法传人的参数为LocationManager.GPS_PROVIDER
|
||||
// getLocationData(location);
|
||||
mLocation = mLocationManager.getLastKnownLocation(bestProvider);
|
||||
// 监听状态
|
||||
mLocationManager.registerGnssStatusCallback(listener);
|
||||
mLocation = mLocationManager.getLastKnownLocation(bestProvider);
|
||||
// 监听状态
|
||||
mLocationManager.registerGnssStatusCallback(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public void startLocation() {
|
||||
// 绑定监听,有4个参数
|
||||
// 参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种
|
||||
// 参数2,位置信息更新周期,单位毫秒
|
||||
// 参数3,位置变化最小距离:当位置距离变化超过此值时,将更新位置信息
|
||||
// 参数4,监听
|
||||
// 备注:参数2和3,如果参数3不为0,则以参数3为准;参数3为0,则通过时间来定时更新;两者为0,则随时刷新
|
||||
|
||||
// 1秒更新一次,或最小位移变化超过1米更新一次;
|
||||
// 注意:此处更新准确度非常低,推荐在service里面启动一个Thread,在run中sleep(10000);然后执行handler.sendMessage(),更新位置
|
||||
mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locationListener);
|
||||
@@ -76,15 +104,15 @@ public class GPSUtils {
|
||||
// 设置定位精确度 Criteria.ACCURACY_COARSE比较粗略,Criteria.ACCURACY_FINE则比较精细
|
||||
criteria.setAccuracy(Criteria.ACCURACY_FINE);
|
||||
// 设置是否要求速度
|
||||
criteria.setSpeedRequired(false);
|
||||
criteria.setSpeedRequired(true);
|
||||
// 设置是否允许运营商收费
|
||||
criteria.setCostAllowed(false);
|
||||
criteria.setCostAllowed(true);
|
||||
// 设置是否需要方位信息
|
||||
criteria.setBearingRequired(false);
|
||||
criteria.setBearingRequired(true);
|
||||
// 设置是否需要海拔信息
|
||||
criteria.setAltitudeRequired(false);
|
||||
criteria.setAltitudeRequired(true);
|
||||
// 设置对电源的需求
|
||||
criteria.setPowerRequirement(Criteria.POWER_LOW);
|
||||
criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
|
||||
return criteria;
|
||||
}
|
||||
|
||||
@@ -137,11 +165,22 @@ public class GPSUtils {
|
||||
mLocationManager.removeUpdates(this);
|
||||
return;
|
||||
}
|
||||
double[] gpsLatLng = Gps.toGCJ02Point(location.getLatitude(), location.getLongitude());
|
||||
location.setLatitude(gpsLatLng[0]);
|
||||
location.setLongitude(gpsLatLng[1]);
|
||||
mLocation = location;
|
||||
Log.i(TAG, "时间:" + location.getTime());
|
||||
Log.i(TAG, "经度:" + location.getLongitude());
|
||||
Log.i(TAG, "纬度:" + location.getLatitude());
|
||||
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状态变化时触发
|
||||
@@ -217,19 +256,16 @@ public class GPSUtils {
|
||||
return;
|
||||
}
|
||||
Log.i(TAG, "卫星状态改变");
|
||||
if (onClickGPSStatus != null) {
|
||||
onClickGPSStatus.onGpsCount(status.getSatelliteCount());
|
||||
if (status != null) {
|
||||
sateliteCount = status.getSatelliteCount();
|
||||
} else {
|
||||
sateliteCount = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
public OnClickGPSStatus onClickGPSStatus;
|
||||
|
||||
public void setOnClickGPSStatus(OnClickGPSStatus onClickGPSStatus) {
|
||||
this.onClickGPSStatus = onClickGPSStatus;
|
||||
}
|
||||
|
||||
public interface OnClickGPSStatus {
|
||||
void onGpsCount(int count);
|
||||
public int getSateliteCount() {
|
||||
return sateliteCount;
|
||||
}
|
||||
|
||||
public void unRegisterAllListener() {
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationLifeCycle implements DefaultLifecycleObserver {
|
||||
private Context mContext;
|
||||
private LOCATION_FROM mainLocationFrom = LOCATION_FROM.TENCENT/*主要位置源*/, referenceLocationFrom = LOCATION_FROM.ORIGIN/*参考位置源*/;
|
||||
private TencentLocation tencentLocation; // 腾讯定位获取到的最新位置信息
|
||||
private TencentLocation gpsLocation; // 原生系统获取到的最新位置
|
||||
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
|
||||
private static LocationLifeCycle instance;
|
||||
|
||||
public static LocationLifeCycle getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new LocationLifeCycle();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void init(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(@NonNull LifecycleOwner owner) {
|
||||
DefaultLifecycleObserver.super.onCreate(owner);
|
||||
if (!EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
startTencentLocation();
|
||||
}
|
||||
|
||||
public void startTencentLocation() {
|
||||
// 开启腾讯定位
|
||||
if (!TalentLocationUtils.getInstance(mContext).isLocationStart()) {
|
||||
TalentLocationUtils.getInstance(mContext).startLocation(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
public void stopTencentLocation() {
|
||||
// 停止腾讯定位
|
||||
TalentLocationUtils.getInstance(mContext).stopLocation();
|
||||
}
|
||||
|
||||
public void startGPSLocation() {
|
||||
GPSUtils.getInstance(mContext).startLocation();
|
||||
}
|
||||
|
||||
public void stopGPSLocation() {
|
||||
GPSUtils.getInstance(mContext).startLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy(@NonNull LifecycleOwner owner) {
|
||||
DefaultLifecycleObserver.super.onDestroy(owner);
|
||||
locationChangedListenerList.clear();
|
||||
locationChangedListenerList = null;
|
||||
stopTencentLocation();
|
||||
GPSUtils.getInstance(mContext).unRegisterAllListener();
|
||||
if (EventBus.getDefault().isRegistered(this)) {
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onEventMessageMainThread(Message msg) {
|
||||
if (msg.what == Constant.EVENT_WHAT_LOCATION_CHANGE) { // 用户位置更新
|
||||
if (msg.arg1 == LOCATION_FROM.ORIGIN.ordinal()) {
|
||||
gpsLocation = (TencentLocation) msg.obj;
|
||||
if (msg.arg1 == mainLocationFrom.ordinal()) { // 如果当前定位方式是主要定位方式
|
||||
MyLocation location = new MyLocation(gpsLocation.getProvider(), gpsLocation);
|
||||
//设置经纬度以及精度
|
||||
location.setLatitude(gpsLocation.getLatitude());
|
||||
location.setLongitude(gpsLocation.getLongitude());
|
||||
if (gpsLocation.getBearing()!=0) {
|
||||
location.setBearing(gpsLocation.getBearing());
|
||||
} else {
|
||||
location.setBearing((float) gpsLocation.getDirection());
|
||||
}
|
||||
location.setAccuracy(gpsLocation.getAccuracy());
|
||||
if (locationChangedListenerList!=null) {
|
||||
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (msg.arg1 == LOCATION_FROM.TENCENT.ordinal()) {
|
||||
tencentLocation = (TencentLocation) msg.obj;
|
||||
// Log.d("LocationLifeCycle",
|
||||
// "isMockGps:"+tencentLocation.isMockGps()
|
||||
// +",FakeReason:"+tencentLocation.getFakeReason()
|
||||
// +"Provider:"+tencentLocation.getProvider()
|
||||
// +"SourceProvider:"+tencentLocation.getSourceProvider()+tencentLocation.getGpsQuality());
|
||||
if (msg.arg1 == mainLocationFrom.ordinal()) { // 如果当前定位方式是主要定位方式
|
||||
MyLocation location = new MyLocation(tencentLocation.getProvider(), tencentLocation);
|
||||
//设置经纬度以及精度
|
||||
location.setLatitude(tencentLocation.getLatitude());
|
||||
location.setLongitude(tencentLocation.getLongitude());
|
||||
if (tencentLocation.getBearing()!=0) {
|
||||
location.setBearing(tencentLocation.getBearing());
|
||||
} else {
|
||||
location.setBearing((float) tencentLocation.getDirection());
|
||||
}
|
||||
location.setAccuracy(tencentLocation.getAccuracy());
|
||||
if (locationChangedListenerList!=null) {
|
||||
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<LocationSource.OnLocationChangedListener> getLocationChangedListenerList() {
|
||||
if (locationChangedListenerList == null) {
|
||||
locationChangedListenerList = new ArrayList<>();
|
||||
}
|
||||
return locationChangedListenerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置主要可用的定位来源
|
||||
* */
|
||||
public void setMainLocationFrom(LOCATION_FROM mainLocationFrom) {
|
||||
this.mainLocationFrom = mainLocationFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置次要可用的定位来源
|
||||
* */
|
||||
public void setReferenceLocationFrom(LOCATION_FROM referenceLocationFrom) {
|
||||
this.referenceLocationFrom = referenceLocationFrom;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取主要位置信息
|
||||
* */
|
||||
public MyLocation getMainLocation() {
|
||||
switch (mainLocationFrom) {
|
||||
case ORIGIN:
|
||||
if (gpsLocation!=null) {
|
||||
return new MyLocation(gpsLocation.getProvider(), gpsLocation);
|
||||
}
|
||||
break;
|
||||
case TENCENT:
|
||||
if (tencentLocation!=null) {
|
||||
return new MyLocation(tencentLocation.getProvider(), tencentLocation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取参考位置信息
|
||||
* */
|
||||
|
||||
/**
|
||||
* 获取主要位置信息
|
||||
* */
|
||||
public MyLocation getReferenceLocation() {
|
||||
switch (referenceLocationFrom) {
|
||||
case ORIGIN:
|
||||
if (gpsLocation!=null) {
|
||||
return new MyLocation(gpsLocation.getProvider(), gpsLocation);
|
||||
}
|
||||
break;
|
||||
case TENCENT:
|
||||
if (tencentLocation!=null) {
|
||||
return new MyLocation(tencentLocation.getProvider(), tencentLocation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum LOCATION_FROM {
|
||||
ORIGIN, TENCENT, SIMULATOR/*模拟定位*/, BAIDU, AMAP
|
||||
}
|
||||
|
||||
public TencentLocation getTencentLocation() {
|
||||
return tencentLocation;
|
||||
}
|
||||
|
||||
private boolean checkInit() throws Exception {
|
||||
if (this.mContext == null) {
|
||||
throw new Exception("LocationLifeCycle 没有初始化!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.location.Address;
|
||||
import android.location.Geocoder;
|
||||
import android.location.Location;
|
||||
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class MyLocation extends Location {
|
||||
private String city;
|
||||
private String cityCode;
|
||||
private String cityPhoneCode;
|
||||
|
||||
public MyLocation(String provider, TencentLocation tencentLocation) {
|
||||
super(provider);
|
||||
this.city = tencentLocation.getCity();
|
||||
this.cityCode = tencentLocation.getCityCode();
|
||||
this.cityPhoneCode = tencentLocation.getCityPhoneCode();
|
||||
this.setAccuracy(tencentLocation.getAccuracy());
|
||||
this.setAltitude(tencentLocation.getAltitude());
|
||||
if (tencentLocation.getBearing()!=0) {
|
||||
this.setBearing(tencentLocation.getBearing());
|
||||
} else {
|
||||
this.setBearing((float) tencentLocation.getDirection());
|
||||
}
|
||||
this.setElapsedRealtimeNanos(tencentLocation.getElapsedRealtime());
|
||||
this.setLatitude(tencentLocation.getLatitude());
|
||||
this.setLongitude(tencentLocation.getLongitude());
|
||||
this.setSpeed(tencentLocation.getSpeed());
|
||||
this.setTime(tencentLocation.getTime());
|
||||
}
|
||||
|
||||
public MyLocation(String provider, Location location) {
|
||||
super(location);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.content.Context;
|
||||
import android.location.Location;
|
||||
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.tencentmap.mapsdk.maps.LocationSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyLocationObserve{
|
||||
public MyLocationObserve instance;
|
||||
private LOCATION_FROM currentLocationFrom = LOCATION_FROM.ORIGIN; // 当前正在启用的定位系统
|
||||
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
|
||||
private Location currentUseLocation; // 当前正在使用的location信息
|
||||
|
||||
public MyLocationObserve() {
|
||||
locationChangedListenerList = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void init(Context mContext) {
|
||||
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
public MyLocationObserve getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new MyLocationObserve();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public enum LOCATION_FROM {
|
||||
ORIGIN, TENCENT, BAIDU, AMAP
|
||||
}
|
||||
|
||||
public void onLocationChangeListener(LOCATION_FROM from, Location location) {
|
||||
if (from == currentLocationFrom) {
|
||||
if (currentUseLocation == null) {
|
||||
currentUseLocation = location;
|
||||
} else {
|
||||
currentUseLocation.set(location);
|
||||
}
|
||||
for (LocationSource.OnLocationChangedListener locationChangedListener: locationChangedListenerList
|
||||
) {
|
||||
locationChangedListener.onLocationChanged(currentUseLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,13 +20,13 @@ public class MyTecentLocationSource implements LocationSource{
|
||||
@Override
|
||||
public void activate(OnLocationChangedListener onLocationChangedListener) {
|
||||
locationChangedListener = onLocationChangedListener;
|
||||
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().add(onLocationChangedListener);
|
||||
LocationLifeCycle.getInstance().getLocationChangedListenerList().add(onLocationChangedListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deactivate() {
|
||||
if (locationChangedListener!=null) {
|
||||
TalentLocationUtils.getInstance(mContext).getLocationChangedListenerList().remove(locationChangedListener);
|
||||
LocationLifeCycle.getInstance().getLocationChangedListenerList().remove(locationChangedListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.kongzue.dialog.v3.CustomDialog;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.NaviCarActivity;
|
||||
@@ -62,6 +63,7 @@ public class NaviUtils {
|
||||
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();
|
||||
@@ -125,7 +127,9 @@ public class NaviUtils {
|
||||
public TencentNaviManager obitainnaviManager(Activity mContext, Constant.NAV_TYPE nav_type, NaviView naviView) {
|
||||
if (nav_type == Constant.NAV_TYPE.CAR) { // 驾车
|
||||
CarNaviView carNaviView = (CarNaviView) naviView;
|
||||
naviManager = new TencentCarNaviManager(mContext);
|
||||
if (naviManager==null||!naviManager.isNavigating()) {
|
||||
naviManager = new TencentCarNaviManager(mContext);
|
||||
}
|
||||
carNaviView.setVisibility(View.VISIBLE);
|
||||
naviManager.addNaviView(carNaviView);
|
||||
CarNaviInfoPanel carNaviInfoPanel = carNaviView.showNaviInfoPanel();
|
||||
@@ -145,19 +149,22 @@ public class NaviUtils {
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
NaviTts naviTts = new NaviTts();
|
||||
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
|
||||
@@ -172,22 +179,22 @@ public class NaviUtils {
|
||||
|
||||
@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
|
||||
@@ -232,7 +239,9 @@ public class NaviUtils {
|
||||
});
|
||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行
|
||||
RideNaviView rideNaviView = (RideNaviView) naviView;
|
||||
naviManager = new TencentRideNaviManager(mContext);
|
||||
if (naviManager==null||!naviManager.isNavigating()) {
|
||||
naviManager = new TencentRideNaviManager(mContext);
|
||||
}
|
||||
rideNaviView.setVisibility(View.VISIBLE);
|
||||
((TencentRideNaviManager)naviManager).addTencentNaviListener(rideNaviView);
|
||||
CarNaviInfoPanel carNaviInfoPanel = rideNaviView.showNaviInfoPanel();
|
||||
@@ -247,7 +256,9 @@ public class NaviUtils {
|
||||
((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
|
||||
@@ -262,14 +273,21 @@ public class NaviUtils {
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
NaviTts naviTts = new NaviTts();
|
||||
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
|
||||
@@ -324,7 +342,9 @@ public class NaviUtils {
|
||||
});
|
||||
} else {
|
||||
WalkNaviView walkNaviView = (WalkNaviView) naviView;
|
||||
naviManager = new TencentRideNaviManager(mContext);
|
||||
if (naviManager==null||!naviManager.isNavigating()) {
|
||||
naviManager = new TencentWalkNaviManager(mContext);
|
||||
}
|
||||
walkNaviView.setVisibility(View.VISIBLE);
|
||||
((TencentWalkNaviManager)naviManager).addTencentNaviListener(walkNaviView);
|
||||
CarNaviInfoPanel carNaviInfoPanel = walkNaviView.showNaviInfoPanel();
|
||||
@@ -339,7 +359,10 @@ public class NaviUtils {
|
||||
((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
|
||||
@@ -354,14 +377,21 @@ public class NaviUtils {
|
||||
|
||||
@Override
|
||||
public void onStopNavi() {
|
||||
NaviTts naviTts = new NaviTts();
|
||||
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
|
||||
@@ -386,6 +416,7 @@ public class NaviUtils {
|
||||
|
||||
@Override
|
||||
public void onUpdateNavigationData(NavigationData navigationData) {
|
||||
XLog.d("Walk更新导航信息");
|
||||
|
||||
}
|
||||
|
||||
@@ -406,7 +437,7 @@ public class NaviUtils {
|
||||
|
||||
@Override
|
||||
public void onUpdateCurrentRoute(RouteData routeData) {
|
||||
|
||||
XLog.d("Walk更新当前route信息", "currentLocDistance:"+LocationLifeCycle.getInstance().getTencentLocation()+","+routeData.getRoutePoints().get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -415,12 +446,8 @@ public class NaviUtils {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (tencentMap == null) {
|
||||
tencentMap = naviView.getMap();
|
||||
}
|
||||
if (this.mContext == null) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
this.tencentMap = naviView.getMap();
|
||||
this.mContext = mContext;
|
||||
|
||||
// 开启语音播报
|
||||
naviManager.setInternalTtsEnabled(true);
|
||||
@@ -432,22 +459,46 @@ public class NaviUtils {
|
||||
/**
|
||||
* 获取路径规划
|
||||
* */
|
||||
// private NaviPoi currentStart, currentEnd;
|
||||
// private Constant.NAV_TYPE currentNaviType;
|
||||
public void searchRoute(Constant.NAV_TYPE nav_type, TencentNaviManager naviManager,
|
||||
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();
|
||||
carNaviManager.searchRoute(start, end, new ArrayList<>(), options, routeSearchCallback);
|
||||
NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude());
|
||||
carNaviManager.searchRoute(newStart, end, new ArrayList<>(), options, routeSearchCallback);
|
||||
} else if (nav_type == Constant.NAV_TYPE.RIDE) { // 骑行模式
|
||||
TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager;
|
||||
RideRouteSearchOptions options = RideRouteSearchOptions.create();
|
||||
rideNaviManager.searchRoute(start, end, options, routeSearchCallback);
|
||||
} else { // 步行模式
|
||||
TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager;
|
||||
walkNaviManager.searchRoute(start, end, routeSearchCallback);
|
||||
NaviPoi newStart = new NaviPoi(start.getLatitude(), start.getLongitude());
|
||||
walkNaviManager.searchRoute(newStart, end, routeSearchCallback);
|
||||
}
|
||||
}
|
||||
|
||||
// public void reSearchRoute(TencentNaviManager naviManager,
|
||||
// NaviPoi start) throws Exception {
|
||||
// currentStart = start;
|
||||
// if (currentNaviType == Constant.NAV_TYPE.CAR) { // 驾车模式
|
||||
// TencentCarNaviManager carNaviManager = (TencentCarNaviManager)naviManager;
|
||||
// CarRouteSearchOptions options = CarRouteSearchOptions.create();
|
||||
// carNaviManager.searchRoute(start, currentEnd, new ArrayList<>(), options, routeSearchCallback);
|
||||
// } else if (currentNaviType == Constant.NAV_TYPE.RIDE) { // 骑行模式
|
||||
// TencentRideNaviManager rideNaviManager = (TencentRideNaviManager)naviManager;
|
||||
// RideRouteSearchOptions options = RideRouteSearchOptions.create();
|
||||
// rideNaviManager.searchRoute(start, currentEnd, options, routeSearchCallback);
|
||||
// } else { // 步行模式
|
||||
// TencentWalkNaviManager walkNaviManager = (TencentWalkNaviManager) naviManager;
|
||||
// walkNaviManager.searchRoute(start, currentEnd, routeSearchCallback);
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* 仅进行路径规划,无需导航
|
||||
* */
|
||||
@@ -471,6 +522,7 @@ public class NaviUtils {
|
||||
/**
|
||||
* 算路回调
|
||||
*/
|
||||
private Polyline currentRouteLine; // 当前绘制的道路线
|
||||
private TencentRouteSearchCallback routeSearchCallback = new TencentRouteSearchCallback() {
|
||||
@Override
|
||||
public void onRouteSearchFailure(int i, String s) {
|
||||
@@ -481,19 +533,25 @@ public class NaviUtils {
|
||||
@Override
|
||||
public void onRouteSearchSuccess(ArrayList<RouteData> arrayList) {
|
||||
// 添加道路Route到地图,默认选取第一条
|
||||
addRoutes(arrayList.get(0), tencentMap);
|
||||
currentRouteLine = addRoutes(arrayList.get(0), tencentMap);
|
||||
zoomToRoute(mContext, arrayList.get(0), tencentMap);
|
||||
try {
|
||||
// 自动开始导航
|
||||
if (Constant.currentNaviType == Constant.NAV_TYPE.CAR) {
|
||||
((TencentCarNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentCarNaviManager)naviManager).startSimulateNavi(0);
|
||||
if (!((TencentCarNaviManager)naviManager).isNavigating()) {
|
||||
((TencentCarNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentCarNaviManager)naviManager).startSimulateNavi(0);
|
||||
}
|
||||
} else if (Constant.currentNaviType == Constant.NAV_TYPE.RIDE) {
|
||||
((TencentRideNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentRideNaviManager)naviManager).startSimulateNavi(0);
|
||||
if (!((TencentRideNaviManager)naviManager).isNavigating()) {
|
||||
((TencentRideNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentRideNaviManager)naviManager).startSimulateNavi(0);
|
||||
}
|
||||
} else {
|
||||
((TencentWalkNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0);
|
||||
if (!((TencentWalkNaviManager)naviManager).isNavigating()) {
|
||||
((TencentWalkNaviManager)naviManager).startNavi(0);
|
||||
// ((TencentWalkNaviManager)naviManager).startSimulateNavi(0);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -544,6 +602,10 @@ public class NaviUtils {
|
||||
}
|
||||
|
||||
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();
|
||||
// 点的个数
|
||||
@@ -661,7 +723,7 @@ public class NaviUtils {
|
||||
* 开始路径规划
|
||||
* */
|
||||
public void startNav(Activity mContext, LatLng startLatlng, LatLng endLatlng) {
|
||||
if (Constant.currentLocation == null) {
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() == null) {
|
||||
ToastUtils.Message(mContext, "无法获取当前位置,请检查是否授权应用获取位置权限!");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import com.elvishew.xlog.XLog
|
||||
import com.github.lazylibrary.util.FileUtils
|
||||
import com.github.lazylibrary.util.PreferencesUtils
|
||||
import com.google.gson.Gson
|
||||
import com.lzy.okgo.model.HttpParams
|
||||
import com.navinfo.ocr.OCRManager.Companion.instance
|
||||
import com.navinfo.ocr.model.OcrViewResultModel
|
||||
import com.navinfo.outdoor.api.Constant
|
||||
import com.navinfo.outdoor.bean.TaskNameBean
|
||||
import com.navinfo.outdoor.http.Callback
|
||||
import com.navinfo.outdoor.http.HttpInterface
|
||||
import com.navinfo.outdoor.http.OkGoBuilder
|
||||
import com.otaliastudios.cameraview.PictureResult
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 照片辅助检查工具类
|
||||
* */
|
||||
class PictureCheckHelper(val context: Context, val checkFile: File) {
|
||||
var checkResult = CheckResult()
|
||||
val gson = Gson()
|
||||
private val sensorDegree by lazy { PreferencesUtils.getString(context, "sensorDegree", "45").toInt()}
|
||||
private val poiMinSpeed by lazy { PreferencesUtils.getString(context, "poiMinSpeed", "5").toDouble() }
|
||||
private val poiMaxSpeed by lazy { PreferencesUtils.getString(context, "poiMaxSpeed", "30").toDouble() }
|
||||
private val roadMinSpeed by lazy { PreferencesUtils.getString(context, "roadMinSpeed", "20").toDouble() }
|
||||
private val roadMaxSpeed by lazy { PreferencesUtils.getString(context, "roadMaxSpeed", "120").toDouble() }
|
||||
private val satelliteCount by lazy { PreferencesUtils.getString(context, "satelliteCount", "15").toInt() }
|
||||
private val nameSet: MutableSet<String> = mutableSetOf()
|
||||
|
||||
init {
|
||||
// 初始化时读取已有文件,如果存在按照文件内容初始化数据
|
||||
if (checkFile!=null&&checkFile.exists()) {
|
||||
val checkResultStr = FileUtils.readFileContent(checkFile.absolutePath)
|
||||
checkResult = gson.fromJson(checkResultStr, CheckResult::class.java)
|
||||
}
|
||||
}
|
||||
|
||||
fun addocrCheck(result: Boolean) {
|
||||
if (result) checkResult.ocrChecked++
|
||||
checkResult.ocrCount++
|
||||
}
|
||||
|
||||
fun addAngleCheck(result: Boolean) {
|
||||
if (result) checkResult.angleChecked++
|
||||
checkResult.angleCount++
|
||||
}
|
||||
|
||||
fun addNearestCheck(result: Boolean) {
|
||||
if (result) checkResult.nearestChecked++
|
||||
checkResult.nearestCount++
|
||||
}
|
||||
|
||||
fun addSpeedCheck(result: Boolean) {
|
||||
if (result) checkResult.speedChecked++
|
||||
checkResult.speedCount++
|
||||
}
|
||||
|
||||
fun setMockLocationCheck(result: Boolean) { // 只要检查到模拟信号,该数据的模拟信号值就为true
|
||||
if (result and !checkResult.mockLocationChecker) {
|
||||
checkResult.mockLocationChecker = true
|
||||
}
|
||||
}
|
||||
|
||||
fun setAutoTakeCheck(result: Boolean) { // 只要是自动捕捉,设置该值为自动捕捉值就是true
|
||||
if (result and !checkResult.autoTakeChecker) {
|
||||
checkResult.autoTakeChecker = true
|
||||
}
|
||||
}
|
||||
|
||||
fun addSatelliteCheck(result: Boolean) {
|
||||
if (result) checkResult.satelliteChecked++
|
||||
checkResult.satelliteCount++
|
||||
}
|
||||
|
||||
fun addGpsRssiCheck(result: Int) {
|
||||
checkResult.gpsRssiChecked=checkResult.gpsRssiChecked+result
|
||||
checkResult.gpsRssiCount=checkResult.gpsRssiCount++
|
||||
}
|
||||
|
||||
|
||||
fun addDistanceCheck(result: Boolean) {
|
||||
if (result) checkResult.distanceChecked++
|
||||
checkResult.distanceCount++
|
||||
}
|
||||
|
||||
inner class CheckResult {
|
||||
// ocr检查结果
|
||||
var ocrChecked: Int = 0
|
||||
var ocrCount: Int = 0
|
||||
|
||||
// 方向检查结果,判断手机姿态
|
||||
var angleChecked = 0
|
||||
var angleCount = 0
|
||||
|
||||
// 附近POI查询结果
|
||||
var nearestChecked = 0
|
||||
var nearestCount = 0
|
||||
|
||||
// 速度检查结果
|
||||
var speedChecked = 0
|
||||
var speedCount = 0
|
||||
|
||||
// 模拟定位结果
|
||||
var mockLocationChecker = false
|
||||
|
||||
// 是否为自动捕捉检查
|
||||
var autoTakeChecker = false
|
||||
|
||||
// 卫星个数检查
|
||||
var satelliteChecked = 0
|
||||
var satelliteCount = 0
|
||||
|
||||
// 信号强度检查
|
||||
var gpsRssiChecked = 0
|
||||
var gpsRssiCount = 0
|
||||
|
||||
// 距离检查
|
||||
var distanceChecked = 0
|
||||
var distanceCount = 0
|
||||
}
|
||||
|
||||
fun savePictureCheckResult(activity: Activity, type: Int/*采集类型*/,
|
||||
map: android.util.Pair<Int, PictureResult>,
|
||||
yDegree: Float/*y轴上的旋转角*/, currentSpeed: Double, distance: Double, isAutoTakePicture: Boolean) {
|
||||
val resultMap: MutableMap<String, String> = mutableMapOf()
|
||||
val pictureResult = map.second
|
||||
// 如果当前拍照是POI拍照模式,才需要做ocr识别以及附近POI查询
|
||||
// 如果当前拍照是POI拍照模式,才需要做ocr识别以及附近POI查询
|
||||
if (type == 3) {
|
||||
// 开始ocr文字识别
|
||||
val ocrViewResultModels = instance.ocr(
|
||||
BitmapUtil.getBitmapFromBytes(
|
||||
pictureResult!!.data
|
||||
)
|
||||
)
|
||||
if (ocrViewResultModels != null && !ocrViewResultModels.isEmpty()) {
|
||||
this.addocrCheck(true)
|
||||
resultMap["ocr"] = "true"
|
||||
// 该照片存在文字信息,获取占比最大的文字,为后续POI判定做准备
|
||||
val maxOcrViewResult = ocrViewResultModels.stream()
|
||||
.max { t0, t1 ->
|
||||
val t0Value = (Math.abs(t0.bounds[2].x - t0.bounds[0].x)
|
||||
* Math.abs(t0.bounds[2].y - t0.bounds[0].y))
|
||||
val t1Value = (Math.abs(t1.bounds[2].x - t1.bounds[0].x)
|
||||
* Math.abs(t1.bounds[2].y - t1.bounds[0].y))
|
||||
if (t0Value > t1Value) {
|
||||
return@max 1
|
||||
} else if (t0Value < t1Value) {
|
||||
return@max -1
|
||||
}
|
||||
return@max 0
|
||||
}
|
||||
.get()
|
||||
resultMap["name"] = maxOcrViewResult.name
|
||||
// 周边搜索,判定周边POI是否存在
|
||||
if (this.checkResult.nearestChecked < 3 && !nameSet.contains(maxOcrViewResult.name)) {
|
||||
// 发送请求,查询周边POI是否存在
|
||||
val name = maxOcrViewResult.name
|
||||
val httpParams = HttpParams()
|
||||
val encode = Geohash.getInstance().encode(
|
||||
LocationLifeCycle.getInstance().mainLocation.latitude,
|
||||
LocationLifeCycle.getInstance().mainLocation.longitude
|
||||
)
|
||||
httpParams.put("geo", encode)
|
||||
httpParams.put("name", name)
|
||||
val okGoBuilder = OkGoBuilder.getInstance()
|
||||
.time(30)
|
||||
.Builder(activity)
|
||||
.url(HttpInterface.TASK_NAME)
|
||||
.cls(TaskNameBean::class.java)
|
||||
.params(httpParams)
|
||||
.token(Constant.ACCESS_TOKEN)
|
||||
okGoBuilder.getRequest(object : Callback<TaskNameBean?> {
|
||||
override fun onSuccess(taskNameBean: TaskNameBean?, id: Int) {
|
||||
if (taskNameBean!!.code == 200&&taskNameBean.body!=null) { // body中保存了当前名称是否在周边存在对应的POI
|
||||
this@PictureCheckHelper.addNearestCheck(true)
|
||||
XLog.d("nearest: ${name}, taskBean: ${gson.toJson(taskNameBean)}")
|
||||
} else {
|
||||
this@PictureCheckHelper.addNearestCheck(false)
|
||||
}
|
||||
FileUtils.writeFile(
|
||||
checkFile.getAbsolutePath(),
|
||||
gson.toJson(this@PictureCheckHelper.checkResult),
|
||||
false
|
||||
)
|
||||
}
|
||||
|
||||
override fun onError(e: Throwable, id: Int) {
|
||||
this@PictureCheckHelper.addNearestCheck(false)
|
||||
FileUtils.writeFile(
|
||||
checkFile.getAbsolutePath(),
|
||||
gson.toJson(this@PictureCheckHelper.checkResult),
|
||||
false
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 将当前名称添加到name缓存中
|
||||
nameSet.add(maxOcrViewResult.name)
|
||||
} else {
|
||||
this@PictureCheckHelper.addocrCheck(false)
|
||||
resultMap["ocr"] = "false"
|
||||
resultMap["name"] = "null"
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前手机姿态,判定该照片手机姿态是否合格
|
||||
|
||||
// 获取当前手机姿态,判定该照片手机姿态是否合格
|
||||
// val yDegree: Float = sensorOritationLifecycle.yDegree
|
||||
resultMap["angle"] = yDegree.toString() + ""
|
||||
if (yDegree > -90 - sensorDegree && yDegree < -90 + sensorDegree) {
|
||||
this@PictureCheckHelper.addAngleCheck(true)
|
||||
} else {
|
||||
this@PictureCheckHelper.addAngleCheck(false)
|
||||
}
|
||||
|
||||
// 检查当前速度
|
||||
resultMap["speed"] = currentSpeed.toString() + ""
|
||||
if (type == 3) { // poi录像
|
||||
if (currentSpeed in poiMinSpeed..poiMaxSpeed) {
|
||||
this@PictureCheckHelper.addSpeedCheck(true)
|
||||
} else {
|
||||
this@PictureCheckHelper.addSpeedCheck(false)
|
||||
}
|
||||
} else if (type == 4) { // 道路任务
|
||||
if (currentSpeed in roadMinSpeed..roadMaxSpeed) {
|
||||
this@PictureCheckHelper.addSpeedCheck(true)
|
||||
} else {
|
||||
this@PictureCheckHelper.addSpeedCheck(false)
|
||||
}
|
||||
}
|
||||
|
||||
// 记录卫星颗数
|
||||
resultMap["satellite"] = GPSUtils.getInstance(activity).sateliteCount.toString() + ""
|
||||
if (GPSUtils.getInstance(activity).sateliteCount >= satelliteCount) {
|
||||
this@PictureCheckHelper.addSatelliteCheck(true)
|
||||
} else {
|
||||
this@PictureCheckHelper.addSatelliteCheck(false)
|
||||
}
|
||||
|
||||
// 记录卫星强度
|
||||
resultMap["gpsRssi"] = LocationLifeCycle.getInstance().tencentLocation.gpsRssi.toString() + ""
|
||||
this@PictureCheckHelper.addGpsRssiCheck(LocationLifeCycle.getInstance().tencentLocation.gpsRssi)
|
||||
|
||||
// 记录距离检查
|
||||
resultMap["distance"] = distance.toString()
|
||||
if (distance<50) {
|
||||
this@PictureCheckHelper.addDistanceCheck(true)
|
||||
} else {
|
||||
this@PictureCheckHelper.addDistanceCheck(false)
|
||||
}
|
||||
|
||||
// 记录json文件到指定文件
|
||||
FileUtils.writeFile(
|
||||
checkFile.absolutePath,
|
||||
gson.toJson(this@PictureCheckHelper.checkResult),
|
||||
false
|
||||
)
|
||||
FileUtils.writeFile(
|
||||
checkFile.parentFile.absolutePath + "/result.json",
|
||||
gson.toJson(resultMap) + "\r",
|
||||
true
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前测评结果
|
||||
* */
|
||||
fun getCheckResultScore(): Int {
|
||||
var score = 0
|
||||
if (checkResult!=null) {
|
||||
// 是否有模拟定位
|
||||
if (Constant.mockGPSMap!=null&&Constant.mockGPSMap.isNotEmpty()) {
|
||||
score -= 100
|
||||
}
|
||||
//任务线与定位点匹配
|
||||
if (checkResult.distanceCount!=0&&checkResult.distanceChecked.toFloat()/checkResult.distanceCount>0.5f) {
|
||||
score += 20
|
||||
}
|
||||
//TODO 使用自动捕捉
|
||||
//作业速度
|
||||
if (checkResult.speedCount!=0&&checkResult.speedChecked.toFloat()/checkResult.speedCount>0.7f) {
|
||||
score += 20
|
||||
}
|
||||
// 拍照姿态
|
||||
if (checkResult.angleCount!=0&&checkResult.angleChecked.toFloat()/checkResult.angleCount>0.7f) {
|
||||
score += 10
|
||||
}
|
||||
// 照片清晰度
|
||||
if (checkResult.ocrChecked>5) {
|
||||
score += 30
|
||||
}
|
||||
// 信号强度
|
||||
if (checkResult.gpsRssiCount!=0) {
|
||||
val rssiCheckResult = checkResult.gpsRssiChecked.toFloat()/checkResult.gpsRssiCount
|
||||
if (rssiCheckResult >= 0f&&rssiCheckResult<0.2f) {
|
||||
// 无信号
|
||||
score -= 100
|
||||
} else if (rssiCheckResult>=0.2f&&rssiCheckResult<1.2f) {
|
||||
score -= 20
|
||||
} else if (rssiCheckResult>=1.2f&&rssiCheckResult<2.2f) {
|
||||
score -= 0
|
||||
}else {
|
||||
score += 20
|
||||
}
|
||||
}
|
||||
if (checkResult.nearestChecked>=3) {
|
||||
score += 30
|
||||
}
|
||||
}
|
||||
return score
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng
|
||||
|
||||
class PicturesSpeedCheck {
|
||||
val pointList = mutableListOf<MyLocation>()
|
||||
val LIST_SIZE = 5
|
||||
val DISTANCE = 2
|
||||
|
||||
/**
|
||||
* 与前面的4个点做检查,如果当前点位距离前面4个点的距离超过阈值,且当前卫星信号强度为中以上(8颗),则返回false
|
||||
* */
|
||||
fun checkIsMove(myLocation: MyLocation, gpsRssi: Int/*定位信号强度*/): Boolean {
|
||||
pointList.add(myLocation)
|
||||
if (pointList.size<5) { // 点位小于4个,不做判断,默认为运动中
|
||||
return true
|
||||
}
|
||||
if (pointList.size>5) { // 如果点位信息超过5个,移除第一个数据
|
||||
pointList.removeAt(0)
|
||||
}
|
||||
|
||||
if (gpsRssi<3) { // 腾讯定位信号强度不是“强”,则忽略速度判定
|
||||
return true
|
||||
}
|
||||
|
||||
var distance = 0.0
|
||||
for (index in pointList.indices) {
|
||||
if (index+1<pointList.size) {
|
||||
distance += GeometryTools.distanceToDouble(
|
||||
LatLng(
|
||||
pointList[index].latitude,
|
||||
pointList[index].longitude
|
||||
),
|
||||
LatLng(pointList[index + 1].latitude, pointList[index + 1].longitude)
|
||||
)
|
||||
}
|
||||
if (distance>DISTANCE) { // 如果距离已经大于设置的距离阈值,无需再计算后面的点位,车辆运动中
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,9 @@ public class PoiEntityDeleteUtil {
|
||||
if (poiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) {
|
||||
File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto());
|
||||
file.delete();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (poiEntity.getId() != null) {
|
||||
@@ -59,7 +61,9 @@ public class PoiEntityDeleteUtil {
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < chargingPileFileList.size(); i++) {
|
||||
chargingPileFileList.get(i).delete();
|
||||
if (chargingPileFileList.get(i).exists()) {
|
||||
chargingPileFileList.get(i).delete();
|
||||
}
|
||||
}
|
||||
PoiDatabase.getInstance(context).getChargingPileDao().deleteChargingPileEntity(chargingPileEntity);
|
||||
}
|
||||
@@ -71,10 +75,14 @@ public class PoiEntityDeleteUtil {
|
||||
private void initPicture(PoiEntity poiEntity) {
|
||||
List<File> fileListByUUID = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||
for (int i = 0; i < fileListByUUID.size(); i++) {
|
||||
fileListByUUID.get(i).delete();
|
||||
if (fileListByUUID.get(i).exists()) {
|
||||
fileListByUUID.get(i).delete();
|
||||
}
|
||||
}
|
||||
File filePath = AWMp4ParserHelper.getInstance().getFilePath(poiEntity.getId());
|
||||
filePath.delete();
|
||||
if (filePath.exists()) {
|
||||
filePath.delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +91,9 @@ public class PoiEntityDeleteUtil {
|
||||
if (poiEntity.getPhotoInfo() != null) {
|
||||
for (int i = 0; i < poiEntity.getPhotoInfo().size(); i++) {
|
||||
File file = new File(poiEntity.getPhotoInfo().get(i).getPhoto());
|
||||
file.delete();
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import android.os.Message;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.elvishew.xlog.Logger;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.github.lazylibrary.util.ToastUtils;
|
||||
import com.github.lazylibrary.util.ZipUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.lzy.okgo.OkGo;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
@@ -28,17 +28,16 @@ import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.AbstractMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.ObservableSource;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
@@ -56,6 +55,8 @@ public class PoiSaveUtils {
|
||||
private int anInt = 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) {
|
||||
if (instance == null) {
|
||||
@@ -74,55 +75,47 @@ public class PoiSaveUtils {
|
||||
*/
|
||||
public void uploadPoiEntityBatch(List<PoiEntity> poiEntityList) {
|
||||
if (poiEntityList != null&&!poiEntityList.isEmpty()) {
|
||||
logger.d("开始批量上传-------------------------共"+poiEntityList.size()+"个");
|
||||
// 因为道路任务和POI录像任务需要分包提交,因此和其他要素分开,分别放在两个管道里
|
||||
List<PoiEntity> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
List<PoiEntity> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
List<PoiEntity> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
for (PoiEntity poiEntity: poiEntityList) {
|
||||
List<Map.Entry<Integer, PoiEntity>> chargePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
List<Map.Entry<Integer, PoiEntity>> spliteFilePoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
List<Map.Entry<Integer, PoiEntity>> otherPoiEntityList = new ArrayList<>();/*充电站POI列表*/
|
||||
for (int i = 0; i < poiEntityList.size(); i++) {
|
||||
PoiEntity poiEntity = poiEntityList.get(i);
|
||||
logger.d("准备数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
||||
if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||
continue;
|
||||
}
|
||||
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
||||
if (poiEntity.getType()==2) {
|
||||
chargePoiEntityList.add(poiEntity);
|
||||
} else if (poiEntity.getType() == 3 || poiEntity.getType() == 4) {
|
||||
spliteFilePoiEntityList.add(poiEntity);
|
||||
chargePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
||||
} else if (poiEntity.getType() == 3 || poiEntity.getType() == 4 || poiEntity.getType() == 11 || poiEntity.getType() == 12 || poiEntity.getType() == 13) {
|
||||
spliteFilePoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
||||
} else {
|
||||
otherPoiEntityList.add(poiEntity);
|
||||
otherPoiEntityList.add(new AbstractMap.SimpleEntry<>(i, poiEntity));
|
||||
}
|
||||
}
|
||||
|
||||
Observable chargePoiObserable = Observable.fromIterable(chargePoiEntityList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnNext(new Consumer<PoiEntity>() {
|
||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
||||
@Override
|
||||
public void accept(PoiEntity poiEntity) throws Exception {
|
||||
Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
||||
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 (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||
Constant.submitIdSet.remove(poiEntity.getId());
|
||||
}
|
||||
if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
||||
// 开始上传流程
|
||||
if (saveChargingPileUploadChargingStation(poiEntity)) {
|
||||
uploadPoiNet(poiEntity);
|
||||
uploadPoiNet(integerPoiEntityEntry);
|
||||
}else {
|
||||
bInt++;
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
poiEntityUploadFailed(poiEntity, "充电桩数据上传失败!");
|
||||
}
|
||||
}else {
|
||||
bInt++;
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
||||
}
|
||||
} else {
|
||||
bInt++;
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
Constant.submitIdSet.remove(poiEntity.getId());
|
||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -130,17 +123,16 @@ public class PoiSaveUtils {
|
||||
// 处理普通数据
|
||||
Observable otherObserable = Observable.fromIterable(otherPoiEntityList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnNext(new Consumer<PoiEntity>() {
|
||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
||||
@Override
|
||||
public void accept(PoiEntity poiEntity) throws Exception {
|
||||
public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
||||
logger.d("开始上传普通数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
||||
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||
//走上传流程:
|
||||
uploadPoiNet(poiEntity);
|
||||
uploadPoiNet(integerPoiEntityEntry);
|
||||
}else {
|
||||
bInt++;
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -148,44 +140,44 @@ public class PoiSaveUtils {
|
||||
// 处理需要分包上传数据的POI录像和道路数据
|
||||
Observable spliteFileObserable = Observable.fromIterable(spliteFilePoiEntityList)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.doOnNext(new Consumer<PoiEntity>() {
|
||||
.doOnNext(new Consumer<Map.Entry<Integer, PoiEntity>>() {
|
||||
@Override
|
||||
public void accept(PoiEntity poiEntity) throws Exception {
|
||||
public void accept(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
||||
logger.d("开始上传分包数据:"+poiEntity.getId()+"-"+poiEntity.getName());
|
||||
if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||
//走上传流程:
|
||||
if (poiEntity == null) {
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "当前数据为null!");
|
||||
return;
|
||||
}
|
||||
int bodyId = poiEntity.getBodyId();
|
||||
if (bodyId == 0) {
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "bodyId为0");
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
bInt++;
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
poiEntityUploadFailed(poiEntity, "网络保存失败");
|
||||
}
|
||||
}
|
||||
})
|
||||
.concatMap(new Function<PoiEntity, ObservableSource<?>>() {
|
||||
.concatMap(new Function<Map.Entry<Integer, PoiEntity>, ObservableSource<PoiEntity>>() {
|
||||
@Override
|
||||
public ObservableSource<?> apply(PoiEntity poiEntity) throws Exception {
|
||||
public ObservableSource<PoiEntity> apply(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) throws Exception {
|
||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
||||
List<File> photoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||
if (photoFileList == null||photoFileList.isEmpty()) {
|
||||
bInt++;
|
||||
if (photoFileList == null||photoFileList.size()<2/*如果文件压缩包内小于2个文件,说明拍摄的照片丢失了*/) {
|
||||
poiEntityUploadFailed(poiEntity, "照片数据获取为空!");
|
||||
return Observable.empty();
|
||||
}
|
||||
return DataSaveUtils.getInstance().getUploadSpliteFilesObservble(mContext, poiEntity, photoFileList)
|
||||
.toObservable();
|
||||
}
|
||||
})
|
||||
.doOnNext(new Consumer<Object>() {
|
||||
.doOnNext(new Consumer<PoiEntity>() {
|
||||
@Override
|
||||
public void accept(Object o) throws Exception {
|
||||
anInt++;
|
||||
public void accept(PoiEntity poiEntity) throws Exception {
|
||||
poiEntityUploadSuccess(poiEntity, "上传成功");
|
||||
}
|
||||
})
|
||||
.doOnError(new Consumer<Throwable>() {
|
||||
@@ -208,6 +200,7 @@ public class PoiSaveUtils {
|
||||
uploadCount = chargePoiEntityList.size()+spliteFilePoiEntityList.size()+otherPoiEntityList.size();
|
||||
Log.d("PoiSaveUtils", "开始上传");
|
||||
ToastUtils.showToast(mContext, "开始批量上传数据,本次共需上传"+uploadCount+"条数据");
|
||||
mDisposable = d;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,80 +227,33 @@ public class PoiSaveUtils {
|
||||
Constant.isPresent = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
// new Thread(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// anInt = 0;
|
||||
// bInt = 0;
|
||||
// Log.d("PoiSaveUtils", "开始上传");
|
||||
// for (int i = 0; i < poiEntityList.size(); i++) {
|
||||
// PoiEntity poiEntity = poiEntityList.get(i);
|
||||
// Log.d("PoiSaveUtils", "poiEntity.getType():"+poiEntity.getType());
|
||||
// if (Constant.submitIdSet.contains(poiEntity.getId())) {
|
||||
// continue;
|
||||
// }
|
||||
// if (poiEntity.getType() == 2) { // 如果是充电站数据,首先检查子充电桩的状态
|
||||
// Constant.submitIdSet.add(poiEntity.getId()); // 记录全局的正在提交的数据
|
||||
// if (savePoiNet(poiEntity) == 200&&saveChargingPileByChargingStation(poiEntity)) { // 网络保存成功
|
||||
// Constant.submitIdSet.remove(poiEntity.getId());
|
||||
// if (savePoiNet(poiEntity) == 200) { // 网络保存-冗余操作
|
||||
// // 开始上传流程
|
||||
// if (saveChargingPileUploadChargingStation(poiEntity)) {
|
||||
// uploadPoiNet(poiEntity);
|
||||
// }else {
|
||||
// bInt++;
|
||||
// poiEntity.setChecked(false);
|
||||
// poiEntity.setWork_type(0);
|
||||
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||
// }
|
||||
// }else {
|
||||
// bInt++;
|
||||
// poiEntity.setChecked(false);
|
||||
// poiEntity.setWork_type(0);
|
||||
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||
// }
|
||||
// } else {
|
||||
// bInt++;
|
||||
// poiEntity.setChecked(false);
|
||||
// poiEntity.setWork_type(0);
|
||||
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
// Constant.submitIdSet.remove(poiEntity.getId());
|
||||
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||
// }
|
||||
// } else {//其他类型
|
||||
// if (savePoiNet(poiEntity) == 200) { // 网络保存成功
|
||||
// //走上传流程:
|
||||
// uploadPoiNet(poiEntity);
|
||||
// }else {
|
||||
// bInt++;
|
||||
// poiEntity.setChecked(false);
|
||||
// poiEntity.setWork_type(0);
|
||||
// PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
// sendUploadMessage(poiEntityList.size(), anInt, bInt);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }).start();
|
||||
}
|
||||
}
|
||||
|
||||
private void sendUploadMessage(int count, int success, int fail) {
|
||||
if (success+fail == count) { // 成功和失败的个数与数据总数相同
|
||||
Message obtain = Message.obtain();
|
||||
obtain.what = Constant.STAY_SUBMIT_ITEM;
|
||||
obtain.obj = true;
|
||||
EventBus.getDefault().post(obtain);
|
||||
}
|
||||
Message obtain1 = Message.obtain();
|
||||
obtain1.what = Constant.NEST_WORD_SUBMIT;
|
||||
obtain1.obj = "批量提交数据,共选中"+count+"条数据,成功:" + anInt + "条, 失败:" + bInt+"条";
|
||||
EventBus.getDefault().post(obtain1);
|
||||
/**
|
||||
* 处理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());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -342,14 +288,16 @@ public class PoiSaveUtils {
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 1);
|
||||
// httpParams.put("workType", 1);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
httpParams.put("score", poiEntity.getScore());
|
||||
httpParams.put("drawLine", poiEntity.getDrawLine());
|
||||
url = HttpInterface.INSIDE_API_LIST;
|
||||
} else if (poiEntity.getType() == 4) {
|
||||
httpParams.put("taskId", poiEntity.getTaskId());
|
||||
httpParams.put("name", poiEntity.getName());
|
||||
httpParams.put("address", poiEntity.getAddress());
|
||||
httpParams.put("workType", 0);
|
||||
// httpParams.put("workType", 0);
|
||||
httpParams.put("memo", poiEntity.getMemo());
|
||||
url = HttpInterface.ROAD_TASK_SUBMIT;
|
||||
} else if (poiEntity.getType() == 5) {
|
||||
@@ -404,14 +352,15 @@ public class PoiSaveUtils {
|
||||
/**
|
||||
* 最终上传POI数据到服务
|
||||
*/
|
||||
public void uploadPoiNet(PoiEntity poiEntity) {
|
||||
public void uploadPoiNet(Map.Entry<Integer, PoiEntity> integerPoiEntityEntry) {
|
||||
PoiEntity poiEntity = integerPoiEntityEntry.getValue();
|
||||
if (poiEntity == null) {
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "poiEntity为null");
|
||||
return;
|
||||
}
|
||||
int bodyId = poiEntity.getBodyId();
|
||||
if (bodyId == 0) {
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "bodyId为0");
|
||||
return;
|
||||
}
|
||||
ArrayList<File> photoFile = new ArrayList<>();
|
||||
@@ -424,14 +373,16 @@ public class PoiSaveUtils {
|
||||
}
|
||||
}
|
||||
}
|
||||
poiEntity.setUploadMax(photoFile.size());
|
||||
//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务"
|
||||
if (poiEntity.getType() == 1) {
|
||||
initList(HttpInterface.POI_TASK_UPLOAD_PIC, photoFile, poiEntity);
|
||||
} else if (poiEntity.getType() == 2) {
|
||||
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());
|
||||
if (videoFileList != null && !videoFileList.isEmpty()) {
|
||||
if (videoFileList != null && videoFileList.size()<2) {
|
||||
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
||||
if (!existsPic) {
|
||||
bInt++;
|
||||
@@ -475,7 +426,7 @@ public class PoiSaveUtils {
|
||||
// }
|
||||
} else if (poiEntity.getType() == 4) {
|
||||
List<File> videoFileList = AWMp4ParserHelper.getInstance().getFileListByUUID(poiEntity.getId());
|
||||
if (videoFileList != null && !videoFileList.isEmpty()) {
|
||||
if (videoFileList != null && videoFileList.size()<2) {
|
||||
boolean existsPic = PoiSaveUtils.getInstance(mContext).checkPicExists(videoFileList);
|
||||
if (!existsPic) {
|
||||
bInt++;
|
||||
@@ -505,31 +456,21 @@ public class PoiSaveUtils {
|
||||
// File fileZip = new File(Constant.PICTURE_FOLDER, "files" + ".zip");
|
||||
// ZipUtil.zipFiles(videoFileList, fileZip, null);
|
||||
// photoFile.add(fileZip);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
Log.d("TAGSS", "videoFileList: 失败" + bInt);
|
||||
bInt++;
|
||||
return;
|
||||
}
|
||||
// if (photoFile.size() > 0) {
|
||||
// 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) {
|
||||
}
|
||||
else if (poiEntity.getType() == 5) {
|
||||
initList(HttpInterface.OTHER_TASK_UPLOAD_PIC, photoFile, poiEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private void initList(String url, List<File> list, PoiEntity poiEntity) {
|
||||
try {
|
||||
poiEntity.setUploadResult("");
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("auditId", poiEntity.getBodyId());
|
||||
Response execute = OkGoBuilder.getInstance()
|
||||
@@ -542,56 +483,46 @@ public class PoiSaveUtils {
|
||||
.postFileSynchronization();
|
||||
if (execute == null) {
|
||||
Log.d("TAGSS", "execute: 失败" + bInt);
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "服务返回结果为null");
|
||||
return;
|
||||
}
|
||||
if (execute.code() != 200) {
|
||||
Log.d("TAGSS", "code: 失败" + bInt);
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "服务返回code码不为200"+execute.code());
|
||||
return;
|
||||
}
|
||||
String bodyStr = execute.body().string();
|
||||
if (bodyStr == null) {
|
||||
Log.d("TAGSS", "bodyStr: 失败" + bInt);
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "服务返回body为null");
|
||||
return;
|
||||
}
|
||||
OtherUploadPicBean otherUploadPicBean = new Gson().fromJson(bodyStr, OtherUploadPicBean.class);
|
||||
if (otherUploadPicBean!=null){
|
||||
if (otherUploadPicBean.getCode() == 200) {
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setTaskStatus(100);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.get(i).delete();
|
||||
// 同时删除关联的照片文件和压缩包文件
|
||||
if (!list.isEmpty()&&list.get(0).getParentFile().exists()&&!list.get(0).getParentFile().getName().endsWith("picture")) {
|
||||
// 删除对应的文件夹
|
||||
FileUtils.deleteFile(list.get(0).getParentFile().getAbsolutePath());
|
||||
}
|
||||
// for (int i = 0; i < list.size(); i++) {
|
||||
// list.get(i).delete();
|
||||
// }
|
||||
PoiEntityDeleteUtil.getInstance().deleteUtil(mContext, poiEntity);
|
||||
Log.d("TAGSS", "uploadPoiNet: 成功" + anInt);
|
||||
anInt++;
|
||||
poiEntity.setUploadProgress(poiEntity.getUploadMax());
|
||||
poiEntityUploadSuccess(poiEntity, "");
|
||||
return;
|
||||
} else {
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
poiEntityUploadFailed(poiEntity, "错误:"+otherUploadPicBean.getMessage());
|
||||
Log.d("TAGSS", "uploadPoiNet: 失败" + bInt);
|
||||
bInt++;
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
poiEntity.setChecked(false);
|
||||
poiEntity.setWork_type(0);
|
||||
PoiDatabase.getInstance(mContext).getPoiDao().updatePoiEntity(poiEntity);
|
||||
Log.d("TAGSS", "uploadPoiNet: 失败" + bInt);
|
||||
bInt++;
|
||||
poiEntityUploadFailed(poiEntity, "Json转换失败");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -600,6 +531,16 @@ public class PoiSaveUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* EventBus通知列表当前的上传进度
|
||||
* */
|
||||
private void sendRefreshItem(PoiEntity poiEntity) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constant.EVENT_WHAT_UPLOAD_PROGRESS;
|
||||
msg.obj = poiEntity;
|
||||
EventBus.getDefault().post(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据充电站数据检查充电桩数据,如果没有网络保存,则批量网络保存
|
||||
*/
|
||||
@@ -762,11 +703,21 @@ public class PoiSaveUtils {
|
||||
public boolean checkPicExists(List<File> fileList) {
|
||||
boolean isExistsPic = false; // 是否记录的照片全部不存在
|
||||
for (File picFile: fileList) {
|
||||
if (picFile!=null&&picFile.exists()) {
|
||||
if (picFile!=null&&picFile.exists()&&!picFile.getName().endsWith(".txt")/*至少包含1张照片*/) {
|
||||
isExistsPic = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isExistsPic;
|
||||
}
|
||||
|
||||
public void cancelUploadPoiEntityBatch() {
|
||||
if (mDisposable!=null&&!mDisposable.isDisposed()) {
|
||||
mDisposable.dispose();
|
||||
Toast.makeText(mContext, "已取消批量上传流程", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(mContext, "没有需要取消的批量上传数据", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
Constant.submitIdSet.clear(); // 清空记录的正在上传的id表
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
import android.content.Context
|
||||
import android.hardware.Sensor
|
||||
import android.hardware.SensorEvent
|
||||
import android.hardware.SensorEventListener
|
||||
import android.hardware.SensorManager
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
|
||||
class SensorOritationLifecycle(val context: Context): DefaultLifecycleObserver {
|
||||
private var sensorManager: SensorManager? = null
|
||||
private var accelerometer: Sensor? = null
|
||||
private var magnetic :android.hardware.Sensor? = null
|
||||
private var seneorListener: SensorEventListener? = null
|
||||
private var accelerometerValues = FloatArray(3)
|
||||
private var magneticFieldValues = FloatArray(3)
|
||||
var zDegree: Float = 0f
|
||||
var xDegree: Float = 0f
|
||||
var yDegree: Float = 0f
|
||||
var degreesChangeListener: DegreesChangeListener? = null
|
||||
|
||||
override fun onCreate(owner: LifecycleOwner) {
|
||||
super.onCreate(owner)
|
||||
/**
|
||||
* 初始化传感器
|
||||
* */
|
||||
/**
|
||||
* 初始化传感器
|
||||
*/
|
||||
seneorListener = object : SensorEventListener {
|
||||
override fun onSensorChanged(sensorEvent: SensorEvent) {
|
||||
// 获取角度信息
|
||||
if (sensorEvent.sensor.type == Sensor.TYPE_ACCELEROMETER) {
|
||||
accelerometerValues = sensorEvent.values
|
||||
}
|
||||
if (sensorEvent.sensor.type == Sensor.TYPE_MAGNETIC_FIELD) {
|
||||
magneticFieldValues = sensorEvent.values
|
||||
}
|
||||
calculateOrientation()
|
||||
}
|
||||
|
||||
override fun onAccuracyChanged(sensor: Sensor, i: Int) {}
|
||||
}
|
||||
|
||||
sensorManager = context.getSystemService(Context.SENSOR_SERVICE) as SensorManager
|
||||
if (sensorManager!=null) {
|
||||
with(sensorManager!!) {
|
||||
accelerometer = getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
|
||||
magnetic = getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD)
|
||||
registerListener(
|
||||
seneorListener,
|
||||
accelerometer,
|
||||
SensorManager.SENSOR_DELAY_NORMAL
|
||||
)
|
||||
registerListener(
|
||||
seneorListener,
|
||||
magnetic,
|
||||
SensorManager.SENSOR_DELAY_NORMAL
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) {
|
||||
super.onDestroy(owner)
|
||||
if (sensorManager != null) {
|
||||
sensorManager!!.unregisterListener(seneorListener)
|
||||
}
|
||||
}
|
||||
|
||||
// 计算方向
|
||||
private fun calculateOrientation() {
|
||||
val values = FloatArray(3)
|
||||
val R = FloatArray(9)
|
||||
SensorManager.getRotationMatrix(
|
||||
R, null, accelerometerValues,
|
||||
magneticFieldValues
|
||||
)
|
||||
SensorManager.getOrientation(R, values)
|
||||
zDegree = Math.toDegrees(values[0].toDouble()).toFloat()
|
||||
xDegree = Math.toDegrees(values[1].toDouble()).toFloat()
|
||||
yDegree = Math.toDegrees(values[2].toDouble()).toFloat()
|
||||
degreesChangeListener?.onDegreesChangeListener(xDegree, yDegree, zDegree)
|
||||
}
|
||||
|
||||
fun getDegrees(): FloatArray {
|
||||
return floatArrayOf(xDegree, yDegree, zDegree)
|
||||
}
|
||||
|
||||
interface DegreesChangeListener {
|
||||
fun onDegreesChangeListener(xDegree: Float, yDegree: Float, zDegree: Float)
|
||||
}
|
||||
}
|
||||
@@ -97,5 +97,11 @@ public class SystemTTS extends UtteranceProgressListener implements TTS, TextToS
|
||||
|
||||
}
|
||||
|
||||
public boolean isSpeaking() {
|
||||
if (textToSpeech!=null) {
|
||||
return textToSpeech.isSpeaking();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.github.lazylibrary.util.ToastUtils;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.tencent.map.fusionlocation.observer.TencentGeoLocationObserver;
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentLocationListener;
|
||||
import com.tencent.map.geolocation.TencentLocationManager;
|
||||
@@ -21,7 +24,6 @@ import java.util.List;
|
||||
public class TalentLocationUtils implements TencentLocationListener {
|
||||
private TencentLocationManager locationManager;
|
||||
private TencentLocationRequest locationRequest;
|
||||
private List<LocationSource.OnLocationChangedListener> locationChangedListenerList;
|
||||
private boolean isLocationStart; // 标识是否已经启动定位
|
||||
private static TalentLocationUtils instance;
|
||||
public static TalentLocationUtils getInstance(Context mContext) {
|
||||
@@ -36,7 +38,6 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
}
|
||||
|
||||
private void init(Context mContext) {
|
||||
locationChangedListenerList = new ArrayList<>();
|
||||
//用于访问腾讯定位服务的类, 周期性向客户端提供位置更新
|
||||
locationManager = TencentLocationManager.getInstance(mContext, null);
|
||||
//设置坐标系
|
||||
@@ -55,16 +56,17 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
}
|
||||
if (!isLocationStart) {
|
||||
int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper(), 0);
|
||||
XLog.d( "开始腾讯定位");
|
||||
isLocationStart = true;
|
||||
switch (err) {
|
||||
case 1:
|
||||
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE1);
|
||||
ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE1);
|
||||
break;
|
||||
case 2:
|
||||
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE2);
|
||||
ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE2);
|
||||
break;
|
||||
case 3:
|
||||
ToastUtil.showShort(mContext, Constant.GET_ERR_MESSAGE3);
|
||||
ToastUtils.showToast(mContext, Constant.GET_ERR_MESSAGE3);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -74,14 +76,17 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
|
||||
public void stopLocation() { // 停止定位服务
|
||||
if (isLocationStart) {
|
||||
isLocationStart = false;
|
||||
locationManager.removeUpdates(this);
|
||||
locationManager = null;
|
||||
locationRequest = null;
|
||||
locationChangedListenerList.clear();
|
||||
locationChangedListenerList = null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLocationStart() {
|
||||
return isLocationStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实现位置监听
|
||||
* @param tencentLocation location
|
||||
@@ -89,46 +94,31 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
@Override
|
||||
public void onLocationChanged(TencentLocation tencentLocation, int i, String s) {
|
||||
if (i == TencentLocation.ERROR_OK) {//定位成功
|
||||
Location location = new Location(tencentLocation.getProvider());
|
||||
// //设置经纬度以及精度
|
||||
location.setLatitude(tencentLocation.getLatitude());
|
||||
location.setLongitude(tencentLocation.getLongitude());
|
||||
location.setAccuracy(tencentLocation.getAccuracy());
|
||||
if (tencentLocation.getBearing()!=0) {
|
||||
location.setBearing(tencentLocation.getBearing());
|
||||
} else {
|
||||
location.setBearing((float) tencentLocation.getDirection());
|
||||
}
|
||||
if (locationChangedListenerList!=null) {
|
||||
for (LocationSource.OnLocationChangedListener locationChangedListener:locationChangedListenerList) {
|
||||
locationChangedListener.onLocationChanged(location);
|
||||
}
|
||||
}
|
||||
Constant.currentLocation = tencentLocation;
|
||||
Message currentLocationMsg = Message.obtain();
|
||||
currentLocationMsg.what = Constant.EVENT_WHAT_LOCATION_CHANGE;
|
||||
currentLocationMsg.obj = Constant.currentLocation;
|
||||
EventBus.getDefault().post(currentLocationMsg);
|
||||
currentLocationMsg.arg1 = LocationLifeCycle.LOCATION_FROM.TENCENT.ordinal(); // 设置定位来源
|
||||
currentLocationMsg.obj = tencentLocation;
|
||||
EventBus.getDefault().postSticky(currentLocationMsg);
|
||||
}else if (i==TencentLocation.ERROR_NETWORK){//网络问题引起的定位失败
|
||||
Message currentLocationMsg = Message.obtain();
|
||||
currentLocationMsg.what = Constant.EVENT_MESSAGE;
|
||||
currentLocationMsg.obj = "网络问题引起的定位失败";
|
||||
EventBus.getDefault().post(currentLocationMsg);
|
||||
EventBus.getDefault().postSticky(currentLocationMsg);
|
||||
}else if (i==TencentLocation.ERROR_BAD_JSON){//GPS, Wi-Fi 或基站错误引起的定位失败: 1、用户的手机确实采集不到定位凭据,比如偏远地区比如地下车库电梯内等; 2、开关跟权限问题,比如用户关闭了位置信息,关闭了Wi-Fi,未授予app定位权限等。
|
||||
Message currentLocationMsg = Message.obtain();
|
||||
currentLocationMsg.what = Constant.EVENT_MESSAGE;
|
||||
currentLocationMsg.obj = "GPS, Wi-Fi 或基站错误引起的定位失败";
|
||||
EventBus.getDefault().post(currentLocationMsg);
|
||||
EventBus.getDefault().postSticky(currentLocationMsg);
|
||||
}else if (i==TencentLocation.ERROR_WGS84){
|
||||
Message currentLocationMsg = Message.obtain();
|
||||
currentLocationMsg.what = Constant.EVENT_MESSAGE;
|
||||
currentLocationMsg.obj ="无法将WGS84坐标转换成GCJ-02坐标时的定位失败";
|
||||
EventBus.getDefault().post(currentLocationMsg);
|
||||
EventBus.getDefault().postSticky(currentLocationMsg);
|
||||
}else if (i==TencentLocation.ERROR_UNKNOWN){
|
||||
Message currentLocationMsg = Message.obtain();
|
||||
currentLocationMsg.what = Constant.EVENT_MESSAGE;
|
||||
currentLocationMsg.obj ="未知原因引起的定位失败";
|
||||
EventBus.getDefault().post(currentLocationMsg);
|
||||
EventBus.getDefault().postSticky(currentLocationMsg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,8 +137,4 @@ public class TalentLocationUtils implements TencentLocationListener {
|
||||
public void onNmeaMsgChanged(String s) {
|
||||
|
||||
}
|
||||
|
||||
public List<LocationSource.OnLocationChangedListener> getLocationChangedListenerList() {
|
||||
return locationChangedListenerList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.tencent.map.geolocation.TencentLocation;
|
||||
import com.tencent.map.geolocation.TencentMotion;
|
||||
import com.tencent.map.geolocation.TencentPoi;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.LatLng;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TencentLocationObtain {
|
||||
public static TencentLocation obtainTecentLocation(Location location) {
|
||||
return new TencentLocation() {
|
||||
@Override
|
||||
public String getProvider() {
|
||||
return location.getProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFusionProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSourceProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLatitude() {
|
||||
return location.getLatitude();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getLongitude() {
|
||||
return location.getLongitude();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getAltitude() {
|
||||
return location.getAltitude();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAccuracy() {
|
||||
return location.getAccuracy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAddress() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNation() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProvince() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCity() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDistrict() {
|
||||
return "null";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTown() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVillage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStreet() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStreetNo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getAreaStat() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TencentPoi> getPoiList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getBearing() {
|
||||
return location.getBearing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSpeed() {
|
||||
return location.getSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTime() {
|
||||
return location.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getElapsedRealtime() {
|
||||
return location.getElapsedRealtimeNanos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGPSRssi() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInOutStatus() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndoorBuildingId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIndoorBuildingFloor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIndoorLocationType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDirection() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityPhoneCode() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TencentMotion getMotion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGpsQuality() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDeltaAngle() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDeltaSpeed() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCoordinateType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFakeReason() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int isMockGps() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getExtra() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.navinfo.outdoor.util;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.location.Location;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -185,7 +186,10 @@ public class TencentMarkerUtils {
|
||||
}
|
||||
break;
|
||||
}
|
||||
switch (list.get(i).getType()) {
|
||||
// publish字段标识了当前数据是否已发布,如果未发布,则半透明显示,且不可点击,否则正常显示
|
||||
float alpha = listBean.getPublish() == 0? 0.3f: 1.0f;
|
||||
boolean clickable = listBean.getPublish() == 0? false: true;
|
||||
switch (listBean.getType()) {
|
||||
case 1://poi
|
||||
BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi);
|
||||
//poiDescriptor.getForager().setScale(50);
|
||||
@@ -193,6 +197,7 @@ public class TencentMarkerUtils {
|
||||
Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (poiMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -202,7 +207,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(poiMarker);
|
||||
String poiGeo = initGeo(latLng);
|
||||
geoMarker(poiGeo, poiMarker, removableHashMap);
|
||||
poiMarker.setClickable(true);
|
||||
poiMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 2://充电站
|
||||
@@ -211,6 +216,7 @@ public class TencentMarkerUtils {
|
||||
Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (stationMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -220,7 +226,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(stationMarker);
|
||||
String stationGeo = initGeo(latLng);
|
||||
geoMarker(stationGeo, stationMarker, removableHashMap);
|
||||
stationMarker.setClickable(true);
|
||||
stationMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 3://poi录像
|
||||
@@ -229,6 +235,7 @@ public class TencentMarkerUtils {
|
||||
Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (poiVideoMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -238,7 +245,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(poiVideoMarker);
|
||||
String poiVideoGeo = initGeo(latLng);
|
||||
geoMarker(poiVideoGeo, poiVideoMarker, removableHashMap);
|
||||
poiVideoMarker.setClickable(true);
|
||||
poiVideoMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 4://道路录像
|
||||
@@ -247,6 +254,7 @@ public class TencentMarkerUtils {
|
||||
Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (roadMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -256,7 +264,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(roadMarker);
|
||||
String roadGeo = initGeo(latLng);
|
||||
geoMarker(roadGeo, roadMarker, removableHashMap);
|
||||
roadMarker.setClickable(true);
|
||||
roadMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 5://其他
|
||||
@@ -265,6 +273,7 @@ public class TencentMarkerUtils {
|
||||
Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (otherMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -274,7 +283,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(otherMarker);
|
||||
String otherGeo = initGeo(latLng);
|
||||
geoMarker(otherGeo, otherMarker, removableHashMap);
|
||||
otherMarker.setClickable(true);
|
||||
otherMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 6://面状任务
|
||||
@@ -283,6 +292,7 @@ public class TencentMarkerUtils {
|
||||
Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
|
||||
.anchor(0.5f, 1.0f)
|
||||
.flat(true)
|
||||
.alpha(alpha)
|
||||
.clockwise(false));
|
||||
if (planarMarker != null) {
|
||||
if (listBean != null) {
|
||||
@@ -292,7 +302,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(planarMarker);
|
||||
String planarGeo = initGeo(latLng);
|
||||
geoMarker(planarGeo, planarMarker, removableHashMap);
|
||||
planarMarker.setClickable(true);
|
||||
planarMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Toast;
|
||||
|
||||
/**
|
||||
* 项目名称:ToastUtil
|
||||
* 创建人:mwb
|
||||
* 创建时间:2018/9/3 9:25
|
||||
*/
|
||||
public class ToastUtil {
|
||||
private static boolean isShow = true;//默认显示
|
||||
private static Toast mToast = null;//全局唯一的Toast
|
||||
|
||||
/*private控制不应该被实例化*/
|
||||
private ToastUtil() {
|
||||
throw new UnsupportedOperationException("不能被实例化");
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局控制是否显示Toast
|
||||
*/
|
||||
public static void controlShow(boolean isShowToast) {
|
||||
isShow = isShowToast;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消Toast显示
|
||||
*/
|
||||
public void cancelToast() {
|
||||
if (isShow && mToast != null) {
|
||||
mToast.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 短时间显示Toast
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void showShort(Context context, CharSequence message) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, Toast.LENGTH_SHORT);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 短时间显示Toast
|
||||
* @param resId 资源ID:getResources().getString(R.string);
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void showShort(Context context, int resId) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, resId, Toast.LENGTH_SHORT);
|
||||
} else {
|
||||
mToast.setText(resId);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 长时间显示Toast
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void showLong(Context context, CharSequence message) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, Toast.LENGTH_LONG);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 长时间显示Toast
|
||||
* @param resId 资源ID:getResources().getString(R.string);
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void showLong(Context context, int resId) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, resId, Toast.LENGTH_LONG);
|
||||
} else {
|
||||
mToast.setText(resId);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义显示Toast时间
|
||||
* @param duration 单位:毫秒
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void show(Context context, CharSequence message, int duration) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, duration);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义显示Toast时间
|
||||
* @param resId 资源ID:getResources().getString(R.string);
|
||||
* @param duration 单位:毫秒
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void show(Context context, int resId, int duration) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, resId, duration);
|
||||
} else {
|
||||
mToast.setText(resId);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Toast的View
|
||||
* @param duration 单位:毫秒
|
||||
* @param view 显示自己的View
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void customToastView(Context context, CharSequence message, int duration, View view) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, duration);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
if (view != null) {
|
||||
mToast.setView(view);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Toast的位置
|
||||
* @param duration 单位:毫秒
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void customToastGravity(Context context, CharSequence message, int duration, int gravity, int xOffset, int yOffset) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, duration);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
mToast.setGravity(gravity, xOffset, yOffset);
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义带图片和文字的Toast,最终的效果就是上面是图片,下面是文字
|
||||
* @param iconResId 图片的资源id,如:R.drawable.icon
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void showToastWithImageAndText(Context context, CharSequence message, int iconResId, int duration, int gravity, int xOffset, int yOffset) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, duration);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
mToast.setGravity(gravity, xOffset, yOffset);
|
||||
LinearLayout toastView = (LinearLayout) mToast.getView();
|
||||
ImageView imageView = new ImageView(context);
|
||||
imageView.setImageResource(iconResId);
|
||||
toastView.addView(imageView, 0);
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Toast,针对类型CharSequence
|
||||
* @param isGravity true,表示后面的三个布局参数生效,false,表示不生效
|
||||
* @param isMargin true,表示后面的两个参数生效,false,表示不生效
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void customToastAll(Context context, CharSequence message, int duration, View view, boolean isGravity, int gravity, int xOffset, int yOffset, boolean isMargin, float horizontalMargin, float verticalMargin) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, message, duration);
|
||||
} else {
|
||||
mToast.setText(message);
|
||||
}
|
||||
if (view != null) {
|
||||
mToast.setView(view);
|
||||
}
|
||||
if (isMargin) {
|
||||
mToast.setMargin(horizontalMargin, verticalMargin);
|
||||
}
|
||||
if (isGravity) {
|
||||
mToast.setGravity(gravity, xOffset, yOffset);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Toast,针对类型resId
|
||||
* @param view :应该是一个布局,布局中包含了自己设置好的内容
|
||||
* @param isGravity true,表示后面的三个布局参数生效,false,表示不生效
|
||||
* @param isMargin true,表示后面的两个参数生效,false,表示不生效
|
||||
*/
|
||||
@SuppressLint("ShowToast")
|
||||
public static void customToastAll(Context context, int resId, int duration, View view, boolean isGravity, int gravity, int xOffset, int yOffset, boolean isMargin, float horizontalMargin, float verticalMargin) {
|
||||
if (isShow) {
|
||||
if (mToast == null) {
|
||||
mToast = Toast.makeText(context, resId, duration);
|
||||
} else {
|
||||
mToast.setText(resId);
|
||||
}
|
||||
if (view != null) {
|
||||
mToast.setView(view);
|
||||
}
|
||||
if (isMargin) {
|
||||
mToast.setMargin(horizontalMargin, verticalMargin);
|
||||
}
|
||||
if (isGravity) {
|
||||
mToast.setGravity(gravity, xOffset, yOffset);
|
||||
}
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.navinfo.outdoor.util;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.lifecycle.DefaultLifecycleObserver;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
|
||||
/**
|
||||
* Android实现添加到系统白名单的工具类
|
||||
* */
|
||||
public class WhiteListHelper {
|
||||
final static String IS_HUAWEI = "isHuawei"; //华为
|
||||
final static String IS_XIAOMI = "isXiaomi"; //小米
|
||||
final static String IS_OPPO = "isOppo"; //oppo
|
||||
final static String IS_VIVO = "isVivo"; //vivo
|
||||
final static String IS_MEIZU = "isMeizu"; //魅族
|
||||
final static String IS_SAMSUNG = "isSamsung"; //三星
|
||||
final static String IS_LETV = "isLetv"; //乐视
|
||||
final static String IS_SMARTISAN = "isSmartisan"; //锤子
|
||||
|
||||
/**
|
||||
* 判断当前应用是否在系统白名单内
|
||||
* */
|
||||
@RequiresApi(Build.VERSION_CODES.M)
|
||||
public boolean isIgnoringBatteryOptimizations(Context context){
|
||||
boolean isIgnoring = false;
|
||||
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
|
||||
if (powerManager != null)
|
||||
isIgnoring = powerManager.isIgnoringBatteryOptimizations("包名");
|
||||
|
||||
return isIgnoring;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求系统白名单
|
||||
* */
|
||||
public void requestIgnoreBatteryOptimizations(Context context){
|
||||
try {
|
||||
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
||||
intent.setData(Uri.parse("package:" + "com.navinfo.outdoor"));
|
||||
context.startActivity(intent);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到指定应用的首页
|
||||
*/
|
||||
public void showActivity(String packageName,Context context){
|
||||
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
/**
|
||||
* 跳转到指定应用的指定页面
|
||||
* */
|
||||
public void showActivity(String packageName,String activityDir,Context context){
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent(new ComponentName(packageName, activityDir));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
//判断手机厂商
|
||||
public String checkPhoneFirm(){
|
||||
String phoneState = Build.BRAND.toLowerCase(); //获取手机厂商
|
||||
if (phoneState.equals("huawei") || phoneState.equals("honor"))
|
||||
return WhiteListHelper.IS_HUAWEI;
|
||||
else if (phoneState.equals("xiaomi") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_XIAOMI;
|
||||
else if (phoneState.equals("oppo") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_OPPO;
|
||||
else if (phoneState.equals("vivo") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_VIVO;
|
||||
else if (phoneState.equals("meizu") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_MEIZU;
|
||||
else if (phoneState.equals("samsung") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_SAMSUNG;
|
||||
else if (phoneState.equals("letv") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_LETV;
|
||||
else if (phoneState.equals("smartisan") && Build.BRAND != null)
|
||||
return WhiteListHelper.IS_SMARTISAN;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//前往设置白名单管理界面
|
||||
public void gotoWhiteListSetting(Context context){
|
||||
if (checkPhoneFirm().equals(WhiteListHelper.IS_HUAWEI)){
|
||||
try {
|
||||
showActivity("com.huawei.systemmanager","com.huawei.systemmanager.startupmgr.ui.StartupNormalAppListActivity",context);
|
||||
}catch (Exception e){
|
||||
showActivity("com.huawei.systemmanager",
|
||||
"com.huawei.systemmanager.optimize.bootstart.BootStartActivity",context);
|
||||
}
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_XIAOMI)){
|
||||
showActivity("com.miui.securitycenter",
|
||||
"com.miui.permcenter.autostart.AutoStartManagementActivity",context);
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_OPPO)){
|
||||
//oppo:操作步骤:权限隐私 -> 自启动管理 -> 允许应用自启动
|
||||
try {
|
||||
showActivity("com.coloros.phonemanager",context);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
showActivity("com.oppo.safe",context);
|
||||
} catch (Exception e2) {
|
||||
try {
|
||||
showActivity("com.coloros.oppoguardelf", context);
|
||||
} catch (Exception e3) {
|
||||
showActivity("com.coloros.safecenter", context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_VIVO)){
|
||||
//vivo:操作步骤:权限管理 -> 自启动 -> 允许应用自启动
|
||||
showActivity("com.iqoo.secure", context);
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_MEIZU)){
|
||||
//魅族:操作步骤:权限管理 -> 后台管理 -> 点击应用 -> 允许后台运行
|
||||
showActivity("com.meizu.safe", context);
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_SAMSUNG)){
|
||||
//三星:操作步骤:自动运行应用程序 -> 打开应用开关 -> 电池管理 -> 未监视的应用程序 -> 添加应用
|
||||
try {
|
||||
showActivity("com.samsung.android.sm_cn",context);
|
||||
} catch (Exception e) {
|
||||
showActivity("com.samsung.android.sm",context);
|
||||
}
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_LETV)){
|
||||
//乐视:操作步骤:自启动管理 -> 允许应用自启动
|
||||
showActivity("com.letv.android.letvsafe","com.letv.android.letvsafe.AutobootManageActivity", context);
|
||||
}else if (checkPhoneFirm().equals(WhiteListHelper.IS_SMARTISAN)){
|
||||
//锤子:操作步骤:权限管理 -> 自启动权限管理 -> 点击应用 -> 允许被系统启动
|
||||
showActivity("com.smartisanos.security", context );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.navinfo.outdoor.util
|
||||
|
||||
import com.elvishew.xlog.Logger
|
||||
import com.elvishew.xlog.XLog
|
||||
import com.elvishew.xlog.flattener.ClassicFlattener
|
||||
import com.elvishew.xlog.printer.Printer
|
||||
import com.elvishew.xlog.printer.file.FilePrinter
|
||||
import com.elvishew.xlog.printer.file.naming.DateFileNameGenerator
|
||||
import com.navinfo.outdoor.api.Constant
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
class XLogUtils {
|
||||
val uploadLogWriter by lazy {
|
||||
obtainUploadLogWriter()
|
||||
}
|
||||
val autoTakePictureLogWriter by lazy {
|
||||
obtainAutoTakePictureLogWriter()
|
||||
}
|
||||
companion object {
|
||||
val instance by lazy { XLogUtils() }
|
||||
}
|
||||
|
||||
fun obtainUploadLogWriter(): Logger {
|
||||
val filePrinter: Printer = FilePrinter.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
|
||||
.fileNameGenerator(object : DateFileNameGenerator() {
|
||||
var mLocalDateFormat: ThreadLocal<SimpleDateFormat?> =
|
||||
object : ThreadLocal<SimpleDateFormat?>() {
|
||||
override fun initialValue(): SimpleDateFormat {
|
||||
return SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isFileNameChangeable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun generateFileName(logLevel: Int, timestamp: Long): String {
|
||||
val sdf = mLocalDateFormat.get()
|
||||
sdf!!.timeZone = TimeZone.getDefault()
|
||||
return "批量上传-" + Constant.USHERED+ "-"+ sdf.format(Date(timestamp))
|
||||
}
|
||||
}) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
|
||||
.flattener(ClassicFlattener())
|
||||
.build()
|
||||
return XLog.printers(filePrinter).build()
|
||||
}
|
||||
|
||||
fun obtainAutoTakePictureLogWriter(): Logger {
|
||||
val filePrinter: Printer = FilePrinter.Builder(Constant.LOG_FOLDER) // 指定保存日志文件的路径
|
||||
.fileNameGenerator(object : DateFileNameGenerator() {
|
||||
var mLocalDateFormat: ThreadLocal<SimpleDateFormat?> =
|
||||
object : ThreadLocal<SimpleDateFormat?>() {
|
||||
override fun initialValue(): SimpleDateFormat {
|
||||
return SimpleDateFormat("yyyy-MM-dd", Locale.US)
|
||||
}
|
||||
}
|
||||
|
||||
override fun isFileNameChangeable(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun generateFileName(logLevel: Int, timestamp: Long): String {
|
||||
val sdf = mLocalDateFormat.get()
|
||||
sdf!!.timeZone = TimeZone.getDefault()
|
||||
return "AutoTakePicture-"+ Constant.USHERED+ "-" + sdf.format(Date(timestamp))
|
||||
}
|
||||
}) // 指定日志文件名生成器,默认为 ChangelessFileNameGenerator("log")
|
||||
.flattener(ClassicFlattener())
|
||||
.build()
|
||||
return XLog.printers(filePrinter).build()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.navinfo.outdoor.viewmodel
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.ViewModel
|
||||
import com.navinfo.outdoor.api.Constant
|
||||
import com.tencent.tencentmap.mapsdk.maps.interfaces.Removable
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class RxPicturesViewModel: ViewModel() {
|
||||
private var finalVideoPath: String? = null// 摄像后最终保存的文件名
|
||||
private var geoWkt:String? = null
|
||||
private var detail:String? = null
|
||||
private var type = 0
|
||||
private val radioPicture = 0
|
||||
private var videoIndex = -1
|
||||
private var paperFile: File? = null
|
||||
private var logFile:java.io.File? = null
|
||||
private val removables = mutableListOf<Removable>()
|
||||
|
||||
private fun initDataFromIntent(intent: Intent): Boolean {
|
||||
if (intent != null) {
|
||||
finalVideoPath = intent.getStringExtra(Constant.INTENT_JPG_PATH)
|
||||
type = intent.getIntExtra(Constant.INTENT_TYPE, 0)
|
||||
geoWkt = intent.getStringExtra(Constant.INTENT_GEO_WKT)
|
||||
detail = intent.getStringExtra(Constant.INTENT_DETAIL)
|
||||
if (finalVideoPath != null) {
|
||||
val file: File = File(finalVideoPath)
|
||||
paperFile =
|
||||
File(Objects.requireNonNull(file.parentFile).absoluteFile.toString() + "/" + "paper.txt")
|
||||
videoIndex = file.name.replace(".webp", "").toInt()
|
||||
if (videoIndex == 0) {
|
||||
videoIndex = -1
|
||||
} else {
|
||||
videoIndex = videoIndex - 1
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
@@ -2,13 +2,13 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners
|
||||
android:radius="@dimen/default_corner_radius" />
|
||||
android:radius="@dimen/cardview_default_radius" />
|
||||
<padding
|
||||
android:bottom="@dimen/default_widget_padding"
|
||||
android:left="@dimen/default_widget_padding"
|
||||
android:right="@dimen/default_widget_padding"
|
||||
android:top="@dimen/default_widget_padding" />
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:width="1dp"
|
||||
android:color="@color/colorPrimaryBlue" />
|
||||
</shape>
|
||||
@@ -2,7 +2,7 @@
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
<corners
|
||||
android:radius="@dimen/default_corner_radius" />
|
||||
android:radius="@dimen/cardview_default_radius" />
|
||||
<padding
|
||||
android:bottom="@dimen/default_widget_padding"
|
||||
android:left="@dimen/default_widget_padding"
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<corners android:radius="0.1dip" />
|
||||
<solid android:color="@color/colorGrays"></solid>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/secondaryProgress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="0.1dip" />
|
||||
<solid android:color="@color/black"></solid>
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
|
||||
<item android:id="@android:id/progress">
|
||||
<clip>
|
||||
<shape>
|
||||
<corners android:radius="0.1dip" />
|
||||
<solid android:color="@color/colorBlue"></solid>
|
||||
</shape>
|
||||
</clip>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#460D0D"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M7,14l5,-5 5,5z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12.06,19v-2.01c-0.02,0 -0.04,0 -0.06,0c-1.28,0 -2.56,-0.49 -3.54,-1.46c-1.71,-1.71 -1.92,-4.35 -0.64,-6.29l1.1,1.1c-0.71,1.33 -0.53,3.01 0.59,4.13c0.7,0.7 1.62,1.03 2.54,1.01v-2.14l2.83,2.83L12.06,19zM16.17,14.76l-1.1,-1.1c0.71,-1.33 0.53,-3.01 -0.59,-4.13C13.79,8.84 12.9,8.5 12,8.5c-0.02,0 -0.04,0 -0.06,0v2.15L9.11,7.83L11.94,5v2.02c1.3,-0.02 2.61,0.45 3.6,1.45C17.24,10.17 17.45,12.82 16.17,14.76z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#8C8C8C"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M12,2C6.48,2 2,6.48 2,12c0,5.52 4.48,10 10,10s10,-4.48 10,-10C22,6.48 17.52,2 12,2zM12.06,19v-2.01c-0.02,0 -0.04,0 -0.06,0c-1.28,0 -2.56,-0.49 -3.54,-1.46c-1.71,-1.71 -1.92,-4.35 -0.64,-6.29l1.1,1.1c-0.71,1.33 -0.53,3.01 0.59,4.13c0.7,0.7 1.62,1.03 2.54,1.01v-2.14l2.83,2.83L12.06,19zM16.17,14.76l-1.1,-1.1c0.71,-1.33 0.53,-3.01 -0.59,-4.13C13.79,8.84 12.9,8.5 12,8.5c-0.02,0 -0.04,0 -0.06,0v2.15L9.11,7.83L11.94,5v2.02c1.3,-0.02 2.61,0.45 3.6,1.45C17.24,10.17 17.45,12.82 16.17,14.76z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20.94,11c-0.46,-4.17 -3.77,-7.48 -7.94,-7.94V1h-2v2.06C6.83,3.52 3.52,6.83 3.06,11H1v2h2.06c0.46,4.17 3.77,7.48 7.94,7.94V23h2v-2.06c4.17,-0.46 7.48,-3.77 7.94,-7.94H23v-2h-2.06zM12,19c-3.87,0 -7,-3.13 -7,-7s3.13,-7 7,-7 7,3.13 7,7 -3.13,7 -7,7z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,7 @@
|
||||
<vector android:height="24dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M10,8l0,6l4.7,2.9l0.8,-1.2l-4,-2.4l0,-5.3z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M17.92,12c0.05,0.33 0.08,0.66 0.08,1c0,3.9 -3.1,7 -7,7s-7,-3.1 -7,-7c0,-3.9 3.1,-7 7,-7c0.7,0 1.37,0.1 2,0.29V4.23C12.36,4.08 11.69,4 11,4c-5,0 -9,4 -9,9s4,9 9,9s9,-4 9,-9c0,-0.34 -0.02,-0.67 -0.06,-1H17.92z"/>
|
||||
<path android:fillColor="@android:color/white" android:pathData="M20,5l0,-3l-2,0l0,3l-3,0l0,2l3,0l0,3l2,0l0,-3l3,0l0,-2z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="32dp" android:tint="#000000"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M15.44,0.59l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L11.55,7.3c-0.78,-0.78 -2.05,-0.78 -2.83,0L7.3,8.72c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L6.6,12.25c-0.78,-0.78 -2.05,-0.78 -2.83,0l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l3.54,3.54c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-1.24,-1.24l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l1.41,-1.41c0.78,-0.78 0.78,-2.05 0,-2.83L13.84,9.6l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-3.54,-3.54C17.48,-0.2 16.22,-0.2 15.44,0.59zM6.6,19.32l-1.06,1.06L2,16.85l1.06,-1.06L6.6,19.32zM8.72,17.2l-1.06,1.06l-3.54,-3.54l1.06,-1.06L8.72,17.2zM18.26,7.66L17.2,8.72l-3.54,-3.54l1.06,-1.06L18.26,7.66zM20.38,5.54L19.32,6.6l-3.54,-3.54L16.85,2L20.38,5.54zM14,21l0,2c4.97,0 9,-4.03 9,-9l-2,0C21,17.87 17.87,21 14,21zM14,17l0,2c2.76,0 5,-2.24 5,-5l-2,0C17,15.66 15.66,17 14,17z"/>
|
||||
</vector>
|
||||
@@ -0,0 +1,5 @@
|
||||
<vector android:height="32dp" android:tint="#8C8C8C"
|
||||
android:viewportHeight="24" android:viewportWidth="24"
|
||||
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<path android:fillColor="@android:color/white" android:pathData="M15.44,0.59l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L11.55,7.3c-0.78,-0.78 -2.05,-0.78 -2.83,0L7.3,8.72c-0.78,0.78 -0.78,2.05 0,2.83l1.24,1.24l-0.71,0.71L6.6,12.25c-0.78,-0.78 -2.05,-0.78 -2.83,0l-3.18,3.18c-0.78,0.78 -0.78,2.05 0,2.83l3.54,3.54c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-1.24,-1.24l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l1.41,-1.41c0.78,-0.78 0.78,-2.05 0,-2.83L13.84,9.6l0.71,-0.71l1.24,1.24c0.78,0.78 2.05,0.78 2.83,0l3.18,-3.18c0.78,-0.78 0.78,-2.05 0,-2.83l-3.54,-3.54C17.48,-0.2 16.22,-0.2 15.44,0.59zM6.6,19.32l-1.06,1.06L2,16.85l1.06,-1.06L6.6,19.32zM8.72,17.2l-1.06,1.06l-3.54,-3.54l1.06,-1.06L8.72,17.2zM18.26,7.66L17.2,8.72l-3.54,-3.54l1.06,-1.06L18.26,7.66zM20.38,5.54L19.32,6.6l-3.54,-3.54L16.85,2L20.38,5.54zM14,21l0,2c4.97,0 9,-4.03 9,-9l-2,0C21,17.87 17.87,21 14,21zM14,17l0,2c2.76,0 5,-2.24 5,-5l-2,0C17,15.66 15.66,17 14,17z"/>
|
||||
</vector>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user