From aa777a3371e23bab92821e81e6d4f913ef926f18 Mon Sep 17 00:00:00 2001 From: wds Date: Tue, 6 Jul 2021 19:07:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BB=E5=AE=9D=E9=A1=B5=E9=9D=A2=E5=88=B7?= =?UTF-8?q?=E6=96=B0=EF=BC=8Cmarker=E7=9A=84=E7=82=B9=E5=87=BB=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 2 +- .../outdoor/activity/HomeActivity.java | 7 +- .../outdoor/activity/PictureActivity.java | 129 +--------- .../com/navinfo/outdoor/api/Constant.java | 10 +- .../fragment/ChargingPileFragment.java | 2 +- .../fragment/ChargingStationFragment.java | 52 +++- .../outdoor/fragment/GatherGetFragment.java | 232 +++++++++++------- .../outdoor/fragment/OtherFragment.java | 45 +++- .../navinfo/outdoor/fragment/PoiFragment.java | 66 +++-- .../outdoor/fragment/PoiVideoFragment.java | 44 +++- .../outdoor/fragment/RoadFragment.java | 41 +++- .../outdoor/fragment/TreasureFragment.java | 132 ++++++---- .../com/navinfo/outdoor/room/PoiEntity.java | 2 +- .../res/layout/charging_station_fragment.xml | 50 +++- .../main/res/layout/fragment_gather_get.xml | 3 - app/src/main/res/layout/fragment_other.xml | 104 +++++--- app/src/main/res/layout/fragment_road.xml | 43 ++++ app/src/main/res/layout/poi_fragment.xml | 46 +++- .../main/res/layout/poi_video_fragment.xml | 44 ++++ 19 files changed, 702 insertions(+), 352 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0559a03..554a859 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 29 buildToolsVersion '29.0.2' - ndkVersion '23.0.7123448' + //ndkVersion '23.0.7123448' defaultConfig { applicationId "com.navinfo.outdoor" diff --git a/app/src/main/java/com/navinfo/outdoor/activity/HomeActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/HomeActivity.java index 688d661..52548ea 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/HomeActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/HomeActivity.java @@ -82,7 +82,12 @@ public class HomeActivity extends BaseActivity{ @Override public void onTabSelected(TabLayout.Tab tab) { mTab.getTabAt(tab.getPosition()).setIcon(pic[tab.getPosition()]); - if (tab.getPosition()==3){ + if (tab.getPosition()==1){ + Message obtain = Message.obtain(); + obtain.what = Constant.HOME_TREASURE; + obtain.obj = true; + EventBus.getDefault().post(obtain); + }else if (tab.getPosition()==3){ Message obtain = Message.obtain(); obtain.what = Constant.HOME_MINE; obtain.obj = true; diff --git a/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java index 81f38d3..24f2f9a 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/PictureActivity.java @@ -74,17 +74,15 @@ import java.util.List; import static com.tencent.mapsdk.internal.aaa.getContext; -public class PictureActivity extends BaseActivity implements View.OnClickListener, LocationSource, TencentLocationListener { +public class PictureActivity extends BaseActivity implements View.OnClickListener { private static final CameraLogger LOG = CameraLogger.create("Picture"); private CameraView camera; private ImageButton capturePicture; private long captureTime = 0; private android.widget.Button btnSwitch; private TencentMap tencentMap; - private TencentLocationManager locationManager; - private TencentLocationRequest locationRequest; private MyLocationStyle locationStyle; - private OnLocationChangedListener locationChangedListener; +// private OnLocationChangedListener locationChangedListener; private MapView ivMap; private Button captureVideo; private Button btnVideo; @@ -127,8 +125,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene UiSettings uiSettings = tencentMap.getUiSettings(); //设置logo的大小 uiSettings.setLogoScale(0.7f); - //开启定位权限 - checkNetWork(); //相机预览监听 camera.addCameraListener(new CameraListener() { @@ -172,48 +168,7 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene }); } -// - private void checkNetWork() { - if (NetWorkUtils.isNetworkAvailable(this)) { // 当前网络可用 - checkMyLocation(); - } else { // 当前网络不可用 - ToastUtil.showShort(this, Constant.NETWORK_UNAVAILABLE); - } - } - 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权限的手机执行相应操作 - - XXPermissions.with(this) - .permission(Permission.ACCESS_COARSE_LOCATION) - .request(new OnPermissionCallback() { - - @Override - public void onGranted(List permissions, boolean all) { - if (all) { - //建立定位 - initLocation(); - } else { - Toast.makeText(PictureActivity.this, "申请权限失败", Toast.LENGTH_SHORT).show(); - } - } - - @Override - public void onDenied(List permissions, boolean never) { - if (never) { - Toast.makeText(PictureActivity.this, "被永久拒绝授权,请手动授予定位权限", Toast.LENGTH_SHORT).show(); - // 如果是被永久拒绝就跳转到应用权限系统设置页面 - XXPermissions.startPermissionActivity(PictureActivity.this, permissions); - } - } - }); - } private void message(String content, Boolean important) { if (important) { @@ -259,28 +214,6 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene } } - /** - * 定位的一些初始化设置 - */ - private void initLocation() { - //用于访问腾讯定位服务的类, 周期性向客户端提供位置更新 - locationManager = TencentLocationManager.getInstance(this); - //设置坐标系 - locationManager.setCoordinateType(TencentLocationManager.COORDINATE_TYPE_GCJ02); - //创建定位请求 - locationRequest = TencentLocationRequest.create(); - //设置定位周期(位置监听器回调周期)为3s - // locationRequest.setInterval(3000); - //地图上设置定位数据源 - tencentMap.setLocationSource(this); - //设置当前位置可见 - tencentMap.setMyLocationEnabled(true); - //设置定位图标样式 - setLocMarkerStyle(); -// locationStyle = locationStyle.myLocationType(MyLocationStyle.LOCATION_TYPE_LOCATION_ROTATE); - tencentMap.setMyLocationStyle(locationStyle); - } - private Bitmap getBitMap(int resourceId) { Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId); int width = bitmap.getWidth(); @@ -358,62 +291,4 @@ public class PictureActivity extends BaseActivity implements View.OnClickListene } - @Override - public void activate(OnLocationChangedListener onLocationChangedListener) { - locationChangedListener = onLocationChangedListener; - int err = locationManager.requestLocationUpdates(locationRequest, this, Looper.myLooper()); - switch (err) { - case 1: - ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE1); - break; - case 2: - ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE2); - break; - case 3: - ToastUtil.showShort(this, Constant.GET_ERR_MESSAGE3); - break; - default: - break; - } - } - - @Override - public void deactivate() { - locationManager.removeUpdates(this); - locationManager = null; - locationRequest = null; - locationChangedListener = null; - } - /** - * 实现位置监听 - * - * @param tencentLocation - * @param i - * @param s - */ - @Override - public void onLocationChanged(TencentLocation tencentLocation, int i, String s) { - if (i == TencentLocation.ERROR_OK && locationChangedListener != null) { - Location location = new Location(tencentLocation.getProvider()); - //设置经纬度以及精度 - location.setLatitude(tencentLocation.getLatitude()); - location.setLongitude(tencentLocation.getLongitude()); - location.setAccuracy(tencentLocation.getAccuracy()); - locationChangedListener.onLocationChanged(location); - Constant.currentLocation = tencentLocation; - //显示回调的实时位置信息 - runOnUiThread(new Runnable() { - @Override - public void run() { - //打印tencentLocation的json字符串 -// Toast.makeText(getApplicationContext(), new Gson().toJson(location), Toast.LENGTH_LONG).show(); - } - }); - } - } - - @Override - public void onStatusUpdate(String s, int i, String s1) { - Log.v("State changed", s + "===" + s1); - } } \ No newline at end of file diff --git a/app/src/main/java/com/navinfo/outdoor/api/Constant.java b/app/src/main/java/com/navinfo/outdoor/api/Constant.java index b221f5b..f8c9437 100644 --- a/app/src/main/java/com/navinfo/outdoor/api/Constant.java +++ b/app/src/main/java/com/navinfo/outdoor/api/Constant.java @@ -20,16 +20,16 @@ public class Constant { * 位置权限 */ public static final String SET_LOCATION_PERMISSION = "请在“设置”中给予“TengXunMap”位置权限,否则当前功能将不可使用"; - public static final String SET_LOCATION = "请在“设置”中给予权限否则当前功能将不可使用"; + public static final String SET_LOCATION= "请在“设置”中给予权限否则当前功能将不可使用"; public static final String GET_ERR_MESSAGE1 = "设备缺少使用腾讯定位服务需要的基本条件"; public static final String GET_ERR_MESSAGE2 = "manifest 中配置的 key 不正确"; public static final String GET_ERR_MESSAGE3 = "自动加载libtencentloc.so失败"; - public static final String BASE_FOLDER = SdkFolderCreate.getSDPath() + "/navinfoOutDoor"; + public static final String BASE_FOLDER = SdkFolderCreate.getSDPath()+"/navinfoOutDoor"; // 保存图片的目录 - public static final String PICTURE_FOLDER = BASE_FOLDER + "/picture"; - public static final String POI_DAO = BASE_FOLDER + "/BaseDao/"; + public static final String PICTURE_FOLDER = BASE_FOLDER+"/picture"; + public static final String POI_DAO = BASE_FOLDER+"/BaseDao/"; // 申请权限的RequestCode public static final int PERMISSION_REQUEST_CODE = 0x100; @@ -40,6 +40,7 @@ public class Constant { public static final String DATA_FILE = "dataFile"; + //message word 值 public static final int TREASURE_FRAGMENT = 100;//抽屉界面的展示和隐藏 public static final int TREASURE_WORD = 0;//poi 对地图页面marker 的一个展示 @@ -65,6 +66,7 @@ public class Constant { public static final int JOB_SEARCH_WORD = 28;//任务搜索的数据 public static final int GATHER_GET_MAP = 30;//地图点击marker 后弹窗点击开始采集 public static final int HOME_MINE = 32;//点击我的实时监听刷新 + public static final int HOME_TREASURE = 33;//点击寻宝实时监听刷新 public static String USER_ATTESTATION_NAME; //实名认证姓名 银行卡 public static int NUMBER = 200; //任务个数 diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java index 98b7fc3..6eba81e 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java @@ -371,7 +371,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC station = getArguments().getString("station"); if (station!=null){ PoiEntity poiEntity = new Gson().fromJson(station, PoiEntity.class); - pid = poiEntity.getId(); + pid = poiEntity.getTaskId(); } // 添加信息: ChargingPileEntity chargingPileEntity = (ChargingPileEntity) getArguments().getSerializable("chargingPileEntity"); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java index 34dc9c6..09050dc 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java @@ -90,6 +90,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. private String phone = null; private Spinner spinnerType; String[] ctype = new String[]{"全部", "poi", "充电站", "POI录像", "道路录像"};//1."全部"2 "POI"3 "充电站"4 "POI录像"5 "道路录像", + String[] spinner = new String[]{"存在","不存在","无法验证"}; private ArrayAdapter adapter; private LinearLayout linearChargingPile; private RecyclerView recyclerStation; @@ -99,6 +100,8 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. private PoiEntity showPoiEntity; private ChargingPileDao chargingPileDao; private LatLng latLng; + private RelativeLayout linearExist; + private Spinner spinnerExist; public static ChargingStationFragment newInstance(Bundle bundle) { ChargingStationFragment fragment = new ChargingStationFragment(); @@ -234,6 +237,28 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. public void onNothingSelected(AdapterView parent) { } }); + linearExist = findViewById(R.id.linear_exist); + spinnerExist = findViewById(R.id.spinner_exist); + ArrayAdapter adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); + adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 + spinnerExist.setAdapter(adapterExist); + spinnerExist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + break; + case 1: + break; + case 2: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); //添加桩 linearChargingPile = findViewById(R.id.linear_charging_pile); linearChargingPile.setOnClickListener(this::onClick); @@ -335,6 +360,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. poiBeans.add(new PoiBean("电话*", telPhone, R.drawable.icon_add_bg)); poiRecycleAdapter.setList(poiBeans); } + linearExist.setVisibility(View.VISIBLE); if (showPoiEntity.getPhotoInfo() != null) { for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) { String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto(); @@ -358,6 +384,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } } ArrayList chargingPileEntities = new ArrayList<>(); + new Thread(new Runnable() { @Override public void run() { @@ -377,6 +404,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } }).start(); + } else { poiBeans.add(new PoiBean("电话*", phone, R.drawable.icon_add_bg)); poiRecycleAdapter.setList(poiBeans); @@ -395,7 +423,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. obtains.obj = chargingPileEntity; EventBus.getDefault().post(obtains); initRemovePileSharePre(); - String showStation = initShowStation(); Message obtain = Message.obtain(); obtain.what = Constant.CHARGING_STATION; @@ -409,6 +436,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. //表示文件名,系统将会在/dada/dada/包名/shared_prefs目录下生成 //一个以该参数命名的.xml文件。第二个mode表示创建的模式,通过查看 //方法注释得知,建议以0或者MODE_PRIVATE为默认值。 + SharedPreferences poi = getActivity().getSharedPreferences(Constant.DATA_FILE, 0); //获取Editor对象 SharedPreferences.Editor edit = poi.edit(); @@ -550,8 +578,10 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } else { aBoolean = false; } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); @@ -671,8 +701,10 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. if (tagScutcheon != null&&!tagScutcheon.equals("")) { infoPhoto.add(new Info(tagScutcheon)); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } poiEntity.setPhotoInfo(infoPhoto); poiEntity.setStation_type(station_type); @@ -683,7 +715,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. poiEntity.setCreateTime(format); poiEntity.setType(2); poiEntity.setTaskStatus(2); - new Thread(new Runnable() { + /* new Thread(new Runnable() { @Override public void run() { List allPoi = poiDao.getAllPoi(); @@ -694,7 +726,7 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. } }); } - }).start(); + }).start();*/ String newPoiEntity = new Gson().toJson(poiEntity); return newPoiEntity; } @@ -759,8 +791,10 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. if (tagScutcheon != null&&!tagScutcheon.equals("")) { infoPhoto.add(new Info(tagScutcheon)); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } poiEntity.setPhotoInfo(infoPhoto); poiEntity.setStation_type(station_type); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java index ec4e0f5..ebe0fb3 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/GatherGetFragment.java @@ -28,24 +28,23 @@ import org.greenrobot.eventbus.EventBus; * 领取采集的fragment */ public class GatherGetFragment extends BaseFragment implements View.OnClickListener { - - private Button btnCancelGet,btnGetTask,btnGather,btnFinishGather; + private Button btnCancelGet, btnGetTask, btnGather, btnFinishGather; private TextView tvTitle, tvMoney, tvTime, tvDistance, tvDescribe; private PoiEntity poiEntity; private PoiDao poiDao; + private PoiEntity poiListEntity; + private int aSave; public static GatherGetFragment newInstance(Bundle bundle) { GatherGetFragment fragment = new GatherGetFragment(); fragment.setArguments(bundle); return fragment; } - @Override public void onResume() { super.onResume(); getFocus(); } - //主界面获取焦点 private void getFocus() { getView().setFocusableInTouchMode(true); @@ -65,13 +64,10 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } }); } - - @Override protected int getLayout() { return R.layout.fragment_gather_get; } - @Override protected void initView() { super.initView(); @@ -93,67 +89,124 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe Bundle arguments = getArguments(); if (arguments != null) { poiEntity = (PoiEntity) arguments.getSerializable("poiEntity"); - if (poiEntity != null) { - tvTitle.setText(poiEntity.getName()); - if ( poiEntity.getPrecision()==null){ - tvMoney.setText("¥" +0); - }else { - tvMoney.setText("¥" + poiEntity.getPrecision()); + aSave = arguments.getInt("aSave", 0); + if (aSave == 1) {//普通任务 + if (poiEntity != null) { + tvTitle.setText(poiEntity.getName()); + if (poiEntity.getPrecision() == null) { + tvMoney.setText("¥" + 0); + } else { + tvMoney.setText("¥" + poiEntity.getPrecision()); + } + tvTime.setText("到期时间:" + poiEntity.getCreateTime()); + tvDescribe.setText("任务描述:" + poiEntity.getDescribe()); + if (poiEntity.getDist() != null) { + tvDistance.setText("距离:" + format5(Double.valueOf(poiEntity.getDist()) / 1000) + "km"); + } } - tvTime.setText("到期时间:" + poiEntity.getCreateTime()); - tvDescribe.setText("任务描述:" + poiEntity.getDescribe()); - if (poiEntity.getDist() != null) { - tvDistance.setText("距离:" + format5(Double.valueOf(poiEntity.getDist()) / 1000) + "km"); + int taskStatus = poiEntity.getTaskStatus(); + switch (taskStatus) { + case 0://未领取 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.VISIBLE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.GONE); + break; + case 1://已领取 + btnCancelGet.setVisibility(View.VISIBLE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.GONE); + break; + case 2://已保存 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.VISIBLE); + break; + case 3://已提交 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.GONE); + btnFinishGather.setVisibility(View.GONE); + break; + } + } else if (aSave == 2) {//面妆任务 + if (poiEntity != null) { + tvTitle.setText(poiEntity.getName()); + if (poiEntity.getPrecision() == null) { + tvMoney.setText("¥" + 0); + } else { + tvMoney.setText("¥" + poiEntity.getPrecision()); + } + tvTime.setText("到期时间:" + poiEntity.getCreateTime()); + tvDescribe.setText("任务描述:" + poiEntity.getDescribe()); + if (poiEntity.getDist() != null) { + tvDistance.setText("距离:" + format5(Double.valueOf(poiEntity.getDist())/1000) + "km"); + } + } + int taskStatus = poiEntity.getTaskStatus(); + switch (taskStatus) { + case 0://未领取 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.VISIBLE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.GONE); + break; + + case 1://已领取 + btnCancelGet.setVisibility(View.VISIBLE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.GONE); + break; + + case 2://已保存 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.VISIBLE); + btnFinishGather.setVisibility(View.VISIBLE); + break; + + case 3://已提交 + btnCancelGet.setVisibility(View.GONE); + btnGetTask.setVisibility(View.GONE); + btnGather.setVisibility(View.GONE); + btnFinishGather.setVisibility(View.GONE); + break; + } - } - int taskStatus = poiEntity.getTaskStatus(); - switch (taskStatus){ - case 0://未领取 - btnCancelGet.setVisibility(View.GONE); - btnGetTask.setVisibility(View.VISIBLE); - btnGather.setVisibility(View.VISIBLE); - btnFinishGather.setVisibility(View.GONE); - break; - case 1://已领取 - btnCancelGet.setVisibility(View.VISIBLE); - btnGetTask.setVisibility(View.GONE); - btnGather.setVisibility(View.VISIBLE); - btnFinishGather.setVisibility(View.GONE); - break; - case 2://已保存 - btnCancelGet.setVisibility(View.GONE); - btnGetTask.setVisibility(View.GONE); - btnGather.setVisibility(View.VISIBLE); - btnFinishGather.setVisibility(View.VISIBLE); - break; - case 3://已提交 - btnCancelGet.setVisibility(View.GONE); - btnGetTask.setVisibility(View.GONE); - btnGather.setVisibility(View.GONE); - btnFinishGather.setVisibility(View.GONE); - break; } } } - @Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_cancel_get://结束领取 - poiEntity.setTaskStatus(0); - btnGetTask.setVisibility(View.VISIBLE); - btnCancelGet.setVisibility(View.GONE); + poiEntity.setTaskStatus(0); + btnGetTask.setVisibility(View.VISIBLE); + btnCancelGet.setVisibility(View.GONE); + new Thread(new Runnable() { + @Override + public void run() { + if (poiListEntity!=null){ + poiDao.deletePoiEntity(poiListEntity); + }else { + poiDao.deletePoiEntity(poiEntity); + } + } + }).start(); break; case R.id.btn_get_task://领取任务 - poiEntity.setTaskStatus(1); - btnGetTask.setVisibility(View.GONE); - btnCancelGet.setVisibility(View.VISIBLE); - //网络请求: - if (poiEntity!=null){ - if (poiEntity.getType()==1) {//poi的领取类型 - receivedTaskByNet(HttpInterface.RECEIVED_POI_TASK,poiEntity.getTaskId()+"",false); - }else if (poiEntity.getType() == 5){ - receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK,poiEntity.getTaskId()+"",false); + poiEntity.setTaskStatus(1); + btnGetTask.setVisibility(View.GONE); + btnCancelGet.setVisibility(View.VISIBLE); + //网络请求: + if (poiEntity != null) { + if (poiEntity.getType() == 1) {//poi的领取类型 + receivedTaskByNet(HttpInterface.RECEIVED_POI_TASK, poiEntity.getTaskId() + "", false); + } else if (poiEntity.getType() == 5) { + receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity.getTaskId() + "", false); } } break; @@ -167,37 +220,40 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe EventBus.getDefault().post(obtain); } } else { - if (poiEntity!=null){ - if (poiEntity.getType()==1) {//poi的领取类型 - receivedTaskByNet(HttpInterface.RECEIVED_POI_TASK,poiEntity.getTaskId()+"",true); - }else if (poiEntity.getType() == 5){ - receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK,poiEntity.getTaskId()+"",true); + if (poiEntity != null) { + if (poiEntity.getType() == 1) {//poi的领取类型 + receivedTaskByNet(HttpInterface.RECEIVED_POI_TASK, poiEntity.getTaskId() + "", true); + } else if (poiEntity.getType() == 5) { + receivedTaskByNet(HttpInterface.RECEIVED_OTHER_TASK, poiEntity.getTaskId() + "", true); } } - } break; case R.id.btn_finish_gather://结束采集 - new Thread(new Runnable() { - @Override - public void run() { + btnFinishGather.setVisibility(View.VISIBLE); + new Thread(new Runnable() { + @Override + public void run() { + if (poiListEntity!=null){ + poiDao.deletePoiEntity(poiListEntity); + }else { poiDao.deletePoiEntity(poiEntity); } - }).start(); + } + }).start(); break; } } - /** * @param url 不同任务类型对应的url * @param id 任务id - * */ - private void receivedTaskByNet(String url, String id,boolean isSaver) { + */ + private void receivedTaskByNet(String url, String id, boolean isSaver) { showLoadingDialog(); OkGoBuilder.getInstance() .Builder(getActivity()) - .url(url+id) + .url(url + id) .method(OkGoBuilder.GET) .cls(ReceivedPoiBean.class) .callback(new Callback() { @@ -205,7 +261,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe public void onSuccess(ReceivedPoiBean response, int id) { dismissLoadingDialog(); ReceivedPoiBean.BodyBean listBean = response.getBody(); - PoiEntity poiListEntity = new PoiEntity(); + poiListEntity = new PoiEntity(); poiListEntity.setTaskId(listBean.getId()); poiListEntity.setName(listBean.getName()); poiListEntity.setAddress(listBean.getAddress()); @@ -218,18 +274,29 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe poiListEntity.setX(latLng.longitude + ""); poiListEntity.setY(latLng.latitude + ""); } else if (geometry.getGeometryType().equals("LineString")) {//线 - } else if (geometry.getGeometryType().equals("Polygon")) {//面 + } else if (geometry.getGeometryType().equals("Polygon")) {}//面 - } - if (isSaver){ - Message obtain = Message.obtain(); - obtain.what = Constant.GATHER_GET_MAP; - obtain.obj = poiListEntity; - EventBus.getDefault().post(obtain); - } + new Thread(new Runnable() { + @Override + public void run() { + poiDao.insertPoiEntity(poiListEntity); + + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + btnFinishGather.setVisibility(View.VISIBLE); + if (isSaver&&aSave==1) { + Message obtain = Message.obtain(); + obtain.what = Constant.GATHER_GET_MAP; + obtain.obj = poiListEntity; + EventBus.getDefault().post(obtain); + } + } + }); + } + }).start(); } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -237,10 +304,7 @@ public class GatherGetFragment extends BaseFragment implements View.OnClickListe } }).build(); } - public static String format5(double value) { return String.format("%.2f", value).toString(); - } - } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java index ad76c78..377a875 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java @@ -87,7 +87,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis private PoiEntity showPoiEntity; private LatLng latLng; private int station_type=0; - private String name; + String[] spinner = new String[]{"存在","不存在","无法验证"}; + private RelativeLayout linearExist; + private Spinner spinnerExist; + private ArrayList otheruploadList; private String takePhotoPath; private String takePhotoPath2; @@ -197,6 +200,28 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis btnOtherLocal.setOnClickListener(this::onClick); btnOtherUploading = findViewById(R.id.btn_other_uploading); btnOtherUploading.setOnClickListener(this::onClick); + linearExist = findViewById(R.id.linear_exist); + spinnerExist = findViewById(R.id.spinner_exist); + ArrayAdapter adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); + adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 + spinnerExist.setAdapter(adapterExist); + spinnerExist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + break; + case 1: + break; + case 2: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); //数据展示 initShowPoi(); @@ -233,6 +258,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis if (describe != null &&!describe.equals("")) { editOtherDescribe.setText(describe); } + linearExist.setVisibility(View.VISIBLE); int station_type = showPoiEntity.getStation_type(); spinnerOther.setSelection(station_type,true); if (showPoiEntity.getPhotoInfo() != null) { @@ -276,8 +302,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis PoiEntity poiEntity = new PoiEntity(); List infoList = new ArrayList<>(); - //名称 - name = editTaskName.getText().toString().trim(); + String name = editTaskName.getText().toString().trim();//名称 if (name == null || name.equals("")) { Toast.makeText(getActivity(), "请输入poi 名称", Toast.LENGTH_SHORT).show(); return; @@ -313,8 +338,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis } else { infoList.add(new Info(tagPictures)); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } poiEntity.setStation_type(station_type); poiEntity.setPhotoInfo(infoList); @@ -376,7 +403,7 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis HttpParams httpParams = new HttpParams(); httpParams.put("type",poiEntity.getStation_type()); httpParams.put("taskId", poiEntity.getTaskId()); - httpParams.put("name", name); + httpParams.put("name", poiEntity.getName()); httpParams.put("existence", "1"); String encode = Geohash.getInstance().encode(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); httpParams.put("geo", encode); @@ -439,8 +466,10 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis if (tagPictures != null&&!tagPictures.equals("")) { arrayList.add(new Info(tagPictures)); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } poiEntity.setPhotoInfo(arrayList); poiEntity.setStation_type(station_type); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java index 4142353..6b2cf7d 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java @@ -8,12 +8,16 @@ import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -44,7 +48,6 @@ import com.navinfo.outdoor.base.BaseDrawerFragment; import com.navinfo.outdoor.bean.Info; import com.navinfo.outdoor.bean.PoiBean; import com.navinfo.outdoor.bean.PoiSaveBean; -import com.navinfo.outdoor.bean.TaskPrefectureBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; @@ -90,8 +93,9 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe private CheckBox checkBoxRight; private PoiEntity showPoiEntity; private LatLng latLng; - private String name; - private String site; + String[] spinner = new String[]{"存在","不存在","无法验证"}; + private RelativeLayout linearExist; + private Spinner spinnerExist; public static PoiFragment newInstance(Bundle bundle) { PoiFragment fragment = new PoiFragment(); @@ -187,6 +191,29 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe rlCard.setOnClickListener(this::onClick); rlElse = findViewById(R.id.rl_else); rlElse.setOnClickListener(this::onClick); + linearExist = findViewById(R.id.linear_exist); + spinnerExist = findViewById(R.id.spinner_exist); + ArrayAdapter adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); + adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 + spinnerExist.setAdapter(adapterExist); + spinnerExist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + break; + case 1: + break; + case 2: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); + recyclerPhone = findViewById(R.id.recycler_phone); recyclerPhone.setLayoutManager(new LinearLayoutManager(getContext())); recyclerPhone.addItemDecoration(new DividerItemDecoration(getContext(), DividerItemDecoration.VERTICAL)); @@ -257,6 +284,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe poiRecycleAdapter.setList(poiBeans); } + linearExist.setVisibility(View.VISIBLE); if (showPoiEntity.getPhotoInfo() != null) { for (int i = 0; i < showPoiEntity.getPhotoInfo().size(); i++) { String photo = showPoiEntity.getPhotoInfo().get(i).getPhoto(); @@ -333,15 +361,14 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe //保存数据库: PoiEntity poiEntity = new PoiEntity(); ArrayList infoPhoto = new ArrayList<>(); - //名称 - name = editNameContent.getText().toString().trim(); + String name = editNameContent.getText().toString().trim();//名称 if (name == null || name.equals("")) { Toast.makeText(getActivity(), "请输入poi 名称", Toast.LENGTH_SHORT).show(); return; } else { poiEntity.setName(name); } - site = editSiteContent.getText().toString().trim(); + String site = editSiteContent.getText().toString().trim(); if (site == null || site.equals("")) { Toast.makeText(getActivity(), "请输入poi 地址", Toast.LENGTH_SHORT).show(); return; @@ -382,9 +409,7 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe } else { infoPhoto.add(new Info(tagName)); } - if (showPoiEntity.getTaskId() != 0) { - poiEntity.setTaskId(showPoiEntity.getTaskId()); - } + String tagInternal = (String) ivInternal.getTag(); if (tagInternal != null) { infoPhoto.add(new Info(tagInternal)); @@ -397,8 +422,8 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe if (tagCard != null) { infoPhoto.add(new Info(tagCard)); } - if (showPoiEntity != null) { - if (showPoiEntity.getTaskId() != 0) { + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ poiEntity.setTaskId(showPoiEntity.getTaskId()); } } @@ -462,7 +487,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe case R.id.rl_else: Intent intentElse = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intentElse, 105); - break; } @@ -474,11 +498,11 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe if (poiEntity.getTaskId() != 0) { httpParams.put("taskId", poiEntity.getTaskId()); } - if (name != null && !name.equals("")) { - httpParams.put("name", name); + if (poiEntity.getName() != null && !poiEntity.getName().equals("")) { + httpParams.put("name", poiEntity.getName()); } - if (site != null && !site.equals("")) { - httpParams.put("address", site); + if (poiEntity.getAddress() != null && !poiEntity.getAddress().equals("")) { + httpParams.put("address", poiEntity.getAddress()); } httpParams.put("existence", "1"); if (poiEntity.getY() != null && poiEntity.getX() != null) { @@ -565,12 +589,12 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe if (tagCard != null && !tagCard.equals("")) { infoPhoto.add(new Info(tagCard)); } - if (showPoiEntity.getTaskId() != 0) { - poiEntity.setTaskId(showPoiEntity.getTaskId()); - } - if (showPoiEntity.getTaskId() != 0) { - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } + poiEntity.setPhotoInfo(infoPhoto); DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java index a40a8c3..6255645 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java @@ -9,11 +9,15 @@ import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.RadioButton; import android.widget.RadioGroup; +import android.widget.RelativeLayout; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -57,6 +61,9 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick private PoiDatabase poiDatabase; private PoiDao poiDao; private PoiEntity showPoiEntity; + private RelativeLayout linearExist; + private Spinner spinnerExist; + String[] spinner = new String[]{"存在","不存在","无法验证"}; public static PoiVideoFragment newInstance(Bundle bundle) { PoiVideoFragment fragment = new PoiVideoFragment(); @@ -114,7 +121,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick tvPictures.setOnClickListener(this::onClick); etRoadName = (EditText) findViewById(R.id.et_road_name); ivRoadPicture = (ImageView) findViewById(R.id.iv_road_picture); - // Glide.with(getContext()).load(getLocalVideoBitmap(String.valueOf(R.drawable.bg_01))).into(ivRoadPicture); rbCar = (RadioButton) findViewById(R.id.rb_car); rbBicycle = (RadioButton) findViewById(R.id.rb_bicycle); rbWalking = (RadioButton) findViewById(R.id.rb_walking); @@ -123,11 +129,32 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick btnRoadSave = (Button) findViewById(R.id.btn_road_save); btnRoadSave.setOnClickListener(this::onClick); rgType = (RadioGroup) findViewById(R.id.rg_type); + linearExist = findViewById(R.id.linear_exist); + spinnerExist = findViewById(R.id.spinner_exist); + ArrayAdapter adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); + adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 + spinnerExist.setAdapter(adapterExist); + spinnerExist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + break; + case 1: + break; + case 2: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); //添加数据 initShowPoi(); //禁用可操作性控件 // disables(); - //获取 } private void initShowPoi() { // 添加信息: @@ -143,6 +170,7 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick int type= roadExtend.getType(); showPictureType(type); } + linearExist.setVisibility(View.VISIBLE); String describe = showPoiEntity.getDescribe();//任务描述 if (describe != null && !describe.equals("")) { etDesc.setText(describe); @@ -220,8 +248,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick } else { poiEntity.setDescribe(desc); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); @@ -298,8 +328,10 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick if (desc != null && !desc.equals("")) { poiEntity.setDescribe(desc); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java index 45a7051..c0cb769 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java @@ -9,11 +9,15 @@ import android.os.Message; import android.util.Log; import android.view.LayoutInflater; import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.RadioButton; import android.widget.RadioGroup; +import android.widget.RelativeLayout; +import android.widget.Spinner; import android.widget.TextView; import android.widget.Toast; @@ -64,6 +68,8 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList private PoiDao poiDao; private PoiEntity showPoiEntity; private ImageView ivRoadFinal; + private RelativeLayout linearExist; + String[] spinner = new String[]{"存在","不存在","无法验证"}; public static RoadFragment newInstance(Bundle bundle) { RoadFragment fragment = new RoadFragment(); @@ -128,6 +134,28 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList btnRoadSave = (Button) findViewById(R.id.btn_road_save); btnRoadSave.setOnClickListener(this::onClick); rgType = (RadioGroup) findViewById(R.id.rg_type); + linearExist = findViewById(R.id.linear_exist); + Spinner spinnerExist = findViewById(R.id.spinner_exist); + ArrayAdapter adapterExist = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_item, spinner); + adapterExist.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); //设置下拉列表框的下拉选项样式 + spinnerExist.setAdapter(adapterExist); + spinnerExist.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView parent, View view, int position, long id) { + switch (position) { + case 0: + break; + case 1: + break; + case 2: + break; + } + } + + @Override + public void onNothingSelected(AdapterView parent) { + } + }); //数据展示 initShowPoi(); //禁用可操作性控件 @@ -148,6 +176,7 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList int type= roadExtend.getType(); showPictureType(type); } + linearExist.setVisibility(View.VISIBLE); String describe = showPoiEntity.getDescribe();//任务描述 if (describe != null && !describe.equals("")) { etDesc.setText(describe); @@ -226,8 +255,10 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList } else { poiEntity.setDescribe(desc); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); @@ -305,8 +336,10 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList if (desc != null && !desc.equals("")) { poiEntity.setDescribe(desc); } - if (showPoiEntity.getTaskId()!=0){ - poiEntity.setTaskId(showPoiEntity.getTaskId()); + if (showPoiEntity!=null){ + if (showPoiEntity.getTaskId()!=0){ + poiEntity.setTaskId(showPoiEntity.getTaskId()); + } } DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Calendar calendar = Calendar.getInstance(); diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java index 0e3a5c2..76c9357 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java @@ -66,6 +66,7 @@ import com.tencent.tencentmap.mapsdk.maps.LocationSource; import com.tencent.tencentmap.mapsdk.maps.MapView; import com.tencent.tencentmap.mapsdk.maps.Projection; import com.tencent.tencentmap.mapsdk.maps.TencentMap; +import com.tencent.tencentmap.mapsdk.maps.TencentMapContext; import com.tencent.tencentmap.mapsdk.maps.UiSettings; import com.tencent.tencentmap.mapsdk.maps.interfaces.Removable; import com.tencent.tencentmap.mapsdk.maps.model.BitmapDescriptor; @@ -191,6 +192,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen UiSettings uiSettings = tencentMap.getUiSettings(); //设置logo的大小 uiSettings.setLogoScale(0.7f); + uiSettings.setRotateGesturesEnabled(false);//禁止地图旋转手势. + uiSettings.setTiltGesturesEnabled(false);//禁止倾斜手势. //开启定位权限 checkNetWork(); //检查是否有没有填完的页面 @@ -202,6 +205,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen tencentMap.addOnMapLoadedCallback(new TencentMap.OnMapLoadedCallback() { @Override public void onMapLoaded() { + if (Constant.currentLocation != null ) { + initList(Constant.currentLocation); + } tencentMap.setOnMarkerClickListener(new TencentMap.OnMarkerClickListener() { @Override public boolean onMarkerClick(Marker marker) { @@ -231,7 +237,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen showSlidingFragment(otherFragment); break; } - } else { + }else if(marker.getTitle().equals("面妆任务")) {//面妆任务 JobSearchBean.BodyBean.ListBean listBean = (JobSearchBean.BodyBean.ListBean) marker.getTag(); PoiEntity poiListEntity = new PoiEntity(); poiListEntity.setTaskId(listBean.getId()); @@ -249,9 +255,28 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen poiListEntity.setY(latLng.latitude + ""); } else if (geometry.getGeometryType().equals("LineString")) {//线 } else if (geometry.getGeometryType().equals("Polygon")) {//面 - } initMarker(poiListEntity,2); + }else { + JobSearchBean.BodyBean.ListBean listBean = (JobSearchBean.BodyBean.ListBean) marker.getTag(); + PoiEntity poiListEntity = new PoiEntity(); + poiListEntity.setTaskId(listBean.getId()); + poiListEntity.setName(listBean.getName()); + poiListEntity.setAddress(listBean.getAddress()); + poiListEntity.setTelPhone(listBean.getTelephone() + ""); + poiListEntity.setPrecision(listBean.getPrice()); + poiListEntity.setDist(listBean.getDist()); + poiListEntity.setType(Integer.valueOf(listBean.getType())); + String geo = listBean.getGeo(); + Geometry geometry = GeometryTools.createGeometry(geo); + if (geometry.getGeometryType().equals("Point")) {//点 + LatLng latLng = GeometryTools.createLatLng(geo); + poiListEntity.setX(latLng.longitude + ""); + poiListEntity.setY(latLng.latitude + ""); + } else if (geometry.getGeometryType().equals("LineString")) {//线 + } else if (geometry.getGeometryType().equals("Polygon")) {//面 + } + initMarker(poiListEntity,1); } return false; } @@ -268,9 +293,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen @Override public void onCameraChangeFinished(CameraPosition cameraPosition) { // 地图移动结束 - if (Constant.currentLocation != null) { - initList(Constant.currentLocation); - } + + } }; @@ -308,47 +332,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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 latLng = GeometryTools.createLatLng(geo); - switch (Integer.valueOf(list.get(i).getType())) { - case 1://poi - Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.POI_ICON).alpha(0.5f) - .flat(true) - .clockwise(false)); - poiMarker.setTag(listBean); - removables.add(poiMarker); - poiMarker.setClickable(true); - break; - case 2://充电站 - Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.STATION_ICON).alpha(0.7f) - .flat(true) - .clockwise(false)); - stationMarker.setTag(listBean); - removables.add(stationMarker); - stationMarker.setClickable(true); - break; - case 3://poi录像 - break; - case 4://道路录像 - Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.ROAD_ICON).alpha(0.7f) - .flat(true) - .clockwise(false)); - roadMarker.setTag(listBean); - removables.add(roadMarker); - roadMarker.setClickable(true); - break; - case 5://其他 - break; - case 6://面状任务 - Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.PLANAR_TASK_ICON).alpha(0.7f) - .flat(true) - .clockwise(false)); - planarMarker.setTag(listBean); - removables.add(planarMarker); - planarMarker.setClickable(true); - break; - - } + latLng = GeometryTools.createLatLng(geo); } else if (geometry.getGeometryType().equals("LineString")) {//线 List latLineString = GeometryTools.getLatLngs(geo); // 构造 PolylineOpitons @@ -367,6 +353,9 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen // 绘制折线 Polyline polyline = tencentMap.addPolyline(polylineOptions); 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(). @@ -379,6 +368,50 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen //边线宽度15像素 strokeWidth(5)); removables.add(polygon); + if (latPolygon!=null&&latPolygon.size()>0){ + latLng = latPolygon.get(0); + } + } + switch (Integer.valueOf(list.get(i).getType())) { + case 1://poi + Marker poiMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.POI_ICON).alpha(0.5f) + .flat(true) + .clockwise(false)); + poiMarker.setTag(listBean); + removables.add(poiMarker); + poiMarker.setClickable(true); + break; + case 2://充电站 + Marker stationMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.STATION_ICON).alpha(0.7f) + .flat(true) + .clockwise(false)); + stationMarker.setTag(listBean); + removables.add(stationMarker); + stationMarker.setClickable(true); + break; + case 3://poi录像 + break; + case 4://道路录像 + Marker roadMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.ROAD_ICON).alpha(0.7f) + .flat(true) + .clockwise(false)); + roadMarker.setTag(listBean); + removables.add(roadMarker); + roadMarker.setClickable(true); + break; + case 5://其他 + break; + case 6://面状任务 + Marker planarMarker = tencentMap.addMarker(new MarkerOptions(latLng).icon(Constant.PLANAR_TASK_ICON).alpha(0.7f) + .flat(true) + .clockwise(false)); + Log.d("面妆任务", "onSuccess: "+planarMarker); + planarMarker.setTag(listBean); + removables.add(planarMarker); + planarMarker.setTitle("面妆任务");//1:面妆任务 + planarMarker.setClickable(true); + break; + } } Message obtain = Message.obtain(); @@ -406,7 +439,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen Bundle bundle = new Bundle(); bundle.putSerializable("poiEntity", poiEntity); bundle.putBoolean("boolean",false); - bundle.putInt("isServe",aInt); + bundle.putInt("aSave",aInt); gatherGetFragment = GatherGetFragment.newInstance(bundle); fragmentTransaction.replace(R.id.frame_layout, gatherGetFragment); fragmentTransaction.commit(); @@ -425,9 +458,8 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen Marker marker = tencentMap.addMarker(new MarkerOptions(position)); marker.setClickable(true); PoiEntity poiEntity = allPoi.get(i); - marker.setTitle("本地"); + marker.setTitle("本地");//1:本地 marker.setTag(poiEntity); - } } }); @@ -659,6 +691,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen showSlidingFragment(chargingPileFragment); } else if (data.what == Constant.CHARGING_STATION_PILE) {//充电站的充电桩 chargingPileEntity = (ChargingPileEntity) data.obj; + }else if (data.what==Constant.HOME_TREASURE){//寻宝的刷新 + if ((boolean)data.obj){ + initList(Constant.currentLocation); + } } } diff --git a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java index 4c9ac6d..5822ce1 100644 --- a/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java +++ b/app/src/main/java/com/navinfo/outdoor/room/PoiEntity.java @@ -55,7 +55,7 @@ public class PoiEntity implements Serializable { private String y;//纬度 private String detail;//深度信息 private String dist;//距离用户位置 - private int taskStatus;//任务状态 1.已领取,2.已保存,3已提交 + private int taskStatus;//任务状态 0.未领取 1.已领取,2.未保存(保存到本地但未提交成功),3.已保存(保存到本地提交成功),4已上传(结束采集), private int type;//1 "POI"2 "充电站"3 "POI录像"4 "道路录像"5 "其他"6 "面状任务" private int station_type;//1."全部"2 "POI"3 "充电站"4 "POI录像"5 "道路录像", "门牌:6 公交:7 情报:8 private int isLocalData;//是否是本地数据 0,服务 1,本地//现在没用 diff --git a/app/src/main/res/layout/charging_station_fragment.xml b/app/src/main/res/layout/charging_station_fragment.xml index 1c6c8fc..bee0a85 100644 --- a/app/src/main/res/layout/charging_station_fragment.xml +++ b/app/src/main/res/layout/charging_station_fragment.xml @@ -13,10 +13,6 @@ - - - - + + + + + + + app:layout_constraintTop_toBottomOf="@id/linear_exist" /> - -