Java Code Examples for com.mapbox.services.android.navigation.v5.utils.LocaleUtils#inferDeviceLanguage()

The following examples show how to use com.mapbox.services.android.navigation.v5.utils.LocaleUtils#inferDeviceLanguage() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InstructionView.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
/**
 * Inflates this layout needed for this view and initializes the locale as the device locale.
 */
private void initialize() {
  LocaleUtils localeUtils = new LocaleUtils();
  String language = localeUtils.inferDeviceLanguage(getContext());
  String unitType = localeUtils.getUnitTypeForDeviceLocale(getContext());
  int roundingIncrement = NavigationConstants.ROUNDING_INCREMENT_FIFTY;
  distanceFormatter = new DistanceFormatter(getContext(), language, unitType, roundingIncrement);
  inflate(getContext(), R.layout.instruction_view_layout, this);
}
 
Example 2
Source File: SummaryBottomSheet.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void initializeDistanceFormatter() {
  LocaleUtils localeUtils = new LocaleUtils();
  String language = localeUtils.inferDeviceLanguage(getContext());
  String unitType = localeUtils.getUnitTypeForDeviceLocale(getContext());
  int roundingIncrement = NavigationConstants.ROUNDING_INCREMENT_FIFTY;
  distanceFormatter = new DistanceFormatter(getContext(), language, unitType, roundingIncrement);
}
 
Example 3
Source File: MapboxNavigationNotification.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
private void initializeDistanceFormatter(Context context, MapboxNavigation mapboxNavigation) {
  RouteOptions routeOptions = mapboxNavigation.getRoute().routeOptions();
  LocaleUtils localeUtils = new LocaleUtils();
  String language = localeUtils.inferDeviceLanguage(context);
  String unitType = localeUtils.getUnitTypeForDeviceLocale(context);
  if (routeOptions != null) {
    language = routeOptions.language();
    unitType = routeOptions.voiceUnits();
  }
  MapboxNavigationOptions mapboxNavigationOptions = mapboxNavigation.options();
  distanceFormatter = new DistanceFormatter(context, language, unitType, mapboxNavigationOptions.roundingIncrement());
}
 
Example 4
Source File: NaviBeeMapBoxNotification.java    From NaviBee with GNU General Public License v3.0 4 votes vote down vote up
private void initializeDistanceFormatter(Context context) {
    LocaleUtils localeUtils = new LocaleUtils();
    String language = localeUtils.inferDeviceLanguage(context);
    String unitType = localeUtils.getUnitTypeForDeviceLocale(context);
    distanceFormatter = new DistanceFormatter(context, language, unitType);
}