@Test public void getHeaders_withUserPreferredLanguageAsEmptyString_shouldReturnDefaultLanguageCode() throws Exception { Map<String, String> expectedHeaders = new TreeMap<String, String>(); expectedHeaders.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), "en"); activity.getResources().getConfiguration().locale = new Locale(" "); assertThat(subject.getHeaders()).isEqualTo(expectedHeaders); }
@Override public Map<String, String> getHeaders() { TreeMap<String, String> headers = new TreeMap<String, String>(); String languageCode = Locale.getDefault().getLanguage(); Locale userLocale = mContext.getResources().getConfiguration().locale; if (userLocale != null) { if (! userLocale.getLanguage().trim().isEmpty()) { languageCode = userLocale.getLanguage().trim(); } } if (! languageCode.isEmpty()) { headers.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), languageCode); } return headers; }
AdRequest extends Request<AdResponse> { @Override public Map<String, String> getHeaders() { TreeMap<String, String> headers = new TreeMap<String, String>(); String languageCode = Locale.getDefault().getLanguage(); Locale userLocale = mContext.getResources().getConfiguration().locale; if (userLocale != null) { if (! userLocale.getLanguage().trim().isEmpty()) { languageCode = userLocale.getLanguage().trim(); } } if (! languageCode.isEmpty()) { headers.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), languageCode); } return headers; } }
AdRequest extends Request<AdResponse> { @Override public Map<String, String> getHeaders() { TreeMap<String, String> headers = new TreeMap<String, String>(); String languageCode = Locale.getDefault().getLanguage(); Locale userLocale = mContext.getResources().getConfiguration().locale; if (userLocale != null) { if (! userLocale.getLanguage().trim().isEmpty()) { languageCode = userLocale.getLanguage().trim(); } } if (! languageCode.isEmpty()) { headers.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), languageCode); } return headers; } AdRequest(@NonNull final String url,
            @NonNull final AdFormat adFormat,
            @Nullable final String adUnitId,
            @NonNull Context context,
            @NonNull final Listener listener); }
AdRequest extends Request<AdResponse> { @Override public Map<String, String> getHeaders() { TreeMap<String, String> headers = new TreeMap<String, String>(); String languageCode = Locale.getDefault().getLanguage(); Locale userLocale = mContext.getResources().getConfiguration().locale; if (userLocale != null) { if (! userLocale.getLanguage().trim().isEmpty()) { languageCode = userLocale.getLanguage().trim(); } } if (! languageCode.isEmpty()) { headers.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), languageCode); } return headers; } AdRequest(@NonNull final String url,
            @NonNull final AdFormat adFormat,
            @Nullable final String adUnitId,
            @NonNull Context context,
            @NonNull final Listener listener); @NonNull Listener getListener(); @Override Map<String, String> getHeaders(); }
AdRequest extends Request<AdResponse> { @Override public Map<String, String> getHeaders() { TreeMap<String, String> headers = new TreeMap<String, String>(); String languageCode = Locale.getDefault().getLanguage(); Locale userLocale = mContext.getResources().getConfiguration().locale; if (userLocale != null) { if (! userLocale.getLanguage().trim().isEmpty()) { languageCode = userLocale.getLanguage().trim(); } } if (! languageCode.isEmpty()) { headers.put(ResponseHeader.ACCEPT_LANGUAGE.getKey(), languageCode); } return headers; } AdRequest(@NonNull final String url,
            @NonNull final AdFormat adFormat,
            @Nullable final String adUnitId,
            @NonNull Context context,
            @NonNull final Listener listener); @NonNull Listener getListener(); @Override Map<String, String> getHeaders();  }