@OnClick(R.id.btn_next) public void onNextEvent() { String phone = mPhoneView.getText().toString(); if (StringUtils.isBlank(phone)) { mPhoneView.setError(getString(R.string.reqd_login_info)); return; } Object countrySelection = mCountryListView.getSelectedItem(); CountryVO selectedCountryVO = mCountriesView2VOMap.get(countrySelection.toString()); PhonePINVerifyFragment next = PhonePINVerifyFragment.newInstance( phone, selectedCountryVO == null ? "" : selectedCountryVO.getCode()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Transition exit = TransitionInflater.from(getContext()).inflateTransition(R.transition.slide_right); Transition enter = TransitionInflater.from(getContext()).inflateTransition(R.transition.slide_left); next.setSharedElementEnterTransition(enter); next.setEnterTransition(enter); setExitTransition(exit); next.setSharedElementReturnTransition(exit); } getActivity() .getSupportFragmentManager() .beginTransaction() .addSharedElement(mBtnNextView, "btn_next") .replace(R.id.container, next) .addToBackStack(null) .commit(); }
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); } }