// 新しい Presenter クラスを追加します。
public class Presenter {
private MapLongitude mapLongitude;
private MapLatitude mapLatitude;
private boolean autoUpdateEnabled;
public Presenter(MapLongitude mapLongitude, MapLatitude mapLatitude) {
this.mapLongitude = mapLongitude;
this.mapLatitude = mapLatitude;
this.autoUpdateEnabled = true; // デフォルトでは自動更新がONです。
}
public void setAutoUpdateEnabled(boolean enabled) {
this.autoUpdateEnabled = enabled;
}
public void updateGPS(double lat, double lon) {
if (autoUpdateEnabled) {
mapLatitude.updateLatitude(lat);
mapLongitude.updateLongitude(lon);
}
}
// 手動で地図の表示位置を更新するメソッドを追加します。
public void manualUpdate(double lat, double lon) {
mapLatitude.updateLatitude(lat);
mapLongitude.updateLongitude(lon);
}
}