-
-
Save jezinka/1104e1f1aa3470b181026f3a2b0a46fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public boolean onPreferenceChange(Preference preference, Object newValue) { | |
Toast error = Toast.makeText(getContext(), R.string.plan_length_error_message, Toast.LENGTH_SHORT); | |
String planKey = getString(R.string.plan_length_key); | |
if (preference.getKey().equals(planKey)) { | |
String stringSize = ((String) (newValue)).trim(); | |
if (stringSize.equals("")) stringSize = getString(R.string.plan_length_default_value); | |
try { | |
int size = Integer.parseInt(stringSize); | |
if (size < 1 || size > 30) { | |
error.show(); | |
return false; | |
} | |
} catch (NumberFormatException nfe) { | |
error.show(); | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment