|
@@ -1,6 +1,7 @@
|
|
package com.sjkj.appthreefloor_tsgz.fragment;
|
|
package com.sjkj.appthreefloor_tsgz.fragment;
|
|
|
|
|
|
import android.os.Bundle;
|
|
import android.os.Bundle;
|
|
|
|
+import android.os.Handler;
|
|
import android.util.Log;
|
|
import android.util.Log;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
@@ -13,28 +14,32 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
|
import com.amap.api.maps.CameraUpdate;
|
|
import com.amap.api.maps.CameraUpdate;
|
|
import com.amap.api.maps.CameraUpdateFactory;
|
|
import com.amap.api.maps.CameraUpdateFactory;
|
|
|
|
+import com.amap.api.maps.model.BitmapDescriptorFactory;
|
|
import com.amap.api.maps.model.CameraPosition;
|
|
import com.amap.api.maps.model.CameraPosition;
|
|
import com.amap.api.maps.model.LatLng;
|
|
import com.amap.api.maps.model.LatLng;
|
|
|
|
+import com.amap.api.maps.model.MarkerOptions;
|
|
import com.hjq.permissions.OnPermissionCallback;
|
|
import com.hjq.permissions.OnPermissionCallback;
|
|
import com.hjq.permissions.Permission;
|
|
import com.hjq.permissions.Permission;
|
|
import com.hjq.permissions.XXPermissions;
|
|
import com.hjq.permissions.XXPermissions;
|
|
import com.sjkj.appthreefloor_tsgz.R;
|
|
import com.sjkj.appthreefloor_tsgz.R;
|
|
import com.sjkj.appthreefloor_tsgz.adapter.RecycleviewLeftAdapter;
|
|
import com.sjkj.appthreefloor_tsgz.adapter.RecycleviewLeftAdapter;
|
|
import com.sjkj.appthreefloor_tsgz.adapter.RecycleviewRightAdapter;
|
|
import com.sjkj.appthreefloor_tsgz.adapter.RecycleviewRightAdapter;
|
|
|
|
+import com.sjkj.appthreefloor_tsgz.app.App;
|
|
import com.sjkj.appthreefloor_tsgz.bean.CommonDateBean;
|
|
import com.sjkj.appthreefloor_tsgz.bean.CommonDateBean;
|
|
import com.sjkj.appthreefloor_tsgz.bean.ResourcesListBean;
|
|
import com.sjkj.appthreefloor_tsgz.bean.ResourcesListBean;
|
|
import com.sjkj.appthreefloor_tsgz.databinding.FragmentEventNearbyBinding;
|
|
import com.sjkj.appthreefloor_tsgz.databinding.FragmentEventNearbyBinding;
|
|
import com.sjkj.appthreefloor_tsgz.fragment.viewModel.EventFargmentViewModel;
|
|
import com.sjkj.appthreefloor_tsgz.fragment.viewModel.EventFargmentViewModel;
|
|
-import com.sjkj.appthreefloor_tsgz.utils.JsonUtil;
|
|
|
|
|
|
+import com.sjkj.appthreefloor_tsgz.net.EventDetailsResourcesListRequest;
|
|
|
|
+import com.sjkj.appthreefloor_tsgz.net.EventResourcesListRequest;
|
|
import com.sjkj.base_lib.app.AppManager;
|
|
import com.sjkj.base_lib.app.AppManager;
|
|
-import com.sjkj.base_lib.utils.Constants;
|
|
|
|
|
|
+import com.sjkj.base_lib.entity.Params;
|
|
|
|
+import com.sjkj.base_lib.net.domain.interactor.ProcessErrorSubscriber;
|
|
|
|
+import com.sjkj.base_lib.utils.CommonUtils;
|
|
|
|
+import com.sjkj.base_lib.utils.LocationUtils;
|
|
|
|
+import com.sjkj.base_lib.utils.MapUtils;
|
|
import com.sjkj.base_lib.utils.ToastUtils;
|
|
import com.sjkj.base_lib.utils.ToastUtils;
|
|
import com.sjkj.base_lib.view.BaseFragment;
|
|
import com.sjkj.base_lib.view.BaseFragment;
|
|
|
|
|
|
-import org.json.JSONArray;
|
|
|
|
-import org.json.JSONException;
|
|
|
|
-import org.json.JSONObject;
|
|
|
|
-
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
@@ -48,7 +53,13 @@ public class EventNearByFragment extends BaseFragment {
|
|
private List<CommonDateBean> resourceSelectList = new ArrayList<>();
|
|
private List<CommonDateBean> resourceSelectList = new ArrayList<>();
|
|
ResourcesListBean resourcesListBean;
|
|
ResourcesListBean resourcesListBean;
|
|
CommonDateBean commonDateBean;
|
|
CommonDateBean commonDateBean;
|
|
- private List<String> distance = new ArrayList<>();
|
|
|
|
|
|
+ private List<String> distanceList = new ArrayList<>();
|
|
|
|
+ private EventDetailsResourcesListRequest ResourcesListRequest = new EventDetailsResourcesListRequest(App.getInstance());
|
|
|
|
+ private EventResourcesListRequest eventResourcesListRequest = new EventResourcesListRequest(App.getInstance());
|
|
|
|
+ List<CommonDateBean> DistancelistChoose = new ArrayList<>();
|
|
|
|
+ private Handler handler = new Handler();
|
|
|
|
+ private String tagVale = "";
|
|
|
|
+ private String tagValeText = "";
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected int initLayout() {
|
|
protected int initLayout() {
|
|
@@ -68,10 +79,57 @@ public class EventNearByFragment extends BaseFragment {
|
|
binding.mapView.getMap().getUiSettings().setZoomControlsEnabled(true);
|
|
binding.mapView.getMap().getUiSettings().setZoomControlsEnabled(true);
|
|
binding.mapView.getMap().getUiSettings().setMyLocationButtonEnabled(false);
|
|
binding.mapView.getMap().getUiSettings().setMyLocationButtonEnabled(false);
|
|
//binding.mapView.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(43.911535, 125.324667), zoomValue));
|
|
//binding.mapView.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(43.911535, 125.324667), zoomValue));
|
|
- changeCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(Constants.DEFAULT_LOCATION_LAT, Constants.DEFAULT_LOCATION_LNG, true), 10, 30, 30)));
|
|
|
|
|
|
+ viewModel.getMessage().observe(getViewLifecycleOwner(), message -> {
|
|
|
|
+ // 处理消息
|
|
|
|
+ binding.tvTitle.setText(message.getEventName());
|
|
|
|
+ viewModel.eventType.set(message.getEventType());
|
|
|
|
+
|
|
|
|
+ viewModel.latitude.set(Double.parseDouble(message.getLatitude()));
|
|
|
|
+ viewModel.longitude.set(Double.parseDouble(message.getLongitude()));
|
|
|
|
+ changeCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(Double.parseDouble(message.getLatitude()), Double.parseDouble(message.getLongitude()), true), 10, 30, 30)));
|
|
|
|
+ LoadListData(message.getEventType(), viewModel.latitude.get(), viewModel.longitude.get());
|
|
|
|
+ });
|
|
|
|
+
|
|
return binding.getRoot();
|
|
return binding.getRoot();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void LoadListData(String eventType, Double lat, Double log) {
|
|
|
|
+
|
|
|
|
+ Params params = new Params();
|
|
|
|
+ params.put("typeId", eventType);
|
|
|
|
+ ResourcesListRequest.setParams(params);
|
|
|
|
+ ResourcesListRequest.execute(new ProcessErrorSubscriber<List<ResourcesListBean>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(Throwable e) {
|
|
|
|
+ super.onError(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onNext(List<ResourcesListBean> list) {
|
|
|
|
+ super.onNext(list);
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
+ //多加一条
|
|
|
|
+ ResourcesListBean bean = new ResourcesListBean();
|
|
|
|
+ bean.setName("范围选择");
|
|
|
|
+ bean.setValue("zidingyi");
|
|
|
|
+ resourceSelectTextList.add(bean);
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+ resourcesListBean = new ResourcesListBean();
|
|
|
|
+ resourcesListBean.setValue(list.get(i).getValue());
|
|
|
|
+ resourcesListBean.setName(list.get(i).getName());
|
|
|
|
+ resourceSelectTextList.add(resourcesListBean);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ leftAdapter.refreshList(resourceSelectTextList);
|
|
|
|
+
|
|
|
|
+ // Log.d("zhr1121", resourceSelectTextList.get(1).getName());
|
|
|
|
+ LoadRightList(true, resourceSelectTextList.get(1).getValue(), resourceSelectTextList.get(1).getName(), lat, log, DistancelistChoose.get(rightAdapter.getCheckedPosition()).getName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域
|
|
* 根据动画按钮状态,调用函数animateCamera或moveCamera来改变可视区域
|
|
*/
|
|
*/
|
|
@@ -118,64 +176,24 @@ public class EventNearByFragment extends BaseFragment {
|
|
@Override
|
|
@Override
|
|
public void initView() {
|
|
public void initView() {
|
|
requestPermissionsLocation();
|
|
requestPermissionsLocation();
|
|
- distance.add("5km");
|
|
|
|
- distance.add("10km");
|
|
|
|
- distance.add("15km");
|
|
|
|
- distance.add("20km");
|
|
|
|
- distance.add("25km");
|
|
|
|
- distance.add("30km");
|
|
|
|
- distance.add("35km");
|
|
|
|
- distance.add("40km");
|
|
|
|
- distance.add("45km");
|
|
|
|
- distance.add("50km");
|
|
|
|
- //多加一条
|
|
|
|
- resourceSelectTextList.add(new ResourcesListBean("范围选择", "zidingyi"));
|
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
|
- String jsonString = JsonUtil.loadJSONFromAsset(getActivity(), "json_list.json");
|
|
|
|
- try {
|
|
|
|
- JSONObject jsonObject = new JSONObject(jsonString);
|
|
|
|
- jsonArray = jsonObject.getJSONArray("data");
|
|
|
|
- // 从这里你可以访问你的JSON数据,例如:jsonObject.getString("key");
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- for (int i = 0; i < jsonArray.length(); i++) {
|
|
|
|
-
|
|
|
|
- try {
|
|
|
|
- JSONObject obj = jsonArray.getJSONObject(i);
|
|
|
|
- resourcesListBean = new ResourcesListBean(obj.getString("name"), obj.getString("value"));
|
|
|
|
- resourceSelectTextList.add(resourcesListBean);
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-// //资源列表
|
|
|
|
-
|
|
|
|
- JSONArray jsonArray2 = new JSONArray();
|
|
|
|
- String jsonString2 = JsonUtil.loadJSONFromAsset(getActivity(), "json_list2.json");
|
|
|
|
- try {
|
|
|
|
- JSONObject jsonObject2 = new JSONObject(jsonString2);
|
|
|
|
- jsonArray2 = jsonObject2.getJSONArray("data");
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
|
+ distanceList.add("5");
|
|
|
|
+ distanceList.add("10");
|
|
|
|
+ distanceList.add("15");
|
|
|
|
+ distanceList.add("20");
|
|
|
|
+ distanceList.add("25");
|
|
|
|
+ distanceList.add("30");
|
|
|
|
+ distanceList.add("35");
|
|
|
|
+ distanceList.add("40");
|
|
|
|
+ distanceList.add("45");
|
|
|
|
+ distanceList.add("50");
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < distanceList.size(); i++) {
|
|
|
|
+ commonDateBean = new CommonDateBean();
|
|
|
|
+ commonDateBean.setType(1);
|
|
|
|
+ commonDateBean.setName(distanceList.get(i));
|
|
|
|
+ DistancelistChoose.add(commonDateBean);
|
|
}
|
|
}
|
|
- for (int i = 0; i < jsonArray2.length(); i++) {
|
|
|
|
|
|
|
|
- try {
|
|
|
|
- JSONObject obj = jsonArray2.getJSONObject(i);
|
|
|
|
- commonDateBean = new CommonDateBean();
|
|
|
|
- commonDateBean.setDistance(obj.getString("distance"));
|
|
|
|
- commonDateBean.setId(obj.getString("id"));
|
|
|
|
- commonDateBean.setLatitude(obj.getString("latitude"));
|
|
|
|
- commonDateBean.setLongitude(obj.getString("longitude"));
|
|
|
|
- commonDateBean.setName(obj.getString("name"));
|
|
|
|
- commonDateBean.setType(2);
|
|
|
|
- resourceSelectList.add(commonDateBean);
|
|
|
|
- } catch (JSONException e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
//左边recyclerview
|
|
//左边recyclerview
|
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
|
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getActivity());
|
|
@@ -188,15 +206,8 @@ public class EventNearByFragment extends BaseFragment {
|
|
binding.recyclerViewRight.smoothScrollToPosition(0);
|
|
binding.recyclerViewRight.smoothScrollToPosition(0);
|
|
LinearLayoutManager layoutManagerRight = new LinearLayoutManager(getActivity());
|
|
LinearLayoutManager layoutManagerRight = new LinearLayoutManager(getActivity());
|
|
binding.recyclerViewRight.setLayoutManager(layoutManagerRight);
|
|
binding.recyclerViewRight.setLayoutManager(layoutManagerRight);
|
|
- List<CommonDateBean> list = new ArrayList<>();
|
|
|
|
- for (int i = 0; i < distance.size(); i++) {
|
|
|
|
- commonDateBean = new CommonDateBean();
|
|
|
|
- commonDateBean.setType(1);
|
|
|
|
- commonDateBean.setName(distance.get(i));
|
|
|
|
- list.add(commonDateBean);
|
|
|
|
|
|
|
|
- }
|
|
|
|
- rightAdapter = new RecycleviewRightAdapter(getActivity(), list);
|
|
|
|
|
|
+ rightAdapter = new RecycleviewRightAdapter(getActivity(), DistancelistChoose);
|
|
binding.recyclerViewRight.setAdapter(rightAdapter);
|
|
binding.recyclerViewRight.setAdapter(rightAdapter);
|
|
rightAdapter.setCheckedPosition(0);
|
|
rightAdapter.setCheckedPosition(0);
|
|
rightAdapter.setOnItemClickListener(new RecycleviewRightAdapter.OnItemClickListener() {
|
|
rightAdapter.setOnItemClickListener(new RecycleviewRightAdapter.OnItemClickListener() {
|
|
@@ -205,7 +216,7 @@ public class EventNearByFragment extends BaseFragment {
|
|
if (type == rightAdapter.TYPE_ITEM_ONE) {
|
|
if (type == rightAdapter.TYPE_ITEM_ONE) {
|
|
rightAdapter.setCheckedPosition(position);
|
|
rightAdapter.setCheckedPosition(position);
|
|
} else {
|
|
} else {
|
|
- Log.d("zhr1111", bean.getName());
|
|
|
|
|
|
+ Log.d("zhr1111", bean.getName() + "===" + bean.getId() + tagVale + tagValeText);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -230,30 +241,154 @@ public class EventNearByFragment extends BaseFragment {
|
|
private void LoadZiYuanData(ResourcesListBean resourcesListBean) {
|
|
private void LoadZiYuanData(ResourcesListBean resourcesListBean) {
|
|
if (resourcesListBean.getValue().equals("zidingyi")) {
|
|
if (resourcesListBean.getValue().equals("zidingyi")) {
|
|
List<CommonDateBean> list = new ArrayList<>();
|
|
List<CommonDateBean> list = new ArrayList<>();
|
|
- for (int i = 0; i < distance.size(); i++) {
|
|
|
|
|
|
+ for (int i = 0; i < distanceList.size(); i++) {
|
|
commonDateBean = new CommonDateBean();
|
|
commonDateBean = new CommonDateBean();
|
|
commonDateBean.setType(1);
|
|
commonDateBean.setType(1);
|
|
- commonDateBean.setName(distance.get(i));
|
|
|
|
|
|
+ commonDateBean.setName(distanceList.get(i));
|
|
list.add(commonDateBean);
|
|
list.add(commonDateBean);
|
|
|
|
|
|
}
|
|
}
|
|
rightAdapter.refush(list);
|
|
rightAdapter.refush(list);
|
|
} else {
|
|
} else {
|
|
- rightAdapter.refush(resourceSelectList);
|
|
|
|
|
|
+
|
|
|
|
+ //根据左侧选中 加载右侧数据
|
|
|
|
+ LoadRightList(false, resourcesListBean.getValue(), resourcesListBean.getName(), viewModel.latitude.get(), viewModel.longitude.get(), DistancelistChoose.get(rightAdapter.getCheckedPosition()).getName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void LoadRightList(boolean isFirst, String tag, String tagText, Double latitude, Double longitude, String distance) {
|
|
|
|
+ tagVale = tag;
|
|
|
|
+ tagValeText = tagText;
|
|
|
|
+ if (isFirst) {
|
|
|
|
+ DistancelistChoose.clear();
|
|
|
|
+ for (int i = 0; i < distanceList.size(); i++) {
|
|
|
|
+ commonDateBean = new CommonDateBean();
|
|
|
|
+ commonDateBean.setType(1);
|
|
|
|
+ commonDateBean.setName(distanceList.get(i));
|
|
|
|
+ DistancelistChoose.add(commonDateBean);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ clear();//清除上一个图层
|
|
|
|
+ resourceSelectList.clear();
|
|
|
|
+ Params params = new Params();
|
|
|
|
+ params.put("tag", tag);
|
|
|
|
+ params.put("longitude", longitude);
|
|
|
|
+ params.put("latitude", latitude);
|
|
|
|
+ params.put("distance", distance);
|
|
|
|
+ eventResourcesListRequest.setParams(params);
|
|
|
|
+ eventResourcesListRequest.execute(new ProcessErrorSubscriber<List<CommonDateBean>>() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onError(Throwable e) {
|
|
|
|
+ super.onError(e);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onNext(List<CommonDateBean> list) {
|
|
|
|
+ super.onNext(list);
|
|
|
|
+ if (list != null && list.size() > 0) {
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < list.size(); i++) {
|
|
|
|
+
|
|
|
|
+ commonDateBean = new CommonDateBean();
|
|
|
|
+ commonDateBean.setDistance(list.get(i).getDistance());
|
|
|
|
+ commonDateBean.setId(list.get(i).getId());
|
|
|
|
+ commonDateBean.setLatitude(list.get(i).getLatitude());
|
|
|
|
+ commonDateBean.setLongitude(list.get(i).getLongitude());
|
|
|
|
+ commonDateBean.setName(list.get(i).getName());
|
|
|
|
+ commonDateBean.setType(2);
|
|
|
|
+ resourceSelectList.add(commonDateBean);
|
|
|
|
+ }
|
|
|
|
+ if (isFirst) {
|
|
|
|
+ rightAdapter.refush(DistancelistChoose);
|
|
|
|
+ } else {
|
|
|
|
+ rightAdapter.refush(resourceSelectList);
|
|
|
|
+ }
|
|
|
|
|
|
- rightAdapter.notifyDataSetChanged();
|
|
|
|
|
|
+ rightAdapter.notifyDataSetChanged();
|
|
|
|
+
|
|
|
|
+ new Thread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ handler.post(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ try {
|
|
|
|
+ for (CommonDateBean newList : list) {
|
|
|
|
+ if (CommonUtils.checkLongitudeLatitude(newList.getLongitude(), newList.getLatitude())) {
|
|
|
|
+ MapUtils.GPS gps = MapUtils.gps84_To_Gcj02(Double.parseDouble(newList.getLatitude()), Double.parseDouble(newList.getLongitude()));
|
|
|
|
+ if (gps != null) {
|
|
|
|
+ setLocationIcon(gps, newList.getId(), newList.getName() + "", newList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ changeCamera(CameraUpdateFactory.newCameraPosition(new CameraPosition(new LatLng(Double.parseDouble(list.get(list.size() - 1).getLatitude()), Double.parseDouble(list.get(list.size() - 1).getLongitude()), true), 10, 30, 30)));
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }).start();
|
|
|
|
+ } else {
|
|
|
|
+ //Log.d("zhr112", (leftAdapter.getSelectedPosition() == 0) + "");
|
|
|
|
+ if (leftAdapter.getSelectedPosition() == 0) {
|
|
|
|
+ rightAdapter.refush(DistancelistChoose);
|
|
|
|
+ } else {
|
|
|
|
+ rightAdapter.refush(new ArrayList<CommonDateBean>());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ToastUtils.show("暂无数据");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void initListener() {
|
|
public void initListener() {
|
|
|
|
|
|
|
|
+ binding.ivEventLocation.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View view) {
|
|
|
|
+ binding.ivLocation.setBackground(getResources().getDrawable(R.drawable.icon_current));
|
|
|
|
+ binding.ivEventLocation.setBackground(getResources().getDrawable(R.drawable.icon_event_current_select));
|
|
|
|
+ //根据事件的经纬度
|
|
|
|
+ LoadRightList(leftAdapter.getSelectedPosition() == 0, tagVale, tagValeText, viewModel.latitude.get(), viewModel.longitude.get(), DistancelistChoose.get(rightAdapter.getCheckedPosition()).getName());
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ binding.ivLocation.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View view) {
|
|
|
|
+ binding.ivLocation.setBackground(getResources().getDrawable(R.drawable.icon_current_select));
|
|
|
|
+ binding.ivEventLocation.setBackground(getResources().getDrawable(R.drawable.icon_event_current));
|
|
|
|
+ LocationUtils.getInstance().startLocation(true, new LocationUtils.OnLocationListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onLocationChanged(double lat, double lng, String address, int code) {
|
|
|
|
+
|
|
|
|
+ if (CommonUtils.checkLongitudeLatitude(lng + "", lat + "")) {
|
|
|
|
+ //根据当前经纬度
|
|
|
|
+ LoadRightList(leftAdapter.getSelectedPosition() == 0, tagVale, tagValeText, lat, lng, DistancelistChoose.get(rightAdapter.getCheckedPosition()).getName());
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ ToastUtils.show("定位失败,请检查定位权限或者稍后重试");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void loadData() {
|
|
public void loadData() {
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -284,6 +419,25 @@ public class EventNearByFragment extends BaseFragment {
|
|
public void onDestroyView() {
|
|
public void onDestroyView() {
|
|
super.onDestroyView();
|
|
super.onDestroyView();
|
|
binding.mapView.onDestroy();
|
|
binding.mapView.onDestroy();
|
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void clear() {
|
|
|
|
+ if (binding.mapView.getMap() != null)
|
|
|
|
+ binding.mapView.getMap().clear();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void setLocationIcon(MapUtils.GPS gps, String id, String type, CommonDateBean bean) {
|
|
|
|
+ MarkerOptions options = new MarkerOptions();
|
|
|
|
+ options.position(new LatLng(gps.getLat(), gps.getLon()));
|
|
|
|
+ options.visible(true);
|
|
|
|
+ options.snippet(id);
|
|
|
|
+ options.infoWindowEnable(false);
|
|
|
|
+ //options.title(bean.getName());
|
|
|
|
+ options.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_agriculture_cooperatives));//设置图标
|
|
|
|
+ binding.mapView.getMap().addMarker(options);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
}
|
|
}
|