hbb20 / hbb20/CountryCodePickerProject
NPE at !detectedCountry.equals(selectedCountry)
- 主要言語
- Java
- スター
- 1.5k
- フォーク
- 509
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
`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();
}
}
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- android, java
- 領域
- mobile
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100