| | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | /** |
| | | * Created by hjzhang on 2018/7/2. |
| | | */ |
| | | |
| | | public class MapActivity extends BaseActivity { |
| | | private TextView tv_left; |
| | | private TextView tv_left,tv_right; |
| | | private MapView bmapView; |
| | | private BaiduMap mBaiduMap; |
| | | BitmapDescriptor bdNormal = BitmapDescriptorFactory |
| | |
| | | private ImageView iv_close; |
| | | private LinearLayout ll_pop; |
| | | private DeviceBean curDeviceBean; |
| | | private Timer timer; |
| | | /** |
| | | * 计时器 |
| | | */ |
| | | private boolean isFinish = false; |
| | | private void showData() { |
| | | timer = new Timer(); |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | if(!isFinish){ |
| | | getData(false); |
| | | } |
| | | } |
| | | },0,10*1000); |
| | | } |
| | | @Override |
| | | protected void getBundleExtras(Bundle extras) { |
| | | |
| | |
| | | @Override |
| | | protected void initViews() { |
| | | tv_left = findView(R.id.tv_left); |
| | | tv_right = findView(R.id.tv_right); |
| | | bmapView = findView(R.id.bmapView); |
| | | popView = LayoutInflater.from(this).inflate(R.layout.pop_layout,null); |
| | | tv_name = popView.findViewById(R.id.tv_name); |
| | |
| | | startActivity(intent); |
| | | } |
| | | }); |
| | | tv_right.setOnClickListener(this); |
| | | } |
| | | |
| | | @Override |
| | | protected void initData() { |
| | | getData(); |
| | | getData(true); |
| | | showData(); |
| | | } |
| | | |
| | | @Override |
| | | protected void processClick(View view) { |
| | | switch (view.getId()){ |
| | | case R.id.tv_left: |
| | | finish(); |
| | | break; |
| | | case R.id.tv_right: |
| | | MainApp.theApp.mSharedPreferencesUtil.exitLogin(); |
| | | Intent intent = new Intent(MapActivity.this,LoginActivity.class); |
| | | startActivity(intent); |
| | | finish(); |
| | | break; |
| | | } |
| | |
| | | /** |
| | | * 标注地图 |
| | | */ |
| | | private void showMapData(){ |
| | | private void showMapData(boolean show){ |
| | | mBaiduMap.clear(); |
| | | MarkerOptions mo = null; |
| | | Marker mMarker = null; |
| | |
| | | .zIndex(i); |
| | | } |
| | | // 掉下动画 |
| | | mo.animateType(MarkerOptions.MarkerAnimateType.drop); |
| | | mo.animateType(MarkerOptions.MarkerAnimateType.grow); |
| | | mMarker = (Marker) (mBaiduMap.addOverlay(mo)); |
| | | mkList.add(mMarker); |
| | | } |
| | |
| | | bdC.recycle(); |
| | | super.onDestroy(); |
| | | bmapView.onDestroy(); |
| | | if(timer!=null){ |
| | | timer.cancel(); |
| | | timer =null; |
| | | } |
| | | } |
| | | |
| | | private void getData() { |
| | | private void getData(final boolean show) { |
| | | HashMap<String, String> params = new HashMap<>(); |
| | | params.put("organizationId", MainApp.theApp.orgId+""); |
| | | mHttpUtils.doGet(API.DEVICES, params, CacheMode.DEFAULT, true, new HttpCallBack() { |
| | | mHttpUtils.doGet(API.DEVICES, params, CacheMode.DEFAULT, show, new HttpCallBack() { |
| | | @Override |
| | | public void onSuccess(String res, String msg) { |
| | | if (progressDialog.isShowing()) { |
| | |
| | | deviceList.clear(); |
| | | deviceList.addAll(temp); |
| | | } |
| | | if(deviceList.size()>0){ |
| | | DeviceBean bean = deviceList.get(0); |
| | | LatLng ll = new LatLng(bean.getLatitude(), |
| | | bean.getLongitude()); |
| | | MapStatus.Builder builder = new MapStatus.Builder(); |
| | | builder.target(ll).zoom(18.0f); |
| | | mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); |
| | | if(show){ |
| | | if(deviceList.size()>0){ |
| | | DeviceBean bean = deviceList.get(0); |
| | | LatLng ll = new LatLng(bean.getLatitude(), |
| | | bean.getLongitude()); |
| | | MapStatus.Builder builder = new MapStatus.Builder(); |
| | | builder.target(ll).zoom(18.0f); |
| | | mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); |
| | | } |
| | | } |
| | | showMapData(); |
| | | showMapData(show); |
| | | } |
| | | |
| | | @Override |