diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8e005d2..5f0ed82 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,5 +1,6 @@
@@ -9,6 +10,13 @@
+
+
+
+
+
@@ -89,6 +97,21 @@
android:screenOrientation="portrait"/>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java
index 9c4ec37..dd369cc 100644
--- a/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java
+++ b/app/src/main/java/com/navinfo/outdoor/activity/MainActivity.java
@@ -4,6 +4,7 @@ import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
+import android.os.Build;
import android.os.CountDownTimer;
import android.os.Environment;
import android.os.Handler;
@@ -13,6 +14,7 @@ import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
+import androidx.core.content.FileProvider;
import com.hjq.permissions.OnPermissionCallback;
import com.hjq.permissions.Permission;
@@ -47,18 +49,30 @@ public class MainActivity extends BaseActivity {
@Override
public boolean handleMessage(@NonNull Message msg) {
if (msg.what==0){
+ Toast.makeText(MainActivity.this, "下载完成", Toast.LENGTH_SHORT).show();
//将下载进度对话框取消
pBar.cancel();
-//安装apk,也可以进行静默安装
+ //调用系统安装程序
+ //安装apk,也可以进行静默安装
Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setDataAndType(Uri.fromFile(new File(Constant.NAVINFO_APk, "navinfo.apk")),
- "application/vnd.android.package-archive");
- startActivityForResult(intent, 10);
+ File file = new File(Constant.NAVINFO_APk+"DTXB.apk");
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
+ intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
+ Uri contentUri = FileProvider.getUriForFile(MainActivity.this, "com.navinfo.outdoor.fileprovider", file);
+ intent.setDataAndType(contentUri, "application/vnd.android.package-archive");
+ } else {
+ intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ }
+ startActivity(intent);
+ }else if (msg.what==1){
+ pBar.setProgress(progress);
}
return false;
}
});
private ProgressDialog pBar;
+ private int progress;
@Override
protected int getLayout() {
@@ -91,6 +105,7 @@ public class MainActivity extends BaseActivity {
.permission(Permission.MANAGE_EXTERNAL_STORAGE/*, Permission.READ_EXTERNAL_STORAGE, Permission.WRITE_EXTERNAL_STORAGE*/)
// 申请相机权限
.permission(Permission.CAMERA)
+ .permission(Permission.REQUEST_INSTALL_PACKAGES)
// 位置权限
.permission(Permission.ACCESS_FINE_LOCATION)
//.permission(Permission.ACCESS_BACKGROUND_LOCATION)
@@ -143,7 +158,7 @@ public class MainActivity extends BaseActivity {
dismissLoadingDialog();
if (response.getCode() == 200) {
int version = response.getBody().getVersion();
- if (versionCode < version) {
+ if (versionCode () {
- @Override
- public void onSuccess(UserBean response, int id) {
- dismissLoadingDialog();
- if (response.getCode()==200){
- Toast.makeText(getActivity(), "成功", Toast.LENGTH_SHORT).show();
- Log.d("TAG", "onSuccess: ssssssssssssssssssssssssss 成功");
- }else {
- Toast.makeText(getActivity(), response.getMessage()+"", Toast.LENGTH_SHORT).show();
- Log.d("TAG", "onSuccess: "+response.getCode()+response.getMessage()+""+response.getBody());
- }
- }
-
- @Override
- public void onError(Throwable e, int id) {
- dismissLoadingDialog();
- Log.d("TAG", "onSuccess: sss********sssssssssssss 成功"+e.getMessage()+"");
- }
- });
- }
-
- private void initList(TencentLocation tencentLocation) {
- int task_type = Constant.TASK_TYPE;
- int limit_type = Constant.LIMIT_TTPE;
- int taskStatus = Constant.TASK_STASTUS;
- if (taskStatus == 1 || taskStatus == 2 || taskStatus == 3) {
- Message obtain = Message.obtain();
- obtain.what = Constant.JOB_SEARCH_WORD;
- obtain.obj = null;
- EventBus.getDefault().post(obtain);
- return;
- }
- //获取中心点位置
- LatLng mapCenterPoint = getMapCenterPoint();
- if (mapCenterPoint != null) {
- centerEncode = Geohash.getInstance().encode(mapCenterPoint.latitude, mapCenterPoint.longitude);
- }
- userEncode = Geohash.getInstance().encode(tencentLocation.getLatitude(), tencentLocation.getLongitude());
- long date = System.currentTimeMillis();
- OkGo.getInstance().cancelTag(this);
- showLoadingDialog();
- // 请求方式和请求url
- HttpParams httpParams = new HttpParams();
- httpParams.put("userGeo", userEncode);
- httpParams.put("centerGeo", centerEncode);
- httpParams.put("date", date);
- httpParams.put("pageSize", Constant.NUMBER);
- httpParams.put("pageNum", "1");
- httpParams.put("type", task_type);
- httpParams.put("isExclusive", limit_type);
- OkGoBuilder.getInstance()
- .Builder(getActivity())
- .url(HttpInterface.TASK_LIST)
- .cls(JobSearchBean.class)
- .params(httpParams)
- .token(Constant.ACCESS_TOKEN)
- .getRequest(new Callback() {
- @Override
- public void onSuccess(JobSearchBean response, int id) {
- dismissLoadingDialog();
- JobSearchBean.BodyBean body = response.getBody();
- if (body != null) {
- Log.d("TAG", "onSuccess: " + response.getBody().toString() + "sssssssssssss");
- for (int i = 0; i < removables.size(); i++) {
- removables.get(i).remove();
+ Geometry geometry = GeometryTools.createGeometry(new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()));
+ try {
+ String encode = Base64.desEncrypt(geometry.toString());
+ HttpParams httpParams = new HttpParams();
+ httpParams.put("geom", encode);
+ long time = System.currentTimeMillis();
+ httpParams.put("datetime", time);
+ OkGoBuilder.getInstance().Builder(getActivity())
+ .url(HttpInterface.USER_LOCATION)
+ .cls(UserBean.class)
+ .params(httpParams)
+ .token(Constant.ACCESS_TOKEN)
+ .postRequest(new Callback() {
+ @Override
+ public void onSuccess(UserBean response, int id) {
+ dismissLoadingDialog();
+ if (response.getCode() == 200) {
+ Toast.makeText(getActivity(), "成功", Toast.LENGTH_SHORT).show();
+ Log.d("TAG", "onSuccess: ssssssssssssssssssssssssss 成功");
+ } else {
+ Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show();
+ Log.d("TAG", "onSuccess: " + response.getCode() + response.getMessage() + "" + response.getBody());
}
- removables.clear();
- List list = response.getBody().getList();
- for (int i = 0; i < list.size(); i++) {
- JobSearchBean.BodyBean.ListBean listBean = list.get(i);
- String geo = list.get(i).getGeo();
- Log.d("TAG", "onSuccess: " + geo);
- Geometry geometry = GeometryTools.createGeometry(geo);
- LatLng latLng = null;
- if (geometry.getGeometryType().equals("Point")) {//点
- latLng = GeometryTools.createLatLng(geo);
- } else if (geometry.getGeometryType().equals("LineString")) {//线
- List latLineString = GeometryTools.getLatLngs(geo);
- // 构造 PolylineOpitons
- PolylineOptions polylineOptions = new PolylineOptions()
- .addAll(latLineString)
- // 折线设置圆形线头
- .lineCap(true)
- // 折线的颜色为绿色
- .color(0xff00ff00)
- // 折线宽度为5像素
- .width(5)
- // 还可以添加描边颜色
- .borderColor(0xffff0000)
- // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
- .borderWidth(1);
- // 绘制折线
- Polyline polyline = tencentMap.addPolyline(polylineOptions);
- polyline.setZIndex(3);
- removables.add(polyline);
- if (latLineString != null && latLineString.size() > 0) {
- latLng = latLineString.get(0);
- }
- } else if (geometry.getGeometryType().equals("Polygon")) {//面
- List latPolygon = GeometryTools.getLatLngs(geo);
- Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
- //连接封闭图形的点
- addAll(latPolygon).
- //填充颜色为红色
- fillColor(Color.parseColor("#97E0E7EC")).
- //边线颜色为黑色
- strokeColor(0xff000000).
- //边线宽度15像素
- strokeWidth(5));
- polygon.setZIndex(1);
- removables.add(polygon);
- com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
- double x = centroid.getX();
- double y = centroid.getY();
- if (centroid != null) {
- latLng = new LatLng();
- latLng.setLatitude(y);
- latLng.setLongitude(x);
- }
+ }
+
+ @Override
+ public void onError(Throwable e, int id) {
+ dismissLoadingDialog();
+ Log.d("TAG", "onSuccess: sss********sssssssssssss 成功" + e.getMessage() + "");
+ }
+ });
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ private void initList (TencentLocation tencentLocation){
+ int task_type = Constant.TASK_TYPE;
+ int limit_type = Constant.LIMIT_TTPE;
+ int taskStatus = Constant.TASK_STASTUS;
+ if (taskStatus == 1 || taskStatus == 2 || taskStatus == 3) {
+ Message obtain = Message.obtain();
+ obtain.what = Constant.JOB_SEARCH_WORD;
+ obtain.obj = null;
+ EventBus.getDefault().post(obtain);
+ return;
+ }
+ //获取中心点位置
+ LatLng mapCenterPoint = getMapCenterPoint();
+ if (mapCenterPoint != null) {
+ centerEncode = Geohash.getInstance().encode(mapCenterPoint.latitude, mapCenterPoint.longitude);
+ }
+ userEncode = Geohash.getInstance().encode(tencentLocation.getLatitude(), tencentLocation.getLongitude());
+ long date = System.currentTimeMillis();
+ OkGo.getInstance().cancelTag(this);
+ showLoadingDialog();
+ // 请求方式和请求url
+ HttpParams httpParams = new HttpParams();
+ httpParams.put("userGeo", userEncode);
+ httpParams.put("centerGeo", centerEncode);
+ httpParams.put("date", date);
+ httpParams.put("pageSize", Constant.NUMBER);
+ httpParams.put("pageNum", "1");
+ httpParams.put("type", task_type);
+ httpParams.put("isExclusive", limit_type);
+ OkGoBuilder.getInstance()
+ .Builder(getActivity())
+ .url(HttpInterface.TASK_LIST)
+ .cls(JobSearchBean.class)
+ .params(httpParams)
+ .token(Constant.ACCESS_TOKEN)
+ .getRequest(new Callback() {
+ @Override
+ public void onSuccess(JobSearchBean response, int id) {
+ dismissLoadingDialog();
+ JobSearchBean.BodyBean body = response.getBody();
+ if (body != null) {
+ Log.d("TAG", "onSuccess: " + response.getBody().toString() + "sssssssssssss");
+ for (int i = 0; i < removables.size(); i++) {
+ removables.get(i).remove();
+ }
+ removables.clear();
+ List list = response.getBody().getList();
+ for (int i = 0; i < list.size(); i++) {
+ JobSearchBean.BodyBean.ListBean listBean = list.get(i);
+ String geo = list.get(i).getGeo();
+ Log.d("TAG", "onSuccess: " + geo);
+ Geometry geometry = GeometryTools.createGeometry(geo);
+ LatLng latLng = null;
+ if (geometry.getGeometryType().equals("Point")) {//点
+ latLng = GeometryTools.createLatLng(geo);
+ } else if (geometry.getGeometryType().equals("LineString")) {//线
+ List latLineString = GeometryTools.getLatLngs(geo);
+ // 构造 PolylineOpitons
+ PolylineOptions polylineOptions = new PolylineOptions()
+ .addAll(latLineString)
+ // 折线设置圆形线头
+ .lineCap(true)
+ // 折线的颜色为绿色
+ .color(0xff00ff00)
+ // 折线宽度为5像素
+ .width(5)
+ // 还可以添加描边颜色
+ .borderColor(0xffff0000)
+ // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
+ .borderWidth(1);
+ // 绘制折线
+ Polyline polyline = tencentMap.addPolyline(polylineOptions);
+ polyline.setZIndex(3);
+ removables.add(polyline);
+ if (latLineString != null && latLineString.size() > 0) {
+ latLng = latLineString.get(0);
+ }
+ } else if (geometry.getGeometryType().equals("Polygon")) {//面
+ List latPolygon = GeometryTools.getLatLngs(geo);
+ Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
+ //连接封闭图形的点
+ addAll(latPolygon).
+ //填充颜色为红色
+ fillColor(Color.parseColor("#97E0E7EC")).
+ //边线颜色为黑色
+ strokeColor(0xff000000).
+ //边线宽度15像素
+ strokeWidth(5));
+ polygon.setZIndex(1);
+ removables.add(polygon);
+ com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
+ double x = centroid.getX();
+ double y = centroid.getY();
+ if (centroid != null) {
+ latLng = new LatLng();
+ latLng.setLatitude(y);
+ latLng.setLongitude(x);
+ }
/* if (latPolygon != null && latPolygon.size() > 0) {
latLng = latPolygon.get(0);
}*/
- }
- switch (Integer.valueOf(list.get(i).getType())) {
- case 1://poi
- BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1);
- Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- poiMarker.setZIndex(2);
- poiMarker.setTag(listBean);
- removables.add(poiMarker);
- poiMarker.setClickable(true);
- break;
- case 2://充电站
- BitmapDescriptor chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bg1);
- Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- stationMarker.setTag(listBean);
- removables.add(stationMarker);
- stationMarker.setClickable(true);
- stationMarker.setZIndex(2);
- break;
- case 3://poi录像
- BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_bg1);
- Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- poiVideoMarker.setTag(listBean);
- removables.add(poiVideoMarker);
- poiVideoMarker.setClickable(true);
- poiVideoMarker.setZIndex(2);
- break;
- case 4://道路录像
- BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bg);
- Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- roadMarker.setTag(listBean);
- removables.add(roadMarker);
- roadMarker.setClickable(true);
- roadMarker.setZIndex(2);
- break;
- case 5://其他
- BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bg1);
- Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- otherMarker.setTag(listBean);
- removables.add(otherMarker);
- otherMarker.setClickable(true);
- otherMarker.setZIndex(2);
- break;
- case 6://面状任务
- BitmapDescriptor Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bg);
- Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- Log.d("面状任务", "onSuccess: " + planarMarker);
- planarMarker.setTag(listBean);
- removables.add(planarMarker);
- planarMarker.setClickable(true);
- planarMarker.setZIndex(2);
- break;
+ }
+ switch (Integer.valueOf(list.get(i).getType())) {
+ case 1://poi
+ BitmapDescriptor poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1);
+ Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ poiMarker.setZIndex(2);
+ poiMarker.setTag(listBean);
+ removables.add(poiMarker);
+ poiMarker.setClickable(true);
+ break;
+ case 2://充电站
+ BitmapDescriptor chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bg1);
+ Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ stationMarker.setTag(listBean);
+ removables.add(stationMarker);
+ stationMarker.setClickable(true);
+ stationMarker.setZIndex(2);
+ break;
+ case 3://poi录像
+ BitmapDescriptor poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_bg1);
+ Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ poiVideoMarker.setTag(listBean);
+ removables.add(poiVideoMarker);
+ poiVideoMarker.setClickable(true);
+ poiVideoMarker.setZIndex(2);
+ break;
+ case 4://道路录像
+ BitmapDescriptor roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bg);
+ Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ roadMarker.setTag(listBean);
+ removables.add(roadMarker);
+ roadMarker.setClickable(true);
+ roadMarker.setZIndex(2);
+ break;
+ case 5://其他
+ BitmapDescriptor otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bg1);
+ Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ otherMarker.setTag(listBean);
+ removables.add(otherMarker);
+ otherMarker.setClickable(true);
+ otherMarker.setZIndex(2);
+ break;
+ case 6://面状任务
+ BitmapDescriptor Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bg);
+ Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ Log.d("面状任务", "onSuccess: " + planarMarker);
+ planarMarker.setTag(listBean);
+ removables.add(planarMarker);
+ planarMarker.setClickable(true);
+ planarMarker.setZIndex(2);
+ break;
+ }
}
}
+ Message obtain = Message.obtain();
+ obtain.what = Constant.JOB_SEARCH_WORD;
+ obtain.obj = response;
+ EventBus.getDefault().post(obtain);
}
- Message obtain = Message.obtain();
- obtain.what = Constant.JOB_SEARCH_WORD;
- obtain.obj = response;
- EventBus.getDefault().post(obtain);
- }
- @Override
- public void onError(Throwable e, int id) {
- dismissLoadingDialog();
- Log.d("TAG", "onError: " + e.getMessage() + "");
- }
- });
- dismissDialog();
- }
- public void initMarker(PoiEntity poiEntity) {
- sliding_layout.setPanelHeight(0);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
- for (int i = 0; i < removablesMarker.size(); i++) {
- removablesMarker.get(i).remove();
+ @Override
+ public void onError(Throwable e, int id) {
+ dismissLoadingDialog();
+ Log.d("TAG", "onError: " + e.getMessage() + "");
+ }
+ });
+ dismissDialog();
}
- removablesMarker.clear();
- String geo = poiEntity.getGeoWkt();
- Log.d("TAG", "onSuccess: " + geo);
- Geometry geometry = GeometryTools.createGeometry(geo);
- LatLng latLng = null;
- if (geometry.getGeometryType().equals("Point")) {//点
- latLng = GeometryTools.createLatLng(geo);
- } else if (geometry.getGeometryType().equals("LineString")) {//线
- List latLineString = GeometryTools.getLatLngs(geo);
- // 构造 PolylineOpitons
- PolylineOptions polylineOptions = new PolylineOptions()
- .addAll(latLineString)
- // 折线设置圆形线头
- .lineCap(true)
- // 折线的颜色为绿色
- .color(0xff00ff00)
- // 折线宽度为5像素
- .width(25)
- // 还可以添加描边颜色
- .borderColor(0xffff0000)
- // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
- .borderWidth(1);
- // 绘制折线
- Polyline polyline = tencentMap.addPolyline(polylineOptions);
- polyline.setZIndex(3);
- removablesMarker.add(polyline);
- if (latLineString != null && latLineString.size() > 0) {
- latLng = latLineString.get(0);
- }
- } else if (geometry.getGeometryType().equals("Polygon")) {//面
- List latPolygon = GeometryTools.getLatLngs(geo);
- Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
- //连接封闭图形的点
- addAll(latPolygon).
- //填充颜色为红色
- fillColor(Color.parseColor("#97E0E7EC")).
- //边线颜色为黑色
- strokeColor(0xff000000).
- //边线宽度15像素
- strokeWidth(25));
- polygon.setZIndex(1);
- removablesMarker.add(polygon);
- com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
- double x = centroid.getX();
- double y = centroid.getY();
- if (centroid != null) {
- latLng = new LatLng();
- latLng.setLatitude(y);
- latLng.setLongitude(x);
+
+ public void initMarker (PoiEntity poiEntity){
+ sliding_layout.setPanelHeight(0);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
+ for (int i = 0; i < removablesMarker.size(); i++) {
+ removablesMarker.get(i).remove();
}
+ removablesMarker.clear();
+ String geo = poiEntity.getGeoWkt();
+ Log.d("TAG", "onSuccess: " + geo);
+ Geometry geometry = GeometryTools.createGeometry(geo);
+ LatLng latLng = null;
+ if (geometry.getGeometryType().equals("Point")) {//点
+ latLng = GeometryTools.createLatLng(geo);
+ } else if (geometry.getGeometryType().equals("LineString")) {//线
+ List latLineString = GeometryTools.getLatLngs(geo);
+ // 构造 PolylineOpitons
+ PolylineOptions polylineOptions = new PolylineOptions()
+ .addAll(latLineString)
+ // 折线设置圆形线头
+ .lineCap(true)
+ // 折线的颜色为绿色
+ .color(0xff00ff00)
+ // 折线宽度为5像素
+ .width(25)
+ // 还可以添加描边颜色
+ .borderColor(0xffff0000)
+ // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
+ .borderWidth(1);
+ // 绘制折线
+ Polyline polyline = tencentMap.addPolyline(polylineOptions);
+ polyline.setZIndex(3);
+ removablesMarker.add(polyline);
+ if (latLineString != null && latLineString.size() > 0) {
+ latLng = latLineString.get(0);
+ }
+ } else if (geometry.getGeometryType().equals("Polygon")) {//面
+ List latPolygon = GeometryTools.getLatLngs(geo);
+ Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
+ //连接封闭图形的点
+ addAll(latPolygon).
+ //填充颜色为红色
+ fillColor(Color.parseColor("#97E0E7EC")).
+ //边线颜色为黑色
+ strokeColor(0xff000000).
+ //边线宽度15像素
+ strokeWidth(25));
+ polygon.setZIndex(1);
+ removablesMarker.add(polygon);
+ com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
+ double x = centroid.getX();
+ double y = centroid.getY();
+ if (centroid != null) {
+ latLng = new LatLng();
+ latLng.setLatitude(y);
+ latLng.setLongitude(x);
+ }
/* if (latPolygon != null && latPolygon.size() > 0) {
latLng = latPolygon.get(0);
}*/
- }
- BitmapDescriptor descriptor = null;
- if (poiEntity.getType()==1){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bags);
- }else if (poiEntity.getType()==2){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bags);
- }else if (poiEntity.getType()==3){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bag);
- }else if (poiEntity.getType()==4){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bag);
- }else if (poiEntity.getType()==5){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bag);
- }else if (poiEntity.getType()==6){
- descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bag);
- }
- if (bigMarker == null) {
- bigMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(descriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- } else {
- bigMarker.setPosition(latLng);
- bigMarker.setIcon(descriptor);
- }
- bigMarker.setVisible(true);
- bigMarker.setClickable(false);
- bigMarker.setZIndex(4);
- frameLayout.setVisibility(View.VISIBLE);
- setMainButtonVisiable(View.GONE);
- fragmentTransaction = supportFragmentManager.beginTransaction();
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- gatherGetFragment = GatherGetFragment.newInstance(bundle);
- fragmentTransaction.replace(R.id.frame_layout, gatherGetFragment);
- fragmentTransaction.commit();
- }
-
-
- private void initThread() {
- int taskStatus = Constant.TASK_STASTUS;
- int type = Constant.TASK_TYPE;
- int limit = Constant.LIMIT_TTPE;
- new Thread(new Runnable() {
- @Override
- public void run() {
- List allTaskStatus = poiDao.getAllTaskStatus(taskStatus, taskStatus, type, type, limit, limit);
- //List allTaskStatus = poiDao.getAllPoi();
- getActivity().runOnUiThread(new Runnable() {
- @Override
- public void run() {
- for (int i = 0; i < removablesLocality.size(); i++) {
- removablesLocality.get(i).remove();
- }
- removablesLocality.clear();
- for (int i = 0; i < allTaskStatus.size(); i++) {
- PoiEntity poiEntity = allTaskStatus.get(i);
- String geo = allTaskStatus.get(i).getGeoWkt();
- LatLng latLng = null;
- Log.d("TAG", "onSuccess: " + geo);
- Geometry geometry = GeometryTools.createGeometry(geo);
- if (geometry != null) {
- if (geometry.getGeometryType().equals("Point")) {//点
- latLng = GeometryTools.createLatLng(geo);
- } else if (geometry.getGeometryType().equals("LineString")) {//线
- List latLineString = GeometryTools.getLatLngs(geo);
- // 构造 PolylineOpitons
- PolylineOptions polylineOptions = new PolylineOptions()
- .addAll(latLineString)
- // 折线设置圆形线头
- .lineCap(true)
- .color(0xffff0000)
- // 折线宽度为5像素
- .width(5)
- // 还可以添加描边颜色
- .borderColor(0xffff0000)
- // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
- .borderWidth(1);
- // 绘制折线
- Polyline polyline = tencentMap.addPolyline(polylineOptions);
- polyline.setZIndex(3);
- removablesLocality.add(polyline);
- if (latLineString != null && latLineString.size() > 0) {
- latLng = latLineString.get(0);
- }
- } else if (geometry.getGeometryType().equals("Polygon")) {//面
- List latPolygon = GeometryTools.getLatLngs(geo);
- Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
- //连接封闭图形的点
- addAll(latPolygon).
- //填充颜色为红色
- fillColor(Color.parseColor("#97E0E74C")).
- //边线颜色为黑色
- strokeColor(0xff00ff00).
- //边线宽度15像素
- strokeWidth(5));
- polygon.setZIndex(1);
- removablesLocality.add(polygon);
- com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
- double x = centroid.getX();
- double y = centroid.getY();
- if (centroid != null) {
- latLng = new LatLng();
- latLng.setLatitude(y);
- latLng.setLongitude(x);
- }
- /* if (latPolygon != null && latPolygon.size() > 0) {
- latLng = latPolygon.get(0);
- }*/
- }
- } else {
- if (allTaskStatus.get(i).getX() != null && allTaskStatus.get(i).getY() != null) {
- latLng = new LatLng(Double.valueOf(allTaskStatus.get(i).getY()), Double.valueOf(allTaskStatus.get(i).getX()));
- }
- }
- switch (Integer.valueOf(poiEntity.getType())) {
- case 1://poi
- BitmapDescriptor poiDescriptor=null;
- if (poiEntity.getTaskStatus()==1){
- poiDescriptor= BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1);
- }else {
- poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graypoi);
- }
- Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- poiMarker.setClickable(true);
- poiMarker.setZIndex(2);
- poiMarker.setTitle(poiEntity.getName() + "");
- poiMarker.setTag(poiEntity);
- removablesLocality.add(poiMarker);
-
-
- break;
- case 2://充电站
- BitmapDescriptor chargeDescriptor = null;
- if (poiEntity.getTaskStatus()==1){
- chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bg1);
- }else {
- chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graycharge);
- }
- Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- stationMarker.setClickable(true);
- stationMarker.setZIndex(2);
- stationMarker.setTitle(poiEntity.getName() + "");
- stationMarker.setTag(poiEntity);
- removablesLocality.add(stationMarker);
- break;
- case 3://poi录像
- BitmapDescriptor poiVideoDescriptor = null;
- if (poiEntity.getTaskStatus()==1){
- poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_bg1);
- }else {
- poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_have_bg);
- }
- Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- poiVideoMarker.setClickable(true);
- poiVideoMarker.setZIndex(2);
- poiVideoMarker.setTitle(poiEntity.getName() + "");
- poiVideoMarker.setTag(poiEntity);
- removablesLocality.add(poiVideoMarker);
- break;
- case 4://道路录像
- BitmapDescriptor roadDescriptor =null;
- if (poiEntity.getTaskStatus()==1){
- roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bg);
- }else {
- roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayroad);
- }
- Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- roadMarker.setClickable(true);
- roadMarker.setZIndex(2);
- roadMarker.setTitle(poiEntity.getName() + "");
- roadMarker.setTag(poiEntity);
- removablesLocality.add(roadMarker);
- break;
- case 5://其他
- BitmapDescriptor otherDescriptor = null;
- if (poiEntity.getTaskStatus()==1){
- otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bg1);
- }else {
- otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayother);
- }
- Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
- .flat(true)
- .clockwise(false));
- otherMarker.setClickable(true);
- otherMarker.setZIndex(2);
- otherMarker.setTitle(poiEntity.getName() + "");
- otherMarker.setTag(poiEntity);
- removablesLocality.add(otherMarker);
- break;
- case 6://面状任务
- BitmapDescriptor Descriptor =null;
- if (poiEntity.getTaskStatus()==1){
- Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bg);
- }else {
- Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_have_bag);
- }
- Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
- .clockwise(false)
- .flat(true));
- planarMarker.setClickable(true);
- planarMarker.setZIndex(2);
- planarMarker.setTitle(poiEntity.getName() + "");
- planarMarker.setTag(poiEntity);
- removablesLocality.add(planarMarker);
- break;
- }
- }
- Message obtain = Message.obtain();
- obtain.what = Constant.JOB_SEARCH_POI_WORD;
- obtain.obj = allTaskStatus;
- EventBus.getDefault().post(obtain);
- }
- });
}
- }).start();
- }
-
- private void initSharePre() {
- //根据保存时所用的name属性,获取SharedPreferences对象
- SharedPreferences dataFile = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
- //根据数据类型,调用对应的get方法,通过键取得对应的值。
- String dataFileString = dataFile.getString("poiEntity", null);
- if (dataFileString != null) {
- PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class);
- switch (poiEntity.getType()) {
- case 1:
- DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
- MessageDialog.show((AppCompatActivity) getContext(), "提示", "你poi页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
- @Override
- public boolean onClick(BaseDialog baseDialog, View v) {
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- PoiFragment poiFragment = PoiFragment.newInstance(bundle);
- LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
- showPoiMarkerByType(1, newPoiLatLng);
- showSlidingFragment(poiFragment);
- initRemovePoiSharePre();
- return false;
- }
- });
- break;
- case 2:
- DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
- MessageDialog.show((AppCompatActivity) getContext(), "提示", "你充电站页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
- @Override
- public boolean onClick(BaseDialog baseDialog, View v) {
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
- LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
- showPoiMarkerByType(4, newPoiLatLng);
- showSlidingFragment(chargingStationFragment);
- initRemovePoiSharePre();
- return false;
- }
- });
- break;
- case 3:
- DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
- MessageDialog.show((AppCompatActivity) getContext(), "提示", "你poi录像页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
- @Override
- public boolean onClick(BaseDialog baseDialog, View v) {
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
- LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
- showPoiMarkerByType(2, newPoiLatLng);
- showSlidingFragment(poiVideoFragment);
- initRemovePoiSharePre();
- return false;
- }
- });
- break;
- case 4:
- DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
- MessageDialog.show((AppCompatActivity) getContext(), "提示", "你道路页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
- @Override
- public boolean onClick(BaseDialog baseDialog, View v) {
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- RoadFragment roadFragment = RoadFragment.newInstance(bundle);
- LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
- showPoiMarkerByType(3, newPoiLatLng);
- showSlidingFragment(roadFragment);
- initRemovePoiSharePre();
- return false;
- }
- });
- break;
-
- case 5:
- DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
- MessageDialog.show((AppCompatActivity) getContext(), "提示", "你其他页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
- @Override
- public boolean onClick(BaseDialog baseDialog, View v) {
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- OtherFragment otherFragment = OtherFragment.newInstance(bundle);
- LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()),Double.valueOf(poiEntity.getX()));
- showPoiMarkerByType(5, newPoiLatLng);
- showSlidingFragment(otherFragment);
- initRemovePoiSharePre();
- return false;
- }
- });
- break;
-
+ BitmapDescriptor descriptor = null;
+ if (poiEntity.getType() == 1) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bags);
+ } else if (poiEntity.getType() == 2) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bags);
+ } else if (poiEntity.getType() == 3) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bag);
+ } else if (poiEntity.getType() == 4) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bag);
+ } else if (poiEntity.getType() == 5) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bag);
+ } else if (poiEntity.getType() == 6) {
+ descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bag);
}
- }
- }
-
- public void initRemovePoiSharePre() {
- //获取SharedPreferences对象,方法中两个参数的意思为:第一个name
- //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
- //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
- //方法注释得知,建议以0或者MODE_PRIVATE为默认值。
- SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
- //获取Editor对象
- SharedPreferences.Editor edit = poi.edit();
- //根据要保存的数据的类型,调用对应的put方法,
- //以键值对的形式添加新值。
- edit.putString("poiEntity", null);
- //提交新值。必须执行,否则前面的操作都无效。
- edit.commit();
- }
-
- @Subscribe
- public void onEvent(Message data) {
- if (data.what == Constant.FILTER_LIST_ITEM) { // 点击筛选的item
- PoiEntity poiEntity = (PoiEntity) data.obj;
- if (poiEntity.getX() != null && poiEntity.getY() != null) {
- LatLng position = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
- CameraUpdateFactory.newCameraPosition(new CameraPosition(
- position, //中心点坐标,地图目标经纬度
- tencentMap.getCameraPosition().zoom, //目标缩放级别
- tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
- tencentMap.getCameraPosition().bearing));//目标旋转角 0~360° (正北方为0)
+ if (bigMarker == null) {
+ bigMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(descriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ } else {
+ bigMarker.setPosition(latLng);
+ bigMarker.setIcon(descriptor);
}
- sliding_layout.setPanelHeight(0);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
+ bigMarker.setVisible(true);
+ bigMarker.setClickable(false);
+ bigMarker.setZIndex(4);
frameLayout.setVisibility(View.VISIBLE);
+ setMainButtonVisiable(View.GONE);
fragmentTransaction = supportFragmentManager.beginTransaction();
Bundle bundle = new Bundle();
bundle.putSerializable("poiEntity", poiEntity);
gatherGetFragment = GatherGetFragment.newInstance(bundle);
fragmentTransaction.replace(R.id.frame_layout, gatherGetFragment);
fragmentTransaction.commit();
- // 如果当前fragment是筛选,则移除该fragment
- FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
- if (filterFragment != null) {
- fragmentTransaction.remove(filterFragment);
+ }
+
+
+ private void initThread () {
+ int taskStatus = Constant.TASK_STASTUS;
+ int type = Constant.TASK_TYPE;
+ int limit = Constant.LIMIT_TTPE;
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ List allTaskStatus = poiDao.getAllTaskStatus(taskStatus, taskStatus, type, type, limit, limit);
+ //List allTaskStatus = poiDao.getAllPoi();
+ getActivity().runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ for (int i = 0; i < removablesLocality.size(); i++) {
+ removablesLocality.get(i).remove();
+ }
+ removablesLocality.clear();
+ for (int i = 0; i < allTaskStatus.size(); i++) {
+ PoiEntity poiEntity = allTaskStatus.get(i);
+ String geo = allTaskStatus.get(i).getGeoWkt();
+ LatLng latLng = null;
+ Log.d("TAG", "onSuccess: " + geo);
+ Geometry geometry = GeometryTools.createGeometry(geo);
+ if (geometry != null) {
+ if (geometry.getGeometryType().equals("Point")) {//点
+ latLng = GeometryTools.createLatLng(geo);
+ } else if (geometry.getGeometryType().equals("LineString")) {//线
+ List latLineString = GeometryTools.getLatLngs(geo);
+ // 构造 PolylineOpitons
+ PolylineOptions polylineOptions = new PolylineOptions()
+ .addAll(latLineString)
+ // 折线设置圆形线头
+ .lineCap(true)
+ .color(0xffff0000)
+ // 折线宽度为5像素
+ .width(5)
+ // 还可以添加描边颜色
+ .borderColor(0xffff0000)
+ // 描边颜色的宽度,线宽还是 25 像素,不过填充的部分宽度为 `width` - 2 * `borderWidth`
+ .borderWidth(1);
+ // 绘制折线
+ Polyline polyline = tencentMap.addPolyline(polylineOptions);
+ polyline.setZIndex(3);
+ removablesLocality.add(polyline);
+ if (latLineString != null && latLineString.size() > 0) {
+ latLng = latLineString.get(0);
+ }
+ } else if (geometry.getGeometryType().equals("Polygon")) {//面
+ List latPolygon = GeometryTools.getLatLngs(geo);
+ Polygon polygon = tencentMap.addPolygon(new PolygonOptions().
+ //连接封闭图形的点
+ addAll(latPolygon).
+ //填充颜色为红色
+ fillColor(Color.parseColor("#97E0E74C")).
+ //边线颜色为黑色
+ strokeColor(0xff00ff00).
+ //边线宽度15像素
+ strokeWidth(5));
+ polygon.setZIndex(1);
+ removablesLocality.add(polygon);
+ com.vividsolutions.jts.geom.Point centroid = geometry.getCentroid();
+ double x = centroid.getX();
+ double y = centroid.getY();
+ if (centroid != null) {
+ latLng = new LatLng();
+ latLng.setLatitude(y);
+ latLng.setLongitude(x);
+ }
+ /* if (latPolygon != null && latPolygon.size() > 0) {
+ latLng = latPolygon.get(0);
+ }*/
+ }
+ } else {
+ if (allTaskStatus.get(i).getX() != null && allTaskStatus.get(i).getY() != null) {
+ latLng = new LatLng(Double.valueOf(allTaskStatus.get(i).getY()), Double.valueOf(allTaskStatus.get(i).getX()));
+ }
+ }
+ switch (Integer.valueOf(poiEntity.getType())) {
+ case 1://poi
+ BitmapDescriptor poiDescriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1);
+ } else {
+ poiDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graypoi);
+ }
+ Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ poiMarker.setClickable(true);
+ poiMarker.setZIndex(2);
+ poiMarker.setTitle(poiEntity.getName() + "");
+ poiMarker.setTag(poiEntity);
+ removablesLocality.add(poiMarker);
+
+
+ break;
+ case 2://充电站
+ BitmapDescriptor chargeDescriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bg1);
+ } else {
+ chargeDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.graycharge);
+ }
+ Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(chargeDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ stationMarker.setClickable(true);
+ stationMarker.setZIndex(2);
+ stationMarker.setTitle(poiEntity.getName() + "");
+ stationMarker.setTag(poiEntity);
+ removablesLocality.add(stationMarker);
+ break;
+ case 3://poi录像
+ BitmapDescriptor poiVideoDescriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_video_bg1);
+ } else {
+ poiVideoDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_have_bg);
+ }
+ Marker poiVideoMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(poiVideoDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ poiVideoMarker.setClickable(true);
+ poiVideoMarker.setZIndex(2);
+ poiVideoMarker.setTitle(poiEntity.getName() + "");
+ poiVideoMarker.setTag(poiEntity);
+ removablesLocality.add(poiVideoMarker);
+ break;
+ case 4://道路录像
+ BitmapDescriptor roadDescriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bg);
+ } else {
+ roadDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayroad);
+ }
+ Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(roadDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ roadMarker.setClickable(true);
+ roadMarker.setZIndex(2);
+ roadMarker.setTitle(poiEntity.getName() + "");
+ roadMarker.setTag(poiEntity);
+ removablesLocality.add(roadMarker);
+ break;
+ case 5://其他
+ BitmapDescriptor otherDescriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bg1);
+ } else {
+ otherDescriptor = BitmapDescriptorFactory.fromResource(R.drawable.grayother);
+ }
+ Marker otherMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(otherDescriptor).alpha(0.9f)
+ .flat(true)
+ .clockwise(false));
+ otherMarker.setClickable(true);
+ otherMarker.setZIndex(2);
+ otherMarker.setTitle(poiEntity.getName() + "");
+ otherMarker.setTag(poiEntity);
+ removablesLocality.add(otherMarker);
+ break;
+ case 6://面状任务
+ BitmapDescriptor Descriptor = null;
+ if (poiEntity.getTaskStatus() == 1) {
+ Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bg);
+ } else {
+ Descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_have_bag);
+ }
+ Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Descriptor).alpha(0.9f)
+ .clockwise(false)
+ .flat(true));
+ planarMarker.setClickable(true);
+ planarMarker.setZIndex(2);
+ planarMarker.setTitle(poiEntity.getName() + "");
+ planarMarker.setTag(poiEntity);
+ removablesLocality.add(planarMarker);
+ break;
+ }
+ }
+ Message obtain = Message.obtain();
+ obtain.what = Constant.JOB_SEARCH_POI_WORD;
+ obtain.obj = allTaskStatus;
+ EventBus.getDefault().post(obtain);
+ }
+ });
+ }
+ }).start();
+ }
+
+ private void initSharePre () {
+ //根据保存时所用的name属性,获取SharedPreferences对象
+ SharedPreferences dataFile = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
+ //根据数据类型,调用对应的get方法,通过键取得对应的值。
+ String dataFileString = dataFile.getString("poiEntity", null);
+ if (dataFileString != null) {
+ PoiEntity poiEntity = new Gson().fromJson(dataFileString, PoiEntity.class);
+ switch (poiEntity.getType()) {
+ case 1:
+ DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
+ MessageDialog.show((AppCompatActivity) getContext(), "提示", "你poi页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
+ @Override
+ public boolean onClick(BaseDialog baseDialog, View v) {
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ PoiFragment poiFragment = PoiFragment.newInstance(bundle);
+ LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ showPoiMarkerByType(1, newPoiLatLng);
+ showSlidingFragment(poiFragment);
+ initRemovePoiSharePre();
+ return false;
+ }
+ });
+ break;
+ case 2:
+ DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
+ MessageDialog.show((AppCompatActivity) getContext(), "提示", "你充电站页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
+ @Override
+ public boolean onClick(BaseDialog baseDialog, View v) {
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
+ LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ showPoiMarkerByType(4, newPoiLatLng);
+ showSlidingFragment(chargingStationFragment);
+ initRemovePoiSharePre();
+ return false;
+ }
+ });
+ break;
+ case 3:
+ DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
+ MessageDialog.show((AppCompatActivity) getContext(), "提示", "你poi录像页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
+ @Override
+ public boolean onClick(BaseDialog baseDialog, View v) {
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
+ LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ showPoiMarkerByType(2, newPoiLatLng);
+ showSlidingFragment(poiVideoFragment);
+ initRemovePoiSharePre();
+ return false;
+ }
+ });
+ break;
+ case 4:
+ DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
+ MessageDialog.show((AppCompatActivity) getContext(), "提示", "你道路页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
+ @Override
+ public boolean onClick(BaseDialog baseDialog, View v) {
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ RoadFragment roadFragment = RoadFragment.newInstance(bundle);
+ LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ showPoiMarkerByType(3, newPoiLatLng);
+ showSlidingFragment(roadFragment);
+ initRemovePoiSharePre();
+ return false;
+ }
+ });
+ break;
+
+ case 5:
+ DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE;
+ MessageDialog.show((AppCompatActivity) getContext(), "提示", "你其他页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() {
+ @Override
+ public boolean onClick(BaseDialog baseDialog, View v) {
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ OtherFragment otherFragment = OtherFragment.newInstance(bundle);
+ LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ showPoiMarkerByType(5, newPoiLatLng);
+ showSlidingFragment(otherFragment);
+ initRemovePoiSharePre();
+ return false;
+ }
+ });
+ break;
+
+ }
}
- } else if (data.what == Constant.GATHER_GET) { //筛选item 点击开始采集
- PoiEntity poiEntity = (PoiEntity) data.obj;
- Bundle bundle = new Bundle();
- bundle.putBoolean("isSliding", false); // 通知抽屉不收回
- bundle.putSerializable("poiEntity", poiEntity);
- switch (poiEntity.getType()) {
- case 1:
- PoiFragment poiFragment = PoiFragment.newInstance(bundle);
- showSlidingFragment(poiFragment);
- break;
- case 2:
- ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
- showSlidingFragment(chargingStationFragment);
- break;
- case 3:
- PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
- showSlidingFragment(poiVideoFragment);
- break;
- case 4:
- RoadFragment roadFragment = RoadFragment.newInstance(bundle);
- showSlidingFragment(roadFragment);
- break;
- case 5:
- OtherFragment otherFragment = OtherFragment.newInstance(bundle);
- showSlidingFragment(otherFragment);
- break;
- }
- frameLayout.setVisibility(View.GONE);
- if (gatherGetFragment != null) {
- fragmentTransaction.remove(gatherGetFragment);
- }
- } else if (data.what == Constant.GATHER_GET_MAP) { //地图界面点击采集 点击开始采集
- PoiEntity poiEntity = (PoiEntity) data.obj;
- Bundle bundle = new Bundle();
- bundle.putSerializable("poiEntity", poiEntity);
- bundle.putBoolean("isSliding", true); // 通知抽屉不收回
- switch (poiEntity.getType()) {
- case 1:
- PoiFragment poiFragment = PoiFragment.newInstance(bundle);
- showSlidingFragment(poiFragment);
- break;
- case 2:
- ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
- showSlidingFragment(chargingStationFragment);
- break;
- case 3:
- PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
- showSlidingFragment(poiVideoFragment);
- break;
- case 4:
- RoadFragment roadFragment = RoadFragment.newInstance(bundle);
- showSlidingFragment(roadFragment);
- break;
- case 5:
- OtherFragment otherFragment = OtherFragment.newInstance(bundle);
- showSlidingFragment(otherFragment);
- break;
- }
- frameLayout.setVisibility(View.GONE);
- if (gatherGetFragment != null) {
- fragmentTransaction.remove(gatherGetFragment);
- }
- } else if (data.what == Constant.TREASURE_WORD) { // POI采集-移动位置
- initPoiMarker((LatLng) data.obj);
- } else if (data.what == Constant.TREASURE_CHECKED_WORD) {//poi采集 -确定位置
- if ((boolean) data.obj) {
- initCheckedMarker(Constant.POI_WORD);
- }
- } else if (data.what == Constant.MAIN_CHARGING_STATION) {//充电站采集-移动位置
- initPoiMarker((LatLng) data.obj);
- } else if (data.what == Constant.MAIN_CHARGING_CHECKED_STATION) {//充电站采集 -确定位置
- if ((boolean) data.obj) {
- initCheckedMarker(Constant.CHARGING_STATION_WORD);
- }
- } else if (data.what == Constant.MAIN_CHARGING_PILE) {//充电桩采集-移动位置
- initPileMarker((LatLng) data.obj);
- } else if (data.what == Constant.MAIN_CHARGING_CHECKED_PILE) {//充电桩采集-确定位置
- if ((boolean) data.obj) {
- initCheckedPileMarker(Constant.CHARGING_PILE_WORD);
- }
- } else if (data.what == Constant.MAIN_OTHER) {//其他采集-移动位置
- initPoiMarker((LatLng) data.obj);
- } else if (data.what == Constant.MAIN_CHECKED_OTHER) {//其他采集-确定位置
- if ((boolean) data.obj) {
- initCheckedMarker(Constant.OTHER_WORD);
- }
- } else if (data.what == Constant.TREASURE_FRAGMENT) {//抽屉界面的展示和隐藏
- if ((boolean) data.obj == true) {
- frameLayout.setVisibility(View.GONE);
+ }
+
+ public void initRemovePoiSharePre () {
+ //获取SharedPreferences对象,方法中两个参数的意思为:第一个name
+ //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成
+ //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看
+ //方法注释得知,建议以0或者MODE_PRIVATE为默认值。
+ SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0);
+ //获取Editor对象
+ SharedPreferences.Editor edit = poi.edit();
+ //根据要保存的数据的类型,调用对应的put方法,
+ //以键值对的形式添加新值。
+ edit.putString("poiEntity", null);
+ //提交新值。必须执行,否则前面的操作都无效。
+ edit.commit();
+ }
+
+ @Subscribe
+ public void onEvent (Message data){
+ if (data.what == Constant.FILTER_LIST_ITEM) { // 点击筛选的item
+ PoiEntity poiEntity = (PoiEntity) data.obj;
+ if (poiEntity.getX() != null && poiEntity.getY() != null) {
+ LatLng position = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX()));
+ CameraUpdateFactory.newCameraPosition(new CameraPosition(
+ position, //中心点坐标,地图目标经纬度
+ tencentMap.getCameraPosition().zoom, //目标缩放级别
+ tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
+ tencentMap.getCameraPosition().bearing));//目标旋转角 0~360° (正北方为0)
+ }
sliding_layout.setPanelHeight(0);
sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
+ frameLayout.setVisibility(View.VISIBLE);
+ fragmentTransaction = supportFragmentManager.beginTransaction();
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ gatherGetFragment = GatherGetFragment.newInstance(bundle);
+ fragmentTransaction.replace(R.id.frame_layout, gatherGetFragment);
+ fragmentTransaction.commit();
+ // 如果当前fragment是筛选,则移除该fragment
+ FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
+ if (filterFragment != null) {
+ fragmentTransaction.remove(filterFragment);
+ }
+ } else if (data.what == Constant.GATHER_GET) { //筛选item 点击开始采集
+ PoiEntity poiEntity = (PoiEntity) data.obj;
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isSliding", false); // 通知抽屉不收回
+ bundle.putSerializable("poiEntity", poiEntity);
+ switch (poiEntity.getType()) {
+ case 1:
+ PoiFragment poiFragment = PoiFragment.newInstance(bundle);
+ showSlidingFragment(poiFragment);
+ break;
+ case 2:
+ ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
+ showSlidingFragment(chargingStationFragment);
+ break;
+ case 3:
+ PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
+ showSlidingFragment(poiVideoFragment);
+ break;
+ case 4:
+ RoadFragment roadFragment = RoadFragment.newInstance(bundle);
+ showSlidingFragment(roadFragment);
+ break;
+ case 5:
+ OtherFragment otherFragment = OtherFragment.newInstance(bundle);
+ showSlidingFragment(otherFragment);
+ break;
+ }
+ frameLayout.setVisibility(View.GONE);
+ if (gatherGetFragment != null) {
+ fragmentTransaction.remove(gatherGetFragment);
+ }
+ } else if (data.what == Constant.GATHER_GET_MAP) { //地图界面点击采集 点击开始采集
+ PoiEntity poiEntity = (PoiEntity) data.obj;
+ Bundle bundle = new Bundle();
+ bundle.putSerializable("poiEntity", poiEntity);
+ bundle.putBoolean("isSliding", true); // 通知抽屉不收回
+ switch (poiEntity.getType()) {
+ case 1:
+ PoiFragment poiFragment = PoiFragment.newInstance(bundle);
+ showSlidingFragment(poiFragment);
+ break;
+ case 2:
+ ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
+ showSlidingFragment(chargingStationFragment);
+ break;
+ case 3:
+ PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
+ showSlidingFragment(poiVideoFragment);
+ break;
+ case 4:
+ RoadFragment roadFragment = RoadFragment.newInstance(bundle);
+ showSlidingFragment(roadFragment);
+ break;
+ case 5:
+ OtherFragment otherFragment = OtherFragment.newInstance(bundle);
+ showSlidingFragment(otherFragment);
+ break;
+ }
+ frameLayout.setVisibility(View.GONE);
+ if (gatherGetFragment != null) {
+ fragmentTransaction.remove(gatherGetFragment);
+ }
+ } else if (data.what == Constant.TREASURE_WORD) { // POI采集-移动位置
+ initPoiMarker((LatLng) data.obj);
+ } else if (data.what == Constant.TREASURE_CHECKED_WORD) {//poi采集 -确定位置
+ if ((boolean) data.obj) {
+ initCheckedMarker(Constant.POI_WORD);
+ }
+ } else if (data.what == Constant.MAIN_CHARGING_STATION) {//充电站采集-移动位置
+ initPoiMarker((LatLng) data.obj);
+ } else if (data.what == Constant.MAIN_CHARGING_CHECKED_STATION) {//充电站采集 -确定位置
+ if ((boolean) data.obj) {
+ initCheckedMarker(Constant.CHARGING_STATION_WORD);
+ }
+ } else if (data.what == Constant.MAIN_CHARGING_PILE) {//充电桩采集-移动位置
+ initPileMarker((LatLng) data.obj);
+ } else if (data.what == Constant.MAIN_CHARGING_CHECKED_PILE) {//充电桩采集-确定位置
+ if ((boolean) data.obj) {
+ initCheckedPileMarker(Constant.CHARGING_PILE_WORD);
+ }
+ } else if (data.what == Constant.MAIN_OTHER) {//其他采集-移动位置
+ initPoiMarker((LatLng) data.obj);
+ } else if (data.what == Constant.MAIN_CHECKED_OTHER) {//其他采集-确定位置
+ if ((boolean) data.obj) {
+ initCheckedMarker(Constant.OTHER_WORD);
+ }
+ } else if (data.what == Constant.TREASURE_FRAGMENT) {//抽屉界面的展示和隐藏
+ if ((boolean) data.obj == true) {
+ frameLayout.setVisibility(View.GONE);
+ sliding_layout.setPanelHeight(0);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.HIDDEN);
+ }
+ if (markerPoi != null) {
+ markerPoi.remove();
+ }
+ if (markerPile != null) {
+ markerPile.remove();
+ }
+
+ if (bigMarker != null) {
+ bigMarker.setVisible(false);
+ }
+ for (int i = 0; i < removablesMarker.size(); i++) {
+ removablesMarker.get(i).remove();
+ }
+ removablesMarker.clear();
+ } else if (data.what == Constant.MAIN_BUTTON_VISIABLE) {//控制主界面各个按钮显隐状态的what值
+ setMainButtonVisiable((Integer) data.obj);
+ } else if (data.what == Constant.MAIN_HEADER) {// 控制主界面各个header
+ View view = (View) data.obj;
+ if (view != null) {
+ initHeader(view);
+ }
+
+ } else if (data.what == Constant.MAIN_REMOVE) {//// 控制主界面各个header移除
+ if ((boolean) data.obj) {
+ dragView.removeAllViews();
+ }
+ } else if (data.what == Constant.GATHER_GET_RETURN) {//item 点击页面的返回事件的处理
+ if ((boolean) data.obj) {
+ frameLayout.setVisibility(View.GONE);
+ sliding_layout.setPanelHeight(1000);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ } else {
+ frameLayout.setVisibility(View.GONE);
+ setMainButtonVisiable(View.VISIBLE);
+ fragmentTransaction.remove(gatherGetFragment);
+ }
+ if (bigMarker != null) {
+ bigMarker.setVisible(false);
+ }
+ for (int i = 0; i < removablesMarker.size(); i++) {
+ removablesMarker.get(i).remove();
+ }
+ removablesMarker.clear();
+ } else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩-新增
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isSliding", false); // 通知抽屉不收回
+ bundle.putString("station", (String) data.obj);
+ if (chargingPileEntity != null) {
+ bundle.putSerializable("chargingPileEntity", chargingPileEntity);
+ }
+ BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.mipmap.datouzhen);
+ LatLng mapCenterPoint = getMapCenterPoint();
+ markerPile = tencentMap.addMarker(new MarkerOptions(mapCenterPoint).icon(pileDescriptor));
+ ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
+ showSlidingFragment(chargingPileFragment);
+ } else if (data.what == Constant.CHARGING_STATION_PILE) {//充电站的充电桩
+ chargingPileEntity = (ChargingPileEntity) data.obj;
+ } else if (data.what == Constant.CHARGING_STATION_ITEM) {//充电站的item 跳转到充电桩
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isSliding", false); // 通知抽屉不收回
+ bundle.putSerializable("chargingPileEntity", (ChargingPileEntity) data.obj);
+ ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
+ showSlidingFragment(chargingPileFragment);
+ } else if (data.what == Constant.HOME_TREASURE) {//寻宝的刷新
+ if ((boolean) data.obj) {
+ initList(Constant.currentLocation);
+ }
+ } else if (data.what == Constant.JOB_WORD_MONITOR) {//筛选条件界面的刷新
+ // 移除网络数据
+ for (int i = 0; i < removables.size(); i++) {
+ removables.get(i).remove();
+ }
+ removables.clear();
+ // 移除本地图层marker
+ for (int i = 0; i < removablesLocality.size(); i++) {
+ removablesLocality.get(i).remove();
+ }
+ removablesLocality.clear();
+ initThread();// 查询本地数据库
+ initList(Constant.currentLocation);//网络数据
+ } else if (data.what == Constant.EVENT_WHAT_CURRENT_MARKER) {
+ LatLng latLng = (LatLng) data.obj;
+ int type = data.arg1;
+ showPoiMarkerByType(type, latLng);
+ } else if (data.what == Constant.EVENT_WHAT_COMPLETE_TASK) {
+ // initRemoveFragment();
+ PoiEntity poiEntity = (PoiEntity) data.obj;
+ Bundle bundle = new Bundle();
+ bundle.putBoolean("isSliding", true); // 通知抽屉不收回
+ bundle.putSerializable("poiEntity", poiEntity);
+ switch (poiEntity.getType()) {
+ case 1:
+ PoiFragment poiFragment = PoiFragment.newInstance(bundle);
+ showSlidingFragment(poiFragment);
+ break;
+ case 2:
+ ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
+ showSlidingFragment(chargingStationFragment);
+ break;
+ case 3:
+ PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
+ showSlidingFragment(poiVideoFragment);
+ break;
+ case 4:
+ RoadFragment roadFragment = RoadFragment.newInstance(bundle);
+ showSlidingFragment(roadFragment);
+ break;
+ case 5:
+ OtherFragment otherFragment = OtherFragment.newInstance(bundle);
+ showSlidingFragment(otherFragment);
+ break;
+ }
+ frameLayout.setVisibility(View.GONE);
+ if (gatherGetFragment != null) {
+ fragmentTransaction.remove(gatherGetFragment);
+ }
}
+ }
+
+ private void initRemoveFragment () {
+ PoiFragment poiFragments = (PoiFragment) supportFragmentManager.findFragmentByTag(PoiFragment.class.getName());
+ if (poiFragments != null) {
+ fragmentTransaction.remove(poiFragments);
+ }
+ ChargingStationFragment chargingStationFragment = (ChargingStationFragment) supportFragmentManager.findFragmentByTag(ChargingStationFragment.class.getName());
+ if (chargingStationFragment != null) {
+ fragmentTransaction.remove(chargingStationFragment);
+ }
+ PoiVideoFragment poiVideoFragment = (PoiVideoFragment) supportFragmentManager.findFragmentByTag(PoiVideoFragment.class.getName());
+ if (poiVideoFragment != null) {
+ fragmentTransaction.remove(poiVideoFragment);
+ }
+ RoadFragment roadFragment = (RoadFragment) supportFragmentManager.findFragmentByTag(RoadFragment.class.getName());
+ if (roadFragment != null) {
+ fragmentTransaction.remove(roadFragment);
+ }
+ OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName());
+ if (otherFragment != null) {
+ fragmentTransaction.remove(otherFragment);
+ }
+ }
+
+
+ /**
+ * 控制主界面各个按钮的显示状态
+ */
+ private void setMainButtonVisiable ( int visiable){
+ ivZoomAdd.setVisibility(visiable);
+ ivZoomDel.setVisibility(visiable);
+ ivLocation.setVisibility(visiable);
+ ivRefish.setVisibility(visiable);
+ cbMapType.setVisibility(visiable);
+ ivSubmit.setVisibility(visiable);
+ ivFilter.setVisibility(visiable);
+ ivMessage.setVisibility(visiable);
+ }
+
+ private void initPoiMarker (LatLng latLng){
+ LatLng mapCenterPoint = getMapCenterPoint();
+ CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
+ mapCenterPoint, //中心点坐标,地图目标经纬度
+ tencentMap.getCameraPosition().zoom, //目标缩放级别
+ tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
+ tencentMap.getCameraPosition().bearing)); //目标旋转角 0~360° (正北方为0)
+ tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
+ @Override
+ public void onFinish() {
+ screenPosition = tencentMap.getProjection().toScreenLocation(latLng);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ //创建Marker对象之前,设置属性
+ if (markerPoi != null) {
+ markerPoi.setFixingPoint(screenPosition.x, screenPosition.y);
+ }
+ }
+
+ @Override
+ public void onCancel() {
+ }
+ });
+ }
+
+ private void initPileMarker (LatLng latLng){
+ LatLng mapCenterPoint = getMapCenterPoint();
+ CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
+ mapCenterPoint, //中心点坐标,地图目标经纬度
+ tencentMap.getCameraPosition().zoom, //目标缩放级别
+ tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
+ tencentMap.getCameraPosition().bearing)); //目标旋转角 0~360° (正北方为0)
+ tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
+ @Override
+ public void onFinish() {
+ screenPosition = tencentMap.getProjection().toScreenLocation(latLng);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ //创建Marker对象之前,设置属性
+ if (markerPile != null) {
+ markerPile.setFixingPoint(screenPosition.x, screenPosition.y);
+ }
+ }
+
+ @Override
+ public void onCancel() {
+ }
+ });
+ }
+
+ private void initCheckedPileMarker ( int poiWord){
+ if (screenPosition != null) {
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ LatLng latLng = tencentMap.getProjection().fromScreenLocation(screenPosition);
+ markerPile.setPosition(latLng);
+ markerPile.setFixingPointEnable(false);
+ Constant.markerLatlng = latLng;
+ Message obtain = Message.obtain();
+ obtain.what = poiWord;
+ obtain.obj = latLng;
+ EventBus.getDefault().post(obtain);
+ }
+ }
+
+ private void initCheckedMarker ( int poiWord){
+ if (screenPosition != null) {
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ LatLng latLng = tencentMap.getProjection().fromScreenLocation(screenPosition);
+ markerPoi.setPosition(latLng);
+ markerPoi.setFixingPointEnable(false);
+ Constant.markerLatlng = latLng;
+ Message obtain = Message.obtain();
+ obtain.what = poiWord;
+ obtain.obj = latLng;
+ EventBus.getDefault().post(obtain);
+ }
+ }
+
+ /**
+ * 设置定位图标样式
+ */
+ private void setLocMarkerStyle () {
+ locationStyle = new MyLocationStyle();
+ locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
+ //创建图标
+ BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location));
+ locationStyle.icon(bitmapDescriptor);
+ //设置定位圆形区域的边框宽度;
+ locationStyle.strokeWidth(1);
+ //设置圆区域的颜色
+ // locationStyle.fillColor(R.color.colormap);
+ // locationStyle.anchor(1000,2000);
+ tencentMap.setMyLocationStyle(locationStyle);
+ }
+
+ /**
+ * 定位的一些初始化设置
+ */
+ private void initLocation () {
+ //设置定位周期(位置监听器回调周期)为3s
+ // locationRequest.setInterval(3000);
+ //地图上设置定位数据源
+ tencentMap.setLocationSource(new MyTecentLocationSource(getActivity()));
+ //设置当前位置可见
+ tencentMap.setMyLocationEnabled(true);
+ //设置定位图标样式
+ setLocMarkerStyle();
+ tencentMap.setMyLocationStyle(locationStyle);
+ }
+
+ private Bitmap getBitMap ( int resourceId){
+ Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
+ int width = bitmap.getWidth();
+ int height = bitmap.getHeight();
+ int newWidth = 55;
+ int newHeight = 55;
+ float widthScale = ((float) newWidth) / width;
+ float heightScale = ((float) newHeight) / height;
+ Matrix matrix = new Matrix();
+ matrix.postScale(widthScale, heightScale);
+ bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
+ return bitmap;
+ }
+
+ @Override
+ protected void initData () {
+ super.initData();
+ }
+
+ @Override
+ public void onStart () {
+ super.onStart();
+ treasureMap.onStart();
+ }
+
+ @Override
+ public void onResume () {
+ super.onResume();
+ ivMessage.setVisibility(View.VISIBLE);
+ treasureMap.onResume();
+ }
+
+ @Override
+ public void onPause () {
+ super.onPause();
+ ivMessage.setVisibility(View.GONE);
+ treasureMap.onPause();
+ }
+
+ @Override
+ public void onStop () {
+ super.onStop();
+ treasureMap.onStop();
+ }
+
+ @Override
+ public void onDestroy () {
+ super.onDestroy();
+ treasureMap.onDestroy();
if (markerPoi != null) {
markerPoi.remove();
}
- if (markerPile != null) {
- markerPile.remove();
- }
-
if (bigMarker != null) {
- bigMarker.setVisible(false);
+ bigMarker.remove();
}
for (int i = 0; i < removablesMarker.size(); i++) {
removablesMarker.get(i).remove();
}
removablesMarker.clear();
- } else if (data.what == Constant.MAIN_BUTTON_VISIABLE) {//控制主界面各个按钮显隐状态的what值
- setMainButtonVisiable((Integer) data.obj);
- } else if (data.what == Constant.MAIN_HEADER) {// 控制主界面各个header
- View view = (View) data.obj;
- if (view != null) {
- initHeader(view);
- }
+ EventBus.getDefault().unregister(this);
+ }
- } else if (data.what == Constant.MAIN_REMOVE) {//// 控制主界面各个header移除
- if ((boolean) data.obj) {
- dragView.removeAllViews();
- }
- } else if (data.what == Constant.GATHER_GET_RETURN) {//item 点击页面的返回事件的处理
- if ((boolean) data.obj) {
- frameLayout.setVisibility(View.GONE);
- sliding_layout.setPanelHeight(1000);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- } else {
- frameLayout.setVisibility(View.GONE);
- setMainButtonVisiable(View.VISIBLE);
- fragmentTransaction.remove(gatherGetFragment);
- }
- if (bigMarker != null) {
- bigMarker.setVisible(false);
- }
- for (int i = 0; i < removablesMarker.size(); i++) {
- removablesMarker.get(i).remove();
- }
- removablesMarker.clear();
- } else if (data.what == Constant.CHARGING_STATION) {//充电站的充电桩-新增
- Bundle bundle = new Bundle();
- bundle.putBoolean("isSliding", false); // 通知抽屉不收回
- bundle.putString("station", (String) data.obj);
- if (chargingPileEntity != null) {
- bundle.putSerializable("chargingPileEntity", chargingPileEntity);
- }
- BitmapDescriptor pileDescriptor = BitmapDescriptorFactory.fromResource(R.mipmap.datouzhen);
- LatLng mapCenterPoint = getMapCenterPoint();
- markerPile = tencentMap.addMarker(new MarkerOptions(mapCenterPoint).icon(pileDescriptor));
- ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
- showSlidingFragment(chargingPileFragment);
- } else if (data.what == Constant.CHARGING_STATION_PILE) {//充电站的充电桩
- chargingPileEntity = (ChargingPileEntity) data.obj;
- } else if (data.what == Constant.CHARGING_STATION_ITEM) {//充电站的item 跳转到充电桩
- Bundle bundle = new Bundle();
- bundle.putBoolean("isSliding", false); // 通知抽屉不收回
- bundle.putSerializable("chargingPileEntity", (ChargingPileEntity) data.obj);
- ChargingPileFragment chargingPileFragment = ChargingPileFragment.newInstance(bundle);
- showSlidingFragment(chargingPileFragment);
- } else if (data.what == Constant.HOME_TREASURE) {//寻宝的刷新
- if ((boolean) data.obj) {
- initList(Constant.currentLocation);
- }
- } else if (data.what == Constant.JOB_WORD_MONITOR) {//筛选条件界面的刷新
- // 移除网络数据
- for (int i = 0; i < removables.size(); i++) {
- removables.get(i).remove();
- }
- removables.clear();
- // 移除本地图层marker
- for (int i = 0; i < removablesLocality.size(); i++) {
- removablesLocality.get(i).remove();
- }
- removablesLocality.clear();
- initThread();// 查询本地数据库
- initList(Constant.currentLocation);//网络数据
- } else if (data.what == Constant.EVENT_WHAT_CURRENT_MARKER) {
- LatLng latLng = (LatLng) data.obj;
- int type = data.arg1;
- showPoiMarkerByType(type, latLng);
- } else if (data.what == Constant.EVENT_WHAT_COMPLETE_TASK) {
- // initRemoveFragment();
- PoiEntity poiEntity = (PoiEntity) data.obj;
- Bundle bundle = new Bundle();
- bundle.putBoolean("isSliding", true); // 通知抽屉不收回
- bundle.putSerializable("poiEntity", poiEntity);
- switch (poiEntity.getType()) {
- case 1:
- PoiFragment poiFragment = PoiFragment.newInstance(bundle);
- showSlidingFragment(poiFragment);
+ @Override
+ public void onClick (View v){
+ switch (v.getId()) {
+ case R.id.iv_zoom_add://放大
+ CameraUpdate cameraUpdateIn = CameraUpdateFactory.zoomIn();
+ tencentMap.animateCamera(cameraUpdateIn);
break;
- case 2:
- ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
- showSlidingFragment(chargingStationFragment);
+ case R.id.iv_zoom_del://缩小
+ CameraUpdate cameraUpdateOut = CameraUpdateFactory.zoomOut();
+ tencentMap.animateCamera(cameraUpdateOut);
break;
- case 3:
- PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
- showSlidingFragment(poiVideoFragment);
+ case R.id.iv_refrish://刷新
+ initList(Constant.currentLocation);
+ initThread();
break;
- case 4:
- RoadFragment roadFragment = RoadFragment.newInstance(bundle);
- showSlidingFragment(roadFragment);
+ case R.id.iv_location://定位:
+ if (Constant.currentLocation != null) {
+ CameraUpdate cameraSigma =
+ CameraUpdateFactory.newCameraPosition(new CameraPosition(
+ new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
+ tencentMap.getCameraPosition().zoom, //目标缩放级别
+ 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
+ 0)); //目标旋转角 0~360° (正北方为0)
+ tencentMap.animateCamera(cameraSigma);
+ } else {
+ Toast.makeText(getActivity(), "无定位", Toast.LENGTH_SHORT).show();
+ checkNetWork();
+ }
break;
- case 5:
- OtherFragment otherFragment = OtherFragment.newInstance(bundle);
- showSlidingFragment(otherFragment);
- break;
- }
- frameLayout.setVisibility(View.GONE);
- if (gatherGetFragment != null) {
- fragmentTransaction.remove(gatherGetFragment);
- }
- }
- }
+ case R.id.iv_submit://弹窗
+ //分享
+ CharSequence title = "请选择上报类型";
+ // 如果当前fragment是筛选,则移除该fragment
+ FilterFragment filterFragments = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
+ if (filterFragments != null) {
+ fragmentTransaction.remove(filterFragments);
+ }
+ DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI;
+ List itemList = new ArrayList<>();
+ itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_poi, "POI"));
+ itemList.add(new ShareDialog.Item(getContext(), R.drawable.poi_video, "POI录像"));
+ itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_road, "道路"));
+ itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_chongdianzhuang, "充电站"));
+ itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_qingbao, "其他"));
- private void initRemoveFragment() {
- PoiFragment poiFragments = (PoiFragment) supportFragmentManager.findFragmentByTag(PoiFragment.class.getName());
- if (poiFragments != null) {
- fragmentTransaction.remove(poiFragments);
- }
- ChargingStationFragment chargingStationFragment = (ChargingStationFragment) supportFragmentManager.findFragmentByTag(ChargingStationFragment.class.getName());
- if (chargingStationFragment != null) {
- fragmentTransaction.remove(chargingStationFragment);
- }
- PoiVideoFragment poiVideoFragment = (PoiVideoFragment) supportFragmentManager.findFragmentByTag(PoiVideoFragment.class.getName());
- if (poiVideoFragment != null) {
- fragmentTransaction.remove(poiVideoFragment);
- }
- RoadFragment roadFragment = (RoadFragment) supportFragmentManager.findFragmentByTag(RoadFragment.class.getName());
- if (roadFragment != null) {
- fragmentTransaction.remove(roadFragment);
- }
- OtherFragment otherFragment = (OtherFragment) supportFragmentManager.findFragmentByTag(OtherFragment.class.getName());
- if (otherFragment != null) {
- fragmentTransaction.remove(otherFragment);
- }
- }
-
-
- /**
- * 控制主界面各个按钮的显示状态
- */
- private void setMainButtonVisiable(int visiable) {
- ivZoomAdd.setVisibility(visiable);
- ivZoomDel.setVisibility(visiable);
- ivLocation.setVisibility(visiable);
- ivRefish.setVisibility(visiable);
- cbMapType.setVisibility(visiable);
- ivSubmit.setVisibility(visiable);
- ivFilter.setVisibility(visiable);
- ivMessage.setVisibility(visiable);
- }
-
- private void initPoiMarker(LatLng latLng) {
- LatLng mapCenterPoint = getMapCenterPoint();
- CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
- mapCenterPoint, //中心点坐标,地图目标经纬度
- tencentMap.getCameraPosition().zoom, //目标缩放级别
- tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
- tencentMap.getCameraPosition().bearing)); //目标旋转角 0~360° (正北方为0)
- tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
- @Override
- public void onFinish() {
- screenPosition = tencentMap.getProjection().toScreenLocation(latLng);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- //创建Marker对象之前,设置属性
- if (markerPoi != null) {
- markerPoi.setFixingPoint(screenPosition.x, screenPosition.y);
- }
- }
- @Override
- public void onCancel() {}
- });
- }
-
- private void initPileMarker(LatLng latLng) {
- LatLng mapCenterPoint = getMapCenterPoint();
- CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition(
- mapCenterPoint, //中心点坐标,地图目标经纬度
- tencentMap.getCameraPosition().zoom, //目标缩放级别
- tencentMap.getCameraPosition().tilt, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
- tencentMap.getCameraPosition().bearing)); //目标旋转角 0~360° (正北方为0)
- tencentMap.animateCamera(cameraSigma, new TencentMap.CancelableCallback() {
- @Override
- public void onFinish() {
- screenPosition = tencentMap.getProjection().toScreenLocation(latLng);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- //创建Marker对象之前,设置属性
- if (markerPile != null) {
- markerPile.setFixingPoint(screenPosition.x, screenPosition.y);
- }
- }
- @Override
- public void onCancel() {}
- });
- }
-
- private void initCheckedPileMarker(int poiWord) {
- if (screenPosition != null) {
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- LatLng latLng = tencentMap.getProjection().fromScreenLocation(screenPosition);
- markerPile.setPosition(latLng);
- markerPile.setFixingPointEnable(false);
- Constant.markerLatlng = latLng;
- Message obtain = Message.obtain();
- obtain.what = poiWord;
- obtain.obj = latLng;
- EventBus.getDefault().post(obtain);
- }
- }
-
- private void initCheckedMarker(int poiWord) {
- if (screenPosition != null) {
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- LatLng latLng = tencentMap.getProjection().fromScreenLocation(screenPosition);
- markerPoi.setPosition(latLng);
- markerPoi.setFixingPointEnable(false);
- Constant.markerLatlng = latLng;
- Message obtain = Message.obtain();
- obtain.what = poiWord;
- obtain.obj = latLng;
- EventBus.getDefault().post(obtain);
- }
- }
-
- /**
- * 设置定位图标样式
- */
- private void setLocMarkerStyle() {
- locationStyle = new MyLocationStyle();
- locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE_NO_CENTER);
- //创建图标
- BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(getBitMap(R.drawable.location));
- locationStyle.icon(bitmapDescriptor);
- //设置定位圆形区域的边框宽度;
- locationStyle.strokeWidth(1);
- //设置圆区域的颜色
- // locationStyle.fillColor(R.color.colormap);
- // locationStyle.anchor(1000,2000);
- tencentMap.setMyLocationStyle(locationStyle);
- }
-
- /**
- * 定位的一些初始化设置
- */
- private void initLocation() {
- //设置定位周期(位置监听器回调周期)为3s
- // locationRequest.setInterval(3000);
- //地图上设置定位数据源
- tencentMap.setLocationSource(new MyTecentLocationSource(getActivity()));
- //设置当前位置可见
- tencentMap.setMyLocationEnabled(true);
- //设置定位图标样式
- setLocMarkerStyle();
- tencentMap.setMyLocationStyle(locationStyle);
- }
-
- private Bitmap getBitMap(int resourceId) {
- Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
- int width = bitmap.getWidth();
- int height = bitmap.getHeight();
- int newWidth = 55;
- int newHeight = 55;
- float widthScale = ((float) newWidth) / width;
- float heightScale = ((float) newHeight) / height;
- Matrix matrix = new Matrix();
- matrix.postScale(widthScale, heightScale);
- bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
- return bitmap;
- }
-
- @Override
- protected void initData() {
- super.initData();
- }
-
- @Override
- public void onStart() {
- super.onStart();
- treasureMap.onStart();
- }
-
- @Override
- public void onResume() {
- super.onResume();
- ivMessage.setVisibility(View.VISIBLE);
- treasureMap.onResume();
- }
-
- @Override
- public void onPause() {
- super.onPause();
- ivMessage.setVisibility(View.GONE);
- treasureMap.onPause();
- }
-
- @Override
- public void onStop() {
- super.onStop();
- treasureMap.onStop();
- }
-
- @Override
- public void onDestroy() {
- super.onDestroy();
- treasureMap.onDestroy();
- if (markerPoi != null) {
- markerPoi.remove();
- }
- if (bigMarker != null) {
- bigMarker.remove();
- }
- for (int i = 0; i < removablesMarker.size(); i++) {
- removablesMarker.get(i).remove();
- }
- removablesMarker.clear();
- EventBus.getDefault().unregister(this);
- }
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.iv_zoom_add://放大
- CameraUpdate cameraUpdateIn = CameraUpdateFactory.zoomIn();
- tencentMap.animateCamera(cameraUpdateIn);
- break;
- case R.id.iv_zoom_del://缩小
- CameraUpdate cameraUpdateOut = CameraUpdateFactory.zoomOut();
- tencentMap.animateCamera(cameraUpdateOut);
- break;
- case R.id.iv_refrish://刷新
- initList(Constant.currentLocation);
- initThread();
- break;
- case R.id.iv_location://定位:
- if (Constant.currentLocation != null) {
- CameraUpdate cameraSigma =
- CameraUpdateFactory.newCameraPosition(new CameraPosition(
- new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude()), //中心点坐标,地图目标经纬度
- tencentMap.getCameraPosition().zoom, //目标缩放级别
- 0, //目标倾斜角[0.0 ~ 45.0] (垂直地图时为0)
- 0)); //目标旋转角 0~360° (正北方为0)
- tencentMap.animateCamera(cameraSigma);
- } else {
- Toast.makeText(getActivity(), "无定位", Toast.LENGTH_SHORT).show();
- checkNetWork();
- }
- break;
- case R.id.iv_submit://弹窗
- //分享
- CharSequence title = "请选择上报类型";
- // 如果当前fragment是筛选,则移除该fragment
- FilterFragment filterFragments = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
- if (filterFragments != null) {
- fragmentTransaction.remove(filterFragments);
- }
- DialogSettings.style = DialogSettings.STYLE.STYLE_MIUI;
- List itemList = new ArrayList<>();
- itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_poi, "POI"));
- itemList.add(new ShareDialog.Item(getContext(), R.drawable.poi_video, "POI录像"));
- itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_road, "道路"));
- itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_chongdianzhuang, "充电站"));
- itemList.add(new ShareDialog.Item(getContext(), R.drawable.push_qingbao, "其他"));
-
- Bundle bundle = new Bundle();
- PoiEntity poiEntity = new PoiEntity();
- // 上报时以当前用户位置为准
- if (Constant.currentLocation == null) {
- ToastUtil.showShort(getContext(), "无法获取当前位置,请检查GPS是否打开!");
- return;
- }
+ Bundle bundle = new Bundle();
+ PoiEntity poiEntity = new PoiEntity();
+ // 上报时以当前用户位置为准
+ if (Constant.currentLocation == null) {
+ ToastUtil.showShort(getContext(), "无法获取当前位置,请检查GPS是否打开!");
+ return;
+ }
// LatLng mapCenterPoint = getMapCenterPoint();
- LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
- poiEntity.setX(newPoiLatLng.getLongitude() + "");
- poiEntity.setY(newPoiLatLng.getLatitude() + "");
- bundle.putSerializable("poiEntity", poiEntity);
- ShareDialog.show((AppCompatActivity) getActivity(), itemList, new ShareDialog.OnItemClickListener() {
- @Override
- public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) {
- switch (index) {
- case 0: // POI
- showPoiMarkerByType(1, newPoiLatLng);
- PoiFragment poiFragment = PoiFragment.newInstance(bundle);
- showSlidingFragment(poiFragment);
- break;
- case 1: // POI录像
- showPoiMarkerByType(2, newPoiLatLng);
- PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
- showSlidingFragment(poiVideoFragment);
- break;
- case 2://道路录像
- showPoiMarkerByType(3, newPoiLatLng);
- RoadFragment roadFragment = RoadFragment.newInstance(bundle);
- showSlidingFragment(roadFragment);
- break;
- case 3://充电站
- showPoiMarkerByType(4, newPoiLatLng);
- ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
- showSlidingFragment(chargingStationFragment);
- break;
- case 4://其他
- showPoiMarkerByType(5, newPoiLatLng);
- OtherFragment otherFragment = OtherFragment.newInstance(bundle);
- showSlidingFragment(otherFragment);
- break;
+ LatLng newPoiLatLng = new LatLng(Constant.currentLocation.getLatitude(), Constant.currentLocation.getLongitude());
+ poiEntity.setX(newPoiLatLng.getLongitude() + "");
+ poiEntity.setY(newPoiLatLng.getLatitude() + "");
+ bundle.putSerializable("poiEntity", poiEntity);
+ ShareDialog.show((AppCompatActivity) getActivity(), itemList, new ShareDialog.OnItemClickListener() {
+ @Override
+ public boolean onClick(ShareDialog shareDialog, int index, ShareDialog.Item item) {
+ switch (index) {
+ case 0: // POI
+ showPoiMarkerByType(1, newPoiLatLng);
+ PoiFragment poiFragment = PoiFragment.newInstance(bundle);
+ showSlidingFragment(poiFragment);
+ break;
+ case 1: // POI录像
+ showPoiMarkerByType(2, newPoiLatLng);
+ PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle);
+ showSlidingFragment(poiVideoFragment);
+ break;
+ case 2://道路录像
+ showPoiMarkerByType(3, newPoiLatLng);
+ RoadFragment roadFragment = RoadFragment.newInstance(bundle);
+ showSlidingFragment(roadFragment);
+ break;
+ case 3://充电站
+ showPoiMarkerByType(4, newPoiLatLng);
+ ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle);
+ showSlidingFragment(chargingStationFragment);
+ break;
+ case 4://其他
+ showPoiMarkerByType(5, newPoiLatLng);
+ OtherFragment otherFragment = OtherFragment.newInstance(bundle);
+ showSlidingFragment(otherFragment);
+ break;
+ }
+ return false;
}
- return false;
- }
- }).setTitle(title);
- break;
- case R.id.iv_filter:
- initThread();
- initList(Constant.currentLocation);
- FilterFragment filterFragment = FilterFragment.newInstance(new Bundle());
- showSlidingFragment(filterFragment);
- break;
- case R.id.iv_message:
- Intent messageIntent = new Intent(getContext(), FragmentManagement.class);
- messageIntent.putExtra("tag", 35);
- startActivity(messageIntent);
- break;
- }
- }
-
- private void showPoiMarkerByType(int type, LatLng latLng) {
- if (type == 1) {
- markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor1).zIndex(2));
- } else if (type == 2) {
- markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor2).zIndex(2));
- } else if (type == 3) {
- markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor3).zIndex(2));
- } else if (type == 4) {
- markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor4).zIndex(2));
- } else if (type == 5) {
- markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor5).zIndex(2));
- }
- }
-
- /**
- * header 头部布局
- *
- * @param view
- */
- public void initHeader(View view) {
- dragView.removeAllViews();
- dragView.addView(view);
- }
-
- /**
- * 将fragment显示到抽屉内
- */
- private void showSlidingFragment(BaseDrawerFragment fragment) {
- fragmentTransaction = supportFragmentManager.beginTransaction();
- int[] deviceInfo = DensityUtil.getDeviceInfo(getActivity());
- sliding_layout.setPanelHeight(deviceInfo[1] / 2);
- sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
- fragmentTransaction.add(R.id.scroll_view, fragment, fragment.getClass().getName());
- if (!(fragment instanceof FilterFragment)) {
- FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
- if (filterFragment != null) {
- fragmentTransaction.hide(filterFragment);
+ }).setTitle(title);
+ break;
+ case R.id.iv_filter:
+ initThread();
+ initList(Constant.currentLocation);
+ FilterFragment filterFragment = FilterFragment.newInstance(new Bundle());
+ showSlidingFragment(filterFragment);
+ break;
+ case R.id.iv_message:
+ Intent messageIntent = new Intent(getContext(), FragmentManagement.class);
+ messageIntent.putExtra("tag", 35);
+ startActivity(messageIntent);
+ break;
}
}
- if (!(fragment instanceof ChargingStationFragment)) {
- ChargingStationFragment chargingStationFragment = (ChargingStationFragment) supportFragmentManager.findFragmentByTag(ChargingStationFragment.class.getName());
- if (chargingStationFragment != null) {
- fragmentTransaction.hide(chargingStationFragment);
+
+ private void showPoiMarkerByType ( int type, LatLng latLng){
+ if (type == 1) {
+ markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor1).zIndex(2));
+ } else if (type == 2) {
+ markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor2).zIndex(2));
+ } else if (type == 3) {
+ markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor3).zIndex(2));
+ } else if (type == 4) {
+ markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor4).zIndex(2));
+ } else if (type == 5) {
+ markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor5).zIndex(2));
}
}
- if (!(fragment instanceof PoiFragment)) {
- PoiFragment poiFragment = (PoiFragment) supportFragmentManager.findFragmentByTag(PoiFragment.class.getName());
- if (poiFragment != null) {
- fragmentTransaction.hide(poiFragment);
+
+ /**
+ * header 头部布局
+ *
+ * @param view
+ */
+ public void initHeader (View view){
+ dragView.removeAllViews();
+ dragView.addView(view);
+ }
+
+ /**
+ * 将fragment显示到抽屉内
+ */
+ private void showSlidingFragment (BaseDrawerFragment fragment){
+ fragmentTransaction = supportFragmentManager.beginTransaction();
+ int[] deviceInfo = DensityUtil.getDeviceInfo(getActivity());
+ sliding_layout.setPanelHeight(deviceInfo[1] / 2);
+ sliding_layout.setPanelState(SlidingUpPanelLayout.PanelState.COLLAPSED);
+ fragmentTransaction.add(R.id.scroll_view, fragment, fragment.getClass().getName());
+ if (!(fragment instanceof FilterFragment)) {
+ FilterFragment filterFragment = (FilterFragment) supportFragmentManager.findFragmentByTag(FilterFragment.class.getName());
+ if (filterFragment != null) {
+ fragmentTransaction.hide(filterFragment);
+ }
+ }
+ if (!(fragment instanceof ChargingStationFragment)) {
+ ChargingStationFragment chargingStationFragment = (ChargingStationFragment) supportFragmentManager.findFragmentByTag(ChargingStationFragment.class.getName());
+ if (chargingStationFragment != null) {
+ fragmentTransaction.hide(chargingStationFragment);
+ }
+ }
+ if (!(fragment instanceof PoiFragment)) {
+ PoiFragment poiFragment = (PoiFragment) supportFragmentManager.findFragmentByTag(PoiFragment.class.getName());
+ if (poiFragment != null) {
+ fragmentTransaction.hide(poiFragment);
+ }
+ }
+ if (!(fragment instanceof RoadFragment)) {
+ RoadFragment roadFragment = (RoadFragment) supportFragmentManager.findFragmentByTag(RoadFragment.class.getName());
+ if (roadFragment != null) {
+ fragmentTransaction.hide(roadFragment);
+ }
+ }
+ if (!(fragment instanceof PoiVideoFragment)) {
+ PoiVideoFragment poiVideoFragment = (PoiVideoFragment) supportFragmentManager.findFragmentByTag(PoiVideoFragment.class.getName());
+ if (poiVideoFragment != null) {
+ fragmentTransaction.hide(poiVideoFragment);
+ }
+ }
+ fragmentTransaction.show(fragment);
+ fragmentTransaction.addToBackStack(null);
+ fragmentTransaction.commit();
+ }
+
+ /**
+ * 检查网络状态
+ */
+ private void checkNetWork () {
+ if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
+ checkMyLocation();
+ } else { // 当前网络不可用
+ ToastUtil.showShort(getContext(), Constant.NETWORK_UNAVAILABLE);
}
}
- if (!(fragment instanceof RoadFragment)) {
- RoadFragment roadFragment = (RoadFragment) supportFragmentManager.findFragmentByTag(RoadFragment.class.getName());
- if (roadFragment != null) {
- fragmentTransaction.hide(roadFragment);
- }
- }
- if (!(fragment instanceof PoiVideoFragment)) {
- PoiVideoFragment poiVideoFragment = (PoiVideoFragment) supportFragmentManager.findFragmentByTag(PoiVideoFragment.class.getName());
- if (poiVideoFragment != null) {
- fragmentTransaction.hide(poiVideoFragment);
- }
- }
- fragmentTransaction.show(fragment);
- fragmentTransaction.addToBackStack(null);
- fragmentTransaction.commit();
- }
- /**
- * 检查网络状态
- */
- private void checkNetWork() {
- if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用
- checkMyLocation();
- } else { // 当前网络不可用
- ToastUtil.showShort(getContext(), Constant.NETWORK_UNAVAILABLE);
- }
- }
+ /**
+ * 检查所需权限
+ */
+ private void checkMyLocation () {
- /**
- * 检查所需权限
- */
- private void checkMyLocation() {
+ // 1.判断是否拥有定位的权限
+ // 1.1 拥有权限进行相应操作
+ // 1.2 没有权限申请权限
+ // 1.2.1 Android 6.0 动态申请权限
+ // 1.2.1.1 用户给予权限进行相应操作
+ // 1.2.1.2 用户没有给予权限 作出相应提示
+ // 1.2.2 某些5.0权限的手机执行相应操作
- // 1.判断是否拥有定位的权限
- // 1.1 拥有权限进行相应操作
- // 1.2 没有权限申请权限
- // 1.2.1 Android 6.0 动态申请权限
- // 1.2.1.1 用户给予权限进行相应操作
- // 1.2.1.2 用户没有给予权限 作出相应提示
- // 1.2.2 某些5.0权限的手机执行相应操作
+ XXPermissions.with(this)
+ .permission(Permission.ACCESS_COARSE_LOCATION)
+ .request(new OnPermissionCallback() {
- XXPermissions.with(this)
- .permission(Permission.ACCESS_COARSE_LOCATION)
- .request(new OnPermissionCallback() {
+ @Override
+ public void onGranted(List permissions, boolean all) {
+ if (all) {
+ //建立定位
+ initLocation();
- @Override
- public void onGranted(List permissions, boolean all) {
- if (all) {
- //建立定位
- initLocation();
-
- } else {
- Toast.makeText(getActivity(), "申请权限失败", Toast.LENGTH_SHORT).show();
+ } else {
+ Toast.makeText(getActivity(), "申请权限失败", Toast.LENGTH_SHORT).show();
+ }
}
- }
- @Override
- public void onDenied(List permissions, boolean never) {
- if (never) {
- Toast.makeText(getActivity(), "被永久拒绝授权,请手动授予定位权限", Toast.LENGTH_SHORT).show();
- // 如果是被永久拒绝就跳转到应用权限系统设置页面
- XXPermissions.startPermissionActivity(getActivity(), permissions);
+ @Override
+ public void onDenied(List permissions, boolean never) {
+ if (never) {
+ Toast.makeText(getActivity(), "被永久拒绝授权,请手动授予定位权限", Toast.LENGTH_SHORT).show();
+ // 如果是被永久拒绝就跳转到应用权限系统设置页面
+ XXPermissions.startPermissionActivity(getActivity(), permissions);
+ }
}
- }
- });
- }
+ });
+ }
- @Override
- public boolean onBackPressed() {
- getActivity().finish();
- return true;
- }
+ @Override
+ public boolean onBackPressed () {
+ getActivity().finish();
+ return true;
+ }
- /**
- * 获取屏幕中心点位置
- *
- * @return
- */
- public LatLng getMapCenterPoint() {
+ /**
+ * 获取屏幕中心点位置
+ *
+ * @return
+ */
+ public LatLng getMapCenterPoint () {
// int left = treasureMap.getLeft();
// int top = treasureMap.getTop();
// int right = treasureMap.getRight();
@@ -1627,18 +1641,18 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen
// int y = (int) (treasureMap.getY() + (bottom - top) / 2);
// Projection projection = tencentMap.getProjection();
// LatLng pt = projection.fromScreenLocation(new Point(x, y));
- return tencentMap.getCameraPosition().target;
- }
-
- @Override
- public void onConfigurationChanged(@NonNull Configuration newConfig) {
- super.onConfigurationChanged(newConfig);
- int measuredWidth = treasureMap.getWidth();
- int measuredHeight = treasureMap.getHeight();
- if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
- treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
- } else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
- treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
+ return tencentMap.getCameraPosition().target;
}
- }
-}
\ No newline at end of file
+
+ @Override
+ public void onConfigurationChanged (@NonNull Configuration newConfig){
+ super.onConfigurationChanged(newConfig);
+ int measuredWidth = treasureMap.getWidth();
+ int measuredHeight = treasureMap.getHeight();
+ if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
+ treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
+ } else if (newConfig.orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
+ treasureMap.onSizeChanged(measuredHeight, measuredWidth, measuredWidth, measuredHeight);
+ }
+ }
+ }
\ 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 05ccf59..35af2eb 100644
--- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java
+++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java
@@ -17,7 +17,7 @@ public class HttpInterface {
//dtxbmaps.navinfo.com/dtxb/m4/user/appVersion/checkVersion?version=155&operationType=android
//172.23.139.4:8001/appVersion/checkVersion?version=155&operationType=android version是版本 operationType固定值 安卓 get
public static final String APKIP="http://172.23.139.4:8001/";
- public static final String APP_CHECK_VERSION = IP+"appVersion/checkVersion"; //版本升级
+ public static final String APP_CHECK_VERSION = IP+USER_PATH+"appVersion/1/checkVersion"; //版本升级
/**
* 我的
* Path=/m4/user/*
@@ -31,7 +31,7 @@ public class HttpInterface {
public static final String USER_AUTH_ADD = IP+USER_PATH+ "userAuth/add"; //实名认证
//172.23.139.4:9999/m4/user/userLocation/1/userLocation post 参数 geom:geohash加密
public static final String geomIP="http://172.23.139.4:9999/m4";
- public static final String USER_LOCATION = geomIP+USER_PATH+ "userLocation/"+USERID+"/userLocation"; //上传用户坐标
+ public static final String USER_LOCATION = IP+USER_PATH+ "userLocation/"+USERID+"/userLocation"; //上传用户坐标
/**
* 发现
diff --git a/app/src/main/java/com/navinfo/outdoor/util/APKVersionCodeUtils.java b/app/src/main/java/com/navinfo/outdoor/util/APKVersionCodeUtils.java
index 0c57a8f..6dd7574 100644
--- a/app/src/main/java/com/navinfo/outdoor/util/APKVersionCodeUtils.java
+++ b/app/src/main/java/com/navinfo/outdoor/util/APKVersionCodeUtils.java
@@ -13,8 +13,7 @@ public class APKVersionCodeUtils {
int versionCode = 0;
try {
//获取软件版本号,对应AndroidManifest.xml下android:versionCode
- versionCode = mContext.getPackageManager().
- getPackageInfo(mContext.getPackageName(), 0).versionCode;
+ versionCode = mContext.getPackageManager().getPackageInfo(mContext.getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
diff --git a/app/src/main/res/xml/file_paths.xml b/app/src/main/res/xml/file_paths.xml
new file mode 100644
index 0000000..9721635
--- /dev/null
+++ b/app/src/main/res/xml/file_paths.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file