private void fillCountryListView() { String userCountryCode; if (mUser != null && StringUtils.isNotBlank(mUser.getCountry())) { userCountryCode = mUser.getCountry(); } else { TelephonyManager tm = (TelephonyManager) getContext().getSystemService(getContext().TELEPHONY_SERVICE); userCountryCode = StringUtils.upperCase(tm.getNetworkCountryIso()); } String preSelection = null; try { String countryPhonePrefix; for (CountryVO countryVO : Utils.countryList()) { countryPhonePrefix = countryVO.getPhonePrefix(); mCountriesView2VOMap.put(countryVO.getPhonePrefix(), countryVO); // track entry if (StringUtils.equals(userCountryCode, countryVO.getCode())) { preSelection = countryPhonePrefix; } } } catch (Exception e) { // muted } List<String> _countries = new ArrayList<>(mCountriesView2VOMap.keySet()); // spinner stuff ArrayAdapter<String> mCountryListAdapter = new ArrayAdapter<String>(getActivity(), R.layout.phoneverify_prefix, _countries); mCountryListView.setAdapter(mCountryListAdapter); // default setup if (StringUtils.isNotBlank(preSelection)) { int preSelectionIdx = Collections.binarySearch(_countries, preSelection); mCountryListView.setSelection(preSelectionIdx); } }
private void fillPhoneNumber() { if (mUser != null && StringUtils.isNotBlank(mUser.getPhno())) { mPhoneView.setText(mUser.getPhno()); } }