don’t throw error if location is not set

This commit is contained in:
Morten Delenk 2022-08-15 10:42:29 +01:00
parent df839b4c03
commit eefd8134c3
No known key found for this signature in database
GPG key ID: 5130416C797067B6

View file

@ -103,7 +103,8 @@ public class MapFragment extends FragmentBase<FragmentMapBinding> {
var map = this.getBinding().map;
map.getOverlays().clear();
this.subscribe(this.getClient().toObservable()
.flatMap(client -> client.streamObjects().toObservable()),
.flatMap(client -> client.streamObjects().toObservable())
.filter(item -> item.lastKnownLocation().isPresent()),
this::addMarker);
}
@ -117,7 +118,7 @@ public class MapFragment extends FragmentBase<FragmentMapBinding> {
config.setUserAgentValue(this.requireActivity().getPackageName()); // Set the user agent for mapnik
config.setOsmdroidBasePath(this.requireActivity().getFilesDir()); // Technically not necessary, but recommended
config.setOsmdroidTileCache(this.requireActivity().getCacheDir()); // Set the cache directory
map.setMultiTouchControls(true);
map.setMultiTouchControls(true);
fusedLocationClient = LocationServices.getFusedLocationProviderClient(this.requireActivity()); // Initialize the fused location provider
this.tryRestoreState(); // Restore state if possible
this.getBinding().fab.setOnClickListener(__ -> this.navigate(R.id.action_mapFragment_to_QRScanFragment));