新需求:将行程实时显示在地图上
1.TirpManager的程序的入口,需要和外层打交道和交互
2.应该在TripManager增加一个接口,回调给上层
public class TripManager {
private TripTracker mTracker;
private TripSetting mSettings;
private OnLocationChangedListener listener;
public void startTrip() {
mSettings = new TripSetting();
mTracker = new TripTracker(mSettings);
mTracker.setLocationChangedListener(listener);
mTracker.startTracker();
}
public void stopTrip() {
mTracker.stopTracker();
mTracker = null;
}
public void setLocationChangedListener(OnLocationChangedListener listener) {
this.listener = listener;
if (mTracker != null) {
mTracker.setLocationChangedListener(listener);
}
}
public interface OnLocationChangedListener {
void onLocationChangedListener(GpsTracker.GpsEntity location);
}
}
@Override
public void onGpsChanged(GpsTracker.GpsEntity gpsEntity) {
mtripWriter.onGpschanged(gpsEntity);
mListener.onLocationChangedListener(gpsEntity);
}
@Override
public void onSensorChanged(SensorTracker.SensorEntity sensorEntity) {
mtripWriter.onSensorchanged(sensorEntity);
}
public void setLocationChangedListener(TripManager.OnLocationChangedListener listener) {
this.mListener = listener;
}