-------------------------------Function.class--------------------------------
public class Function {
/*/...........................Email_validation.......................*/
public boolean emailValidator(String email)
{
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
/*/...........................Password_validation.......................*/
public static boolean isValidPassword(final String password) {
Pattern pattern;
Matcher matcher;
final String PASSWORD_PATTERN =
"^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$%^&+=!])(?=\\S+$).{4,}$";
pattern = Pattern.compile(PASSWORD_PATTERN);
matcher = pattern.matcher(password);
return matcher.matches();
}
/*/...........................Mobile_number_validation.......................*/
private boolean isValidMobile(String phone, Context context) {
boolean check=false;
if(!Pattern.matches("[a-zA-Z]+", phone)) {
if(phone.length() < 6 || phone.length() > 13) {
// if(phone.length() != 10) {
check = false;
Toast.makeText(context, "Not Valid Number", Toast.LENGTH_SHORT).show();
} else {
check = true;
}
} else {
check=false;
}
return check;
}
/*/...........................Snack_bar_show.......................*/
public static void Snackbar(Context context, View view, String s) {
Snackbar snack = Snackbar.make(view, s, Snackbar.LENGTH_LONG);
View sbview = snack.getView();
TextView textView = sbview.findViewById(android.support.design.R.id.snackbar_text);
sbview.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary));
textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
snack.show();
}
/*.....................Six_random_digit_genrate............................*/
public static int sixDigitRandomNum() {
int longtime = (int) System.currentTimeMillis();
String number = String.valueOf(longtime).substring(4);
int bookingNumber = Integer.parseInt(number);
/* Random random = new Random();
int num = random.nextInt(1) + 5;*/
return bookingNumber;
}
/*.....................Current_date...................................*/
public static String currentDateBooking() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
return df1.format(c.getTime());
}
/*.....................Current_date...................................*/
public static String currentTimeBooking() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
return df.format(c.getTime());
}
}
public class Function {
/*/...........................Email_validation.......................*/
public boolean emailValidator(String email)
{
Pattern pattern;
Matcher matcher;
final String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
pattern = Pattern.compile(EMAIL_PATTERN);
matcher = pattern.matcher(email);
return matcher.matches();
}
/*/...........................Password_validation.......................*/
public static boolean isValidPassword(final String password) {
Pattern pattern;
Matcher matcher;
final String PASSWORD_PATTERN =
"^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$%^&+=!])(?=\\S+$).{4,}$";
pattern = Pattern.compile(PASSWORD_PATTERN);
matcher = pattern.matcher(password);
return matcher.matches();
}
/*/...........................Mobile_number_validation.......................*/
private boolean isValidMobile(String phone, Context context) {
boolean check=false;
if(!Pattern.matches("[a-zA-Z]+", phone)) {
if(phone.length() < 6 || phone.length() > 13) {
// if(phone.length() != 10) {
check = false;
Toast.makeText(context, "Not Valid Number", Toast.LENGTH_SHORT).show();
} else {
check = true;
}
} else {
check=false;
}
return check;
}
/*/...........................Snack_bar_show.......................*/
public static void Snackbar(Context context, View view, String s) {
Snackbar snack = Snackbar.make(view, s, Snackbar.LENGTH_LONG);
View sbview = snack.getView();
TextView textView = sbview.findViewById(android.support.design.R.id.snackbar_text);
sbview.setBackgroundColor(ContextCompat.getColor(context, R.color.colorPrimary));
textView.setTextColor(ContextCompat.getColor(context, R.color.colorAccent));
snack.show();
}
/*.....................Six_random_digit_genrate............................*/
public static int sixDigitRandomNum() {
int longtime = (int) System.currentTimeMillis();
String number = String.valueOf(longtime).substring(4);
int bookingNumber = Integer.parseInt(number);
/* Random random = new Random();
int num = random.nextInt(1) + 5;*/
return bookingNumber;
}
/*.....................Current_date...................................*/
public static String currentDateBooking() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df1 = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
return df1.format(c.getTime());
}
/*.....................Current_date...................................*/
public static String currentTimeBooking() {
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss", Locale.getDefault());
return df.format(c.getTime());
}
}
No comments:
Post a Comment