This commit is contained in:
Sem van der Hoeven
2021-01-05 13:03:42 +01:00
parent 40331f3135
commit 65d2f31e3f
2 changed files with 14 additions and 5 deletions

View File

@@ -61,7 +61,7 @@ public class HomeFragment extends Fragment implements LocationListener {
private MapView mapView; private MapView mapView;
private final int REQUEST_PERMISSIONS_REQUEST_CODE = 1; private final int REQUEST_PERMISSIONS_REQUEST_CODE = 1;
private final String TAG = HomeFragment.class.getCanonicalName(); private final String TAG = HomeFragment.class.getCanonicalName();
private RoadManager roadManager; // private RoadManager roadManager;
private Polyline roadOverlay; private Polyline roadOverlay;
private int color; private int color;
@@ -75,8 +75,8 @@ public class HomeFragment extends Fragment implements LocationListener {
Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION,
// WRITE_EXTERNAL_STORAGE is required in order to show the map // WRITE_EXTERNAL_STORAGE is required in order to show the map
Manifest.permission.WRITE_EXTERNAL_STORAGE); Manifest.permission.WRITE_EXTERNAL_STORAGE);
roadManager = new MapQuestRoadManager(MAPQUEST_API_KEY); // roadManager = new MapQuestRoadManager(MAPQUEST_API_KEY);
roadManager.addRequestOption("routeType=foot-walking"); // roadManager.addRequestOption("routeType=foot-walking");
color = requireContext().getColor(R.color.red); color = requireContext().getColor(R.color.red);
} }
@@ -93,8 +93,6 @@ public class HomeFragment extends Fragment implements LocationListener {
((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit(); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, locationFragment).addToBackStack(null).commit();
}); });
// roadManager.addRequestOption("routeType=foot-walking");
ApiHandler.INSTANCE.addListener(this::onDirectionsAvailable); ApiHandler.INSTANCE.addListener(this::onDirectionsAvailable);
return view; return view;
} }
@@ -126,6 +124,10 @@ public class HomeFragment extends Fragment implements LocationListener {
initMap(view); initMap(view);
} }
/**
* This method initializes the map and all the things it needs
* @param view the view the map is on
*/
private void initMap(@NonNull View view) { private void initMap(@NonNull View view) {
// set the user agent // set the user agent
Configuration.getInstance().setUserAgentValue(userAgent); Configuration.getInstance().setUserAgentValue(userAgent);
@@ -193,6 +195,7 @@ public class HomeFragment extends Fragment implements LocationListener {
} }
} }
private void requestPermissionsIfNecessary(String... permissions) { private void requestPermissionsIfNecessary(String... permissions) {
ArrayList<String> permissionsToRequest = new ArrayList<>(); ArrayList<String> permissionsToRequest = new ArrayList<>();
if (this.getContext() != null) if (this.getContext() != null)
@@ -211,6 +214,10 @@ public class HomeFragment extends Fragment implements LocationListener {
} }
} }
/**
* animate to the new location
* @param location the new location
*/
@Override @Override
public void onLocationChanged(@NonNull Location location) { public void onLocationChanged(@NonNull Location location) {

View File

@@ -34,6 +34,8 @@ public class RouteDetailFragment extends Fragment {
this.routeDetailText.setText(this.route.getName()); this.routeDetailText.setText(this.route.getName());
return view; return view;
} }
} }