diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_list.xml b/app/src/main/res/layout/fragment_person_list.xml new file mode 100644 index 0000000..61cb334 --- /dev/null +++ b/app/src/main/res/layout/fragment_person_list.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_list.xml b/app/src/main/res/layout/fragment_person_list.xml new file mode 100644 index 0000000..61cb334 --- /dev/null +++ b/app/src/main/res/layout/fragment_person_list.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_map.xml b/app/src/main/res/layout/fragment_person_map.xml new file mode 100644 index 0000000..ac8cd4e --- /dev/null +++ b/app/src/main/res/layout/fragment_person_map.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_list.xml b/app/src/main/res/layout/fragment_person_list.xml new file mode 100644 index 0000000..61cb334 --- /dev/null +++ b/app/src/main/res/layout/fragment_person_list.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_map.xml b/app/src/main/res/layout/fragment_person_map.xml new file mode 100644 index 0000000..ac8cd4e --- /dev/null +++ b/app/src/main/res/layout/fragment_person_map.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popu_person.xml b/app/src/main/res/layout/popu_person.xml new file mode 100644 index 0000000..fdebb06 --- /dev/null +++ b/app/src/main/res/layout/popu_person.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_list.xml b/app/src/main/res/layout/fragment_person_list.xml new file mode 100644 index 0000000..61cb334 --- /dev/null +++ b/app/src/main/res/layout/fragment_person_list.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_map.xml b/app/src/main/res/layout/fragment_person_map.xml new file mode 100644 index 0000000..ac8cd4e --- /dev/null +++ b/app/src/main/res/layout/fragment_person_map.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popu_person.xml b/app/src/main/res/layout/popu_person.xml new file mode 100644 index 0000000..fdebb06 --- /dev/null +++ b/app/src/main/res/layout/popu_person.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xhdpi/off_line.png b/app/src/main/res/mipmap-xhdpi/off_line.png new file mode 100644 index 0000000..c075500 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/off_line.png Binary files differ diff --git a/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java new file mode 100644 index 0000000..30dcb41 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/bean/PointPersonBean.java @@ -0,0 +1,61 @@ +package com.casic.dcms.bean; + +import com.esri.arcgisruntime.geometry.Point; + +public class PointPersonBean { + private String personName; + private String personPhone; + private String personDept; + private String pointTime; + private Point point; + private boolean onLine; + + + public String getPersonName() { + return personName; + } + + public void setPersonName(String personName) { + this.personName = personName; + } + + public String getPersonPhone() { + return personPhone; + } + + public void setPersonPhone(String personPhone) { + this.personPhone = personPhone; + } + + public String getPersonDept() { + return personDept; + } + + public void setPersonDept(String personDept) { + this.personDept = personDept; + } + + public String getPointTime() { + return pointTime; + } + + public void setPointTime(String pointTime) { + this.pointTime = pointTime; + } + + public Point getPoint() { + return point; + } + + public void setPoint(Point point) { + this.point = point; + } + + public boolean isOnLine() { + return onLine; + } + + public void setOnLine(boolean onLine) { + this.onLine = onLine; + } +} diff --git a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java index caf3c8a..2815fce 100644 --- a/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/ArcGISMapActivity.java @@ -96,7 +96,7 @@ ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); //创建底图、并设置底图图层 - ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_NO_SERVICE_URL); + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); Basemap basemap = new Basemap(baseLayer); arcGISMap.setBasemap(basemap); mapView.setMap(arcGISMap); @@ -120,14 +120,14 @@ ServiceFeatureTable pointFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/0"); pointFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); pointLayer = new FeatureLayer(pointFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, pointLayer)); + arcGISMap.getOperationalLayers().add(pointLayer); break; case "三包上报": //门前三包 (ID: 1) ServiceFeatureTable packageFeatureTable = new ServiceFeatureTable(Constant.COMPONENT_SERVICE_URL + "/1"); packageFeatureTable.setFeatureRequestMode(ServiceFeatureTable.FeatureRequestMode.ON_INTERACTION_NO_CACHE); packageLayer = new FeatureLayer(packageFeatureTable); - arcGISMap.getOperationalLayers().addAll(Arrays.asList(communityLayer, packageLayer)); + arcGISMap.getOperationalLayers().add(packageLayer); break; } mapView.setMap(arcGISMap); diff --git a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java index 09fbc75..5e73969 100644 --- a/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/CaseVerifyDetailActivity.java @@ -132,7 +132,7 @@ private String eorc; private String typeCode; private String typeDetailCode; - private String gridId; + private String gridId;//可能来自案卷详情,也可能来自地图选点 private double longitude, latitude; private String changeState; private MediaPlayer mediaPlayer; @@ -184,6 +184,15 @@ // Log.d(TAG, "obtainCaseDetailData: " + gson.toJson(resultBean)); if (resultBean.isSuccess()) { this.data = resultBean.getData().get(0); + this.gridId = data.getGridId(); + String lng = data.getLng(); + if (!TextUtils.isEmpty(lng)) { + this.longitude = Double.parseDouble(lng); + } + String lat = data.getLat(); + if (!TextUtils.isEmpty(lat)) { + this.latitude = Double.parseDouble(lat); + } caseNumberView.setText(data.getCaseid()); caseTypeView.setText(data.getEorcName()); caseLargeTypeView.setText(data.getCasetypeName()); diff --git a/app/src/main/java/com/casic/dcms/ui/MainActivity.java b/app/src/main/java/com/casic/dcms/ui/MainActivity.java index 1230410..138baf9 100644 --- a/app/src/main/java/com/casic/dcms/ui/MainActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/MainActivity.java @@ -91,15 +91,15 @@ if (TextUtils.isEmpty(imei)) { return; } + //根据条件上传位置信息 LocationHelper.obtainCurrentLocation(this, new ILocationListener() { @Override public void onLocationGet(Location location) { if (location != null) { + Log.d(TAG, "onLocationGet: 位置上报"); uploadPositionPresenter.onReadyRetrofitRequest(imei, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())); - } else { - Log.d(TAG, "onLocationGet: location is null"); } } }); diff --git a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java index fae1753..a26159c 100644 --- a/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java +++ b/app/src/main/java/com/casic/dcms/ui/PersonOnlineActivity.java @@ -1,37 +1,37 @@ package com.casic.dcms.ui; +import android.content.Context; import android.view.View; -import android.widget.ExpandableListView; +import android.widget.LinearLayout; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import com.casic.dcms.R; -import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.adapter.SubViewPagerAdapter; import com.casic.dcms.base.BaseActivity; -import com.casic.dcms.bean.OnlinePersonBean; -import com.casic.dcms.bean.PersonBean; -import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; -import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.ui.fragment.PersonOnLineFragment; +import com.casic.dcms.ui.fragment.PersonOnMapFragment; +import com.casic.dcms.widgets.NoScrollViewPager; +import com.google.android.material.tabs.TabLayout; import com.qmuiteam.qmui.widget.QMUITopBarLayout; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import butterknife.BindView; -public class PersonOnlineActivity extends BaseActivity implements IPersonOnlineView { +public class PersonOnlineActivity extends BaseActivity { - @BindView(R.id.onlineTopLayout) - QMUITopBarLayout onlineTopLayout; - @BindView(R.id.deptTreeView) - ExpandableListView deptTreeView; + private static final String[] pageTitles = {"人员分布", "人员列表"}; + @BindView(R.id.personTopLayout) + QMUITopBarLayout personTopLayout; + @BindView(R.id.personTabLayout) + TabLayout personTabLayout; + @BindView(R.id.personViewPager) + NoScrollViewPager personViewPager; - private PersonOnlinePresenterImpl onlinePresenter; - private HashSet deptSet = new HashSet<>(); - private List deptList = new ArrayList<>();//部门名集合 - private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 - private OnlinePersonAdapter onlinePersonAdapter; + private Context context = this; @Override public int initLayoutView() { @@ -40,9 +40,9 @@ @Override protected void setupTopBarLayout() { - onlineTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); - onlineTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); - onlineTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { + personTopLayout.setTitle("在岗人员").setTextColor(ContextCompat.getColor(this, R.color.white)); + personTopLayout.setBackgroundColor(ContextCompat.getColor(this, R.color.mainThemeColor)); + personTopLayout.addLeftImageButton(R.drawable.ic_left_white, 1).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); @@ -52,55 +52,20 @@ @Override public void initData() { - onlinePresenter = new PersonOnlinePresenterImpl(this); - onlinePresenter.onReadyRetrofitRequest("", "", ""); - onlinePersonAdapter = new OnlinePersonAdapter(this); + List fragmentList = new ArrayList<>(); + fragmentList.add(new PersonOnMapFragment()); + fragmentList.add(new PersonOnLineFragment()); + SubViewPagerAdapter adapter = new SubViewPagerAdapter(getSupportFragmentManager(), pageTitles, fragmentList); + personViewPager.setAdapter(adapter); + //绑定TabLayout + personTabLayout.setupWithViewPager(personViewPager); + LinearLayout linearLayout = (LinearLayout) personTabLayout.getChildAt(0); + linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE); + linearLayout.setDividerDrawable(ContextCompat.getDrawable(context, R.drawable.layout_divider_vertical)); } @Override public void initEvent() { } - - @Override - public void onlineResult(OnlinePersonBean resultBean) { - if (resultBean.isSuccess()) { - List dataBeans = resultBean.getData(); - deptList.clear(); - for (OnlinePersonBean.DataBean bean : dataBeans) { - deptSet.add(bean.getDeptName()); - } - //hashSet去重然后转List - deptList = new ArrayList<>(deptSet); - if (deptList.size() > 0) { - deptAndPersons.clear(); - for (String title : deptList) { - List beanList = new ArrayList<>(); - for (OnlinePersonBean.DataBean dataBean : dataBeans) { - if (title.equals(dataBean.getDeptName())) { - PersonBean personBean = new PersonBean(); - personBean.setPersonDept(dataBean.getDeptName()); - personBean.setPersonName(dataBean.getName()); - personBean.setPersonPhone(dataBean.getPhone()); - personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); - personBean.setOnLine(dataBean.isOnLine()); - - beanList.add(personBean); - } - } - deptAndPersons.add(beanList); - } - onlinePersonAdapter.setData(deptList, deptAndPersons); - deptTreeView.setAdapter(onlinePersonAdapter); - } - } - } - - @Override - protected void onDestroy() { - super.onDestroy(); - if (onlinePresenter != null) { - onlinePresenter.disposeRetrofitRequest(); - } - } } diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java new file mode 100644 index 0000000..434dcb8 --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnLineFragment.java @@ -0,0 +1,95 @@ +package com.casic.dcms.ui.fragment; + +import android.content.Context; +import android.widget.ExpandableListView; + +import com.casic.dcms.R; +import com.casic.dcms.adapter.OnlinePersonAdapter; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; + +import butterknife.BindView; + +public class PersonOnLineFragment extends BaseFragment implements IPersonOnlineView { + + @BindView(R.id.deptTreeView) + ExpandableListView deptTreeView; + + private Context context; + private PersonOnlinePresenterImpl onlinePresenter; + private HashSet deptSet = new HashSet<>(); + private List deptList = new ArrayList<>();//部门名集合 + private List> deptAndPersons = new ArrayList<>();//个人信息集合的集合 + private OnlinePersonAdapter onlinePersonAdapter; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_list; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + onlinePersonAdapter = new OnlinePersonAdapter(context); + } + + @Override + public void initEvent() { + + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + deptList.clear(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + deptSet.add(bean.getDeptName()); + } + //hashSet去重然后转List + deptList = new ArrayList<>(deptSet); + if (deptList.size() > 0) { + deptAndPersons.clear(); + for (String title : deptList) { + List beanList = new ArrayList<>(); + for (OnlinePersonBean.DataBean dataBean : dataBeans) { + if (title.equals(dataBean.getDeptName())) { + PersonBean personBean = new PersonBean(); + personBean.setPersonDept(dataBean.getDeptName()); + personBean.setPersonName(dataBean.getName()); + personBean.setPersonPhone(dataBean.getPhone()); + personBean.setLastTimeFmt(dataBean.getLastTimeFmt()); + personBean.setOnLine(dataBean.isOnLine()); + + beanList.add(personBean); + } + } + deptAndPersons.add(beanList); + } + onlinePersonAdapter.setData(deptList, deptAndPersons); + deptTreeView.setAdapter(onlinePersonAdapter); + } + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java new file mode 100644 index 0000000..4fb14da --- /dev/null +++ b/app/src/main/java/com/casic/dcms/ui/fragment/PersonOnMapFragment.java @@ -0,0 +1,236 @@ +package com.casic.dcms.ui.fragment; + +import android.annotation.SuppressLint; +import android.content.Context; +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.drawable.BitmapDrawable; +import android.os.Handler; +import android.os.Message; +import android.text.TextUtils; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.casic.dcms.R; +import com.casic.dcms.base.BaseFragment; +import com.casic.dcms.bean.OnlinePersonBean; +import com.casic.dcms.bean.PointPersonBean; +import com.casic.dcms.mvp.presenter.PersonOnlinePresenterImpl; +import com.casic.dcms.mvp.view.IPersonOnlineView; +import com.casic.dcms.utils.Constant; +import com.casic.dcms.utils.ToastHelper; +import com.esri.arcgisruntime.concurrent.ListenableFuture; +import com.esri.arcgisruntime.geometry.Point; +import com.esri.arcgisruntime.layers.ArcGISTiledLayer; +import com.esri.arcgisruntime.mapping.ArcGISMap; +import com.esri.arcgisruntime.mapping.Basemap; +import com.esri.arcgisruntime.mapping.BasemapStyle; +import com.esri.arcgisruntime.mapping.view.DefaultMapViewOnTouchListener; +import com.esri.arcgisruntime.mapping.view.Graphic; +import com.esri.arcgisruntime.mapping.view.GraphicsOverlay; +import com.esri.arcgisruntime.mapping.view.IdentifyGraphicsOverlayResult; +import com.esri.arcgisruntime.mapping.view.MapView; +import com.esri.arcgisruntime.symbology.PictureMarkerSymbol; +import com.esri.arcgisruntime.util.ListenableList; +import com.qmuiteam.qmui.util.QMUIDisplayHelper; +import com.qmuiteam.qmui.widget.popup.QMUIPopup; +import com.qmuiteam.qmui.widget.popup.QMUIPopups; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ExecutionException; + +import butterknife.BindView; + +public class PersonOnMapFragment extends BaseFragment implements IPersonOnlineView { + + private static final String TAG = "PersonOnMapFragment"; + @BindView(R.id.mapView) + MapView mapView; + + private PersonOnlinePresenterImpl onlinePresenter; + private ListenableList graphicsOverlays; + private Resources resources; + private Context context; + private List personBeans; + private WeakReferenceHandler weakReferenceHandler; + + @Override + public int initLayoutView() { + return R.layout.fragment_person_map; + } + + @Override + protected void setupTopBarLayout() { + context = getContext(); + resources = context.getResources(); + } + + @Override + public void initData() { + onlinePresenter = new PersonOnlinePresenterImpl(this); + onlinePresenter.onReadyRetrofitRequest("", "", ""); + + mapView.setAttributionTextVisible(false);//去掉左下角属性标识 + mapView.setViewpointScaleAsync(32000); + + ArcGISMap arcGISMap = new ArcGISMap(BasemapStyle.ARCGIS_STREETS); + //创建底图、并设置底图图层 + ArcGISTiledLayer baseLayer = new ArcGISTiledLayer(Constant.BASE_MAP_SERVICE_URL); + Basemap basemap = new Basemap(baseLayer); + arcGISMap.setBasemap(basemap); + mapView.setMap(arcGISMap); + + graphicsOverlays = mapView.getGraphicsOverlays(); + weakReferenceHandler = new WeakReferenceHandler(this); + } + + @SuppressLint("ClickableViewAccessibility") + @Override + public void initEvent() { + mapView.setOnTouchListener(new DefaultMapViewOnTouchListener(context, mapView) { + @Override + public boolean onSingleTapConfirmed(MotionEvent e) { + android.graphics.Point screenPoint = new android.graphics.Point(Math.round(e.getX()), Math.round(e.getY())); + final ListenableFuture> overlaysAsync = mMapView.identifyGraphicsOverlaysAsync(screenPoint, 10.0, false, 1); + overlaysAsync.addDoneListener(new Runnable() { + @Override + public void run() { + try { + List overlayResultList = overlaysAsync.get(); + if (!overlayResultList.isEmpty()) { + IdentifyGraphicsOverlayResult identifyResult = overlayResultList.get(0); + Point point = identifyResult.getGraphicsOverlay().getExtent().getCenter(); + for (PointPersonBean dataBean : personBeans) { + Point beanPoint = dataBean.getPoint(); + if (Math.abs(beanPoint.getX() - point.getX()) <= Constant.DELTA_LNG_10 && + Math.abs(beanPoint.getY() - point.getY()) <= Constant.DELTA_LAT_10) { + Message message = weakReferenceHandler.obtainMessage(); + message.what = 2021051901; + message.obj = dataBean; + weakReferenceHandler.sendMessage(message); + } + } + } else { + weakReferenceHandler.sendEmptyMessage(2021051902); + } + } catch (InterruptedException | ExecutionException e) { + e.printStackTrace(); + } + } + }); + return super.onSingleTapConfirmed(e); + } + }); + } + + private static class WeakReferenceHandler extends Handler { + private WeakReference reference; + + private WeakReferenceHandler(PersonOnMapFragment mapFragment) { + reference = new WeakReference<>(mapFragment); + } + + @Override + public void handleMessage(@NonNull Message msg) { + super.handleMessage(msg); + PersonOnMapFragment mapFragment = reference.get(); + Context context = mapFragment.context; + switch (msg.what) { + case 2021051901: + PointPersonBean dataBean = (PointPersonBean) msg.obj; + View popupView = LayoutInflater.from(context).inflate(R.layout.popu_person, null); + TextView userNameView = popupView.findViewById(R.id.userNameView); + TextView deptNameView = popupView.findViewById(R.id.deptNameView); + TextView phoneNumberView = popupView.findViewById(R.id.phoneNumberView); + TextView lastTimeView = popupView.findViewById(R.id.lastTimeView); + + userNameView.setText(dataBean.getPersonName()); + deptNameView.setText(dataBean.getPersonDept()); + phoneNumberView.setText(dataBean.getPersonPhone()); + lastTimeView.setText(dataBean.getPointTime()); + + QMUIPopups.popup(context, QMUIDisplayHelper.dp2px(context, 250)) + .preferredDirection(QMUIPopup.DIRECTION_BOTTOM) + .view(popupView) + .edgeProtection(QMUIDisplayHelper.dp2px(context, 20)) + .dimAmount(0.6f) + .animStyle(QMUIPopup.ANIM_GROW_FROM_CENTER) + .onDismiss(null) + .show(mapFragment.mapView); + break; + case 2021051902: + ToastHelper.showToast("附近无工作人员,请重新选点", ToastHelper.WARING); + break; + default: + break; + } + } + } + + @Override + public void onlineResult(OnlinePersonBean resultBean) { + if (resultBean.isSuccess()) { + List dataBeans = resultBean.getData(); + if (dataBeans.size() >= 1) { + personBeans = new ArrayList<>(); + for (OnlinePersonBean.DataBean bean : dataBeans) { + String lng = bean.getPositionLng(); + String lat = bean.getPositionLat(); + if (TextUtils.isEmpty(lng) || TextUtils.isEmpty(lat)) { + Log.d(TAG, "案卷经纬度异常"); + } else { + PointPersonBean personBean = new PointPersonBean(); + personBean.setPersonName(bean.getName()); + personBean.setPersonPhone(bean.getPhone()); + personBean.setPersonDept(bean.getDeptName()); + personBean.setPointTime(bean.getLastTimeFmt()); + personBean.setOnLine(bean.isOnLine()); + personBean.setPoint(new Point(Double.parseDouble(lng), Double.parseDouble(lat), mapView.getSpatialReference())); + + personBeans.add(personBean); + } + } + addPictureMarker(personBeans); + } else { + ToastHelper.showToast("当前没有人员在线", ToastHelper.ERROR); + } + } + } + + private void addPictureMarker(List personBeans) { + Bitmap caseBitmap; + for (PointPersonBean bean : personBeans) { + if (bean.isOnLine()) { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.on_line); + } else { + caseBitmap = BitmapFactory.decodeResource(resources, R.mipmap.off_line); + } + BitmapDrawable caseDrawable = new BitmapDrawable(resources, caseBitmap); + PictureMarkerSymbol pictureMarker = new PictureMarkerSymbol(caseDrawable); + pictureMarker.setWidth(64); + pictureMarker.setHeight(42); + pictureMarker.loadAsync();//异步加载Marker,防止阻塞 + + GraphicsOverlay graphicsOverlay = new GraphicsOverlay(); + ListenableList graphics = graphicsOverlay.getGraphics(); + graphics.add(new Graphic(bean.getPoint(), pictureMarker)); + graphicsOverlays.add(graphicsOverlay); + } + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + if (onlinePresenter != null) { + onlinePresenter.disposeRetrofitRequest(); + } + } +} diff --git a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java index 33b95da..2fe93d1 100644 --- a/app/src/main/java/com/casic/dcms/utils/LocationHelper.java +++ b/app/src/main/java/com/casic/dcms/utils/LocationHelper.java @@ -7,7 +7,6 @@ import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; -import android.text.TextUtils; import androidx.core.app.ActivityCompat; @@ -33,9 +32,6 @@ return; } LocationManager mLocationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); - //首次定位 - Location location = mLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); - listener.onLocationGet(location); //位置变化时更新位置 mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 30 * 1000, 10, new LocationListener() { @Override diff --git a/app/src/main/res/drawable/dash_line.xml b/app/src/main/res/drawable/dash_line.xml new file mode 100644 index 0000000..514e788 --- /dev/null +++ b/app/src/main/res/drawable/dash_line.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_case_check_detail.xml b/app/src/main/res/layout/activity_case_check_detail.xml index 5322d70..9fefd0e 100644 --- a/app/src/main/res/layout/activity_case_check_detail.xml +++ b/app/src/main/res/layout/activity_case_check_detail.xml @@ -96,7 +96,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_checked_detail.xml b/app/src/main/res/layout/activity_case_checked_detail.xml index d513b5d..aca3c79 100644 --- a/app/src/main/res/layout/activity_case_checked_detail.xml +++ b/app/src/main/res/layout/activity_case_checked_detail.xml @@ -100,7 +100,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handle_detail.xml b/app/src/main/res/layout/activity_case_handle_detail.xml index bfcfb40..2f8cf65 100644 --- a/app/src/main/res/layout/activity_case_handle_detail.xml +++ b/app/src/main/res/layout/activity_case_handle_detail.xml @@ -57,7 +57,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_handled_detail.xml b/app/src/main/res/layout/activity_case_handled_detail.xml index 4efc380..df9032a 100644 --- a/app/src/main/res/layout/activity_case_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_handled_detail.xml @@ -261,7 +261,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_detail.xml b/app/src/main/res/layout/activity_case_todo_detail.xml index 84e744f..224da68 100644 --- a/app/src/main/res/layout/activity_case_todo_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_detail.xml @@ -170,7 +170,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_todo_handled_detail.xml b/app/src/main/res/layout/activity_case_todo_handled_detail.xml index 88e72b4..2879e91 100644 --- a/app/src/main/res/layout/activity_case_todo_handled_detail.xml +++ b/app/src/main/res/layout/activity_case_todo_handled_detail.xml @@ -258,7 +258,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verified_detail.xml b/app/src/main/res/layout/activity_case_verified_detail.xml index 35926f3..869bb8f 100644 --- a/app/src/main/res/layout/activity_case_verified_detail.xml +++ b/app/src/main/res/layout/activity_case_verified_detail.xml @@ -101,7 +101,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_case_verify_detail.xml b/app/src/main/res/layout/activity_case_verify_detail.xml index 3343b3e..c8ef3a8 100644 --- a/app/src/main/res/layout/activity_case_verify_detail.xml +++ b/app/src/main/res/layout/activity_case_verify_detail.xml @@ -132,7 +132,6 @@ android:paddingVertical="5dp" android:text="播放录音" android:textColor="@color/white" - android:textSize="@dimen/titleFontSize" android:visibility="gone" app:qmui_backgroundColor="@color/mainThemeColor" app:qmui_radius="5dp" /> diff --git a/app/src/main/res/layout/activity_online.xml b/app/src/main/res/layout/activity_online.xml index 8f63d98..00c5e2a 100644 --- a/app/src/main/res/layout/activity_online.xml +++ b/app/src/main/res/layout/activity_online.xml @@ -1,17 +1,36 @@ - + android:layout_height="match_parent" + android:orientation="vertical"> + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_list.xml b/app/src/main/res/layout/fragment_person_list.xml new file mode 100644 index 0000000..61cb334 --- /dev/null +++ b/app/src/main/res/layout/fragment_person_list.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_person_map.xml b/app/src/main/res/layout/fragment_person_map.xml new file mode 100644 index 0000000..ac8cd4e --- /dev/null +++ b/app/src/main/res/layout/fragment_person_map.xml @@ -0,0 +1,11 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/popu_person.xml b/app/src/main/res/layout/popu_person.xml new file mode 100644 index 0000000..fdebb06 --- /dev/null +++ b/app/src/main/res/layout/popu_person.xml @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-xhdpi/off_line.png b/app/src/main/res/mipmap-xhdpi/off_line.png new file mode 100644 index 0000000..c075500 --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/off_line.png Binary files differ diff --git a/app/src/main/res/mipmap-xhdpi/on_line.png b/app/src/main/res/mipmap-xhdpi/on_line.png new file mode 100644 index 0000000..9440b1b --- /dev/null +++ b/app/src/main/res/mipmap-xhdpi/on_line.png Binary files differ