diff --git a/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java b/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java index 4320058..321bf46 100644 --- a/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java +++ b/app/src/main/java/com/navinfo/outdoor/activity/LoginActivity.java @@ -4,6 +4,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.os.Message; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -21,9 +22,13 @@ import com.navinfo.outdoor.bean.LoginOauthTokenBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.util.Base64; import com.navinfo.outdoor.util.Md5Util; +import org.greenrobot.eventbus.EventBus; +import org.greenrobot.eventbus.Subscribe; + /** * 登录页 */ @@ -36,6 +41,14 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener private SharedPreferences navInfo; private SharedPreferences.Editor navInfoEditor; + @Override + public void onStart() { + super.onStart(); + if (!EventBus.getDefault().isRegistered(this)) {//加上判断 + EventBus.getDefault().register(this); + } + + } @Override protected int getLayout() { return R.layout.activity_login; @@ -46,6 +59,15 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener super.initData(); } + @Subscribe + public void onEvent(Message data) { + if (data.what == Constant.REGISTER_WORD) { + if ((boolean)data.obj){ + etLoginName.setText(Constant.user_name); + etLoginPaw.setText(Constant.pass_word); + } + } + } @Override protected void initView() { super.initView(); @@ -150,4 +172,10 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener public void onConfigurationChanged(@NonNull Configuration newConfig) { super.onConfigurationChanged(newConfig); } + @Override + public void onDestroy() { + if (EventBus.getDefault().isRegistered(this))//加上判断 + EventBus.getDefault().unregister(this); + super.onDestroy(); + } } 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 25d5a49..1223a79 100644 --- a/app/src/main/java/com/navinfo/outdoor/api/Constant.java +++ b/app/src/main/java/com/navinfo/outdoor/api/Constant.java @@ -58,6 +58,9 @@ public class Constant { public static String USERID=null; public static String USERNAME=null; + public static String user_name=null; + public static String pass_word=null; + //message word 值 @@ -71,7 +74,7 @@ public class Constant { public static final int TREASURE_GATHER_GET_WORD = 7;//领取采集页面其他marker 的回传 public static final int MAIN_BUTTON_VISIABLE = 8; // 控制主界面各个按钮显隐状态的what值 public static final int MAIN_HEADER = 9; // 控制主界面各个header - public static final int MAIN_REMOVE = 10; // 控制主界面各个header移除 + public static final int POI_DRAWER = 10; //设置每个页面显示屏幕的位置 public static final int GATHER_GET_RETURN = 11;//参加领取的返回 public static final int MAIN_CHARGING_STATION = 13;//充电站的Fragment 对地图页面marker 的一个展示 编辑 public static final int MAIN_CHARGING_CHECKED_STATION = 43;//充电站的Fragment 对地图页面marker 的一个展示 确定 @@ -104,6 +107,8 @@ public class Constant { public static final int EVENT_WORK_HOME = 45; //切换到寻宝 public static final int PICTURE_VIDEO_WORD = 48; //视频页面崩溃后发给poi录像和道路 + public static final int REGISTER_WORD = 46; //注册的返回 + public static int NUMBER = 200; //任务个数 public static int LIMIT_TTPE = -1; //权限类型,普通任务-0,专属任务-1 public static int TASK_TYPE = -1; // 任务类型 diff --git a/app/src/main/java/com/navinfo/outdoor/base/BaseDrawerFragment.java b/app/src/main/java/com/navinfo/outdoor/base/BaseDrawerFragment.java index 0db4230..636b4d6 100644 --- a/app/src/main/java/com/navinfo/outdoor/base/BaseDrawerFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/base/BaseDrawerFragment.java @@ -19,6 +19,7 @@ import com.navinfo.outdoor.room.ChargingPileEntity; import com.navinfo.outdoor.room.PoiEntity; import com.navinfo.outdoor.util.FragmentBackHandler; import com.navinfo.outdoor.util.GPSUtils; +import com.tencent.tencentmap.mapsdk.maps.model.LatLng; import org.greenrobot.eventbus.EventBus; @@ -27,6 +28,7 @@ import org.greenrobot.eventbus.EventBus; */ public abstract class BaseDrawerFragment extends BaseFragment { public boolean isSliding = true; // fragment被销毁时,true-抽屉收回,false-抽屉状态不变 + protected PoiEntity showPoiEntity; @Override protected void initData() { @@ -66,9 +68,24 @@ public abstract class BaseDrawerFragment extends BaseFragment { } + @Override + public void onResume() { + super.onResume(); + if (showPoiEntity!=null){ + Message obtain = Message.obtain(); + obtain.what = Constant.POI_DRAWER; + LatLng latLng = new LatLng(); + latLng.setLatitude(Double.valueOf(showPoiEntity.getY())); + latLng.setLongitude(Double.valueOf(showPoiEntity.getX())); + obtain.obj = latLng; + EventBus.getDefault().post(obtain); + } + } + @Override public void onDestroy() { super.onDestroy(); + showPoiEntity=null; Bundle arguments = getArguments(); if (arguments != null) { isSliding = arguments.getBoolean("isSliding", true); diff --git a/app/src/main/java/com/navinfo/outdoor/bean/MessageCodeBean.java b/app/src/main/java/com/navinfo/outdoor/bean/MessageCodeBean.java new file mode 100644 index 0000000..543489a --- /dev/null +++ b/app/src/main/java/com/navinfo/outdoor/bean/MessageCodeBean.java @@ -0,0 +1,32 @@ +package com.navinfo.outdoor.bean; + +public class MessageCodeBean { + + private Integer code; + private String message; + private String body; + + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public String getBody() { + return body; + } + + public void setBody(String body) { + this.body = body; + } +} 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 28df96f..ebab2dc 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingPileFragment.java @@ -57,6 +57,7 @@ import com.navinfo.outdoor.util.PhotoUtils; import com.navinfo.outdoor.util.PictureUtil; import com.navinfo.outdoor.util.ToastUtil; import com.tencent.tencentmap.mapsdk.maps.model.LatLng; +import com.vividsolutions.jts.geom.impl.PackedCoordinateSequence; import org.greenrobot.eventbus.EventBus; @@ -97,6 +98,9 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private String pid; private String station; private LatLng latLng; + private File file; + + private String takePhotoPath1; private String takePhotoPath2; private String takePhotoPath3; @@ -109,10 +113,7 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private String takePhotoPath10; private int taskId; private Integer chargingPileBody; - private ArrayList phoneLists; - private PoiEntity poiEntity; - private File file; public static ChargingPileFragment newInstance(Bundle bundle) { ChargingPileFragment fragment = new ChargingPileFragment(); @@ -556,12 +557,12 @@ public class ChargingPileFragment extends BaseDrawerFragment implements View.OnC private void initShowPileSharePre() { station = getArguments().getString("station"); if (station != null) { - poiEntity = new Gson().fromJson(station, PoiEntity.class); - pid = poiEntity.getId(); - taskId = poiEntity.getTaskId(); + showPoiEntity = new Gson().fromJson(station, PoiEntity.class); + pid = showPoiEntity.getId(); + taskId = showPoiEntity.getTaskId(); latLng = new LatLng(); - latLng.setLatitude(Constant.currentLocation.getLatitude()); - latLng.setLongitude(Constant.currentLocation.getLongitude()); + latLng.setLatitude(Double.valueOf(showPoiEntity.getY())); + latLng.setLongitude(Double.valueOf(showPoiEntity.getX())); } // 添加信息: 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 ab092f7..c9577d7 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ChargingStationFragment.java @@ -113,7 +113,6 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. private RecyclerView recyclerStation; private ChargingPileAdapter chargingPileAdapter; private int station_type = 0; - private PoiEntity showPoiEntity; // 要显示的entity数据,从外部界面传入 private ChargingPileDao chargingPileDao; private LatLng latLng; private RelativeLayout linearExist; @@ -1333,10 +1332,13 @@ public class ChargingStationFragment extends BaseDrawerFragment implements View. new Thread(new Runnable() { @Override public void run() { - PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); - if (poiDaoPoiEntity != null) { - if (poiDaoPoiEntity.getTaskStatus() == 5) { - poiDao.deletePoiEntity(poiDaoPoiEntity); + if (showPoiEntity.getId()!=null){ + PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); + if (poiDaoPoiEntity != null) { + if (poiDaoPoiEntity.getTaskStatus() == 5) { + poiDao.deletePoiEntity(poiDaoPoiEntity); + } + } } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java index f1d77ef..812a058 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/ForgetPawFragment.java @@ -1,6 +1,7 @@ package com.navinfo.outdoor.fragment; import android.os.Bundle; +import android.os.Message; import android.view.View; import android.widget.Button; import android.widget.EditText; @@ -12,11 +13,14 @@ import com.lzy.okgo.model.HttpParams; import com.navinfo.outdoor.R; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseFragment; +import com.navinfo.outdoor.bean.MessageCodeBean; import com.navinfo.outdoor.bean.UserBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; +import org.greenrobot.eventbus.EventBus; + /** * 忘记密码页面 */ @@ -51,11 +55,8 @@ public class ForgetPawFragment extends BaseFragment implements View.OnClickListe forgetPawGetNote.setOnClickListener(this); btnForgetPaw = findViewById(R.id.btn_forgetPaw); btnForgetPaw.setOnClickListener(this::onClick); - - } - @Override public void onClick(View v) { switch (v.getId()) { @@ -121,6 +122,14 @@ public class ForgetPawFragment extends BaseFragment implements View.OnClickListe @Override public void onSuccess(UserBean response, int id) { dismissLoadingDialog(); + if (response.getCode()==200){ + Constant.user_name = mobile; + Constant.pass_word = password; + Message obtain = Message.obtain(); + obtain.what=Constant.REGISTER_WORD; + obtain.obj = true; + EventBus.getDefault().post(obtain); + } Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } @@ -140,22 +149,22 @@ public class ForgetPawFragment extends BaseFragment implements View.OnClickListe Toast.makeText(getContext(), "请输入手机号", Toast.LENGTH_SHORT).show(); return; } else { - httpParams.put("telephone", mobile); + httpParams.put("mobile", mobile); } httpParams.put("type", 2); showLoadingDialog(); OkGoBuilder.getInstance() .Builder(getActivity()) .url(HttpInterface.USER_MESSAGE) - .cls(UserBean.class) + .cls(MessageCodeBean.class) .token(Constant.ACCESS_TOKEN) .params(httpParams) - .getRequest(new Callback() { + .getRequest(new Callback() { @Override - public void onSuccess(UserBean response, int id) { + public void onSuccess(MessageCodeBean response, int id) { dismissLoadingDialog(); if (response.getCode() == 200) { - sessionId = String.valueOf(response.getBody()); + sessionId = response.getBody(); } Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } 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 ef5251d..30a99ec 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/OtherFragment.java @@ -91,7 +91,6 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis private Button btnOtherUploading; private PoiDatabase poiDatabase; private PoiDao poiDao; - private PoiEntity showPoiEntity; private LatLng latLng; private int station_type = 5; private ArrayList otherUploadList; @@ -592,10 +591,13 @@ public class OtherFragment extends BaseDrawerFragment implements View.OnClickLis new Thread(new Runnable() { @Override public void run() { - PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); - if (poiDaoPoiEntity!=null) { - if (poiDaoPoiEntity.getTaskStatus()==5){ - poiDao.deletePoiEntity(poiDaoPoiEntity); + if (showPoiEntity.getId()!=null){ + PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); + if (poiDaoPoiEntity != null) { + if (poiDaoPoiEntity.getTaskStatus() == 5) { + poiDao.deletePoiEntity(poiDaoPoiEntity); + } + } } } 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 58c34c0..e9025fc 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiFragment.java @@ -93,7 +93,6 @@ public class PoiFragment extends BaseDrawerFragment implements View.OnClickListe private PoiDao poiDao; private CheckBox checkBoxLife; private CheckBox checkBoxRight; - private PoiEntity showPoiEntity; private LatLng latLng; String[] spinner = new String[]{"存在", "不存在", "无法验证"}; private int existence = 0; diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java index 7ecbdac..e76a9e9 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiTaskFragment.java @@ -108,7 +108,7 @@ public class PoiTaskFragment extends BaseFragment implements View.OnClickListene showLoadingDialog(); HttpParams httpParams = new HttpParams(); httpParams.put("type", type); - httpParams.put("pageSize", "10"); + httpParams.put("pageSize", "20"); httpParams.put("pageNum", page); OkGoBuilder.getInstance() .Builder(getActivity()) 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 762c837..381a42d 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/PoiVideoFragment.java @@ -90,7 +90,6 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick private RadioGroup rgType; private PoiDatabase poiDatabase; private PoiDao poiDao; - private PoiEntity showPoiEntity; private Button btnPoiVideoUpload; private String videoPath; private File fileZip; @@ -558,10 +557,13 @@ public class PoiVideoFragment extends BaseDrawerFragment implements View.OnClick new Thread(new Runnable() { @Override public void run() { - PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); - if (poiDaoPoiEntity != null) { - if (poiDaoPoiEntity.getTaskStatus() == 5) { - poiDao.deletePoiEntity(poiDaoPoiEntity); + if (showPoiEntity.getId()!=null){ + PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); + if (poiDaoPoiEntity != null) { + if (poiDaoPoiEntity.getTaskStatus() == 5) { + poiDao.deletePoiEntity(poiDaoPoiEntity); + } + } } } diff --git a/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java b/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java index 5cc8849..87b2a56 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RegisterFragment.java @@ -3,33 +3,30 @@ package com.navinfo.outdoor.fragment; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer; +import android.os.Message; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import android.widget.Toast; - import com.lzy.okgo.model.HttpParams; import com.navinfo.outdoor.R; import com.navinfo.outdoor.activity.LoginActivity; import com.navinfo.outdoor.api.Constant; import com.navinfo.outdoor.base.BaseFragment; - +import com.navinfo.outdoor.bean.MessageCodeBean; import com.navinfo.outdoor.bean.UserBean; import com.navinfo.outdoor.http.Callback; import com.navinfo.outdoor.http.HttpInterface; import com.navinfo.outdoor.http.OkGoBuilder; - -import com.navinfo.outdoor.util.RegexUtil; +import org.greenrobot.eventbus.EventBus; /** * 注册页面 */ public class RegisterFragment extends BaseFragment implements View.OnClickListener { - - private EditText etRegisterPhone, etRegisterNote, etRegisterReferrer, etRegisterPaw, etRegisterConfirmPaw; private ImageView ivRegisterCheck, ivFinish; private TextView haveGoLogin, registerGetNote; @@ -86,6 +83,7 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen break; case R.id.btn_register: initRegister(); + break; case R.id.register_get_note: registerNote(); initGetNote(); @@ -100,24 +98,23 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen Toast.makeText(getContext(), "请输入手机号", Toast.LENGTH_SHORT).show(); return; } else { - httpParams.put("telephone", mobile); + httpParams.put("mobile", mobile); } httpParams.put("type", 1); showLoadingDialog(); OkGoBuilder.getInstance() .Builder(getActivity()) .url(HttpInterface.USER_MESSAGE) - .cls(UserBean.class) - .token(null) + .cls(MessageCodeBean.class) .params(httpParams) - .getRequest(new Callback() { + .getRequest(new Callback() { @Override - public void onSuccess(UserBean response, int id) { + public void onSuccess(MessageCodeBean response, int id) { dismissLoadingDialog(); if (response.getCode() == 200) { - sessionId = String.valueOf(response.getBody()); + sessionId = response.getBody(); } - Toast.makeText(getActivity(), response.getMessage()+ "", Toast.LENGTH_SHORT).show(); + Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } @Override @@ -159,14 +156,14 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen if (!conFirmPaw.equals(password)) { Toast.makeText(getContext(), "密码和确认密码请保持一致", Toast.LENGTH_SHORT).show(); } - if (sessionId == null||sessionId.equals("")) { + if (sessionId == null || sessionId.equals("")) { Toast.makeText(getContext(), "请短信获取验证码", Toast.LENGTH_SHORT).show(); return; } else { httpParams.put("sessionId", sessionId); } - long time=System.currentTimeMillis(); - httpParams.put("datetime",time); + long time = System.currentTimeMillis(); + httpParams.put("datetime", time); showLoadingDialog(); OkGoBuilder.getInstance() .Builder(getActivity()) @@ -179,12 +176,16 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen public void onSuccess(UserBean response, int id) { dismissLoadingDialog(); if (response.getCode() == 200) { - Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); - } else { - Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); + Constant.user_name = mobile; + Constant.pass_word = password; + Message obtain = Message.obtain(); + obtain.what=Constant.REGISTER_WORD; + obtain.obj = true; + EventBus.getDefault().post(obtain); + getActivity().finish(); } + Toast.makeText(getActivity(), response.getMessage() + "", Toast.LENGTH_SHORT).show(); } - @Override public void onError(Throwable e, int id) { dismissLoadingDialog(); @@ -196,13 +197,12 @@ public class RegisterFragment extends BaseFragment implements View.OnClickListen } private void registerNote() { - if (timer!=null){ + if (timer != null) { timer.cancel(); - timer= null; + timer = null; } registerGetNote.setEnabled(false); timer = new CountDownTimer(60 * 1000, 1000) { - @Override public void onTick(long millisUntilFinished) { registerGetNote.setText(millisUntilFinished / 1000 + "秒后重新获取验证码"); 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 9ea8d90..463aff0 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/RoadFragment.java @@ -92,7 +92,6 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList private RadioGroup rgType; private PoiDatabase poiDatabase; private PoiDao poiDao; - private PoiEntity showPoiEntity; private Button roadUpload; private File fileZip; private FrameLayout fmRoadPic; @@ -599,10 +598,13 @@ public class RoadFragment extends BaseDrawerFragment implements View.OnClickList new Thread(new Runnable() { @Override public void run() { - PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); - if (poiDaoPoiEntity!=null) { - if (poiDaoPoiEntity.getTaskStatus()==5){ - poiDao.deletePoiEntity(poiDaoPoiEntity); + if (showPoiEntity.getId()!=null){ + PoiEntity poiDaoPoiEntity = poiDao.getPoiEntity(showPoiEntity.getId()); + if (poiDaoPoiEntity != null) { + if (poiDaoPoiEntity.getTaskStatus() == 5) { + poiDao.deletePoiEntity(poiDaoPoiEntity); + } + } } } 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 58596a0..88d659c 100644 --- a/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java +++ b/app/src/main/java/com/navinfo/outdoor/fragment/TreasureFragment.java @@ -148,6 +148,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen Message msg = Message.obtain(); msg.what = Constant.FILTER_DATA_CLEAR; EventBus.getDefault().post(msg); + dismissLoadingDialog(); initThread(); // 刷新筛选的本地数据 initList(Constant.currentLocation); // 刷新筛选的网络数据 } @@ -242,6 +243,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen dismissLoadingDialog(); refreshFilterData(); } + @Override public void onCancel() { } @@ -364,12 +366,12 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen if (response.getCode() == 200) { Toast.makeText(getActivity(), "成功", Toast.LENGTH_SHORT).show(); Log.d("TAG", "onSuccess: ssssssssssssssssssssssssss 成功"); + showLoadingDialog(); } 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(); @@ -380,191 +382,190 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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 encodeStr = list.get(i).getGeo(); - // 解密geo - String geo = Geohash.getInstance().decode(encodeStr); - listBean.setGeo(geo); - 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); - } + 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 encodeStr = list.get(i).getGeo(); + // 解密geo + String geo = Geohash.getInstance().decode(encodeStr); + listBean.setGeo(geo); + 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); } - - @Override - public void onError(Throwable e, int id) { - dismissLoadingDialog(); - Log.d("TAG", "onError: " + e.getMessage() + ""); - } - }); - dismissDialog(); + 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); @@ -627,17 +628,17 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen }*/ } BitmapDescriptor descriptor = null; - if (poiEntity.getType()==1){ + if (poiEntity.getType() == 1) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bags); - }else if (poiEntity.getType()==2){ + } else if (poiEntity.getType() == 2) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_charge_bags); - }else if (poiEntity.getType()==3){ + } else if (poiEntity.getType() == 3) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.poi_video_bag); - }else if (poiEntity.getType()==4){ + } else if (poiEntity.getType() == 4) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_road_bag); - }else if (poiEntity.getType()==5){ + } else if (poiEntity.getType() == 5) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_other_bag); - }else if (poiEntity.getType()==6){ + } else if (poiEntity.getType() == 6) { descriptor = BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bag); } if (bigMarker == null) { @@ -651,6 +652,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bigMarker.setVisible(true); bigMarker.setClickable(false); bigMarker.setZIndex(4); + initPileMarker(latLng); frameLayout.setVisibility(View.VISIBLE); setMainButtonVisiable(View.GONE); fragmentTransaction = supportFragmentManager.beginTransaction(); @@ -661,7 +663,6 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen fragmentTransaction.commit(); } - private void initThread() { int taskStatus = Constant.TASK_STASTUS; int type = Constant.TASK_TYPE; @@ -738,7 +739,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen latLng.setLatitude(y); latLng.setLongitude(x); } - /* if (latPolygon != null && latPolygon.size() > 0) { + /*if (latPolygon != null && latPolygon.size() > 0) { latLng = latPolygon.get(0); }*/ } @@ -749,10 +750,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen } switch (Integer.valueOf(poiEntity.getType())) { case 1://poi - BitmapDescriptor poiDescriptor=null; - if (poiEntity.getTaskStatus()==1){ - poiDescriptor= BitmapDescriptorFactory.fromResource(R.drawable.marker_poi_bg1); - }else { + 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) @@ -766,10 +767,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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); + 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) @@ -782,10 +783,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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); + 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) @@ -797,11 +798,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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); + 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) @@ -814,10 +815,10 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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); + 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) @@ -829,11 +830,11 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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); + 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) @@ -856,8 +857,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen }).start(); } - - private void initSharePre () { + private void initSharePre() { //根据保存时所用的name属性,获取SharedPreferences对象 SharedPreferences dataFile = getActivity().getSharedPreferences(Constant.DATA_FILE, 0); //根据数据类型,调用对应的get方法,通过键取得对应的值。 @@ -874,7 +874,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bundle.putSerializable("poiEntity", poiEntity); PoiFragment poiFragment = PoiFragment.newInstance(bundle); LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); - showPoiMarkerByType(1, newPoiLatLng); + // showPoiMarkerByType(1, newPoiLatLng); showSlidingFragment(poiFragment); initRemovePoiSharePre(); return false; @@ -890,7 +890,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bundle.putSerializable("poiEntity", poiEntity); ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); - showPoiMarkerByType(4, newPoiLatLng); + //showPoiMarkerByType(4, newPoiLatLng); showSlidingFragment(chargingStationFragment); initRemovePoiSharePre(); return false; @@ -906,7 +906,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bundle.putSerializable("poiEntity", poiEntity); PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); - showPoiMarkerByType(2, newPoiLatLng); + //showPoiMarkerByType(2, newPoiLatLng); showSlidingFragment(poiVideoFragment); initRemovePoiSharePre(); return false; @@ -922,14 +922,13 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bundle.putSerializable("poiEntity", poiEntity); RoadFragment roadFragment = RoadFragment.newInstance(bundle); LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); - showPoiMarkerByType(3, newPoiLatLng); + // showPoiMarkerByType(3, newPoiLatLng); showSlidingFragment(roadFragment); initRemovePoiSharePre(); return false; } }); break; - case 5: DialogSettings.style = DialogSettings.STYLE.STYLE_KONGZUE; MessageDialog.show((AppCompatActivity) getContext(), "提示", "你其他页面还有未提交完的数据", "确定").setOkButton(new OnDialogButtonClickListener() { @@ -939,565 +938,582 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen bundle.putSerializable("poiEntity", poiEntity); OtherFragment otherFragment = OtherFragment.newInstance(bundle); LatLng newPoiLatLng = new LatLng(Double.valueOf(poiEntity.getY()), Double.valueOf(poiEntity.getX())); - showPoiMarkerByType(5, newPoiLatLng); + //showPoiMarkerByType(5, newPoiLatLng); showSlidingFragment(otherFragment); initRemovePoiSharePre(); return false; } }); break; - } } } - 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(); - } + 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) - } + @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); + setMainButtonVisiable(View.VISIBLE); 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); - setMainButtonVisiable(View.VISIBLE); - 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.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) { - refreshFilterData(); - } - } 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(); - refreshFilterData(); - } 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 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.remove(); + bigMarker.setVisible(false); } 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); + } else if (data.what == Constant.MAIN_BUTTON_VISIABLE) {//控制主界面各个按钮显隐状态的what值 + setMainButtonVisiable((Integer) data.obj); + } 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) { + refreshFilterData(); + } + } 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(); + refreshFilterData(); + } 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 R.id.iv_zoom_del://缩小 - CameraUpdate cameraUpdateOut = CameraUpdateFactory.zoomOut(); - tencentMap.animateCamera(cameraUpdateOut); + case 2: + ChargingStationFragment chargingStationFragment = ChargingStationFragment.newInstance(bundle); + showSlidingFragment(chargingStationFragment); break; - case R.id.iv_refrish://刷新 - refreshFilterData(); + case 3: + PoiVideoFragment poiVideoFragment = PoiVideoFragment.newInstance(bundle); + showSlidingFragment(poiVideoFragment); 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(); - } + case 4: + RoadFragment roadFragment = RoadFragment.newInstance(bundle); + showSlidingFragment(roadFragment); 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; - } -// 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); - poiEntity.setWork_type(1); - bundle.putSerializable("poiEntity", poiEntity); - 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; + 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.POI_DRAWER){//设置每个点的中心位置 + LatLng latLng = (LatLng) data.obj; + if (latLng!=null){ + CameraUpdate cameraSigma = CameraUpdateFactory.newCameraPosition(new CameraPosition( + latLng, //中心点坐标,地图目标经纬度 + 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); + markerPoi = tencentMap.addMarker(new MarkerOptions(latLng).icon(bitmapDescriptor1).zIndex(2)); + if (markerPoi != null) { + markerPoi.setFixingPoint(screenPosition.x, screenPosition.y); } - }).setTitle(title); - break; - case R.id.iv_filter: - FilterFragment filterFragment = FilterFragment.newInstance(new Bundle()); - showSlidingFragment(filterFragment); - refreshFilterData(); - break; - case R.id.iv_message: - Intent messageIntent = new Intent(getContext(), FragmentManagement.class); - messageIntent.putExtra("tag", 35); - startActivity(messageIntent); - break; + } + @Override + public void onCancel() { + } + }); } - } - 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)); + } + } + + + /** + * 控制主界面各个按钮的显示状态 + */ + 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( + latLng, //中心点坐标,地图目标经纬度 + 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对象之前,设置属性 + + } + @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://刷新 + refreshFilterData(); + 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; + } +// 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); + poiEntity.setWork_type(1); + bundle.putSerializable("poiEntity", poiEntity); + 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; + } + }).setTitle(title); + break; + case R.id.iv_filter: + FilterFragment filterFragment = FilterFragment.newInstance(new Bundle()); + showSlidingFragment(filterFragment); + refreshFilterData(); + 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)); + } + }*/ /** * 将fragment显示到抽屉内 @@ -1519,19 +1535,20 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen if (chargingStationFragment != null) { fragmentTransaction.hide(chargingStationFragment); } - if (!(fragment instanceof PoiFragment)) { + } + if (!(fragment instanceof PoiFragment)) { PoiFragment poiFragment = (PoiFragment) supportFragmentManager.findFragmentByTag(PoiFragment.class.getName()); if (poiFragment != null) { fragmentTransaction.hide(poiFragment); } } - if (!(fragment instanceof RoadFragment)) { + if (!(fragment instanceof RoadFragment)) { RoadFragment roadFragment = (RoadFragment) supportFragmentManager.findFragmentByTag(RoadFragment.class.getName()); if (roadFragment != null) { fragmentTransaction.hide(roadFragment); } } - if (!(fragment instanceof PoiVideoFragment)) { + if (!(fragment instanceof PoiVideoFragment)) { PoiVideoFragment poiVideoFragment = (PoiVideoFragment) supportFragmentManager.findFragmentByTag(PoiVideoFragment.class.getName()); if (poiVideoFragment != null) { fragmentTransaction.hide(poiVideoFragment); @@ -1540,20 +1557,20 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen fragmentTransaction.show(fragment); fragmentTransaction.addToBackStack(null); fragmentTransaction.commit(); - } } /** * 检查网络状态 */ private void checkNetWork() { - if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用 - checkMyLocation(); - } else { // 当前网络不可用 - dismissLoadingDialog(); - ToastUtil.showShort(getContext(), Constant.NETWORK_UNAVAILABLE); - } + if (NetWorkUtils.iConnected(getContext())) { // 当前网络可用 + checkMyLocation(); + } else { // 当前网络不可用 + dismissLoadingDialog(); + ToastUtil.showShort(getContext(), Constant.NETWORK_UNAVAILABLE); } + } + /** * 检查所需权限 */ @@ -1578,6 +1595,7 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen Toast.makeText(getActivity(), "申请权限失败", Toast.LENGTH_SHORT).show(); } } + @Override public void onDenied(List permissions, boolean never) { if (never) { @@ -1587,22 +1605,22 @@ public class TreasureFragment extends BaseFragment implements View.OnClickListen 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(); @@ -1612,18 +1630,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; - } + 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); - } + @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 + } +} \ 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 94bcbb7..bd28e26 100644 --- a/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java +++ b/app/src/main/java/com/navinfo/outdoor/http/HttpInterface.java @@ -1,7 +1,5 @@ package com.navinfo.outdoor.http; - import com.navinfo.outdoor.api.Constant; - public class HttpInterface { public static final String IP="http://dtxbmaps.navinfo.com/dtxb/m4";//正式接口 public static final String USER_PATH="/user/";//我的 @@ -10,7 +8,6 @@ public class HttpInterface { public static final String PRICE_PATH="/price/";//提现 public static final String TASK_PATH="/task/";//任务 public static final String USERID= Constant.USERID; - /** * 用户版本升级 */ @@ -32,21 +29,20 @@ public class HttpInterface { //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 = IP+USER_PATH+ "userLocation/"+USERID+"/userLocation"; //上传用户坐标 - /** * 发现 * Path=/m4/msgList/** */ // public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/msg/"; - public static final String listTask = IP +MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//任务专区 - public static final String listEvent = IP +MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//活动专区 - public static final String listTaskExplain = IP +MSG_LIST_PATH+"m4/findAndMessage/"+USERID+"/msg_list";//任务说明 + public static final String LIST_TASK =IP+MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//任务专区 + public static final String LIST_EVENT =IP+MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//活动专区 + public static final String LIST_TASK_EXPLAIN =IP+MSG_LIST_PATH+"m4/findAndMessage/"+USERID+"/msg_list";//任务说明 //http://172.23.139.4:8002/m4/findAndMessage/1/msg_list?fid=1&pageNum=1&pageSize=2 - public static final String MSG_LISt = IP +MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//发现查询接口 + public static final String MSG_LISt =IP+MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/msg_list";//发现查询接口 //http://172.23.139.4:8002/m4/findAndMessage/1/exam_content?id=11 - public static final String EXAM_CONTENT = IP +MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/exam_content";//发现 -能力测评获取试题接口 + public static final String EXAM_CONTENT =IP+MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/exam_content";//发现 -能力测评获取试题接口 //http://172.23.139.4:8002/m4/findAndMessage/1/submitExam - public static final String EXAM_SUBMIT = IP +MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/submitExam";//发现 -能力测评提交试卷 post + public static final String EXAM_SUBMIT =IP+MSG_LIST_PATH+ "m4/findAndMessage/"+USERID+"/submitExam";//发现 -能力测评提交试卷 post /** * 登录 * Path=/m4/userlogin/** @@ -56,12 +52,11 @@ public class HttpInterface { ///m4/user/m4/user/register public static final String USER_REGISTER=IP+USER_PATH+"m4/user/register";//注册接口 ///m4/user/ phone/message - public static final String USER_MESSAGE=IP+USER_PATH+"phone/message ";//获取验证码 type 1:注册获取 2:更新 + public static final String USER_MESSAGE=IP+USER_PATH+"phone/message";//获取验证码 type 1:注册获取 2:更新 ///m4/user/m4/user/forgetPassword public static final String USER_FORGET_PASSWORD=IP +USER_PATH+"m4/user/forgetPassword";//忘记密码 - //Flat.: + //Flat //dtxbmaps.navinfo.com/dtxb/m4/user/phone/message?mobile=18811794839&type=2 - /** * 提现 金额 * Path=/m4/price/** @@ -122,55 +117,35 @@ public class HttpInterface { public static final String COMPLETE = IP+TASK_PATH + "polygonTask/"+USERID+"/complete";//面状任务任务采集 public static final String SUBMIT_POLYGON_TASK = IP+TASK_PATH + "polygonTask/"+USERID+"/submitPolygontask";//面状任务结束采集 - - - - - - - /* public static final String IPm8 = "http://172.23.139.4:8003/m4/"; - //http://172.23.139.4:8003/m4/task/1/unReceivedTask?taskIds=&auditIds=214,278 - 、、public static final String UN_RECEIVED_TASK = + "task/1/unReceivedTask";//所以类型的结束领取 -*/ - - /** - * + * public static final String IPm8 = "http://172.23.139.4:8003/m4/"; + * http://172.23.139.4:8003/m4/task/1/unReceivedTask?taskIds=&auditIds=214,278 + * public static final String UN_RECEIVED_TASK = + "task/1/unReceivedTask";//所以类型的结束领取 //http://172.21.91.160:8000/api/user/list //发现接口 //http://172.23.139.4:8002/m4/findAndMessage/1/msg_list?fid=1&pageNum=1&pageSize=2 //能力测评接口 //http://172.23.139.4:8002/m4/findAndMessage/1/exam_content?id=11 //http://172.23.139.4:8002/m4/findAndMessage/1/submitExam - public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/msg/m4/findAndMessage/1/"; //发现:测试接口 - public static final String listTask = IP1 + "msg_list";//任务专区 public static final String listEvent = IP1 + "msg_list";//活动专区 public static final String listTaskExplain = IP1 + "msg_list";//任务说明 public static final String MSG_LISt = IP1 + "msg_list";//发现查询接口 public static final String EXAM_CONTENT = IP1 + "exam_content";//发现 -能力测评获取试题接口 public static final String EXAM_SUBMIT = IP1 + "submitExam";//发现 -能力测评提交试卷 post - - public static final String IPm4 = "http://dtxbmaps.navinfo.com/dtxb/user/m4"; - public static final String MSG_CONTENT = IPm4 + "/1/msg_content";//发现 -富文本详情页请求 - - //172.23.139.4:8001/m4/user/update public static final String USER_UPDATE = IPm4 + "/user/update";//用户资料 //172.23.139.4:8001/m4/userBankcard/update public static final String USER_BANKCARD_UP_DATA = IPm4 + "/userBankcard/update"; //绑定银行卡 - public static final String IPm5 = "http://dtxbmaps.navinfo.com/dtxb/price/"; //http://172.23.139.4:8004/userPrice/1/getPrice public static final String GET_PRICE = IPm5 + "userPrice/1/getPrice";//我的-总资产 //http://172.23.139.4:8004/userPrice/1/userPriceExchange?exchangeMoney=10&payType=1 public static final String USER_PRICE_EXCHANGE = IPm5 + "userPrice/1/userPriceExchange";//我的-财务信息-提现 - - public static final String IPm6 = "http://dtxbmaps.navinfo.com/dtxb/task/"; //172.23.139.4:8003/m4/task/1/getList public static final String TASK_LIST = IPm6 + "m4/task/1/getList"; //任务搜索 @@ -198,16 +173,12 @@ public class HttpInterface { public static final String RECEIVED_POI_VIDEO_TASK = IPm6 + "poivideotask/1/receivedPoivideotask";//poi录像任务获取 // 172.23.139.4:8003/poivideotask/1/submitPoivideotask public static final String INSIDE_API_LIST = IPm6 + "poivideotask/1/submitPoivideotask";//poi录像 保存 - //172.23.139.4:8003/poivideotask/1/uploadpic public static final String POI_VIDEO_UPLOAD_PIC = IPm6 + "poivideotask/1/uploadpic";//poi录像-上传 - //172.23.139.4:8003/roadtask/1/submitRoadtask?taskId=0&name=段哥&address=二娃&memo=1rn7exd5uhxy&workType=2 public static final String ROAD_TASK_SUBMIT = IPm6+"roadtask/1/submitRoadtask";//道路录像-保存本地 - //172.23.139.4:8003/roadtask/1/uploadpic public static final String ROAD_TASK_UPLOAD_PIC=IPm6+"roadtask/1/uploadpic";//道路录像—上传 - //http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy public static final String GET_PHONE = IPm6 + "m4/task/1/getPhone"; //任务搜索 //http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy @@ -218,53 +189,39 @@ public class HttpInterface { public static final String C_TASK_UP_LOAD_PIC= IPm6+"ctask/1/uploadpic";//充电站-上传 //172.23.139.4:8003/m4/task/1/taskName?geo=1rn7exd5uhxy&name=四维 public static final String TASK_NAME = IPm6+"m4/task/1/taskName";//poi-查重 - //172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1 public static final String GET_COMMIT_LIST = IPm6+"m4/task/1/getCommitList"; - public static final String IPm7 = "http://dtxbmaps.navinfo.com/dtxb/user"; //172.23.139.4:8001/m4/userAuth/add public static final String USER_AUTH_ADD = IPm7 + "/userAuth/add"; //实名认证 - public static final String IPm8 = "http://172.23.139.4:9999/m4/"; //http://172.23.139.4:9999/m4/userlogin/oauth/token public static final String USER_LOGIN_OAUTH_TOKEN = IPm8 + "userlogin/oauth/token"; //登录 - //http://172.21.91.160:8000/api/user/list //发现接口 //http://172.23.139.4:8002/m4/findAndMessage/1/msg_list?fid=1&pageNum=1&pageSize=2 //能力测评接口 //http://172.23.139.4:8002/m4/findAndMessage/1/exam_content?id=11 //http://172.23.139.4:8002/m4/findAndMessage/1/submitExam - public static final String IP1 = "http://dtxbmaps.navinfo.com/dtxb/msg/m4/findAndMessage/1/"; //发现:测试接口 - public static final String listTask = IP1 + "msg_list";//任务专区 public static final String listEvent = IP1 + "msg_list";//活动专区 public static final String listTaskExplain = IP1 + "msg_list";//任务说明 public static final String MSG_LISt = IP1 + "msg_list";//发现查询接口 public static final String EXAM_CONTENT = IP1 + "exam_content";//发现 -能力测评获取试题接口 public static final String EXAM_SUBMIT = IP1 + "submitExam";//发现 -能力测评提交试卷 post - - public static final String IPm4 = "http://dtxbmaps.navinfo.com/dtxb/user/m4"; - public static final String MSG_CONTENT = IPm4 + "/1/msg_content";//发现 -富文本详情页请求 - - //172.23.139.4:8001/m4/user/update public static final String USER_UPDATE = IPm4 + "/user/update";//用户资料 //172.23.139.4:8001/m4/userBankcard/update public static final String USER_BANKCARD_UP_DATA = IPm4 + "/userBankcard/update"; //绑定银行卡 - public static final String IPm5 = "http://dtxbmaps.navinfo.com/dtxb/price/"; //http://172.23.139.4:8004/userPrice/1/getPrice public static final String GET_PRICE = IPm5 + "userPrice/1/getPrice";//我的-总资产 //http://172.23.139.4:8004/userPrice/1/userPriceExchange?exchangeMoney=10&payType=1 public static final String USER_PRICE_EXCHANGE = IPm5 + "userPrice/1/userPriceExchange";//我的-财务信息-提现 - - public static final String IPm6 = "http://dtxbmaps.navinfo.com/dtxb/task/"; //172.23.139.4:8003/m4/task/1/getList public static final String TASK_LIST = IPm6 + "m4/task/1/getList"; //任务搜索 @@ -292,16 +249,12 @@ public class HttpInterface { public static final String RECEIVED_POI_VIDEO_TASK = IPm6 + "poivideotask/1/receivedPoivideotask";//poi录像任务获取 // 172.23.139.4:8003/poivideotask/1/submitPoivideotask public static final String INSIDE_API_LIST = IPm6 + "poivideotask/1/submitPoivideotask";//poi录像 保存 - //172.23.139.4:8003/poivideotask/1/uploadpic public static final String POI_VIDEO_UPLOAD_PIC = IPm6 + "poivideotask/1/uploadpic";//poi录像-上传 - //172.23.139.4:8003/roadtask/1/submitRoadtask?taskId=0&name=段哥&address=二娃&memo=1rn7exd5uhxy&workType=2 public static final String ROAD_TASK_SUBMIT = IPm6+"roadtask/1/submitRoadtask";//道路录像-保存本地 - //172.23.139.4:8003/roadtask/1/uploadpic public static final String ROAD_TASK_UPLOAD_PIC=IPm6+"roadtask/1/uploadpic";//道路录像—上传 - //http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy public static final String GET_PHONE = IPm6 + "m4/task/1/getPhone"; //任务搜索 //http://172.23.139.4:8003/m4/task/1/getPhone?geo=1rn7exd5uhxy @@ -312,18 +265,14 @@ public class HttpInterface { public static final String C_TASK_UP_LOAD_PIC= IPm6+"ctask/1/uploadpic";//充电站-上传 //172.23.139.4:8003/m4/task/1/taskName?geo=1rn7exd5uhxy&name=四维 public static final String TASK_NAME = IPm6+"m4/task/1/taskName";//poi-查重 - //172.23.139.4:8003/m4/task/1/getCommitList?type=2&pageSize=10&pageNum=1 public static final String GET_COMMIT_LIST = IPm6+"m4/task/1/getCommitList"; - public static final String IPm7 = "http://dtxbmaps.navinfo.com/dtxb/user"; //172.23.139.4:8001/m4/userAuth/add public static final String USER_AUTH_ADD = IPm7 + "/userAuth/add"; //实名认证 - public static final String IPm8 = "http://172.23.139.4:9999/m4/"; //http://172.23.139.4:9999/m4/userlogin/oauth/token public static final String USER_LOGIN_OAUTH_TOKEN = IPm8 + "userlogin/oauth/token"; //登录 - *面状任务 public static final String RECEIVED_POLYGON_TASK = IPm6 + "polygonTask/1/receivedPolygontask"; //任务领取 public static final String UNRECEIVED_POLYGON_TASK = IPm6 + "polygonTask/1/unReceivedPolygontask";//结束领取 @@ -332,8 +281,6 @@ public class HttpInterface { public static final String RECEIVED_POLYGON_TASK = IPm6 + "polygonTask/1/receivedPolygontask"; //任务领取 public static final String COMPLETE = IPm6 + "polygonTask/1/complete";//任务采集 public static final String SUBMIT_POLYGON_TASK = IPm6 + "polygonTask/1/submitPolygontask";//结束采集 - - * */ diff --git a/app/src/main/res/layout/fragment_forget_paw.xml b/app/src/main/res/layout/fragment_forget_paw.xml index 2f31a2a..8ba49d9 100644 --- a/app/src/main/res/layout/fragment_forget_paw.xml +++ b/app/src/main/res/layout/fragment_forget_paw.xml @@ -66,7 +66,7 @@ android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:background="@null" - android:digits="1234567890" + android:inputType="number" android:hint="11为手机号码" android:maxLength="11" android:paddingTop="10dp" @@ -104,6 +104,7 @@ android:layout_height="wrap_content" android:background="@null" android:hint="6为短信验证" + android:inputType="number" android:paddingTop="10dp" android:paddingBottom="10dp" android:layout_marginLeft="20dp" diff --git a/app/src/main/res/layout/fragment_register.xml b/app/src/main/res/layout/fragment_register.xml index 1de46c8..a923c0a 100644 --- a/app/src/main/res/layout/fragment_register.xml +++ b/app/src/main/res/layout/fragment_register.xml @@ -77,9 +77,9 @@ android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="11为手机号码" + android:inputType="number" android:layout_marginLeft="35dp" style="@style/register_hint_style" - android:digits="1234567890" android:maxLength="11" android:textColorHint="@color/colorTransparent" android:textCursorDrawable="@drawable/text_color" @@ -110,6 +110,7 @@ android:layout_width="250dp" android:layout_height="wrap_content" android:hint="6位短信验证" + android:inputType="number" style="@style/register_hint_style" android:textColorHint="@color/colorTransparent" android:textCursorDrawable="@drawable/text_color" @@ -183,6 +184,7 @@ android:layout_width="300dp" android:layout_height="wrap_content" android:hint="6-20位密码" + android:inputType="textPassword" style="@style/register_hint_style" android:maxLength="20" android:textColorHint="@color/colorTransparent" @@ -215,6 +217,7 @@ android:layout_height="wrap_content" android:hint="请再次输入一遍密码" android:maxLength="20" + android:inputType="textPassword" style="@style/register_hint_style" android:textColorHint="@color/colorTransparent" android:textCursorDrawable="@drawable/text_color" diff --git a/app/src/main/res/xml/file_paths.xml b/app/src/main/res/xml/file_paths.xml index bb50317..82a2442 100644 --- a/app/src/main/res/xml/file_paths.xml +++ b/app/src/main/res/xml/file_paths.xml @@ -1,6 +1,5 @@ - - - \ No newline at end of file + + + +