Number check fix
This commit is contained in:
@@ -106,7 +106,7 @@ public class ActivityManageActionSetSystemSetting extends Activity
|
|||||||
selectedDataType.equalsIgnoreCase("Long")
|
selectedDataType.equalsIgnoreCase("Long")
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || Miscellaneous.isNonDecimalNumber(etSettingValue.getText().toString()))
|
if(!Miscellaneous.isNumeric(etSettingValue.getText().toString()) || !Miscellaneous.isNumericNonDecimal(etSettingValue.getText().toString()))
|
||||||
{
|
{
|
||||||
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
Toast.makeText(ActivityManageActionSetSystemSetting.this, getResources().getString(R.string.enter_a_number), Toast.LENGTH_LONG).show();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1154,12 +1154,24 @@ public class Miscellaneous extends Service
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNonDecimalNumber(String number)
|
public static boolean isNumericNonDecimal(String number)
|
||||||
{
|
{
|
||||||
if (number == null)
|
if (number == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return !number.contains(String.valueOf(getDecimalSeparator()));
|
try
|
||||||
|
{
|
||||||
|
int temp = Integer.parseInt(number);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(number.contains(String.valueOf(getDecimalSeparator())))
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isNumeric(String str)
|
public static boolean isNumeric(String str)
|
||||||
|
|||||||
Reference in New Issue
Block a user