public class Presenter {
private boolean autoUpdateEnabled = true; // 初期状態では自動更新をONにします
private Longitude longitude;
private Latitude latitude;
private MapLongitude mapLongitude;
private MapLatitude mapLatitude;
public Presenter(Longitude longitude, Latitude latitude, MapLongitude mapLongitude, MapLatitude mapLatitude) {
this.longitude = longitude;
this.latitude = latitude;
this.mapLongitude = mapLongitude;
this.mapLatitude = mapLatitude;
}
public void updateGPS(double lat2, double long2) {
// GPSの状態を更新します
longitude.updateValue(long2);
latitude.updateValue(lat2);
// 自動更新が有効な場合のみ地図の中心位置を更新します
if (autoUpdateEnabled) {
mapLongitude.updateLongitude(long2);
mapLatitude.updateLatitude(lat2);
}
}
// 自動更新のON/OFFを切り替えるメソッド
public void setAutoUpdateEnabled(boolean enabled) {
this.autoUpdateEnabled = enabled;
}
// 手動更新を行うメソッド
public void manualUpdate() {
mapLongitude.updateLongitude(longitude.getValue());
mapLatitude.updateLatitude(latitude.getValue());
}
}