Skip to content

Commit

Permalink
Small improvements on the things are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
Willena committed Apr 16, 2017
1 parent 365da0d commit 315406d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ protected void onCreate(Bundle savedInstanceState) {
phoneView = (PhoneInputView) findViewById(R.id.phoneId);

CountryConfigurator config = new CountryConfigurator();
config.setDisplayFlag(true);
config.setDisplayFlag(false);
config.setDisplayCountryCode(true);
config.setDisplayDialingCode(true);
config.setDisplayDialingCode(false);

phoneView.setConfig(config);

Expand Down
4 changes: 2 additions & 2 deletions phoneinputview/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionCode 12
versionName "1.2"
consumerProguardFiles 'proguard-rules.pro'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class SpinnerCountryArrayAdapter extends ArrayAdapter<CountryInfo> {
private final PhoneNumberUtil phoneUtils;

SpinnerCountryArrayAdapter(Context context, CountryConfigurator config, PhoneNumberUtil phoneUtil,
List<CountryInfo> objects) {
List<CountryInfo> objects) {
super(context, R.layout.phone_input_spinner_top_item, objects);
this.phoneUtils = phoneUtil;
this.config = config;
Expand All @@ -49,39 +49,48 @@ public View getCustomView(int position, View convertView, ViewGroup parent, Bool
TextView countryName = (TextView) row.findViewById(R.id.phone_input_spinner_item_country_name);
TextView dialCode = (TextView) row.findViewById(R.id.phone_input_spinner_item_dialcode);

if (top)
countryName.setVisibility(View.GONE);
else{
if (!top) {
countryName.setText(getItem(position).getName());
}

if (this.config.getDisplayCountryCode())
dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")");
countryCode.setText(getItem(position).getCode());
else
countryCode.setVisibility(View.GONE);

if (this.config.getDisplayFlag()) {
Resources resources = row.getResources();
int resourceId = resources.getIdentifier(getItem(position).getCode().toLowerCase() + "_", "drawable", row.getContext().getPackageName());

flag.setImageDrawable((resourceId <= 0) ? null : resources.getDrawable(resourceId));


} else {
countryName.setVisibility(View.GONE);

if (this.config.getDisplayCountryCode()) {
countryCode.setText(getItem(position).getCode());
} else {
countryCode.setVisibility(View.GONE);
}

if (resourceId <= 0)
flag.setImageDrawable(null);
else
flag.setImageDrawable(resources.getDrawable(resourceId));
} else
flag.setVisibility(View.GONE);

if (this.config.getDisplayFlag()) {
Resources resources = row.getResources();
int resourceId = resources.getIdentifier(getItem(position).getCode().toLowerCase() + "_", "drawable", row.getContext().getPackageName());

if (this.config.getDisplayDialingCode()) {
try {
dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")");
} catch (Exception e) {
dialCode.setText("");
flag.setImageDrawable((resourceId <= 0) ? null : resources.getDrawable(resourceId));

} else {
flag.setVisibility(View.GONE);
}
} else {
dialCode.setVisibility(View.GONE);


if (this.config.getDisplayDialingCode()) {
try {
dialCode.setText("(+" + phoneUtils.getExampleNumber(getItem(position).getCode()).getCountryCode() + ")");
} catch (Exception e) {
dialCode.setText("");
}
} else {
dialCode.setVisibility(View.GONE);
}

}

return row;
Expand Down

0 comments on commit 315406d

Please sign in to comment.