addvoice
李富 9 years ago
parent f8e6f120ae
commit a1af215b35

@ -525,7 +525,11 @@ public class ChatActivity extends ParentWithNaviActivity implements ObseverListe
*/
public void sendLocationMessage(){
//测试数据真实数据需要从地图SDK中获取
startActivity(LocActivity.class , null, true);
Bundle bundle = new Bundle();
bundle.putSerializable("c", c);
startActivity(LocActivity.class , bundle, true);
/*BmobIMLocationMessage location =new BmobIMLocationMessage("广州番禺区",23.5,112.0);
Map<String,Object> map =new HashMap<>();
map.put("from", "百度地图");

@ -16,8 +16,11 @@ import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.map.MyLocationConfiguration;
import com.baidu.mapapi.map.MyLocationData;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import com.orhanobut.logger.Logger;
@ -43,13 +46,16 @@ public class LocActivity extends ParentWithNaviActivity{
BaiduMap mBaiduMap = null;
public LocationClient mLocationClient = null;
public BDLocationListener myListener = new MyLocationListener();
private LinkedList<LocationEntity> locationList = new LinkedList<LocationEntity>(); // 存放历史定位结果的链表最大存放当前结果的前5次定位结果
//BmobIMConversation c;
//ChatAdapter adapter;
private MyLocationData mylocdata = null;
private MyLocationData friendlocdata = null;
Toast loc_toast = null;
private LinkedList<LocationEntity> locationList = new LinkedList<LocationEntity>(); // 存放历史定位结果的链表最大存放当前结果的前5次定位结果
int exe_count = 0;
BmobIMConversation c;
ChatAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -60,23 +66,32 @@ public class LocActivity extends ParentWithNaviActivity{
mLocationClient.registerLocationListener( myListener );
setContentView(R.layout.activity_loc);
//c= BmobIMConversation.obtain(BmobIMClient.getInstance(), (BmobIMConversation) getBundle().getSerializable("c"));
c= BmobIMConversation.obtain(BmobIMClient.getInstance(), (BmobIMConversation) getBundle().getSerializable("c"));
adapter = new ChatAdapter(this,c);
initNaviView();
//initLocation();
initLocation();
mMapView = (MapView) findViewById(R.id.bmapView);
mBaiduMap = mMapView.getMap();
mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
// 开启定位图层
mBaiduMap.setMyLocationEnabled(true);
mBaiduMap.setMapStatus(MapStatusUpdateFactory.zoomTo(16));
mLocationClient.start();
mLocationClient.requestLocation();
mBaiduMap.clear();
Logger.i("before \n");
//mLocationClient.requestLocation();
Logger.i("after \n");
//mBaiduMap.clear();
//mLocationClient.requestLocation();
//send_recv_real_time();
@ -114,7 +129,7 @@ public class LocActivity extends ParentWithNaviActivity{
/**
*
*/
/* public MessageSendListener listener =new MessageSendListener() {
public MessageSendListener listener =new MessageSendListener() {
@Override
public void onProgress(int value) {
@ -127,21 +142,17 @@ public class LocActivity extends ParentWithNaviActivity{
public void onStart(BmobIMMessage msg) {
super.onStart(msg);
adapter.addMessage(msg);
edit_msg.setText("");
scrollToBottom();
}
@Override
public void done(BmobIMMessage msg, BmobException e) {
adapter.notifyDataSetChanged();
edit_msg.setText("");
scrollToBottom();
if (e != null) {
toast(e.getMessage());
}
}
};
*/
@Override
public ParentWithNaviActivity.ToolBarListener setToolBarListener() {
return new ParentWithNaviActivity.ToolBarListener() {
@ -160,6 +171,8 @@ public class LocActivity extends ParentWithNaviActivity{
super.onDestroy();
mLocationClient.unRegisterLocationListener( myListener );
mLocationClient.stop();
// 当不需要定位图层时关闭定位图层
mBaiduMap.setMyLocationEnabled(false);
//在activity执行onDestroy时执行mMapView.onDestroy(),实现地图生命周期管理
mMapView.onDestroy();
}
@ -227,6 +240,7 @@ public class LocActivity extends ParentWithNaviActivity{
}
}
Logger.i(sb.toString());*/
exe_count = exe_count + 1;
if (location != null && (location.getLocType() == 161 || location.getLocType() == 66)) {
Message locMsg = locHander.obtainMessage();
Bundle locData;
@ -237,6 +251,28 @@ public class LocActivity extends ParentWithNaviActivity{
locHander.sendMessage(locMsg);
}
}
StringBuffer sb = new StringBuffer(256);
sb.append("execute times :");
sb.append( exe_count );
sb.append("\n");
Logger.i( sb.toString() );
mBaiduMap.setMyLocationEnabled(true);
/*
// 构造定位数据
MyLocationData locData = new MyLocationData.Builder()
.accuracy(location.getRadius())
// 此处设置开发者获取到的方向信息顺时针0-360
.direction(100).latitude(location.getLatitude())
.longitude(location.getLongitude()).build();
// 设置定位数据
mBaiduMap.setMyLocationData(locData);
// 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
BitmapDescriptor mCurrentMarker = BitmapDescriptorFactory
.fromResource(R.drawable.chat_voice_bg);
MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, mCurrentMarker);
mBaiduMap.setMyLocationConfigeration(config);
*/
}
}
/***
@ -331,9 +367,28 @@ public class LocActivity extends ParentWithNaviActivity{
overlayManager.setData(aslist);
mBaiduMap.setOnMarkerClickListener(overlayManager);
overlayManager.addToMap();
overlayManager.zoomToSpan();
if( exe_count < 3)
overlayManager.zoomToSpan();
mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng( new LatLng ( (point.latitude + point2.latitude )/ 2,(point.longitude + point2.longitude)/2)) );
BmobIMLocationMessage loc_msg =new BmobIMLocationMessage("myloc",location.getLatitude(),location.getAltitude());
c.sendMessage(loc_msg, new MessageSendListener() {
@Override
public void onStart(BmobIMMessage msg) {
adapter.addMessage(msg);
adapter.notifyDataSetChanged();
}
@Override
public void done(BmobIMMessage msg, BmobException e) {
adapter.notifyDataSetChanged();
if (e != null) {
toast(e.getMessage());
}
}
});
}
} catch (Exception e) {
// TODO: handle exception

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Loading…
Cancel
Save