hbb20 / hbb20/CountryCodePickerProject

NPE at !detectedCountry.equals(selectedCountry)

Abierto
#363 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Java
Estrellas
1.5k
Forks
509
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

`detectedCountry` can be null. But in line `!detectedCountry.equals(selectedCountry)` we use it

```java
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
CCPCountry selectedCountry = getSelectedCountry();
if (selectedCountry != null && (lastCheckedNumber == null || !lastCheckedNumber.equals(s.toString())) && countryDetectionBasedOnAreaAllowed) {
//possible countries
if (currentCountryGroup != null) {
String enteredValue = getEditText_registeredCarrierNumber().getText().toString();
if (enteredValue.length() >= currentCountryGroup.areaCodeLength) {
String digitsValue = PhoneNumberUtil.normalizeDigitsOnly(enteredValue);
if (digitsValue.length() >= currentCountryGroup.areaCodeLength) {
String currentAreaCode = digitsValue.substring(0, currentCountryGroup.areaCodeLength);
if (!currentAreaCode.equals(lastCheckedAreaCode)) {
CCPCountry detectedCountry = currentCountryGroup.getCountryForAreaCode(context, getLanguageToApply(), currentAreaCode);
if (!detectedCountry.equals(selectedCountry)) {
countryChangedDueToAreaCode = true;
lastCursorPosition = Selection.getSelectionEnd(s);
setSelectedCountry(detectedCountry);
}
lastCheckedAreaCode = currentAreaCode;
}
}
}
}
lastCheckedNumber = s.toString();
}
}
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Search for the onTextChanged callback and the expression !detectedCountry.equals(selectedCountry) in the Android library, then trace how getCountryForAreaCode can produce a null result. Verify that entering an area code with no detected country no longer causes an NPE and that country selection still behaves correctly when a country is detected.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
android, java
Área
mobile
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
55/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.