A utility library that does the following things:
- Check internet connection
- Validate for empty edit texts
- Validate for email
- Validate for mobile number
- Validate text for any no of digits
- Fancy Progress Dialog
Add this in the project level build.gradle:
repositories{
....
maven { url 'https://jitpack.io' }
}
And this in the app level build.gradle
compile 'com.github.shree-vastava:ValidUtil:v1.0'
Create an object of the ValidUtils class
ValidUtils validUtils = new ValidUtils()
if (validUtils.isNetworkAvailable(this)){
// do whatever you want to do IF internet is AVAILABLE
}
if(validUtils.validateEditTexts(name,mobile,email)){ //where name,mobile, email are EditTexts
// do whatever you want to do if EditTexts are not empty
}
if(validUtils.validateEmail(email)){
// do whatever you want to do if email is valid i.e in form of [email protected]
}
You can check for more email EditTexts also by passing comma separate EditTexts in the above function
if(validUtils.validateMobileNumber(mobile)){
// do whatever you want to do if mobile number is valid i.e 10 digits
}
You can check for multiple mobile EditTexts
if(validUtils.validateForDigits(Pin,6)){
// do whatever you want to do if Pin is 6 digits
}
Here Pin the EditText
validUtils.showProgresDialog(this,this)
where the arguements are like
validUtils.showProgressDialog(Context, Activity)
To hide the dialog
validUtils.hideProgressDialog()
validUtils.showToast(Context,"some message")