Compare commits
10 Commits
480ff37026
...
ab666e86e6
| Author | SHA1 | Date | |
|---|---|---|---|
| ab666e86e6 | |||
| 143fc22492 | |||
| cbcaf38b65 | |||
| aaaef022ea | |||
| b6ea2b74e0 | |||
| 8bb3d566c9 | |||
| d59e2e65ab | |||
| 89b6c8e01d | |||
| 6153bb607c | |||
| 7a83b510e9 |
@ -6,23 +6,23 @@ plugins {
|
||||
}
|
||||
|
||||
|
||||
sonarqube {
|
||||
properties {
|
||||
//Sonar服务器地址
|
||||
property "sonar.host.url", "http://10.130.14.162:9000/"
|
||||
//Token模式
|
||||
//sonarqube {
|
||||
// properties {
|
||||
// //Sonar服务器地址
|
||||
// property "sonar.host.url", "http://10.130.14.162:9000/"
|
||||
// //Token模式
|
||||
//// property "sonar.login","TRD2022"
|
||||
// //账号密码模式
|
||||
// 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
|
||||
}
|
||||
}
|
||||
// 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'
|
||||
@ -37,15 +37,27 @@ android {
|
||||
applicationId "com.navinfo.outdoor"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 30
|
||||
versionCode 117
|
||||
versionName "8.231011-金山云测试版"
|
||||
versionCode 120
|
||||
versionName "8.231205-测试版"
|
||||
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,
|
||||
@ -81,6 +93,10 @@ android {
|
||||
buildFeatures {
|
||||
viewBinding true
|
||||
}
|
||||
// configurations.all {
|
||||
// all*.exclude group: "com.squareup.okhttp3", module: "okhttp3"
|
||||
// all*.exclude group: "com.squareup.okio", module: "okio"
|
||||
// }
|
||||
}
|
||||
//efs {
|
||||
// //是否对启动过程进程插桩的开关,如果使用自动集成监控则必须开启
|
||||
@ -131,11 +147,11 @@ dependencies {
|
||||
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'
|
||||
@ -207,4 +223,13 @@ dependencies {
|
||||
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'
|
||||
}
|
||||
@ -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" />
|
||||
@ -129,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"
|
||||
@ -153,9 +173,9 @@
|
||||
<activity
|
||||
android:name=".activity.AutoTakePicture4PoiActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".activity.AutoTakePicture4PoiVideoActivity"
|
||||
android:screenOrientation="landscape" />
|
||||
<!-- <activity-->
|
||||
<!-- android:name=".activity.AutoTakePicture4PoiVideoActivity"-->
|
||||
<!-- android:screenOrientation="landscape" />-->
|
||||
<activity
|
||||
android:name=".activity.UserActivity"
|
||||
android:configChanges="keyboardHidden|orientation"
|
||||
@ -223,10 +243,106 @@
|
||||
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>
|
||||
@ -120,8 +120,10 @@ import org.locationtech.jts.geom.Point;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -176,6 +178,7 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
private LocationRecorderDao recorderDao;
|
||||
private PoiDao poiDao;
|
||||
private SimpleDateFormat picFormatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
private DateFormat receiverDateFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");; // 接收任务时间的格式化对象
|
||||
private Button btnClearMatch, btnStopPicture;
|
||||
private Point lastPositionPoint; // 最近一次的定位,用来过滤距离较近的点位
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
@ -604,7 +607,7 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
|
||||
if (poiEntity == null) {
|
||||
// 数据库中不存在,尝试再次领取
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePicture4PoiActivity.this, translateRoadMatchEntity(roadMatchEntity));
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePicture4PoiActivity.this, roadMatchEntity.getDataDetail());
|
||||
// 调用网络领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
}
|
||||
@ -671,19 +674,62 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
* 根据网络数据和本地数据库数据,更新地图上渲染的道路任务
|
||||
* */
|
||||
private void initRoadLine2Map() {
|
||||
roadLinkEntityList.clear();
|
||||
if (Constant.USHERED != null) {
|
||||
// 刷新筛选的本地数据
|
||||
tencentMarkerUtils.initLocalMarker(AutoTakePicture4PoiActivity.this, tencentMap, removablesLocality, removableHashMap, new TencentMarkerUtils.MarkerInitCallback<PoiEntity>() {
|
||||
@Override
|
||||
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet, List<PoiEntity> listData) {
|
||||
|
||||
// 将已领取的任务数据添加到可匹配列表中
|
||||
if (listData!=null&&listData.size()>0) {
|
||||
for (PoiEntity poiEntity: listData) {
|
||||
// 过滤POI录像类型数据,且状态为已领取
|
||||
if (poiEntity.getType() == 3 && poiEntity.getTaskStatus() == 1) {
|
||||
String geometryStr = Geohash.getInstance().decode(poiEntity.getGeoWkt());
|
||||
Geometry geometry = GeometryTools.createGeometry(geometryStr);
|
||||
// 实时设置当前任务的起始角度
|
||||
if (geometry instanceof LineString) {
|
||||
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
|
||||
roadMatchEntity.setId(poiEntity.getTaskId());
|
||||
roadMatchEntity.setDataDetail(poiEntity);
|
||||
roadMatchEntity.setGeometry((LineString) geometry);
|
||||
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
|
||||
LineString lineString = (LineString) geometry;
|
||||
// 计算前两个点的坐标角度
|
||||
// 获取当前数据的前两个点的方向
|
||||
Coordinate[] coordinates = lineString.getCoordinates();
|
||||
// 循环取出当前数据的坐标点,为防止出现重复点,需要循环做判断
|
||||
Coordinate[] lineCoordinates = new Coordinate[2];
|
||||
lineCoordinates[0] = coordinates[0];
|
||||
lineCoordinates[1] = coordinates[0];
|
||||
for (Coordinate c: coordinates) {
|
||||
if (c.x!=lineCoordinates[0].x&&c.y!=lineCoordinates[0].y) {
|
||||
lineCoordinates[1] = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lineCoordinates[0]!=lineCoordinates[1]) {
|
||||
double dataBearing = getBearing(lineCoordinates[0].x, lineCoordinates[1].x, lineCoordinates[0].y, lineCoordinates[1].y);
|
||||
roadMatchEntity.setAngle(dataBearing);
|
||||
}
|
||||
roadMatchEntity.setsPoint(lineString.getStartPoint().toString());
|
||||
roadMatchEntity.setePoint(lineString.getEndPoint().toString());
|
||||
roadLinkEntityList.add(roadMatchEntity);
|
||||
} else {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePicture4PoiActivity.this, "当前界面存在多线任务,已自动过滤!");
|
||||
systemTTS.playText("存在多线任务!");
|
||||
XLog.e("存在多线任务:"+poiEntity.getTaskId()+"-"+poiEntity.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (LocationLifeCycle.getInstance().getMainLocation() != null) { //筛选从服务器获取到的数据
|
||||
// 注意,此处只获取道路数据
|
||||
tencentMarkerUtils.initNetMarkerList(AutoTakePicture4PoiActivity.this, LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables,
|
||||
"3"/*只获取道路数据*/,"0"/*只获取未领取的数据*/, removableHashMap, 30, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
|
||||
"3"/*只获取POI数据*/,"0"/*只获取未领取的数据*/, removableHashMap, 30, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
|
||||
|
||||
@Override
|
||||
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet,
|
||||
@ -693,13 +739,17 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
if (listData!=null) {
|
||||
listData.stream().forEach(
|
||||
it -> {
|
||||
// 如果是半透明显示的未发布任务,直接跳过此次循环
|
||||
if (it.getPublish() == 0) {
|
||||
return;
|
||||
}
|
||||
String geometryStr = Geohash.getInstance().decode(it.getGeo());
|
||||
Geometry geometry = GeometryTools.createGeometry(geometryStr);
|
||||
// 实时设置当前任务的起始角度
|
||||
if (geometry instanceof LineString) {
|
||||
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
|
||||
roadMatchEntity.setId(it.getId());
|
||||
roadMatchEntity.setDataDetail(it);
|
||||
roadMatchEntity.setDataDetail(translateRoadMatchEntity(it));
|
||||
roadMatchEntity.setGeometry((LineString) geometry);
|
||||
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
|
||||
LineString lineString = (LineString) geometry;
|
||||
@ -803,7 +853,7 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
return true;
|
||||
} else {
|
||||
// 根据方向判定无法匹配
|
||||
logger.d(null, "方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getId());
|
||||
logger.d(null, "方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getTaskId());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -1014,11 +1064,9 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
})
|
||||
.min((t1, t2) -> {
|
||||
// 判断距离用户当前位置的距离
|
||||
JobSearchBean.BodyBean.ListBean bean1 = t1.getDataDetail();
|
||||
JobSearchBean.BodyBean.ListBean bean2 = t2.getDataDetail();
|
||||
// 转换geo
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean1.getGeo()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean2.getGeo()));
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(t1.getDataDetail().getGeoWkt()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(t1.getDataDetail().getGeoWkt()));
|
||||
if (currentGeometry.distance(geometry1)>currentGeometry.distance(geometry2)) {
|
||||
return 1;
|
||||
} else if (currentGeometry.distance(geometry1)<currentGeometry.distance(geometry2)) {
|
||||
@ -1036,9 +1084,8 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
.subscribe(new Consumer<RoadMatchEntity>() {
|
||||
@Override
|
||||
public void accept(RoadMatchEntity minRoadLink) throws Exception {
|
||||
JobSearchBean.BodyBean.ListBean bean = minRoadLink.getDataDetail();
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(bean.getGeo())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePicture4PoiActivity.this, "已为您规划距离最近的任务路径:"+bean.getName());
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(minRoadLink.getDataDetail().getGeoWkt())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePicture4PoiActivity.this, "已为您规划距离最近的任务路径:"+minRoadLink.getDataDetail().getName());
|
||||
// 跳转到对应的导航界面
|
||||
try {
|
||||
if (Constant.currentNaviType == null) {
|
||||
@ -1217,13 +1264,13 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
@Override
|
||||
public PoiEntity apply(RoadMatchEntity roadMatchEntity) throws Exception {
|
||||
|
||||
PoiEntity poiEntity = translateRoadMatchEntity(roadMatchEntity);
|
||||
PoiEntity poiEntity = roadMatchEntity.getDataDetail();
|
||||
// 首先发送领取任务的请求
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.time(30)
|
||||
.Builder(AutoTakePicture4PoiActivity.this)
|
||||
.url(HttpInterface.RECEIVED_POI_VIDEO_TASK + "/" + entity.getDataDetail().getId())
|
||||
.url(HttpInterface.RECEIVED_POI_VIDEO_TASK + "/" + entity.getDataDetail().getTaskId())
|
||||
.cls(TaskByNetBean.class)
|
||||
.params(new HttpParams())
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
@ -1243,7 +1290,7 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setMemo(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||
@ -1321,7 +1368,7 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
Gson gson = new Gson();
|
||||
UnPolygonTaskBean response = gson.fromJson(bodyString, UnPolygonTaskBean.class);
|
||||
if (response.getCode() == 200) {
|
||||
PoiDatabase.getInstance(AutoTakePicture4PoiActivity.this).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(AutoTakePicture4PoiActivity.this).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
// 不需要删除照片,自动采集时照片是临时保存在tmp目录下
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(AutoTakePicture4PoiActivity.this);
|
||||
@ -1345,9 +1392,8 @@ public class AutoTakePicture4PoiActivity extends BaseActivity implements View.On
|
||||
});
|
||||
}
|
||||
|
||||
private PoiEntity translateRoadMatchEntity(RoadMatchEntity roadMatchEntity) {
|
||||
private PoiEntity translateRoadMatchEntity(JobSearchBean.BodyBean.ListBean listBean) {
|
||||
PoiEntity poiListEntity = new PoiEntity();
|
||||
JobSearchBean.BodyBean.ListBean listBean = roadMatchEntity.getDataDetail();
|
||||
poiListEntity.setTaskId(listBean.getId());
|
||||
poiListEntity.setGeoWkt(listBean.getGeo());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
|
||||
@ -122,6 +122,7 @@ import org.locationtech.jts.geom.Point;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -147,7 +148,7 @@ import okhttp3.Response;
|
||||
|
||||
/**
|
||||
* 拍照
|
||||
* (poi录像 和 道路)
|
||||
* (poi录像 和 道路),暂时弃用
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements View.OnClickListener {
|
||||
@ -180,6 +181,7 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
private LocationRecorderDao recorderDao;
|
||||
private PoiDao poiDao;
|
||||
private SimpleDateFormat picFormatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
private DateFormat receiverDateFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");; // 接收任务时间的格式化对象
|
||||
private Button btnClearMatch, btnStopPicture;
|
||||
private Point lastPositionPoint; // 最近一次的定位,用来过滤距离较近的点位
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
@ -522,11 +524,11 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
super.onPictureTaken(result);
|
||||
System.out.println("收到拍照按钮jieguo:"+result.getSize().toString());
|
||||
// poi录像不强制要求必须为横向拍照
|
||||
// if (Objects.requireNonNull(camera.getSnapshotSize()).getWidth() < camera.getSnapshotSize().getHeight()) {
|
||||
// ToastUtils.Message(AutoTakePicture4PoiVideoActivity.this, "不允许竖向拍摄...");
|
||||
// systemTTS.playText("不允许竖向拍摄");
|
||||
// return;
|
||||
// }
|
||||
if (Objects.requireNonNull(camera.getSnapshotSize()).getWidth() < camera.getSnapshotSize().getHeight()) {
|
||||
ToastUtils.Message(AutoTakePicture4PoiVideoActivity.this, "不允许竖向拍摄...");
|
||||
systemTTS.playText("不允许竖向拍摄");
|
||||
return;
|
||||
}
|
||||
|
||||
File tmpPicFolder = new File(tmpPicFoldPath);
|
||||
if (!tmpPicFolder.exists()) {
|
||||
@ -609,11 +611,15 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
if (listData!=null) {
|
||||
listData.stream().forEach(
|
||||
it -> {
|
||||
// 如果是半透明显示的未发布任务,直接跳过此次循环
|
||||
if (it.getPublish() == 0) {
|
||||
return;
|
||||
}
|
||||
String geometryStr = Geohash.getInstance().decode(it.getGeo());
|
||||
Geometry geometry = GeometryTools.createGeometry(geometryStr);
|
||||
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
|
||||
roadMatchEntity.setId(it.getId());
|
||||
roadMatchEntity.setDataDetail(it);
|
||||
roadMatchEntity.setDataDetail(translateRoadMatchEntity(it));
|
||||
roadMatchEntity.setGeometry((LineString) geometry);
|
||||
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
|
||||
// 实时设置当前任务的起始角度
|
||||
@ -715,7 +721,7 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
return true;
|
||||
} else {
|
||||
// 根据方向判定无法匹配
|
||||
write2Log("方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getId());
|
||||
write2Log("方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getTaskId());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -916,11 +922,9 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
})
|
||||
.min((t1, t2) -> {
|
||||
// 判断距离用户当前位置的距离
|
||||
JobSearchBean.BodyBean.ListBean bean1 = t1.getDataDetail();
|
||||
JobSearchBean.BodyBean.ListBean bean2 = t2.getDataDetail();
|
||||
// 转换geo
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean1.getGeo()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean2.getGeo()));
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(t1.getDataDetail().getGeoWkt()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(t2.getDataDetail().getGeoWkt()));
|
||||
if (currentGeometry.distance(geometry1)>currentGeometry.distance(geometry2)) {
|
||||
return 1;
|
||||
} else if (currentGeometry.distance(geometry1)<currentGeometry.distance(geometry2)) {
|
||||
@ -938,9 +942,8 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
.subscribe(new Consumer<RoadMatchEntity>() {
|
||||
@Override
|
||||
public void accept(RoadMatchEntity minRoadLink) throws Exception {
|
||||
JobSearchBean.BodyBean.ListBean bean = minRoadLink.getDataDetail();
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(bean.getGeo())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePicture4PoiVideoActivity.this, "已为您规划距离最近的任务路径:"+bean.getName());
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(minRoadLink.getDataDetail().getGeoWkt())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePicture4PoiVideoActivity.this, "已为您规划距离最近的任务路径:"+minRoadLink.getDataDetail().getName());
|
||||
// 跳转到对应的导航界面
|
||||
try {
|
||||
if (Constant.currentNaviType == null) {
|
||||
@ -1119,13 +1122,13 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
@Override
|
||||
public PoiEntity apply(RoadMatchEntity roadMatchEntity) throws Exception {
|
||||
|
||||
PoiEntity poiEntity = translateRoadMatchEntity(roadMatchEntity);
|
||||
PoiEntity poiEntity = roadMatchEntity.getDataDetail();
|
||||
// 首先发送领取任务的请求
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.time(30)
|
||||
.Builder(AutoTakePicture4PoiVideoActivity.this)
|
||||
.url(HttpInterface.RECEIVED_POI_VIDEO_TASK + "/" + entity.getDataDetail().getId())
|
||||
.url(HttpInterface.RECEIVED_POI_VIDEO_TASK + "/" + entity.getDataDetail().getTaskId())
|
||||
.cls(TaskByNetBean.class)
|
||||
.params(new HttpParams())
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
@ -1145,7 +1148,7 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setMemo(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||
@ -1223,7 +1226,7 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
Gson gson = new Gson();
|
||||
UnPolygonTaskBean response = gson.fromJson(bodyString, UnPolygonTaskBean.class);
|
||||
if (response.getCode() == 200) {
|
||||
PoiDatabase.getInstance(AutoTakePicture4PoiVideoActivity.this).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(AutoTakePicture4PoiVideoActivity.this).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
// 不需要删除照片,自动采集时照片是临时保存在tmp目录下
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(AutoTakePicture4PoiVideoActivity.this);
|
||||
@ -1247,9 +1250,8 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
});
|
||||
}
|
||||
|
||||
private PoiEntity translateRoadMatchEntity(RoadMatchEntity roadMatchEntity) {
|
||||
private PoiEntity translateRoadMatchEntity(JobSearchBean.BodyBean.ListBean listBean) {
|
||||
PoiEntity poiListEntity = new PoiEntity();
|
||||
JobSearchBean.BodyBean.ListBean listBean = roadMatchEntity.getDataDetail();
|
||||
poiListEntity.setTaskId(listBean.getId());
|
||||
poiListEntity.setGeoWkt(listBean.getGeo());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
@ -1286,7 +1288,7 @@ public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements Vi
|
||||
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
|
||||
if (poiEntity == null) {
|
||||
// 数据库中不存在,尝试再次领取
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePicture4PoiVideoActivity.this, translateRoadMatchEntity(roadMatchEntity));
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePicture4PoiVideoActivity.this, roadMatchEntity.getDataDetail());
|
||||
// 调用网络领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
}
|
||||
|
||||
@ -227,6 +227,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
private LocationRecorderDao recorderDao;
|
||||
private PoiDao poiDao;
|
||||
private SimpleDateFormat picFormatter = new SimpleDateFormat("yyyyMMdd HHmmss");
|
||||
private DateFormat receiverDateFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");; // 接收任务时间的格式化对象
|
||||
private Button btnClearMatch, btnStopPicture;
|
||||
private Point lastPositionPoint; // 最近一次的定位,用来过滤距离较近的点位
|
||||
private static int BRIGHTNESS=40, FRAMENESS=30;
|
||||
@ -656,7 +657,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
PoiEntity poiEntity = poiDao.getTaskIdPoiEntity(roadMatchEntity.getId());
|
||||
if (poiEntity == null) {
|
||||
// 数据库中不存在,尝试再次领取
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, translateRoadMatchEntity(roadMatchEntity));
|
||||
InsertAndUpdateUtils.getInstance().insertOrUpdate(AutoTakePictureActivity.this, roadMatchEntity.getDataDetail());
|
||||
// 调用网络领取任务
|
||||
receiverRoadTask(roadMatchEntity).subscribe(receiveObserver);
|
||||
}
|
||||
@ -723,12 +724,55 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
* 根据网络数据和本地数据库数据,更新地图上渲染的道路任务
|
||||
* */
|
||||
private void initRoadLine2Map() {
|
||||
roadLinkEntityList.clear();
|
||||
if (Constant.USHERED != null) {
|
||||
// 刷新筛选的本地数据
|
||||
tencentMarkerUtils.initLocalMarker(AutoTakePictureActivity.this, tencentMap, removablesLocality, removableHashMap, new TencentMarkerUtils.MarkerInitCallback<PoiEntity>() {
|
||||
@Override
|
||||
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet, List<PoiEntity> listData) {
|
||||
|
||||
// 将已领取的任务数据添加到可匹配列表中
|
||||
if (listData!=null&&listData.size()>0) {
|
||||
for (PoiEntity poiEntity: listData) {
|
||||
// 过滤道路类型数据,且状态为已领取
|
||||
if (poiEntity.getType() == 4 && poiEntity.getTaskStatus() == 1) {
|
||||
String geometryStr = Geohash.getInstance().decode(poiEntity.getGeoWkt());
|
||||
Geometry geometry = GeometryTools.createGeometry(geometryStr);
|
||||
// 实时设置当前任务的起始角度
|
||||
if (geometry instanceof LineString) {
|
||||
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
|
||||
roadMatchEntity.setId(poiEntity.getTaskId());
|
||||
roadMatchEntity.setDataDetail(poiEntity);
|
||||
roadMatchEntity.setGeometry((LineString) geometry);
|
||||
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
|
||||
LineString lineString = (LineString) geometry;
|
||||
// 计算前两个点的坐标角度
|
||||
// 获取当前数据的前两个点的方向
|
||||
Coordinate[] coordinates = lineString.getCoordinates();
|
||||
// 循环取出当前数据的坐标点,为防止出现重复点,需要循环做判断
|
||||
Coordinate[] lineCoordinates = new Coordinate[2];
|
||||
lineCoordinates[0] = coordinates[0];
|
||||
lineCoordinates[1] = coordinates[0];
|
||||
for (Coordinate c: coordinates) {
|
||||
if (c.x!=lineCoordinates[0].x&&c.y!=lineCoordinates[0].y) {
|
||||
lineCoordinates[1] = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (lineCoordinates[0]!=lineCoordinates[1]) {
|
||||
double dataBearing = getBearing(lineCoordinates[0].x, lineCoordinates[1].x, lineCoordinates[0].y, lineCoordinates[1].y);
|
||||
roadMatchEntity.setAngle(dataBearing);
|
||||
}
|
||||
roadMatchEntity.setsPoint(lineString.getStartPoint().toString());
|
||||
roadMatchEntity.setePoint(lineString.getEndPoint().toString());
|
||||
roadLinkEntityList.add(roadMatchEntity);
|
||||
} else {
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(AutoTakePictureActivity.this, "当前界面存在多线任务,已自动过滤!");
|
||||
systemTTS.playText("存在多线任务!");
|
||||
XLog.e("存在多线任务:"+poiEntity.getTaskId()+"-"+poiEntity.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -741,17 +785,20 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet,
|
||||
List<JobSearchBean.BodyBean.ListBean> listData) {
|
||||
// 根据获取到的网络数据,整理数据的起终点数据,方便接下来自动捕捉数据
|
||||
roadLinkEntityList.clear();
|
||||
if (listData!=null) {
|
||||
listData.stream().forEach(
|
||||
it -> {
|
||||
// 如果是半透明显示的未发布任务,直接跳过此次循环
|
||||
if (it.getPublish() == 0) {
|
||||
return;
|
||||
}
|
||||
String geometryStr = Geohash.getInstance().decode(it.getGeo());
|
||||
Geometry geometry = GeometryTools.createGeometry(geometryStr);
|
||||
// 实时设置当前任务的起始角度
|
||||
if (geometry instanceof LineString) {
|
||||
RoadMatchEntity roadMatchEntity = new RoadMatchEntity();
|
||||
roadMatchEntity.setId(it.getId());
|
||||
roadMatchEntity.setDataDetail(it);
|
||||
roadMatchEntity.setDataDetail(translateRoadMatchEntity(it));
|
||||
roadMatchEntity.setGeometry((LineString) geometry);
|
||||
// roadMatchEntity.setBuffer(geometry.buffer(MATCH_BUFFER_DISTANCE).toString());
|
||||
LineString lineString = (LineString) geometry;
|
||||
@ -855,7 +902,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
return true;
|
||||
} else {
|
||||
// 根据方向判定无法匹配
|
||||
logger.d(null, "方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getId());
|
||||
logger.d(null, "方向不匹配:", "currentBearing:"+currentBearing+",数据角度:"+dataBearing+",数据id:"+it.getDataDetail().getTaskId());
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -1066,11 +1113,9 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
})
|
||||
.min((t1, t2) -> {
|
||||
// 判断距离用户当前位置的距离
|
||||
JobSearchBean.BodyBean.ListBean bean1 = t1.getDataDetail();
|
||||
JobSearchBean.BodyBean.ListBean bean2 = t2.getDataDetail();
|
||||
// 转换geo
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean1.getGeo()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean2.getGeo()));
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(t1.getDataDetail().getGeoWkt()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(t2.getDataDetail().getGeoWkt()));
|
||||
if (currentGeometry.distance(geometry1)>currentGeometry.distance(geometry2)) {
|
||||
return 1;
|
||||
} else if (currentGeometry.distance(geometry1)<currentGeometry.distance(geometry2)) {
|
||||
@ -1088,9 +1133,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
.subscribe(new Consumer<RoadMatchEntity>() {
|
||||
@Override
|
||||
public void accept(RoadMatchEntity minRoadLink) throws Exception {
|
||||
JobSearchBean.BodyBean.ListBean bean = minRoadLink.getDataDetail();
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(bean.getGeo())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePictureActivity.this, "已为您规划距离最近的任务路径:"+bean.getName());
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(minRoadLink.getDataDetail().getGeoWkt())).getCoordinates()[0];
|
||||
ToastUtils.Message(AutoTakePictureActivity.this, "已为您规划距离最近的任务路径:"+minRoadLink.getDataDetail().getName());
|
||||
// 跳转到对应的导航界面
|
||||
try {
|
||||
if (Constant.currentNaviType == null) {
|
||||
@ -1269,13 +1313,13 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
@Override
|
||||
public PoiEntity apply(RoadMatchEntity roadMatchEntity) throws Exception {
|
||||
|
||||
PoiEntity poiEntity = translateRoadMatchEntity(roadMatchEntity);
|
||||
PoiEntity poiEntity = roadMatchEntity.getDataDetail();
|
||||
// 首先发送领取任务的请求
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.time(30)
|
||||
.Builder(AutoTakePictureActivity.this)
|
||||
.url(HttpInterface.RECEIVED_ROAD_TASK + "/" + entity.getDataDetail().getId())
|
||||
.url(HttpInterface.RECEIVED_ROAD_TASK + "/" + entity.getDataDetail().getTaskId())
|
||||
.cls(TaskByNetBean.class)
|
||||
.params(new HttpParams())
|
||||
.token(Constant.ACCESS_TOKEN);
|
||||
@ -1295,7 +1339,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setMemo(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||
@ -1373,7 +1417,7 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
Gson gson = new Gson();
|
||||
UnPolygonTaskBean response = gson.fromJson(bodyString, UnPolygonTaskBean.class);
|
||||
if (response.getCode() == 200) {
|
||||
PoiDatabase.getInstance(AutoTakePictureActivity.this).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(AutoTakePictureActivity.this).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
// 不需要删除照片,自动采集时照片是临时保存在tmp目录下
|
||||
} else if (response.getCode() == 230) {
|
||||
FlushTokenUtil.flushToken(AutoTakePictureActivity.this);
|
||||
@ -1397,9 +1441,8 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
|
||||
});
|
||||
}
|
||||
|
||||
private PoiEntity translateRoadMatchEntity(RoadMatchEntity roadMatchEntity) {
|
||||
private PoiEntity translateRoadMatchEntity(JobSearchBean.BodyBean.ListBean listBean) {
|
||||
PoiEntity poiListEntity = new PoiEntity();
|
||||
JobSearchBean.BodyBean.ListBean listBean = roadMatchEntity.getDataDetail();
|
||||
poiListEntity.setTaskId(listBean.getId());
|
||||
poiListEntity.setGeoWkt(listBean.getGeo());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
|
||||
@ -1,23 +1,29 @@
|
||||
package com.navinfo.outdoor.activity;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.github.lazylibrary.util.PreferencesUtils;
|
||||
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.lzy.okgo.model.HttpParams;
|
||||
import com.navinfo.ocr.OCRManager;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.api.UserApplication;
|
||||
import com.navinfo.outdoor.base.BaseActivity;
|
||||
import com.navinfo.outdoor.bean.CommonRequestSend;
|
||||
import com.navinfo.outdoor.bean.CommonResponse;
|
||||
import com.navinfo.outdoor.bean.NotificationBean;
|
||||
import com.navinfo.outdoor.fragment.FindFragment;
|
||||
import com.navinfo.outdoor.fragment.MineFragment;
|
||||
import com.navinfo.outdoor.fragment.RecordFragment;
|
||||
import com.navinfo.outdoor.fragment.TreasureFragment;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
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;
|
||||
@ -48,6 +54,7 @@ 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;
|
||||
@ -83,6 +90,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) {
|
||||
@ -114,6 +122,22 @@ public class HomeActivity extends BaseActivity {
|
||||
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));
|
||||
// 使用Shared文件记录最近一次的登陆Id和推送需要的请求地址,防止通过推送响应时请求地址为null的问题
|
||||
PreferencesUtils.putString(HomeActivity.this, "MESSAGE_PUSH_GET_OR_CLICK_UPLOAD", HttpInterface.MESSAGE_PUSH_GET_OR_CLICK_UPLOAD);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
@ -133,6 +157,75 @@ 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){
|
||||
int messageId = intent.getIntExtra(Constant.NOTIFYCATION_ID, -1);
|
||||
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);
|
||||
}
|
||||
uploadReceivePushMessage(HomeActivity.this, messageId+"", 1);
|
||||
} 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);
|
||||
}
|
||||
uploadReceivePushMessage(HomeActivity.this, messageId+"", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报获取到推送消息的时间给服务端
|
||||
* @param messageId 推送消息对应的id
|
||||
* @param type 0-获取到消息,1-点击推送消息
|
||||
* */
|
||||
private void uploadReceivePushMessage(Context mContext, String messageId, int type) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("messageId", messageId);
|
||||
httpParams.put("type", type);
|
||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<Integer>>();
|
||||
commonRequestSend.postMethodCommonSilence(mContext, PreferencesUtils.getString(mContext, "MESSAGE_PUSH_GET_OR_CLICK_UPLOAD")/*从SP文件中获取*/,
|
||||
httpParams, Constant.DEFAULT_TIME_OUT, new Callback<CommonResponse<Integer>>() {
|
||||
@Override
|
||||
public void onSuccess(CommonResponse<Integer> response, int id) {
|
||||
if (response.getCode() == 200) {
|
||||
// 推送消息获取时间上报成功
|
||||
XLog.d("上报推送接收成功:"+response.getMessage()+"-messageId:"+messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
XLog.d("上报推送接收失败:"+e.getMessage()+"-messageId:"+messageId);
|
||||
}
|
||||
}, new CommonResponse<Integer>().getClass());
|
||||
}
|
||||
|
||||
private void initUM() {
|
||||
@ -176,7 +269,7 @@ public class HomeActivity extends BaseActivity {
|
||||
Log.i("TAGEE", "click dismissNotification: " + msg.getRaw().toString());
|
||||
}
|
||||
};
|
||||
UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
||||
// UserApplication.instance.setNotificationClickHandler(notificationClickHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -93,6 +93,8 @@ import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||
import com.umeng.commonsdk.internal.crash.UMCrashManager;
|
||||
import com.umeng.umcrash.UMCrash;
|
||||
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.LineString;
|
||||
import org.locationtech.jts.geom.MultiLineString;
|
||||
@ -684,6 +686,11 @@ public class PicturesActivity extends BaseActivity implements View.OnClickListen
|
||||
for (int i = 0; i < multiLineString.getNumGeometries(); i++) {
|
||||
lineStringList.add((LineString) multiLineString.getGeometryN(i));
|
||||
}
|
||||
}
|
||||
else if ("Point".equals(taskGeometry.getGeometryType())) {
|
||||
Coordinate pointCoor = taskGeometry.getCoordinate();
|
||||
Coordinate pointCoor2 = new Coordinate(pointCoor.x, pointCoor.y+0.00001);
|
||||
lineStringList.add(GeometryTools.getLineStrinGeo(new Coordinate[]{pointCoor, pointCoor2}));
|
||||
} else {
|
||||
lineStringList.add((LineString) taskGeometry);
|
||||
}
|
||||
|
||||
@ -0,0 +1,251 @@
|
||||
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().deletePoiEntityById(poiEntity.getId());
|
||||
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());
|
||||
if (poiEntity.getCreateTime()!=null&&!poiEntity.getCreateTime().trim().isEmpty()) {
|
||||
holder.tvCreateTime.setText("领取时间:"+poiEntity.getCreateTime());
|
||||
} else {
|
||||
holder.tvCreateTime.setVisibility(View.GONE);
|
||||
}
|
||||
if (poiEntity.getUnReceivedTime()!=null&&!poiEntity.getUnReceivedTime().trim().isEmpty()) {
|
||||
holder.tvExpirationTime.setText("过期时间:"+poiEntity.getUnReceivedTime());
|
||||
} else {
|
||||
holder.tvExpirationTime.setVisibility(View.GONE);
|
||||
}
|
||||
//获取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, tvCreateTime, tvExpirationTime;
|
||||
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);
|
||||
tvCreateTime = itemView.findViewById(R.id.tv_poi_createtime);
|
||||
tvExpirationTime = itemView.findViewById(R.id.tv_poi_expirationtime);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -117,7 +117,7 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
PoiEntity poiEntity = (PoiEntity) iterator.next();
|
||||
if (poiEntity.isChecked()) {
|
||||
PoiEntityDeleteUtil.getInstance().deleteUtil(context, poiEntity);
|
||||
PoiDatabase.getInstance(context).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(context).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@ -143,7 +143,7 @@ public class StaySubmitAdapter extends RecyclerView.Adapter<StaySubmitAdapter.Vi
|
||||
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());
|
||||
holder.tvDay.setText("保存时间:"+poiEntity.getCreateTime());
|
||||
//获取checkBox点击的记录
|
||||
holder.cbUnSubmit.setChecked(allRoad.get(position).isChecked());
|
||||
holder.cbUnSubmit.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@ -44,6 +44,7 @@ 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) {
|
||||
@ -156,6 +157,10 @@ public class Constant {
|
||||
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
|
||||
@ -282,4 +287,11 @@ 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";
|
||||
public static String NOTIFYCATION_ID = "NOTIFYCATION_ID";
|
||||
}
|
||||
|
||||
55
app/src/main/java/com/navinfo/outdoor/api/KeepLiveUtils.java
Normal file
55
app/src/main/java/com/navinfo/outdoor/api/KeepLiveUtils.java
Normal file
@ -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() {
|
||||
//该回调方法可能会不回调
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.kongzue.dialogx.DialogX;
|
||||
import com.kongzue.dialogx.style.MIUIStyle;
|
||||
import com.kongzue.dialogx.style.MaterialStyle;
|
||||
@ -21,15 +22,16 @@ import com.lzy.okgo.cookie.store.DBCookieStore;
|
||||
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
|
||||
import com.lzy.okgo.model.HttpHeaders;
|
||||
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;
|
||||
@ -70,6 +72,23 @@ public class UserApplication extends Application {
|
||||
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() {
|
||||
@ -129,7 +148,7 @@ public class UserApplication extends Application {
|
||||
//App处于前台时不显示通知
|
||||
//instance.setNotificationOnForeground(false);
|
||||
//设置显示通知的数量
|
||||
instance.setDisplayNotificationNumber(0);
|
||||
// instance.setDisplayNotificationNumber(0);
|
||||
//服务端控制声音
|
||||
//instance.setNotificationPlaySound(MsgConstant.NOTIFICATION_PLAY_SERVER);
|
||||
//通知免打扰时段
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.bean;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
@ -45,36 +46,40 @@ import okhttp3.ResponseBody;
|
||||
public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
public void getMethodCommon(Activity mContext, String url, HttpParams params, int timeOut, Callback<CommonResponse<T>> callback, Class<T> tClass) {
|
||||
try {
|
||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 0, tClass))
|
||||
((GetRequest<CommonResponse<T>>) obitainRequest(url, params, timeOut, 0, tClass))
|
||||
.adapt()
|
||||
.execute();
|
||||
if (response.code() == 200) {
|
||||
if (response.body().getCode() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else if (response.body().getCode() == 230){
|
||||
FlushTokenUtil.flushToken(mContext);
|
||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
||||
callback.onError(throwable, -1);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable(response.message());
|
||||
callback.onError(throwable, -2);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
.execute(new MyJsonCallback<CommonResponse<T>>() {
|
||||
@Override
|
||||
public void onSuccess(Response<CommonResponse<T>> response) {
|
||||
if (response.code() == 200) {
|
||||
if (response.body().getCode() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else if (response.body().getCode() == 230){
|
||||
FlushTokenUtil.flushToken(mContext);
|
||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
||||
callback.onError(throwable, -1);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable(response.message());
|
||||
callback.onError(throwable, -2);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Throwable throwable = e;
|
||||
@ -92,7 +97,7 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
|
||||
public CommonResponse<T> getMethodCommonSync(Activity mContext, String url, HttpParams params, int timeOut, Class<T> tClass) {
|
||||
try {
|
||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 0, tClass))
|
||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(url, params, timeOut, 0, tClass))
|
||||
.adapt()
|
||||
.execute();
|
||||
if (response.code() == 200) {
|
||||
@ -117,38 +122,97 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送post请求,但是无需重试,无需检查是否成功登录
|
||||
* 这个方法用于发送一些不重要的请求,当用户本地token过期时,有可能需要重新登录
|
||||
* */
|
||||
public void postMethodCommonSilence(Context mContext, String url, HttpParams params, int timeOut, Callback<CommonResponse<T>> callback, Class<T> tClass) {
|
||||
try {
|
||||
((PostRequest<CommonResponse<T>>) obitainRequest(url, params, timeOut, 1, tClass))
|
||||
.adapt()
|
||||
.execute(new MyJsonCallback<CommonResponse<T>>() {
|
||||
@Override
|
||||
public void onSuccess(Response<CommonResponse<T>> response) {
|
||||
if (response.code() == 200) {
|
||||
if (response.body().getCode() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else if (response.body().getCode() == 230){
|
||||
FlushTokenUtil.flushTokenSilence(mContext);
|
||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
||||
callback.onError(throwable, -1);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable(response.message());
|
||||
callback.onError(throwable, -2);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Throwable throwable = e;
|
||||
if (throwable != null) {
|
||||
throwable.printStackTrace();
|
||||
callback.onError(throwable, -3);
|
||||
}
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
}
|
||||
|
||||
public void postMethodCommon(Activity mContext, String url, HttpParams params, int timeOut, Callback<CommonResponse<T>> callback, Class<T> tClass) {
|
||||
try {
|
||||
Response<CommonResponse<T>> response = ((GetRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 1, tClass))
|
||||
((PostRequest<CommonResponse<T>>) obitainRequest(url, params, timeOut, 1, tClass))
|
||||
.adapt()
|
||||
.execute();
|
||||
if (response.code() == 200) {
|
||||
if (response.body().getCode() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else if (response.body().getCode() == 230){
|
||||
FlushTokenUtil.flushToken(mContext);
|
||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
||||
callback.onError(throwable, -1);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable(response.message());
|
||||
callback.onError(throwable, -2);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
.execute(new MyJsonCallback<CommonResponse<T>>() {
|
||||
@Override
|
||||
public void onSuccess(Response<CommonResponse<T>> response) {
|
||||
if (response.code() == 200) {
|
||||
if (response.body().getCode() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else if (response.body().getCode() == 230){
|
||||
FlushTokenUtil.flushToken(mContext);
|
||||
Toast.makeText(mContext, "token过期,请重新登录后再试...", Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable("token过期,请重新登录后再试...");
|
||||
callback.onError(throwable, -1);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
Throwable throwable = new Throwable(response.message());
|
||||
callback.onError(throwable, -2);
|
||||
/*
|
||||
* 友盟+
|
||||
* 使用自定义错误,查看时请在错误列表页面选择【自定义异常】
|
||||
*/
|
||||
UMCrash.generateCustomLog("网络请求报错-位置:OKGOBuilder" + throwable, "UmengException");
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(mContext, response.message(), Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Throwable throwable = e;
|
||||
@ -166,7 +230,7 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
|
||||
public CommonResponse<T> postMethodCommonSync(Activity mContext, String url, HttpParams params, int timeOut, List<File> files, Class<T> tClass) {
|
||||
try {
|
||||
PostRequest<CommonResponse<T>> postRequest = (PostRequest<CommonResponse<T>>) obitainRequest(mContext, url, params, timeOut, 1, tClass);
|
||||
PostRequest<CommonResponse<T>> postRequest = (PostRequest<CommonResponse<T>>) obitainRequest(url, params, timeOut, 1, tClass);
|
||||
if (files!=null) {
|
||||
postRequest.addFileParams("file", files);
|
||||
}
|
||||
@ -199,7 +263,7 @@ public class CommonRequestSend<T extends CommonResponseBase> {
|
||||
* 生成通用请求
|
||||
* @param requestType 0-默认为get请求,非0-post请求
|
||||
* */
|
||||
private Request obitainRequest(Activity mContext, String url, HttpParams params, int timeOut, int requestType, Class<T> clazz) throws Exception{
|
||||
private Request obitainRequest(String url, HttpParams params, int timeOut, int requestType, Class<T> clazz) throws Exception{
|
||||
if (!NetWorkUtils.iConnected(UserApplication.userApplication)) { // 当前网络不可用
|
||||
throw new Exception("网络不可用");
|
||||
}
|
||||
@ -237,7 +301,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; // 是否已发布,如果是未发布的数据,则用半透明形式展示,0-未发布,1-已发布
|
||||
|
||||
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;
|
||||
|
||||
@ -816,7 +816,7 @@ public class AreaHubFragment extends BaseDrawerFragment implements View.OnClickL
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
|
||||
@ -917,7 +917,7 @@ public class BuildingInFragment extends BaseDrawerFragment implements View.OnCli
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
|
||||
@ -1767,7 +1767,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View.
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
if (showPoiEntity != null) {
|
||||
List<ChargingPileEntity> chargingPileEntityList = PoiDatabase.getInstance(getActivity()).getChargingPileDao().getChargingPileByStationId(showPoiEntity.getId());
|
||||
if (chargingPileEntityList != null && !chargingPileEntityList.isEmpty()) {
|
||||
|
||||
@ -75,6 +75,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
private StringBuilder gatherGetBuilder;
|
||||
private TextView tvStartNav;
|
||||
private TextView tvMatchTrack; // 手动匹配轨迹照片
|
||||
private DateFormat receiverDateFormate; // 接收任务时间的格式化对象
|
||||
|
||||
public static GatherGetFragment newInstance(Bundle bundle) {
|
||||
GatherGetFragment fragment = new GatherGetFragment();
|
||||
@ -89,6 +90,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
SharedPreferences.Editor sharedEdit = sharedPreferences.edit();
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
DateFormat formatter = new SimpleDateFormat("yyyyMMdd");
|
||||
receiverDateFormate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String newFormat = formatter.format(new Date(System.currentTimeMillis()));
|
||||
String pictures_time = sharedPreferences.getString("pictures_time", null);
|
||||
if (pictures_time == null) {
|
||||
@ -280,32 +282,39 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
* 根据当前数据状态重新构建领取对话框按钮的显隐
|
||||
* */
|
||||
private void initViewByTaskStatus(int taskStatus) {
|
||||
switch (taskStatus) {
|
||||
case 0://未领取
|
||||
btnCancelGet.setVisibility(View.GONE);//取消领取
|
||||
btnGetTask.setVisibility(View.VISIBLE);//领取任务
|
||||
btnGather.setVisibility(View.VISIBLE);//立即采集
|
||||
btnFinishGather.setVisibility(View.GONE);//结束采集
|
||||
break;
|
||||
case 1://已领取
|
||||
btnCancelGet.setVisibility(View.VISIBLE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.VISIBLE);
|
||||
btnFinishGather.setVisibility(View.GONE);
|
||||
break;
|
||||
case 2://已保存
|
||||
case 3://已提交
|
||||
btnCancelGet.setVisibility(View.VISIBLE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.GONE);
|
||||
btnFinishGather.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 4://结束采集
|
||||
btnCancelGet.setVisibility(View.GONE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.GONE);
|
||||
btnFinishGather.setVisibility(View.GONE);
|
||||
break;
|
||||
if (poiEntity.getPublish() == 1) { // 如果是已发布的数据
|
||||
switch (taskStatus) {
|
||||
case 0://未领取
|
||||
btnCancelGet.setVisibility(View.GONE);//取消领取
|
||||
btnGetTask.setVisibility(View.VISIBLE);//领取任务
|
||||
btnGather.setVisibility(View.VISIBLE);//立即采集
|
||||
btnFinishGather.setVisibility(View.GONE);//结束采集
|
||||
break;
|
||||
case 1://已领取
|
||||
btnCancelGet.setVisibility(View.VISIBLE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.VISIBLE);
|
||||
btnFinishGather.setVisibility(View.GONE);
|
||||
break;
|
||||
case 2://已保存
|
||||
case 3://已提交
|
||||
btnCancelGet.setVisibility(View.VISIBLE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.GONE);
|
||||
btnFinishGather.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
case 4://结束采集
|
||||
btnCancelGet.setVisibility(View.GONE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.GONE);
|
||||
btnFinishGather.setVisibility(View.GONE);
|
||||
break;
|
||||
}
|
||||
} else { // 未发布数据,所有按钮都隐藏
|
||||
btnCancelGet.setVisibility(View.GONE);
|
||||
btnGetTask.setVisibility(View.GONE);
|
||||
btnGather.setVisibility(View.GONE);
|
||||
btnFinishGather.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,7 +337,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);
|
||||
}
|
||||
@ -391,7 +400,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
requireActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -457,12 +466,16 @@ 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.setCreateTime(stationBean.getEndDate());
|
||||
chargingStationEntity.setUnReceivedTime(stationBean.getUnReceivedTime());
|
||||
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
|
||||
chargingStationEntity.setAddress(stationBean.getAddress());
|
||||
chargingStationEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
if (stationBean.getTelephone() == null || stationBean.getTelephone().equals("") || stationBean.getTelephone().equals("null")) {
|
||||
chargingStationEntity.setTelPhone(null);
|
||||
} else {
|
||||
@ -497,6 +510,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;
|
||||
@ -599,11 +613,15 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
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());
|
||||
polygonEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
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
|
||||
@ -687,7 +705,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
if (poiEntity.getType() == 2) {
|
||||
PoiDatabase.getInstance(getContext()).getChargingPileDao().deleteChargingFidPileEntity(poiEntity.getId());
|
||||
}
|
||||
@ -696,6 +714,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;
|
||||
@ -838,7 +857,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
@ -906,10 +925,14 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
poiListEntity.setTaskId(poiEntity.getTaskId());
|
||||
poiListEntity.setName(listBean.getName());
|
||||
poiListEntity.setDescribe(listBean.getMemo());
|
||||
poiListEntity.setCreateTime(listBean.getEndDate());
|
||||
// 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());
|
||||
poiEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
if (listBean.getType() == 1) {
|
||||
if (listBean.getTelephone() == null || listBean.getTelephone().equals("") || listBean.getTelephone().equals("null")) {
|
||||
poiListEntity.setTelPhone(null);
|
||||
@ -931,6 +954,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;
|
||||
@ -1026,9 +1050,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.setCreateTime(listBean.getEndDate());
|
||||
poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
|
||||
poiListEntity.setAddress(listBean.getAddress());
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
|
||||
@ -1037,6 +1064,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
|
||||
poiListEntity.setGeoWkt(listBean.getGeo());
|
||||
String encodeStr = listBean.getGeo();
|
||||
String geo = Geohash.getInstance().decode(encodeStr);
|
||||
poiListEntity.setCreateTime(receiverDateFormate.format(new Date()));
|
||||
// 生成对应的x和y poiEntity.setX
|
||||
GeometryTools.obitainPoiEntityXY(geo, poiListEntity);
|
||||
if (statusId == 1 || statusId == 5) {
|
||||
@ -1047,6 +1075,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;
|
||||
|
||||
@ -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.deletePoiEntityById(poiEntity.getId());
|
||||
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.deletePoiEntityById(poiEntity.getId());
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -49,8 +49,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
|
||||
|
||||
/**
|
||||
* 记录-已提交
|
||||
*/
|
||||
|
||||
@ -901,7 +901,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
initList();
|
||||
|
||||
@ -1268,7 +1268,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
initList();
|
||||
|
||||
@ -819,7 +819,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
|
||||
@ -30,7 +30,7 @@ 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) {
|
||||
@ -50,6 +50,8 @@ public class RecordFragment extends BaseFragment {
|
||||
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());
|
||||
// 已提交
|
||||
@ -70,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;
|
||||
@ -126,8 +134,13 @@ public class RecordFragment extends BaseFragment {
|
||||
|
||||
@Subscribe
|
||||
public void onEvent(Message data) {
|
||||
if (data.what == Constant.SWITCH_RECORFER_ITEM) {
|
||||
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;
|
||||
|
||||
@ -927,7 +927,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getContext()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
|
||||
@ -816,7 +816,7 @@ public class TrafficHubFragment extends BaseDrawerFragment implements View.OnCli
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntity(poiEntity);
|
||||
PoiDatabase.getInstance(getActivity()).getPoiDao().deletePoiEntityById(poiEntity.getId());
|
||||
}
|
||||
}).start();
|
||||
if (poiEntity.getId() != null) {
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
package com.navinfo.outdoor.fragment;
|
||||
|
||||
import static anet.channel.util.Utils.context;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -17,6 +19,7 @@ import android.os.Message;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
@ -40,20 +43,22 @@ import androidx.recyclerview.widget.DividerItemDecoration;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.elvishew.xlog.XLog;
|
||||
import com.github.lazylibrary.util.DensityUtil;
|
||||
import com.github.lazylibrary.util.FileUtils;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.hjq.permissions.OnPermissionCallback;
|
||||
import com.hjq.permissions.Permission;
|
||||
import com.hjq.permissions.XXPermissions;
|
||||
import com.jcodecraeer.xrecyclerview.XRecyclerView;
|
||||
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.ShareDialog;
|
||||
import com.kongzue.dialogx.dialogs.CustomDialog;
|
||||
import com.kongzue.dialogx.dialogs.PopMenu;
|
||||
import com.kongzue.dialogx.interfaces.OnBindView;
|
||||
import com.kongzue.dialogx.interfaces.OnIconChangeCallBack;
|
||||
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
@ -67,8 +72,10 @@ import com.navinfo.outdoor.adapter.MarkerAdapter;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.base.BaseDrawerFragment;
|
||||
import com.navinfo.outdoor.base.BaseFragment;
|
||||
import com.navinfo.outdoor.bean.CommonResponse;
|
||||
import com.navinfo.outdoor.bean.GetPhoneBean;
|
||||
import com.navinfo.outdoor.bean.JobSearchBean;
|
||||
import com.navinfo.outdoor.bean.LatestPushMessageResponse;
|
||||
import com.navinfo.outdoor.bean.MessageNoticeBean;
|
||||
import com.navinfo.outdoor.bean.NotificationBean;
|
||||
import com.navinfo.outdoor.bean.UserBean;
|
||||
@ -83,6 +90,7 @@ import com.navinfo.outdoor.util.Geohash;
|
||||
import com.navinfo.outdoor.util.GeometryTools;
|
||||
import com.navinfo.outdoor.util.LocationLifeCycle;
|
||||
import com.navinfo.outdoor.util.MapManager;
|
||||
import com.navinfo.outdoor.util.Md5Util;
|
||||
import com.navinfo.outdoor.util.MyTecentLocationSource;
|
||||
import com.navinfo.outdoor.util.NaviUtils;
|
||||
import com.navinfo.outdoor.util.NetWorkUtils;
|
||||
@ -113,6 +121,8 @@ import com.tencent.tencentmap.mapsdk.maps.model.Polyline;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.PolylineOptions;
|
||||
import com.tencent.tencentmap.mapsdk.maps.model.TencentMapGestureListener;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.locationtech.jts.geom.Coordinate;
|
||||
import org.locationtech.jts.geom.Geometry;
|
||||
import org.locationtech.jts.geom.MultiPoint;
|
||||
@ -131,6 +141,9 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@ -170,6 +183,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
private Marker gatherMarker;
|
||||
private long lastClickTime = 0;
|
||||
private int settingHookClickCount = 1;
|
||||
private TextView tvLatestPush; // 最新的推荐任务按钮
|
||||
private Handler handler = new Handler(new Handler.Callback() {
|
||||
@Override
|
||||
public boolean handleMessage(@NonNull Message msg) {
|
||||
@ -242,6 +256,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
}
|
||||
}
|
||||
});
|
||||
// 最新推荐任务按钮
|
||||
tvLatestPush = findViewById(R.id.tv_latest_push);
|
||||
//地图放大
|
||||
ivZoomAdd = (ImageView) findViewById(R.id.iv_zoom_add);
|
||||
ivZoomAdd.setOnClickListener(this);
|
||||
@ -285,7 +301,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
treasureBuilder.append(TimestampUtil.time()).append(",").append("onFinish-获取到当前位置,");
|
||||
dismissLoadingDialog();
|
||||
refreshFilterData();
|
||||
//上传用户位置金纬度
|
||||
//上传用户位置经纬度
|
||||
iniUserLocation();
|
||||
//得到电话区号,电话位数
|
||||
initPhone();
|
||||
@ -293,6 +309,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
initUM();
|
||||
//检查是否有没有填完的页面
|
||||
initSharePre();
|
||||
// 获取最新的推荐任务,如果存在则显示推荐任务按钮
|
||||
initRecommandTaskInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -314,7 +332,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
|
||||
imgAutoMatchRoad = findViewById(R.id.iv_auto_match_road);
|
||||
// 如果当前用户的level为1或2、3,自动采集功能才会开放
|
||||
if (Constant.LEVEL == 1||Constant.LEVEL==2||Constant.LEVEL==3) {
|
||||
if (Constant.LEVEL == 1 || Constant.LEVEL == 2 || Constant.LEVEL == 3) {
|
||||
imgAutoMatchRoad.setVisibility(View.VISIBLE);
|
||||
}
|
||||
imgAutoMatchRoad.setOnClickListener(new View.OnClickListener() {
|
||||
@ -330,7 +348,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
.setOnIconChangeCallBack(new OnIconChangeCallBack<PopMenu>() {
|
||||
@Override
|
||||
public int getIcon(PopMenu dialog, int index, String menuText) {
|
||||
switch (index){
|
||||
switch (index) {
|
||||
case 0:
|
||||
return R.drawable.marker_road_show;
|
||||
case 1:
|
||||
@ -344,17 +362,35 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
.setOnMenuItemClickListener(new OnMenuItemClickListener<PopMenu>() {
|
||||
@Override
|
||||
public boolean onClick(PopMenu dialog, CharSequence text, int index) {
|
||||
if (index == 0) { // 自动捕捉道路任务
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
} else if (index == 1) {
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePicture4PoiActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
// 检查当前的筛选条件,如果不是默认筛选条件,则提示用户
|
||||
if (Constant.TASK_STARTUP!=-1 || Constant.TASK_TYPE!=-1) {
|
||||
com.kongzue.dialogx.dialogs.MessageDialog messageDialog = com.kongzue.dialogx.dialogs.MessageDialog
|
||||
.show("提示", "注意,当前筛选条件可能导致部分已领取任务无法自动捕捉,是否重置筛选条件?", "确定", "取消")
|
||||
.setOkButtonClickListener(new com.kongzue.dialogx.interfaces.OnDialogButtonClickListener<com.kongzue.dialogx.dialogs.MessageDialog>() {
|
||||
@Override
|
||||
public boolean onClick(com.kongzue.dialogx.dialogs.MessageDialog dialog, View v) {
|
||||
Constant.TASK_STARTUP = -1;
|
||||
Constant.TASK_TYPE = -1;
|
||||
intentToAutoTakePictureActivity(index);
|
||||
dialog.dismiss();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.setCancelButtonClickListener(new com.kongzue.dialogx.interfaces.OnDialogButtonClickListener<com.kongzue.dialogx.dialogs.MessageDialog>() {
|
||||
@Override
|
||||
public boolean onClick(com.kongzue.dialogx.dialogs.MessageDialog dialog, View v) {
|
||||
dialog.dismiss();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
} else {
|
||||
intentToAutoTakePictureActivity(index);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.show();
|
||||
.show();
|
||||
}
|
||||
});
|
||||
ivNaviDistance = findViewById(R.id.img_navi_distance);
|
||||
@ -394,8 +430,21 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航到最近的POIEntity
|
||||
* 跳转到自动捕捉界面
|
||||
* */
|
||||
private void intentToAutoTakePictureActivity(int index) {
|
||||
if (index == 0) { // 自动捕捉道路任务
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePictureActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
} else if (index == 1) {
|
||||
Intent autoMatchIntent = new Intent(getContext(), AutoTakePicture4PoiActivity.class);
|
||||
startActivity(autoMatchIntent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航到最近的POIEntity
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.N)
|
||||
private void navi2NearestPoiEntity() {
|
||||
if (removables == null || removables.isEmpty()) {
|
||||
@ -421,16 +470,16 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
// 转换geo
|
||||
Geometry geometry1 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean1.getGeo()));
|
||||
Geometry geometry2 = GeometryTools.createGeometry(Geohash.getInstance().decode(bean2.getGeo()));
|
||||
if (currentGeometry.distance(geometry1)>currentGeometry.distance(geometry2)) {
|
||||
if (currentGeometry.distance(geometry1) > currentGeometry.distance(geometry2)) {
|
||||
return 1;
|
||||
} else if (currentGeometry.distance(geometry1)<currentGeometry.distance(geometry2)) {
|
||||
} else if (currentGeometry.distance(geometry1) < currentGeometry.distance(geometry2)) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}).get();
|
||||
JobSearchBean.BodyBean.ListBean bean = (JobSearchBean.BodyBean.ListBean)((Marker)minRemoveable).getTag();
|
||||
JobSearchBean.BodyBean.ListBean bean = (JobSearchBean.BodyBean.ListBean) ((Marker) minRemoveable).getTag();
|
||||
Coordinate endPoint = GeometryTools.createGeometry(Geohash.getInstance().decode(bean.getGeo())).getCoordinates()[0];
|
||||
ToastUtils.Message(getActivity(), "自动导航到"+bean.getName());
|
||||
ToastUtils.Message(getActivity(), "自动导航到" + bean.getName());
|
||||
// 跳转到对应的导航界面
|
||||
if (Constant.currentNaviType == null) {
|
||||
NaviUtils.getInstance().selectNaviType((AppCompatActivity) getActivity(), new NaviUtils.SelectNaviTypeListener() {
|
||||
@ -508,7 +557,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
});
|
||||
}
|
||||
if (LocationLifeCycle.getInstance().getTencentLocation() != null) { //筛选从服务器获取到的数据
|
||||
tencentMarkerUtils.initNetMarkerList(getActivity(), LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables,null, null, removableHashMap, 200, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
|
||||
tencentMarkerUtils.initNetMarkerList(getActivity(), LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables, null, null, removableHashMap, 200, new TencentMarkerUtils.MarkerInitCallback<JobSearchBean.BodyBean.ListBean>() {
|
||||
|
||||
@Override
|
||||
public void onMarkerInit(Map<String, List<Marker>> removableHashMap, List<Integer> uploadByNet, List<JobSearchBean.BodyBean.ListBean> listData) {
|
||||
@ -702,6 +751,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
if (Constant.DEVICE_TOKEN != null) {
|
||||
httpParams.put("deviceTokens", Constant.DEVICE_TOKEN);
|
||||
}
|
||||
if (Constant.PUSH_TOKEN != null) {
|
||||
httpParams.put("pushId", Constant.PUSH_TOKEN);
|
||||
}
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.Builder(getActivity())
|
||||
@ -907,7 +959,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
gatherMarker.setVisible(false);
|
||||
}
|
||||
PoiEntity poiEntity = (PoiEntity) data.obj;
|
||||
if (poiEntity!=null) {
|
||||
if (poiEntity != null) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putSerializable("poiEntity", poiEntity);
|
||||
bundle.putBoolean("isSliding", true); // 通知抽屉不收回
|
||||
@ -1071,7 +1123,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
}
|
||||
}
|
||||
} else if (data.what == Constant.EVENT_WHAT_CHANGE_SLIDING_STATE) { // 改变滑动窗口的状态
|
||||
if (sliding_layout!=null) {
|
||||
if (sliding_layout != null) {
|
||||
if (data.arg1 == View.GONE || data.arg1 == View.INVISIBLE) {
|
||||
sliding_layout.setPanelHeight(0);
|
||||
} else {
|
||||
@ -1090,7 +1142,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// 检查当前线型的点位数据,如果小于2个点,无法完成
|
||||
if (drawLinePolyline.getPoints()==null||drawLinePolyline.getPoints().size()<2) {
|
||||
if (drawLinePolyline.getPoints() == null || drawLinePolyline.getPoints().size() < 2) {
|
||||
// 绘制的线不存在
|
||||
ToastUtils.Message(getActivity(), "绘制的线不存在!");
|
||||
return;
|
||||
@ -1098,13 +1150,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
Message drawLineFinishMsg = Message.obtain();
|
||||
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
|
||||
drawLineFinishMsg.obj = drawLinePolyline.getPoints();
|
||||
drawLineFinishMsg.arg1=1; // arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||
drawLineFinishMsg.arg1 = 1; // arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||
EventBus.getDefault().post(drawLineFinishMsg);
|
||||
|
||||
drawFinish.setVisibility(View.GONE);
|
||||
drawCancel.setVisibility(View.GONE);
|
||||
tencentMap.setOnMapClickListener(null);
|
||||
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||
if (drawLineMarkerList != null && !drawLineMarkerList.isEmpty()) {
|
||||
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||
@Override
|
||||
public void accept(Marker marker) {
|
||||
@ -1114,7 +1166,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
drawLineMarkerList.clear();
|
||||
}
|
||||
|
||||
if (drawLinePolyline!=null) {
|
||||
if (drawLinePolyline != null) {
|
||||
drawLinePolyline.remove();
|
||||
}
|
||||
}
|
||||
@ -1124,13 +1176,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
public void onClick(View view) {
|
||||
Message drawLineFinishMsg = Message.obtain();
|
||||
drawLineFinishMsg.what = Constant.EVENT_WHAT_FINISH_DRAW_LINE;
|
||||
drawLineFinishMsg.arg1=0;// arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||
drawLineFinishMsg.arg1 = 0;// arg1为1代表存在绘制的辅助线,为0代表用户点击取消,不需要辅助线
|
||||
EventBus.getDefault().post(drawLineFinishMsg);
|
||||
|
||||
drawFinish.setVisibility(View.GONE);
|
||||
drawCancel.setVisibility(View.GONE);
|
||||
tencentMap.setOnMapClickListener(null);
|
||||
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||
if (drawLineMarkerList != null && !drawLineMarkerList.isEmpty()) {
|
||||
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||
@Override
|
||||
public void accept(Marker marker) {
|
||||
@ -1140,12 +1192,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
drawLineMarkerList.clear();
|
||||
}
|
||||
|
||||
if (drawLinePolyline!=null) {
|
||||
if (drawLinePolyline != null) {
|
||||
drawLinePolyline.remove();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (drawLineMarkerList!=null&&!drawLineMarkerList.isEmpty()) {
|
||||
if (drawLineMarkerList != null && !drawLineMarkerList.isEmpty()) {
|
||||
drawLineMarkerList.stream().forEach(new Consumer<Marker>() {
|
||||
@Override
|
||||
public void accept(Marker marker) {
|
||||
@ -1155,7 +1207,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
drawLineMarkerList.clear();
|
||||
}
|
||||
|
||||
if (drawLinePolyline!=null) {
|
||||
if (drawLinePolyline != null) {
|
||||
drawLinePolyline.remove();
|
||||
}
|
||||
PolylineOptions drawLineOptions = new PolylineOptions() // 用户绘制参考线的线数据
|
||||
@ -1169,7 +1221,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
// 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
|
||||
.borderWidth(5);
|
||||
drawLinePolyline = tencentMap.addPolyline(drawLineOptions);
|
||||
if (tencentMap!=null) {
|
||||
if (tencentMap != null) {
|
||||
tencentMap.setOnMapClickListener(new TencentMap.OnMapClickListener() {
|
||||
@Override
|
||||
public void onMapClick(LatLng latLng) {
|
||||
@ -1180,6 +1232,35 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (data.what == Constant.EVENT_WHAT_NOTIFYCATION_RECOMMAND_TASK) {
|
||||
// 显示推荐任务
|
||||
Map<String, Object> dataMap = (Map<String, Object>) data.obj;
|
||||
String geom = dataMap.get("geom").toString();
|
||||
Geometry geometry = GeometryTools.createGeometry(geom);
|
||||
int zoom = Integer.parseInt(dataMap.get("zoom").toString());
|
||||
// 跳转到该位置
|
||||
// 地图中心点位置设置为当前用户所在位置
|
||||
CameraUpdate cameraSigma =
|
||||
CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(geometry.getCoordinate().y, geometry.getCoordinate().x), //中心点坐标,地图目标经纬度
|
||||
zoom, //目标缩放级别
|
||||
0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0)); //目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
|
||||
@Override
|
||||
public void onFinish() {
|
||||
// 重新刷新数据
|
||||
refreshFilterData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
} else if(data.what == Constant.EVENT_WHAT_HAS_RECEIVE_ITEM) {
|
||||
PoiEntity poiEntity = (PoiEntity) data.obj;
|
||||
initMarker(poiEntity, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1409,10 +1490,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
treasureBuilder.append(TimestampUtil.time()).append(",").append("点击了定位的按钮,");
|
||||
if (LocationLifeCycle.getInstance().getTencentLocation() != null) {
|
||||
CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
|
||||
new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()),//中心点坐标,地图目标经纬度
|
||||
17,//目标缩放级别
|
||||
0,//目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0));//目标旋转角 0~360° (正北方为0)
|
||||
new LatLng(LocationLifeCycle.getInstance().getTencentLocation().getLatitude(), LocationLifeCycle.getInstance().getTencentLocation().getLongitude()),//中心点坐标,地图目标经纬度
|
||||
17,//目标缩放级别
|
||||
0,//目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
|
||||
0));//目标旋转角 0~360° (正北方为0)
|
||||
tencentMap.animateCamera(cameraSigma);
|
||||
} else {
|
||||
ToastUtils.Message(getActivity(), "无定位");
|
||||
@ -1871,6 +1952,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
poiListEntity.setType(listBean.getType());
|
||||
poiListEntity.setRecord_way(listBean.getCanReceived());
|
||||
poiListEntity.setIsExclusive(listBean.getIsExclusive());
|
||||
poiListEntity.setPublish(listBean.getPublish());
|
||||
String beanGeo = listBean.getGeo();
|
||||
String geo = Geohash.getInstance().decode(beanGeo);
|
||||
// 生成对应的x和y poiEntity.setX
|
||||
@ -2031,4 +2113,92 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
|
||||
removableHashMap.put(geo, markers);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最新的推荐任务数据
|
||||
*/
|
||||
private void initRecommandTaskInfo() {
|
||||
if (Constant.PUSH_TOKEN != null) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
long time = System.currentTimeMillis();
|
||||
httpParams.put("datetime", time);
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.time(30)
|
||||
.Builder(requireActivity())
|
||||
.url(HttpInterface.MESSAGE_LATEST_PUSH)
|
||||
.cls(LatestPushMessageResponse.class)
|
||||
.params(httpParams);
|
||||
okGoBuilder.getRequest(new Callback<LatestPushMessageResponse>() {
|
||||
@Override
|
||||
public void onSuccess(LatestPushMessageResponse response, int id) {
|
||||
tvLatestPush.setVisibility(View.GONE); // 默认先隐藏推荐任务按钮
|
||||
if (response != null&&response.getBody()!=null) {
|
||||
Map<String, String> responseBody = response.getBody();
|
||||
// 解析response
|
||||
// 获取当前json的id,如果id大于等于0,则根据Content内容尝试展示提示信息
|
||||
int messageId = Integer.parseInt(responseBody.get("id"));
|
||||
if (messageId >= 0) {
|
||||
// 读取该推送的截止时间,如果当前时间比截止时间晚,则不需要展示
|
||||
if (responseBody.get("endTime") != null) {
|
||||
long endTime = Long.parseLong(responseBody.get("endTime"));
|
||||
if (endTime >= 0 && System.currentTimeMillis() / 1000 > endTime) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String imgUrl = responseBody.get("img");
|
||||
String wkt = responseBody.get("geom");
|
||||
int zoom = (int) Double.parseDouble(responseBody.get("zoom"));
|
||||
|
||||
// 存在最新的推荐任务,显示推荐任务按钮
|
||||
tvLatestPush.setVisibility(View.VISIBLE);
|
||||
tvLatestPush.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// 显示对话框
|
||||
CustomDialog.show(new OnBindView<com.kongzue.dialogx.dialogs.CustomDialog>(R.layout.dialog_push_tesk) {
|
||||
@Override
|
||||
public void onBind(com.kongzue.dialogx.dialogs.CustomDialog dialog, View v) {
|
||||
ImageView photo = v.findViewById(R.id.img_photo);
|
||||
TextView tvConfirm = v.findViewById(R.id.tv_confirm);
|
||||
// // Glide增加加载中图片显示
|
||||
// RequestOptions options = new RequestOptions()
|
||||
// .placeholder(R.mipmap.ic_launcher);
|
||||
// 显示照片
|
||||
Glide.with(requireContext()).load(imgUrl).into(photo);
|
||||
View.OnClickListener clickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// 地图定位到指定位置,发送Event
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("geom", wkt);
|
||||
map.put("zoom", zoom);
|
||||
Message msg = Message.obtain();
|
||||
msg.obj = map;
|
||||
msg.what = Constant.EVENT_WHAT_NOTIFYCATION_RECOMMAND_TASK;
|
||||
EventBus.getDefault().post(msg);
|
||||
dialog.dismiss();
|
||||
}
|
||||
};
|
||||
// 点击对话框的图片
|
||||
photo.setOnClickListener(clickListener);
|
||||
tvConfirm.setOnClickListener(clickListener);
|
||||
}
|
||||
}).setCancelable(true).setAlign(CustomDialog.ALIGN.CENTER);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
tvLatestPush.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,16 +1,21 @@
|
||||
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 IP = "http://dtxbmaps.navinfo.com/dtxb/dev/m4";//开发接口-外网
|
||||
import android.content.SharedPreferences;
|
||||
|
||||
// public static final String IP = "http://120.92.212.218/dtxb/test/m4";//金山云接口地址
|
||||
// public static final String IP_UPLOAD = "http://120.131.12.158/dtxb/test/m4";//金山云接口地址-数据上传
|
||||
public static final String IP = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
|
||||
public static final String IP_UPLOAD = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//正式环境接口
|
||||
public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/test/m4";//测试接口-外网
|
||||
public static final String IP2 = "http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口
|
||||
public static final String IP4 = "http://10.130.23.166/dtxb/jinshan/m4";//心榕给的测试地址
|
||||
import com.github.lazylibrary.util.PreferencesUtils;
|
||||
|
||||
public class HttpInterface {
|
||||
// // 开发
|
||||
// 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/";//登录
|
||||
@ -63,6 +68,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/
|
||||
@ -142,10 +148,13 @@ 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 MESSAGE_PUSH_GET_OR_CLICK_UPLOAD = 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 = "";//关于 -关于地图寻宝
|
||||
@ -168,6 +177,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/
|
||||
@ -183,6 +193,8 @@ 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";//寻宝首页-获取最新推送推荐任务
|
||||
MESSAGE_PUSH_GET_OR_CLICK_UPLOAD = IP + MSG_LIST_PATH + "UserMessage/" + userId + "/feedbackUserMessage";//寻宝-推送数据获取和点击的时间上报
|
||||
|
||||
/* 提现 金额
|
||||
* Path=/m4/price/
|
||||
@ -237,6 +249,7 @@ public class HttpInterface {
|
||||
UPDATE_PHONE_NUM_URL = IP + UPDATE_PHONE_NUM_PATH.replace("{userId}", userId);// 修改手机号
|
||||
CREATE_UPLOAD_TASK = IP + TASK_PATH + "task/"+ userId+"/createUploadTask";// 创建断点续传任务
|
||||
UPLOAD_TASK_FINISH = IP + TASK_PATH + "task/"+ userId+"/uploadTaskFinish";// 断点续传完成
|
||||
GET_RECEIVED_LIST = IP + TASK_PATH + "task/"+ userId+"/getReceivedList";// 断点续传完成
|
||||
|
||||
//172.23.139.4:8003/othertask/1/uploadpic
|
||||
OTHER_TASK_UPLOAD_PIC = IP_UPLOAD + TASK_PATH + "othertask/" + userId + "/uploadpic";//其他-上传
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.navinfo.outdoor.http;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.elvishew.xlog.XLog;
|
||||
@ -44,7 +45,7 @@ import okhttp3.RequestBody;
|
||||
*/
|
||||
|
||||
public class OkGoBuilder<T> {
|
||||
private Activity activity;
|
||||
private Context activity;
|
||||
/**
|
||||
* 请求网址
|
||||
*/
|
||||
@ -87,7 +88,7 @@ public class OkGoBuilder<T> {
|
||||
return mOkGoBuilder;
|
||||
}
|
||||
|
||||
public OkGoBuilder Builder(Activity activity) {
|
||||
public OkGoBuilder Builder(Context activity) {
|
||||
this.activity = activity;
|
||||
return this;
|
||||
}
|
||||
@ -173,7 +174,8 @@ public class OkGoBuilder<T> {
|
||||
if (response.code() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else {
|
||||
ToastUtils.Message(activity, response.message());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, response.message());
|
||||
// ToastUtils.Message(activity, response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +225,8 @@ public class OkGoBuilder<T> {
|
||||
if (response.code() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else {
|
||||
ToastUtils.Message(activity, response.message());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, response.message());
|
||||
// ToastUtils.Message(activity, response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,7 +348,8 @@ public class OkGoBuilder<T> {
|
||||
if (response.code() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else {
|
||||
ToastUtils.Message(activity, response.message());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, response.message());
|
||||
// ToastUtils.Message(activity, response.message());
|
||||
}
|
||||
}
|
||||
|
||||
@ -398,7 +402,8 @@ public class OkGoBuilder<T> {
|
||||
if (response.code() == 200) {
|
||||
callback.onSuccess(response.body(), 1);
|
||||
} else {
|
||||
ToastUtils.Message(activity, response.message());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, response.message());
|
||||
// ToastUtils.Message(activity, response.message());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,442 @@
|
||||
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.github.lazylibrary.util.MD5;
|
||||
import com.github.lazylibrary.util.PreferencesUtils;
|
||||
import com.lzy.okgo.model.HttpParams;
|
||||
import com.navinfo.outdoor.R;
|
||||
import com.navinfo.outdoor.activity.HomeActivity;
|
||||
import com.navinfo.outdoor.api.Constant;
|
||||
import com.navinfo.outdoor.bean.CommonRequestSend;
|
||||
import com.navinfo.outdoor.bean.CommonResponse;
|
||||
import com.navinfo.outdoor.http.Callback;
|
||||
import com.navinfo.outdoor.http.HttpInterface;
|
||||
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);
|
||||
intent.putExtra(Constant.NOTIFYCATION_ID, id);
|
||||
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());
|
||||
|
||||
uploadReceivePushMessage(context, id+"", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报获取到推送消息的时间给服务端
|
||||
* @param messageId 推送消息对应的id
|
||||
* @param type 0-获取到消息,1-点击推送消息
|
||||
* */
|
||||
private void uploadReceivePushMessage(Context mContext, String messageId, int type) {
|
||||
HttpParams httpParams = new HttpParams();
|
||||
httpParams.put("messageId", messageId);
|
||||
httpParams.put("type", type);
|
||||
CommonRequestSend commonRequestSend = new CommonRequestSend<CommonResponse<Integer>>();
|
||||
commonRequestSend.postMethodCommonSilence(mContext, PreferencesUtils.getString(mContext, "MESSAGE_PUSH_GET_OR_CLICK_UPLOAD")/*从SP文件中获取*/,
|
||||
httpParams, Constant.DEFAULT_TIME_OUT, new Callback<CommonResponse<Integer>>() {
|
||||
@Override
|
||||
public void onSuccess(CommonResponse<Integer> response, int id) {
|
||||
if (response.getCode() == 200) {
|
||||
// 推送消息获取时间上报成功
|
||||
XLog.d("上报推送接收成功:"+response.getMessage()+"-messageId:"+messageId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e, int id) {
|
||||
XLog.d("上报推送接收失败:"+e.getMessage()+"-messageId:"+messageId);
|
||||
}
|
||||
}, new CommonResponse<Integer>().getClass());
|
||||
}
|
||||
|
||||
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);
|
||||
intent.putExtra(Constant.NOTIFYCATION_ID, id);
|
||||
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());
|
||||
// 用户点击该提醒后跳转到主界面,并自动定位到指定位置
|
||||
uploadReceivePushMessage(context, id+"", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知展示
|
||||
* @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();
|
||||
@ -57,8 +61,10 @@ public interface PoiDao {
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
@Delete
|
||||
void deletePoiEntity(PoiEntity... poiEntities);
|
||||
// @Delete
|
||||
// void deletePoiEntity(PoiEntity... poiEntities);
|
||||
@Query("DELETE FROM poi where id=:id")
|
||||
void deletePoiEntityById(String id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
|
||||
@ -30,7 +30,7 @@ import java.io.File;
|
||||
* 如果需要在主线程调用则使用allowMainThreadQueries进行说明。
|
||||
*/
|
||||
|
||||
@Database(entities = {PoiEntity.class,ChargingPileEntity.class, LocationRecorder.class}, version = 6, 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;
|
||||
@ -57,6 +57,7 @@ public abstract class PoiDatabase extends RoomDatabase {
|
||||
.addMigrations(migration_3_4)
|
||||
.addMigrations(migration_4_5)
|
||||
.addMigrations(migration_5_6)
|
||||
.addMigrations(migration_6_7)
|
||||
//.fallbackToDestructiveMigration()//数据库更新时删除数据重新创建 改动特别大的时候在用
|
||||
.build();
|
||||
}
|
||||
@ -125,6 +126,16 @@ public abstract class PoiDatabase extends RoomDatabase {
|
||||
}
|
||||
}
|
||||
};
|
||||
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();//充电桩
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
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;
|
||||
@ -11,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;
|
||||
|
||||
@ -56,6 +60,9 @@ public class PoiEntity implements Serializable {
|
||||
private int score; // 置信度
|
||||
private String drawLine; // 用户绘制的线型
|
||||
private String uploadResult; //上传结果
|
||||
private String unReceivedTime; // 任务领取后自动释放的时间
|
||||
@Ignore
|
||||
private int publish = 1; // 是否已发布,0-未发布,1-已发布(默认)
|
||||
|
||||
public int getRecord_way() {
|
||||
return record_way;
|
||||
@ -326,6 +333,39 @@ public class PoiEntity implements Serializable {
|
||||
this.uploadResult = uploadResult;
|
||||
}
|
||||
|
||||
public int getPublish() {
|
||||
return publish;
|
||||
}
|
||||
|
||||
public void setPublish(int publish) {
|
||||
this.publish = publish;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取经过处理后的接受任务失效时间的时间戳
|
||||
* */
|
||||
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{" +
|
||||
@ -346,6 +386,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)
|
||||
}
|
||||
}
|
||||
@ -3,9 +3,7 @@ package com.navinfo.outdoor.util;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
@ -44,15 +42,24 @@ public class FlushTokenUtil {
|
||||
});
|
||||
}
|
||||
|
||||
private static void initLogin(Activity activity) {
|
||||
/**
|
||||
* 后台安静重新登录
|
||||
* */
|
||||
public static void flushTokenSilence(Context mContext) {
|
||||
initLogin(mContext);
|
||||
}
|
||||
|
||||
private static void initLogin(Context activity) {
|
||||
SharedPreferences navInfo = activity.getSharedPreferences(Constant.SHARED_PREFERENCES, Context.MODE_PRIVATE);
|
||||
navInfoEditor = navInfo.edit();
|
||||
if (Constant.USHERED == null) {
|
||||
ToastUtils.Message(activity,"token :更新失败");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, "token :更新失败");
|
||||
// ToastUtils.Message(activity,"token :更新失败");
|
||||
return;
|
||||
} else {
|
||||
if (HttpInterface.USER_LOGIN_OAUTH_TOKEN == null) {
|
||||
ToastUtils.Message(activity,"token :更新失败");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, "token :更新失败");
|
||||
// ToastUtils.Message(activity,"token :更新失败");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -85,16 +92,19 @@ public class FlushTokenUtil {
|
||||
Constant.USHERED = body.getUserId();
|
||||
navInfoEditor.apply();
|
||||
if (HttpInterface.USER_DETAIL_BY_USER_ID == null) {
|
||||
ToastUtils.Message(activity,"token :更新成功");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, "token :更新成功");
|
||||
// ToastUtils.Message(activity,"token :更新成功");
|
||||
} else {
|
||||
initGetUserInfo(activity);//获取用户信息
|
||||
}
|
||||
}else {
|
||||
ToastUtils.Message(activity,"获取用户id 失败");
|
||||
// ToastUtils.Message(activity,"获取用户id 失败");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, "获取用户id 失败");
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastUtils.Message(activity,response.getMessage());
|
||||
// ToastUtils.Message(activity,response.getMessage());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity, response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,9 +118,11 @@ public class FlushTokenUtil {
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.contains("timeout") || message.contains("Read time out")) {
|
||||
ToastUtils.Message(activity,"请求超时");
|
||||
// ToastUtils.Message(activity,"请求超时");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(activity,message);
|
||||
// ToastUtils.Message(activity,message);
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,message);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -119,7 +131,7 @@ public class FlushTokenUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static void initGetUserInfo(Activity activity) {
|
||||
private static void initGetUserInfo(Context activity) {
|
||||
OkGoBuilder okGoBuilder = OkGoBuilder
|
||||
.getInstance()
|
||||
.time(30)
|
||||
@ -167,10 +179,12 @@ public class FlushTokenUtil {
|
||||
Constant.AUDITING = userAuth.getAuditmsg();
|
||||
}
|
||||
navInfoEditor.commit();
|
||||
ToastUtils.Message(activity,"token :更新成功");
|
||||
// ToastUtils.Message(activity,"token :更新成功");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,"token :更新成功");
|
||||
}
|
||||
} else {
|
||||
ToastUtils.Message(activity,response.getMessage());
|
||||
// ToastUtils.Message(activity,response.getMessage());
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,response.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,9 +193,11 @@ public class FlushTokenUtil {
|
||||
String message = e.getMessage();
|
||||
assert message != null;
|
||||
if (message.equals("timeout") || message.equals("Read time out")) {
|
||||
ToastUtils.Message(activity,"请求超时");
|
||||
// ToastUtils.Message(activity,"请求超时");
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,"请求超时");
|
||||
} else {
|
||||
ToastUtils.Message(activity,message);
|
||||
// ToastUtils.Message(activity,message);
|
||||
com.github.lazylibrary.util.ToastUtils.showToast(activity,message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@ -186,7 +186,11 @@ 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;
|
||||
boolean clickable = true;
|
||||
switch (listBean.getType()) {
|
||||
case 1://poi
|
||||
BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi);
|
||||
//poiDescriptor.getForager().setScale(50);
|
||||
@ -194,6 +198,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) {
|
||||
@ -203,7 +208,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(poiMarker);
|
||||
String poiGeo = initGeo(latLng);
|
||||
geoMarker(poiGeo, poiMarker, removableHashMap);
|
||||
poiMarker.setClickable(true);
|
||||
poiMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 2://充电站
|
||||
@ -212,6 +217,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) {
|
||||
@ -221,7 +227,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录像
|
||||
@ -230,6 +236,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) {
|
||||
@ -239,7 +246,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(poiVideoMarker);
|
||||
String poiVideoGeo = initGeo(latLng);
|
||||
geoMarker(poiVideoGeo, poiVideoMarker, removableHashMap);
|
||||
poiVideoMarker.setClickable(true);
|
||||
poiVideoMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 4://道路录像
|
||||
@ -248,6 +255,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) {
|
||||
@ -257,7 +265,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(roadMarker);
|
||||
String roadGeo = initGeo(latLng);
|
||||
geoMarker(roadGeo, roadMarker, removableHashMap);
|
||||
roadMarker.setClickable(true);
|
||||
roadMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 5://其他
|
||||
@ -266,6 +274,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) {
|
||||
@ -275,7 +284,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(otherMarker);
|
||||
String otherGeo = initGeo(latLng);
|
||||
geoMarker(otherGeo, otherMarker, removableHashMap);
|
||||
otherMarker.setClickable(true);
|
||||
otherMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
case 6://面状任务
|
||||
@ -284,6 +293,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) {
|
||||
@ -293,7 +303,7 @@ public class TencentMarkerUtils {
|
||||
removables.add(planarMarker);
|
||||
String planarGeo = initGeo(latLng);
|
||||
geoMarker(planarGeo, planarMarker, removableHashMap);
|
||||
planarMarker.setClickable(true);
|
||||
planarMarker.setClickable(clickable);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
144
app/src/main/java/com/navinfo/outdoor/util/WhiteListHelper.java
Normal file
144
app/src/main/java/com/navinfo/outdoor/util/WhiteListHelper.java
Normal file
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -9,6 +9,6 @@
|
||||
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>
|
||||
24
app/src/main/res/layout/dialog_push_tesk.xml
Normal file
24
app/src/main/res/layout/dialog_push_tesk.xml
Normal file
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/img_photo"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="5dp"
|
||||
android:scaleType="fitCenter" />
|
||||
<TextView
|
||||
android:id="@+id/tv_confirm"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/btn_round_corner"
|
||||
android:gravity="center"
|
||||
android:background="@drawable/selector_default_btn_round_corner_bg"
|
||||
android:text="去看看"></TextView>
|
||||
</LinearLayout>
|
||||
172
app/src/main/res/layout/fragment_has_receive.xml
Normal file
172
app/src/main/res/layout/fragment_has_receive.xml
Normal file
@ -0,0 +1,172 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<LinearLayout
|
||||
android:id="@+id/layer_operate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent">
|
||||
<Button
|
||||
android:id="@+id/btn_stay_submit"
|
||||
style="@style/user_data_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="20dp"
|
||||
android:text="提交"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_del" />
|
||||
<Button
|
||||
android:id="@+id/btn_stay_cancel"
|
||||
style="@style/user_data_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_margin="20dp"
|
||||
android:text="取消"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_del" />
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/layer_operate"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:context=".fragment.StaySubmitFragment">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/cl_has_receive_type"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:background="@drawable/road_shape"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
style="@style/text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="18dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="类型"
|
||||
android:textColor="#333"
|
||||
app:layout_constraintBottom_toTopOf="@+id/tv_stay_type"
|
||||
app:layout_constraintStart_toStartOf="@+id/tv_stay_type"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_stay_type"
|
||||
style="@style/main_about_text_style"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:text="全部"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:background="@drawable/ic_baseline_arrow_forward"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/ll_results"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="80dp"
|
||||
android:background="@drawable/road_shape"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/cl_has_receive_type">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_result"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:text="筛选结果"
|
||||
android:textColor="#333"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_number"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_margin="10dp"
|
||||
android:text="全选"
|
||||
android:visibility="gone"
|
||||
android:textColor="#333"
|
||||
android:textSize="17sp" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/stay_xrv"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/ll_results" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_del"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/stay_xrv">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cb_select"
|
||||
style="@style/CheckBoxTheme"
|
||||
android:padding="@dimen/default_widget_padding"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:text="全选"
|
||||
android:visibility="gone"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_delete"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:padding="@dimen/default_widget_padding"
|
||||
android:visibility="gone"
|
||||
android:text="删除"
|
||||
android:textColor="@color/colorPrimaryBlue"
|
||||
android:textSize="18sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
114
app/src/main/res/layout/has_receive_item.xml
Normal file
114
app/src/main/res/layout/has_receive_item.xml
Normal file
@ -0,0 +1,114 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/stay_main_info"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="90dp"
|
||||
android:layout_margin="10dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/linearLayout3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_road_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:text="测试1"
|
||||
android:textColor="#333"
|
||||
android:textSize="15sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_poi_createtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:text="2021-05-08 13:24:36"
|
||||
android:textColor="#333"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_road_name" />
|
||||
<TextView
|
||||
android:id="@+id/tv_poi_expirationtime"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:text="2021-05-08 13:24:36"
|
||||
android:textColor="#333"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_road_name" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:visibility="gone"
|
||||
android:textColor="#333"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/cb_unSubmit"
|
||||
app:layout_constraintEnd_toStartOf="@+id/cb_unSubmit"
|
||||
app:layout_constraintTop_toTopOf="@+id/cb_unSubmit" />
|
||||
<CheckBox
|
||||
android:id="@+id/cb_unSubmit"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:scaleX="1.1"
|
||||
android:scaleY="1.1"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/layer_pb"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/default_widget_padding"
|
||||
app:layout_constraintTop_toBottomOf="@id/stay_main_info"
|
||||
app:layout_constraintLeft_toLeftOf="parent">
|
||||
<ProgressBar
|
||||
android:id="@+id/pb_stay_upload"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="2dp"
|
||||
android:layout_gravity="center"
|
||||
android:progressDrawable="@drawable/default_progress"
|
||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||
></ProgressBar>
|
||||
<TextView
|
||||
android:id="@+id/tv_pb_stay_upload"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:textSize="8sp"
|
||||
android:background="@color/white80"
|
||||
android:layout_height="wrap_content"></TextView>
|
||||
</FrameLayout>
|
||||
<TextView
|
||||
android:id="@+id/tv_upload_result"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:visibility="invisible"
|
||||
android:textSize="12sp"
|
||||
android:maxLength="20"
|
||||
android:ellipsize="middle"
|
||||
android:lines="1"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/colorRed"
|
||||
android:paddingHorizontal="@dimen/default_widget_padding"
|
||||
app:layout_constraintTop_toBottomOf="@id/layer_pb"
|
||||
app:layout_constraintRight_toRightOf="parent"></TextView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@ -37,8 +37,8 @@
|
||||
android:id="@+id/tv_road_day"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:text="2021-05-08 13:24:36"
|
||||
android:layout_marginHorizontal="10dp"
|
||||
android:text="2021-05-08 13:24:36"
|
||||
android:textColor="#333"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_road_name" />
|
||||
</LinearLayout>
|
||||
|
||||
@ -40,7 +40,17 @@
|
||||
android:background="@drawable/iv_message"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
<androidx.appcompat.widget.AppCompatTextView
|
||||
android:id="@+id/tv_latest_push"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="推荐任务"
|
||||
app:layout_constraintLeft_toRightOf="@id/iv_message"
|
||||
app:layout_constraintTop_toTopOf="@id/iv_message"
|
||||
android:layout_marginHorizontal="@dimen/default_widget_padding"
|
||||
android:visibility="gone"
|
||||
style="@style/btn_round_corner"></androidx.appcompat.widget.AppCompatTextView>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_mas_notification"
|
||||
|
||||
@ -174,7 +174,7 @@
|
||||
</style>
|
||||
|
||||
<style name="btn_round_corner">
|
||||
<item name="background">@drawable/selector_default_btn_round_corner_bg</item>
|
||||
<item name="android:background">@drawable/selector_default_btn_round_corner_bg</item>
|
||||
<item name="android:textColor">@color/selector_default_btn_text_color</item>
|
||||
<item name="android:padding">@dimen/default_widget_padding</item>
|
||||
</style>
|
||||
|
||||
14
app/tpns-configs.json
Normal file
14
app/tpns-configs.json
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"tpns": {
|
||||
"access_id": "1580017520",
|
||||
"access_key": "ABQZ9Z3PDWXM"
|
||||
},
|
||||
"com.navinfo.outdoor": {
|
||||
"channel": {
|
||||
"enable": true
|
||||
}
|
||||
},
|
||||
"debug": true,
|
||||
"version": "1.4.3.1-release",
|
||||
"upgrade": true
|
||||
}
|
||||
54
build.gradle
54
build.gradle
@ -1,8 +1,9 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
ext.anko_version = '0.10.1'//扩展库版本
|
||||
ext.kotlin_version = '1.5.10'
|
||||
ext.kotlin_version = '1.7.10'
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
@ -19,7 +20,6 @@ buildscript {
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
@ -36,31 +36,31 @@ buildscript {
|
||||
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
}
|
||||
}
|
||||
//allprojects {
|
||||
// repositories {
|
||||
// mavenCentral()
|
||||
// //友盟 检测bug
|
||||
// //腾讯地图
|
||||
// maven{
|
||||
// url "https://oss.sonatype.org/content/groups/public"
|
||||
// }
|
||||
// maven { url 'https://repo1.maven.org/maven2/' }
|
||||
// maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
// maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
// maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
// maven { url "https://jitpack.io" }
|
||||
// maven { url "https://repo.spring.io/libs-release/" }
|
||||
// //友盟 检测bug
|
||||
// maven { url 'https://repo1.maven.org/maven2/' }
|
||||
// jcenter()
|
||||
// google()
|
||||
// maven{
|
||||
// url "https://maven.google.com/"
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
#Tue Jul 18 13:25:30 CST 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@ -1 +1,56 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
dependencyResolutionManagement {
|
||||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
|
||||
repositories {
|
||||
mavenCentral()
|
||||
//友盟 检测bug
|
||||
//腾讯地图
|
||||
maven{
|
||||
url "https://oss.sonatype.org/content/groups/public"
|
||||
}
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
maven{ url 'https://maven.aliyun.com/repository/google'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/gradle-plugin'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/public'}
|
||||
maven{ url 'https://maven.aliyun.com/repository/jcenter'}
|
||||
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://jitpack.io" }
|
||||
maven { url "https://repo.spring.io/libs-release/" }
|
||||
//友盟 检测bug
|
||||
maven { url 'https://repo1.maven.org/maven2/' }
|
||||
jcenter()
|
||||
google()
|
||||
maven{
|
||||
url "https://maven.google.com/"
|
||||
}
|
||||
gradlePluginPortal()
|
||||
|
||||
}
|
||||
}
|
||||
rootProject.name = "NavinfoOutDoor"
|
||||
include ':app', ':xrecyclerview', ":ocr"
|
||||
Loading…
x
Reference in New Issue
Block a user