Skip to content

Commit

Permalink
prevent to use the map route until the map is ready and the route fet…
Browse files Browse the repository at this point in the history
…ched and hide the launch navigation fab until a route is fetched to avoid null directions route npe
  • Loading branch information
Guardiola31337 committed Jul 20, 2018
1 parent 12cf518 commit e45bec2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
@Override
public void onNavigationReady(boolean isRunning) {
isNavigationRunning = isRunning;
fetchRoute();
}

@Override
Expand All @@ -99,6 +98,7 @@ public void onMapReady(MapboxMap mapboxMap) {
initLocationEngine();
initLocationLayer();
initMapRoute();
fetchRoute();
}

@Override
Expand All @@ -115,7 +115,6 @@ public void onMapLongClick(@NonNull LatLng point) {
public void onResponse(Call<DirectionsResponse> call, Response<DirectionsResponse> response) {
if (validRouteResponse(response)) {
updateLoadingTo(false);
launchNavigationFab.setVisibility(View.VISIBLE);
launchNavigationFab.show();
route = response.body().routes().get(0);
mapRoute.addRoutes(response.body().routes());
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_dual_navigation_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
android:layout_marginRight="16dp"
android:src="@drawable/ic_navigation"
android:tint="@android:color/white"
android:visibility="visible"
android:visibility="invisible"
app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
android:layout_marginRight="16dp"
android:src="@drawable/ic_navigation"
android:tint="@android:color/white"
android:visibility="visible"
android:visibility="gone"
app:backgroundTint="@color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"/>
Expand Down

0 comments on commit e45bec2

Please sign in to comment.