diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 021f688..c899b57 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -173,9 +173,9 @@
-
+
+
+
() {
@Override
public void onMarkerInit(Map> removableHashMap, List uploadByNet, List 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() {
+ "3"/*只获取POI数据*/,"0"/*只获取未领取的数据*/, removableHashMap, 30, new TencentMarkerUtils.MarkerInitCallback() {
@Override
public void onMarkerInit(Map> removableHashMap, List uploadByNet,
@@ -693,13 +736,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 +850,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 +1061,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)() {
@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 +1261,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);
@@ -1345,9 +1389,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());
diff --git a/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePicture4PoiVideoActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePicture4PoiVideoActivity.java
index 0fb4866..55aba34 100644
--- a/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePicture4PoiVideoActivity.java
+++ b/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePicture4PoiVideoActivity.java
@@ -147,7 +147,7 @@ import okhttp3.Response;
/**
* 拍照
- * (poi录像 和 道路)
+ * (poi录像 和 道路),暂时弃用
*/
@RequiresApi(api = Build.VERSION_CODES.N)
public class AutoTakePicture4PoiVideoActivity extends BaseActivity implements View.OnClickListener {
@@ -609,11 +609,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 +719,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 +920,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)() {
@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 +1120,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);
@@ -1247,9 +1248,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 +1286,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);
}
diff --git a/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePictureActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePictureActivity.java
index 63d590f..b257152 100644
--- a/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePictureActivity.java
+++ b/app/src/main/java/com/navinfo/outdoor/activity/AutoTakePictureActivity.java
@@ -656,7 +656,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 +723,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() {
@Override
public void onMarkerInit(Map> removableHashMap, List uploadByNet, List 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 +784,20 @@ public class AutoTakePictureActivity extends BaseActivity implements View.OnClic
public void onMarkerInit(Map> removableHashMap, List uploadByNet,
List 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 +901,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 +1112,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)() {
@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 +1312,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);
@@ -1397,9 +1440,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());
diff --git a/app/src/main/java/com/navinfo/outdoor/adapter/HasReceiveAdapter.java b/app/src/main/java/com/navinfo/outdoor/adapter/HasReceiveAdapter.java
new file mode 100644
index 0000000..732056d
--- /dev/null
+++ b/app/src/main/java/com/navinfo/outdoor/adapter/HasReceiveAdapter.java
@@ -0,0 +1,241 @@
+package com.navinfo.outdoor.adapter;
+
+import android.annotation.SuppressLint;
+import android.content.Context;
+import android.os.Handler;
+import android.os.Message;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.CheckBox;
+import android.widget.ProgressBar;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.navinfo.outdoor.R;
+import com.navinfo.outdoor.api.Constant;
+import com.navinfo.outdoor.room.PoiDatabase;
+import com.navinfo.outdoor.room.PoiEntity;
+import com.navinfo.outdoor.util.PoiEntityDeleteUtil;
+
+import org.greenrobot.eventbus.EventBus;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+public class HasReceiveAdapter extends RecyclerView.Adapter {
+ private final Vector allRoad = new Vector<>();
+ private Context context;
+
+ public HasReceiveAdapter(Context context) {
+ this.context = context;
+ }
+
+ public List getAllRoad() {
+ return allRoad;
+ }
+
+ public List getCheckedPoiEntity() {
+ List poiEntityList = new ArrayList<>();
+ if (allRoad!=null&&!allRoad.isEmpty()) {
+ for (PoiEntity poiEntity: allRoad) {
+ if (poiEntity.isChecked()) {
+ poiEntityList.add(poiEntity);
+ }
+ }
+ }
+ return poiEntityList;
+ }
+
+ public void setAllRoad(List 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 iterator = allRoad.iterator();
+ while (iterator.hasNext()) {
+ PoiEntity poiEntity = (PoiEntity) iterator.next();
+ if (poiEntity.isChecked()) {
+ PoiEntityDeleteUtil.getInstance().deleteUtil(context, poiEntity);
+ PoiDatabase.getInstance(context).getPoiDao().deletePoiEntity(poiEntity);
+ iterator.remove();
+ }
+ }
+ handler.sendEmptyMessage(0x105);
+ }
+ Message obtain = Message.obtain();
+ obtain.what = Constant.STAY_SUBMIT_ITEM;
+ obtain.obj = true;
+ EventBus.getDefault().post(obtain);
+ }
+
+ }).start();
+ }
+
+ @NotNull
+ @Override
+ public ViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
+ View inflate = LayoutInflater.from(context).inflate(R.layout.has_receive_item, parent, false);
+ return new ViewHolder(inflate);
+ }
+
+ @Override
+ public void onBindViewHolder(@NotNull ViewHolder holder, @SuppressLint("RecyclerView") int position) {
+ PoiEntity poiEntity = allRoad.get(position);
+ holder.tvName.setText(poiEntity.getName());
+ holder.tvDay.setText(poiEntity.getCreateTime());
+ //获取checkBox点击的记录
+ holder.cbUnSubmit.setChecked(allRoad.get(position).isChecked());
+ holder.cbUnSubmit.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ holder.cbUnSubmit.setChecked(!poiEntity.isChecked());
+ poiEntity.setChecked(!poiEntity.isChecked());
+ }
+ });
+ if (poiEntity.getWork_type() == 0) {
+ holder.tvText.setText("待提交");
+ } else if (poiEntity.getWork_type() == 1) {
+ holder.tvText.setText("提交中");
+// poiEntity.setChecked(true);
+ } else if (poiEntity.getWork_type() == 2) {
+ holder.tvText.setText("完成");
+ } else if (poiEntity.getWork_type() == -1) {
+ holder.tvText.setText("出错");
+ }
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (onClickItem != null) {
+ onClickItem.item(position, poiEntity);
+ }
+ }
+ });
+ // 显示进度
+ if (poiEntity.getWork_type()!=0&&poiEntity.getUploadMax()>0&&poiEntity.getUploadProgress()!=poiEntity.getUploadMax()) {
+ holder.layerProgress.setVisibility(View.VISIBLE);
+ holder.pbUpload.setMax(poiEntity.getUploadMax());
+ holder.pbUpload.setProgress(poiEntity.getUploadProgress());
+ holder.tvUploadProgress.setText(poiEntity.getUploadProgress()+"/"+poiEntity.getUploadMax());
+ } else {
+ holder.layerProgress.setVisibility(View.INVISIBLE);
+ }
+ // 显示上传状态
+ if (poiEntity.getUploadResult()!=null&&!poiEntity.getUploadResult().trim().equals("")) {
+ holder.tvUploadResult.setVisibility(View.VISIBLE);
+ holder.tvUploadResult.setText(poiEntity.getUploadResult());
+ holder.layerProgress.setVisibility(View.GONE); // 上传结果存在,不需要显示进度条
+ } else {
+ holder.tvUploadResult.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ @Override
+ public int getItemCount() {
+ return allRoad.size();
+ }
+
+ public static class ViewHolder extends RecyclerView.ViewHolder {
+ private TextView tvName, tvText, tvDay;
+ private CheckBox cbUnSubmit;
+ private ProgressBar pbUpload;
+ private TextView tvUploadProgress, tvUploadResult;
+ private View layerProgress;
+
+ public ViewHolder(@NonNull View itemView) {
+ super(itemView);
+ tvName = itemView.findViewById(R.id.tv_road_name);
+ tvText = itemView.findViewById(R.id.tv_text);
+ tvDay = itemView.findViewById(R.id.tv_road_day);
+ cbUnSubmit = itemView.findViewById(R.id.cb_unSubmit);
+ pbUpload = itemView.findViewById(R.id.pb_stay_upload);
+ tvUploadProgress = itemView.findViewById(R.id.tv_pb_stay_upload);
+ layerProgress = itemView.findViewById(R.id.layer_pb);
+ tvUploadResult = itemView.findViewById(R.id.tv_upload_result);
+ }
+ }
+
+ Handler handler = new Handler() {
+ @SuppressLint("HandlerLeak")
+ @Override
+ public void handleMessage(@NonNull @NotNull Message msg) {
+ super.handleMessage(msg);
+ switch (msg.what) {
+ case 0x105:
+ notifyDataSetChanged();
+ break;
+ }
+ }
+ };
+
+ public onClickItem onClickItem;
+
+ public void setOnClickItem(onClickItem onClickItem) {
+ this.onClickItem = onClickItem;
+ }
+
+ public interface onClickItem {
+ void item(int position, PoiEntity allRoad);
+ }
+
+}
diff --git a/app/src/main/java/com/navinfo/outdoor/api/Constant.java b/app/src/main/java/com/navinfo/outdoor/api/Constant.java
index a096f1a..2449a6c 100644
--- a/app/src/main/java/com/navinfo/outdoor/api/Constant.java
+++ b/app/src/main/java/com/navinfo/outdoor/api/Constant.java
@@ -158,6 +158,9 @@ public class Constant {
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
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/JobSearchBean.java b/app/src/main/java/com/navinfo/outdoor/bean/JobSearchBean.java
index 89cc0e0..9a74b48 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/JobSearchBean.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/JobSearchBean.java
@@ -115,6 +115,8 @@ public class JobSearchBean implements Serializable {
private String memo;
private String telephone;
+ private int publish; // 是否已发布,如果是未发布的数据,则用半透明形式展示
+
public int getCanReceived() {
return canReceived;
}
@@ -210,6 +212,14 @@ public class JobSearchBean implements Serializable {
public void setTelephone(String telephone) {
this.telephone = telephone;
}
+
+ public int getPublish() {
+ return publish;
+ }
+
+ public void setPublish(int publish) {
+ this.publish = publish;
+ }
}
}
}
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/LatestPushMessageResponse.java b/app/src/main/java/com/navinfo/outdoor/bean/LatestPushMessageResponse.java
new file mode 100644
index 0000000..cbb61b5
--- /dev/null
+++ b/app/src/main/java/com/navinfo/outdoor/bean/LatestPushMessageResponse.java
@@ -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 body) {
+ this.code = code;
+ this.message = message;
+ this.body = body;
+ }
+
+ public LatestPushMessageResponse() {
+ }
+
+ protected Map body;
+
+ public Map getBody() {
+ return body;
+ }
+
+ public void setBody(Map body) {
+ this.body = body;
+ }
+}
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/PolygonTaskBean.java b/app/src/main/java/com/navinfo/outdoor/bean/PolygonTaskBean.java
index 8ac7038..1deeb0c 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/PolygonTaskBean.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/PolygonTaskBean.java
@@ -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;
+ }
}
}
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/ReceivedBean.java b/app/src/main/java/com/navinfo/outdoor/bean/ReceivedBean.java
index 75d5731..6d86142 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/ReceivedBean.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/ReceivedBean.java
@@ -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;
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/ReceivedPoiBean.java b/app/src/main/java/com/navinfo/outdoor/bean/ReceivedPoiBean.java
index 61adad5..4e01ab5 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/ReceivedPoiBean.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/ReceivedPoiBean.java
@@ -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;
+ }
}
}
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/RoadMatchEntity.java b/app/src/main/java/com/navinfo/outdoor/bean/RoadMatchEntity.java
index df231e0..81ae86f 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/RoadMatchEntity.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/RoadMatchEntity.java
@@ -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() {
diff --git a/app/src/main/java/com/navinfo/outdoor/bean/TaskByNetBean.java b/app/src/main/java/com/navinfo/outdoor/bean/TaskByNetBean.java
index 7db0550..57813c5 100644
--- a/app/src/main/java/com/navinfo/outdoor/bean/TaskByNetBean.java
+++ b/app/src/main/java/com/navinfo/outdoor/bean/TaskByNetBean.java
@@ -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;
diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java
index 2ecacee..3c238ca 100644
--- a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java
+++ b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java
@@ -328,7 +328,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
EventBus.getDefault().post(obtains);
break;
case R.id.btn_cancel_get://结束领取
- gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了结束领取的按钮 ,");
+ gatherGetBuilder.append(TimestampUtil.time()).append(",").append("点击了取消领取的按钮 ,");
if (poiEntity != null) {
initEndReceiveTask(HttpInterface.UNRECEIVED_POLYGON_TASK, poiEntity);
}
@@ -457,10 +457,13 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
if (taskIdPoiEntity == null) {
PoiEntity chargingStationEntity = new PoiEntity();
chargingStationEntity.setTaskId(poiEntity.getTaskId());
+ chargingStationEntity.setRecord_way(poiEntity.getRecord_way());
+ chargingStationEntity.setWork_type(poiEntity.getWork_type());
chargingStationEntity.setStation_type(stationBean.getSptype());
chargingStationEntity.setName(stationBean.getName());
chargingStationEntity.setDescribe(stationBean.getMemo());
chargingStationEntity.setCreateTime(stationBean.getEndDate());
+ chargingStationEntity.setUnReceivedTime(stationBean.getUnReceivedTime());
chargingStationEntity.setPrecision(stationBean.getPrice() + "");
chargingStationEntity.setAddress(stationBean.getAddress());
if (stationBean.getTelephone() == null || stationBean.getTelephone().equals("") || stationBean.getTelephone().equals("null")) {
@@ -497,6 +500,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
@Override
public void run() {
initViewByTaskStatus(1);
+ ToastUtils.showToast(requireContext(), "领取成功");
if (isSaver) {
Message obtain = Message.obtain();
obtain.what = Constant.GATHER_GET_MAP;
@@ -599,11 +603,14 @@ 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());
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
@@ -696,6 +703,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
@Override
public void run() {
Log.d("TAG", "run: " + response.getMessage());
+ ToastUtils.showToast(requireContext(), "已取消领取:" + poiEntity.getName());
initViewByTaskStatus(0);
Message obtain = Message.obtain();
obtain.what = Constant.JOB_WORD_MONITOR;
@@ -907,9 +915,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
poiListEntity.setName(listBean.getName());
poiListEntity.setDescribe(listBean.getMemo());
poiListEntity.setCreateTime(listBean.getEndDate());
+ poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
poiListEntity.setAddress(listBean.getAddress());
poiListEntity.setType(listBean.getType());
poiListEntity.setIsExclusive(listBean.getIsExclusive());
+ poiListEntity.setRecord_way(poiEntity.getRecord_way());
+ poiListEntity.setWork_type(poiEntity.getWork_type());
if (listBean.getType() == 1) {
if (listBean.getTelephone() == null || listBean.getTelephone().equals("") || listBean.getTelephone().equals("null")) {
poiListEntity.setTelPhone(null);
@@ -931,6 +942,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
@Override
public void run() {
initViewByTaskStatus(1);//已领取
+ ToastUtils.showToast(requireContext(), "领取成功");
if (isSaver) {
Message obtain = Message.obtain();
obtain.what = Constant.GATHER_GET_MAP;
@@ -1026,9 +1038,12 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe
if (taskIdPoiEntity == null) {//数据库没有这条数据
PoiEntity poiListEntity = new PoiEntity();
poiListEntity.setTaskId(poiEntity.getTaskId());
+ poiListEntity.setRecord_way(poiEntity.getRecord_way());
+ poiListEntity.setWork_type(poiEntity.getWork_type());
poiListEntity.setName(listBean.getName());
poiListEntity.setMemo(listBean.getMemo());
poiListEntity.setCreateTime(listBean.getEndDate());
+ poiListEntity.setUnReceivedTime(listBean.getUnReceivedTime());
poiListEntity.setAddress(listBean.getAddress());
poiListEntity.setType(listBean.getType());
poiListEntity.setPrecision(String.valueOf(listBean.getPrice()));
@@ -1047,6 +1062,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;
diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/HasReceiveFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/HasReceiveFragment.java
new file mode 100644
index 0000000..f814ceb
--- /dev/null
+++ b/app/src/main/java/com/navinfo/outdoor/fragment/HasReceiveFragment.java
@@ -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 roadEntities;
+ private ArrayList 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 roadAll = null;
+ if (type == 0) {
+ roadAll = roadDao.getHasReceivePoiByRecoded();
+ } else {
+ roadAll = roadDao.getHasReceivePoiType(type);
+ }
+
+ if (getActivity() != null) {
+ List 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 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 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 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() {
+ @Override
+ public void onSuccess(UnPolygonTaskBean response, int id) {
+ dismissLoadingDialog();
+ if (response.getCode() == 200) {
+ // 启动线程删除对应的图片文件
+ Observable.fromIterable(poiEntities)
+ .subscribeOn(Schedulers.io())
+ .doOnNext(new Consumer() {
+ @Override
+ public void accept(PoiEntity poiEntity) throws Exception {
+ PoiEntityDeleteUtil.getInstance().deleteUtil(getContext(), poiEntity);
+ }
+ })
+ .observeOn(AndroidSchedulers.mainThread())
+ .subscribe(new Consumer() {
+ @Override
+ public void accept(PoiEntity poiEntity) throws Exception {
+ logger.d("数据被删除:"+poiEntity.getId()+"-"+poiEntity.getName()+"-"+poiEntity.getTaskId()+"-"+poiEntity.getBodyId());
+ }
+ },
+ new Consumer() {
+ @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 roadAll = roadDao.getHasReceivePoiByRecoded();
+
+ // 首先过滤数据中记录的领取失效时间超限的数据
+ Iterator iterator = roadAll.iterator();
+ while (iterator.hasNext()) {
+ PoiEntity poiEntity = (PoiEntity) iterator.next();
+ if (poiEntity.getUnReceivedTimeStamp()<=new Date().getTime()) {
+ // 删除该条数据,并且将此数据移除出当前列表
+ roadDao.deletePoiEntity(poiEntity);
+ iterator.remove();
+ }
+ }
+
+ // 再次请求在线已领取数据,做差分处理
+ HttpParams httpParams = new HttpParams();
+ httpParams.put("datetime", System.currentTimeMillis());
+ CommonRequestSend commonRequestSend = new CommonRequestSend>>();
+ CommonResponse> response = commonRequestSend.getMethodCommonSync(requireActivity(), HttpInterface.GET_RECEIVED_LIST, httpParams, Constant.DEFAULT_TIME_OUT, new CommonResponse>().getClass());
+ if (response!=null) {
+ if (response.getCode() == 200) {
+ List ids = response.getBody();
+
+ // 使用id过滤已有的数据,如果数据不在ids中,需要删除该数据,过滤掉
+ Iterator iteratorAgain = roadAll.iterator();
+ a:while (iteratorAgain.hasNext()) {
+ PoiEntity poiEntity = (PoiEntity) iteratorAgain.next();
+ for (double id: ids) {
+ if (((int)id) == poiEntity.getTaskId()) {
+ continue a;
+ }
+ }
+ // 数据库中移除该数据
+ roadDao.deletePoiEntity(poiEntity);
+ iteratorAgain.remove();
+ }
+ } else {
+ ToastUtils.Message(requireActivity(), response.getMessage());
+ }
+ }
+
+ if (getActivity() != null) {
+ getActivity().runOnUiThread(new Runnable() {
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void run() {
+ roadEntities.clear();
+ roadEntities.addAll(roadAll);
+ hasReceiveAdapter.setAllRoad(roadEntities);
+ hasReceiveAdapter.notifyDataSetChanged();
+ if (tvNumber != null) {
+ tvNumber.setText(hasReceiveAdapter.getAllRoad().size() + "条");
+ }
+ }
+ });
+ }
+ } catch (Exception e) {
+ ToastUtils.Message(requireActivity(), "初始化数据失败!");
+ XLog.e("获取数据失败:" + e.getMessage());
+ UMCrash.generateCustomLog(e, "自定义");
+ }
+ }
+ }).start();
+ } else {
+ ToastUtils.Message(getActivity(), "无法读取数据库,请尝试重启程序!");
+ UMCrash.generateCustomLog("无法读取数据库", "自定义");
+ }
+ } else {
+ ToastUtils.Message(getActivity(), "数据库创建失败,请关闭程序重新进入");
+ }
+ }
+
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ }
+
+ @Override
+ public void onDestroy() {
+ if (EventBus.getDefault().isRegistered(this))//加上判断
+ EventBus.getDefault().unregister(this);
+ super.onDestroy();
+ dismissLoadingDialog();
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RecordFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RecordFragment.java
index b5b1779..65ed339 100644
--- a/app/src/main/java/com/navinfo/outdoor/fragment/RecordFragment.java
+++ b/app/src/main/java/com/navinfo/outdoor/fragment/RecordFragment.java
@@ -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 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;
diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java
index 55d0941..77c7469 100644
--- a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java
+++ b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java
@@ -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,21 @@ import androidx.recyclerview.widget.DividerItemDecoration;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+import com.bumptech.glide.Glide;
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 +71,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;
@@ -78,7 +84,6 @@ import com.navinfo.outdoor.http.OkGoBuilder;
import com.navinfo.outdoor.http.UploadCallBack;
import com.navinfo.outdoor.room.ChargingPileEntity;
import com.navinfo.outdoor.room.PoiEntity;
-import com.navinfo.outdoor.util.Base64;
import com.navinfo.outdoor.util.FlushTokenUtil;
import com.navinfo.outdoor.util.Geohash;
import com.navinfo.outdoor.util.GeometryTools;
@@ -115,6 +120,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;
@@ -133,6 +140,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;
@@ -172,6 +182,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) {
@@ -244,6 +255,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);
@@ -318,7 +331,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() {
@@ -334,7 +347,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
.setOnIconChangeCallBack(new OnIconChangeCallBack() {
@Override
public int getIcon(PopMenu dialog, int index, String menuText) {
- switch (index){
+ switch (index) {
case 0:
return R.drawable.marker_road_show;
case 1:
@@ -348,17 +361,35 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@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() {
+ @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() {
+ @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);
@@ -398,8 +429,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()) {
@@ -425,16 +469,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)() {
+ tencentMarkerUtils.initNetMarkerList(getActivity(), LocationLifeCycle.getInstance().getTencentLocation(), tencentMap, removables, null, null, removableHashMap, 200, new TencentMarkerUtils.MarkerInitCallback() {
@Override
public void onMarkerInit(Map> removableHashMap, List uploadByNet, List listData) {
@@ -706,6 +750,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())
@@ -911,7 +958,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); // 通知抽屉不收回
@@ -1075,7 +1122,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 {
@@ -1094,7 +1141,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;
@@ -1102,13 +1149,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() {
@Override
public void accept(Marker marker) {
@@ -1118,7 +1165,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
drawLineMarkerList.clear();
}
- if (drawLinePolyline!=null) {
+ if (drawLinePolyline != null) {
drawLinePolyline.remove();
}
}
@@ -1128,13 +1175,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() {
@Override
public void accept(Marker marker) {
@@ -1144,12 +1191,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() {
@Override
public void accept(Marker marker) {
@@ -1159,7 +1206,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
drawLineMarkerList.clear();
}
- if (drawLinePolyline!=null) {
+ if (drawLinePolyline != null) {
drawLinePolyline.remove();
}
PolylineOptions drawLineOptions = new PolylineOptions() // 用户绘制参考线的线数据
@@ -1173,7 +1220,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) {
@@ -1210,6 +1257,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
}
});
+ } else if(data.what == Constant.EVENT_WHAT_HAS_RECEIVE_ITEM) {
+ PoiEntity poiEntity = (PoiEntity) data.obj;
+ initMarker(poiEntity, true);
}
}
@@ -1439,10 +1489,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(), "无定位");
@@ -2064,13 +2114,86 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
/**
* 获取最新的推荐任务数据
- * */
+ */
private void initRecommandTaskInfo() {
- if (Constant.PUSH_TOKEN!=null) {
+ if (Constant.PUSH_TOKEN != null) {
HttpParams httpParams = new HttpParams();
- httpParams.put("pushId", Constant.PUSH_TOKEN);
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() {
+ @Override
+ public void onSuccess(LatestPushMessageResponse response, int id) {
+ tvLatestPush.setVisibility(View.GONE); // 默认先隐藏推荐任务按钮
+ if (response != null) {
+ Map 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(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.with(requireContext()).load(imgUrl).into(photo);
+ View.OnClickListener clickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ // 地图定位到指定位置,发送Event
+ Map 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);
+ }
+ });
+
}
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java
index 2fa6014..7dd6c3e 100644
--- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java
+++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java
@@ -2,12 +2,12 @@ package com.navinfo.outdoor.http;
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/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/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";//生产地址
@@ -144,10 +144,12 @@ public class HttpInterface {
public static String SUBMIT_POLYGON_TASK = null;//面状任务开始采集
//dtxbmaps.navinfo.com/dtxb_test/m4/msgList/InfoPush/28/push?type=0
public static String MESSAGE_INFO_PUSH = null;//消息通知
+ public static String MESSAGE_LATEST_PUSH = null;//最新的推荐任务推送信息获取
public static String UPDATE_PHONE_NUM_URL = null;//消息通知
public static String CREATE_UPLOAD_TASK = null;//创建断点续传任务
public static String UPLOAD_SPLITE_TASK = null;//执行断点续传
public static String UPLOAD_TASK_FINISH = null;//断点续传完成
+ public static String GET_RECEIVED_LIST = null;//获取当前用户所有已领取的任务ID
public static String CONTACT_US = "";//联系我们
public static String ABOUT_MAP = "";//关于 -关于地图寻宝
@@ -186,6 +188,7 @@ public class HttpInterface {
//172.23.139.4:8002/findAndMessage/1/submitExam
EXAM_SUBMIT = IP + MSG_LIST_PATH + "findAndMessage/" + userId + "/submitExam";//发现 -能力测评提交试卷 post
MESSAGE_INFO_PUSH = IP + MSG_LIST_PATH + "InfoPush/" + userId + "/push";//寻宝-消息通知
+ MESSAGE_LATEST_PUSH = IP + MSG_LIST_PATH + "UserMessage/" + userId + "/getLatestMessage";//寻宝首页-获取最新推送推荐任务
/* 提现 金额
* Path=/m4/price/
@@ -240,6 +243,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";//其他-上传
diff --git a/app/src/main/java/com/navinfo/outdoor/receiver/MessageReceiver.java b/app/src/main/java/com/navinfo/outdoor/receiver/MessageReceiver.java
index 439bfe9..ccf62d5 100644
--- a/app/src/main/java/com/navinfo/outdoor/receiver/MessageReceiver.java
+++ b/app/src/main/java/com/navinfo/outdoor/receiver/MessageReceiver.java
@@ -76,6 +76,11 @@ public class MessageReceiver extends XGPushBaseReceiver {
// 获取当前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", "");
@@ -101,8 +106,7 @@ public class MessageReceiver extends XGPushBaseReceiver {
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
- } else if (type == 1) {
- // 显示普通通知
+ } else if (type == 1) { // 显示普通通知
String title = msgJson.optString("title", "通知");
String content = msgJson.optString("content", "");
// 展示普通notification
@@ -138,7 +142,8 @@ public class MessageReceiver extends XGPushBaseReceiver {
.setSilent(false)
.setAutoCancel(true)
.setContentIntent(pendingIntent)
- .addAction(R.mipmap.ic_launcher, "去看看", pendingIntent);
+ .addAction(R.mipmap.ic_launcher, "去看看", pendingIntent)
+ .setAutoCancel(true);
mManager.notify(2, mBuilder.build());
}
diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiDao.java b/app/src/main/java/com/navinfo/outdoor/room/PoiDao.java
index cd2acf2..b624194 100644
--- a/app/src/main/java/com/navinfo/outdoor/room/PoiDao.java
+++ b/app/src/main/java/com/navinfo/outdoor/room/PoiDao.java
@@ -22,9 +22,13 @@ public interface PoiDao {
@Query("SELECT * FROM poi where taskStatus > 1 and taskStatus!=100 and type!=6 ")
List getAllPoiByRecoded();
+ @Query("SELECT * FROM poi where taskStatus = 1 and type!=6 ")
+ List getHasReceivePoiByRecoded();
@Query("SELECT * FROM poi where type=:type and taskStatus > 1 and taskStatus!=100")
List getAllPoiType(int type);
+ @Query("SELECT * FROM poi where type=:type and taskStatus = 1 and taskStatus!=100")
+ List getHasReceivePoiType(int type);
@Query("SELECT * FROM poi where taskStatus =5")
List getAllPoiStatus();
diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java b/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java
index 0337470..ffb658e 100644
--- a/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java
+++ b/app/src/main/java/com/navinfo/outdoor/room/PoiDatabase.java
@@ -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();//充电桩
diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java
index 146fc62..949067e 100644
--- a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java
+++ b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java
@@ -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,7 @@ public class PoiEntity implements Serializable {
private int score; // 置信度
private String drawLine; // 用户绘制的线型
private String uploadResult; //上传结果
+ private String unReceivedTime; // 任务领取后自动释放的时间
public int getRecord_way() {
return record_way;
@@ -326,6 +331,31 @@ public class PoiEntity implements Serializable {
this.uploadResult = uploadResult;
}
+ /**
+ * 获取经过处理后的接受任务失效时间的时间戳
+ * */
+ public long getUnReceivedTimeStamp() {
+ if (getUnReceivedTime() == null || "".equals(getUnReceivedTime())) {
+ return 0;
+ }
+ DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ long time = 0;
+ try {
+ time = df.parse(getUnReceivedTime()).getTime();
+ } catch (ParseException e) {
+ throw new RuntimeException(e);
+ }
+ return time;
+ }
+
+ public String getUnReceivedTime() {
+ return unReceivedTime;
+ }
+
+ public void setUnReceivedTime(String unReceivedTime) {
+ this.unReceivedTime = unReceivedTime;
+ }
+
@Override
public String toString() {
return "PoiEntity{" +
@@ -346,6 +376,7 @@ public class PoiEntity implements Serializable {
", x='" + x + '\'' +
", y='" + y + '\'' +
", detail='" + detail + '\'' +
+ ", unReceivedTime='" + unReceivedTime + '\'' +
'}';
}
}
diff --git a/app/src/main/java/com/navinfo/outdoor/util/TencentMarkerUtils.java b/app/src/main/java/com/navinfo/outdoor/util/TencentMarkerUtils.java
index 8ebde7b..7601d26 100644
--- a/app/src/main/java/com/navinfo/outdoor/util/TencentMarkerUtils.java
+++ b/app/src/main/java/com/navinfo/outdoor/util/TencentMarkerUtils.java
@@ -186,7 +186,10 @@ public class TencentMarkerUtils {
}
break;
}
- switch (list.get(i).getType()) {
+ // publish字段标识了当前数据是否已发布,如果未发布,则半透明显示,且不可点击,否则正常显示
+ float alpha = listBean.getPublish() == 0? 0.3f: 1.0f;
+ boolean clickable = listBean.getPublish() == 0? false: true;
+ switch (listBean.getType()) {
case 1://poi
BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi);
//poiDescriptor.getForager().setScale(50);
@@ -194,6 +197,7 @@ public class TencentMarkerUtils {
Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (poiMarker != null) {
if (listBean != null) {
@@ -203,7 +207,7 @@ public class TencentMarkerUtils {
removables.add(poiMarker);
String poiGeo = initGeo(latLng);
geoMarker(poiGeo, poiMarker, removableHashMap);
- poiMarker.setClickable(true);
+ poiMarker.setClickable(clickable);
}
break;
case 2://充电站
@@ -212,6 +216,7 @@ public class TencentMarkerUtils {
Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (stationMarker != null) {
if (listBean != null) {
@@ -221,7 +226,7 @@ public class TencentMarkerUtils {
removables.add(stationMarker);
String stationGeo = initGeo(latLng);
geoMarker(stationGeo, stationMarker, removableHashMap);
- stationMarker.setClickable(true);
+ stationMarker.setClickable(clickable);
}
break;
case 3://poi录像
@@ -230,6 +235,7 @@ public class TencentMarkerUtils {
Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (poiVideoMarker != null) {
if (listBean != null) {
@@ -239,7 +245,7 @@ public class TencentMarkerUtils {
removables.add(poiVideoMarker);
String poiVideoGeo = initGeo(latLng);
geoMarker(poiVideoGeo, poiVideoMarker, removableHashMap);
- poiVideoMarker.setClickable(true);
+ poiVideoMarker.setClickable(clickable);
}
break;
case 4://道路录像
@@ -248,6 +254,7 @@ public class TencentMarkerUtils {
Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (roadMarker != null) {
if (listBean != null) {
@@ -257,7 +264,7 @@ public class TencentMarkerUtils {
removables.add(roadMarker);
String roadGeo = initGeo(latLng);
geoMarker(roadGeo, roadMarker, removableHashMap);
- roadMarker.setClickable(true);
+ roadMarker.setClickable(clickable);
}
break;
case 5://其他
@@ -266,6 +273,7 @@ public class TencentMarkerUtils {
Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (otherMarker != null) {
if (listBean != null) {
@@ -275,7 +283,7 @@ public class TencentMarkerUtils {
removables.add(otherMarker);
String otherGeo = initGeo(latLng);
geoMarker(otherGeo, otherMarker, removableHashMap);
- otherMarker.setClickable(true);
+ otherMarker.setClickable(clickable);
}
break;
case 6://面状任务
@@ -284,6 +292,7 @@ public class TencentMarkerUtils {
Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
.anchor(0.5f, 1.0f)
.flat(true)
+ .alpha(alpha)
.clockwise(false));
if (planarMarker != null) {
if (listBean != null) {
@@ -293,7 +302,7 @@ public class TencentMarkerUtils {
removables.add(planarMarker);
String planarGeo = initGeo(latLng);
geoMarker(planarGeo, planarMarker, removableHashMap);
- planarMarker.setClickable(true);
+ planarMarker.setClickable(clickable);
}
break;
}
diff --git a/app/src/main/res/drawable/btn_stroke_corners_bg.xml b/app/src/main/res/drawable/btn_stroke_corners_bg.xml
index 69b2623..2cf6d2b 100644
--- a/app/src/main/res/drawable/btn_stroke_corners_bg.xml
+++ b/app/src/main/res/drawable/btn_stroke_corners_bg.xml
@@ -9,6 +9,6 @@
android:right="@dimen/default_widget_padding"
android:top="@dimen/default_widget_padding" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_push_tesk.xml b/app/src/main/res/layout/dialog_push_tesk.xml
new file mode 100644
index 0000000..c6fa881
--- /dev/null
+++ b/app/src/main/res/layout/dialog_push_tesk.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_has_receive.xml b/app/src/main/res/layout/fragment_has_receive.xml
new file mode 100644
index 0000000..4828078
--- /dev/null
+++ b/app/src/main/res/layout/fragment_has_receive.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/has_receive_item.xml b/app/src/main/res/layout/has_receive_item.xml
new file mode 100644
index 0000000..4ca4022
--- /dev/null
+++ b/app/src/main/res/layout/has_receive_item.xml
@@ -0,0 +1,106 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/treasure_fragment.xml b/app/src/main/res/layout/treasure_fragment.xml
index d457562..8880a9a 100644
--- a/app/src/main/res/layout/treasure_fragment.xml
+++ b/app/src/main/res/layout/treasure_fragment.xml
@@ -40,7 +40,17 @@
android:background="@drawable/iv_message"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
-
+
+