Commit 39e1dd0a authored by fauzi's avatar fauzi

tambahan validatsi email

parent 308655a7
......@@ -120,8 +120,7 @@ public class LoginState extends BottomSheetDialogFragment {
username.setError("This field can't empty");
}else if (TextUtils.isEmpty(password.getText().toString())){
password.setError("This field can't empty");
}else
{
}else {
/**
* Jika tombol sign in ditekan
*
......@@ -144,6 +143,35 @@ public class LoginState extends BottomSheetDialogFragment {
/**
* Jika response atau data ada dan cocok
*/
switch (usersModelsDataResponse.getMessageData().toLowerCase()) {
case "invalid username or password":
bar.setVisibility(View.GONE);
loginButton.setText(DEFAULT_LOGIN_NAME);
sheetDialog.setCancelable(true);
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
errUserPass();
break;
case "please activate your email first":
bar.setVisibility(View.GONE);
loginButton.setText(DEFAULT_LOGIN_NAME);
sheetDialog.setCancelable(true);
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
activateEmail();
}
if (usersModelsDataResponse.getStatusData()) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean(SplashScreen.SESSION, true);
......@@ -160,42 +188,40 @@ public class LoginState extends BottomSheetDialogFragment {
// munculkan tulisan default di button sign in
loginButton.setText(DEFAULT_LOGIN_NAME);
// ubah sheet dialog jadi tidak bisa di slide atau cancel
sheetDialog.setCancelable(true);
// set form jadi enable
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
} else {
/**
* Jika response atau data tidak cocok
*/
bar.setVisibility(View.GONE);
loginButton.setText(DEFAULT_LOGIN_NAME);
sheetDialog.setCancelable(true);
final View customLayout = getLayoutInflater()
.inflate(R.layout.alert_dialog, null);
// tampilkan alert dialog
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Wrong Username or Password",
"The username or password is incorrect. Please try again!",
"Try Again")
.show();
utils.setListener(Dialog::dismiss);
username.setEnabled(true);
password.setEnabled(true);
loginButton.setEnabled(true);
closeBtn.setEnabled(true);
}
// else {
// /**
// * Jika response atau data tidak cocok
// */
//
// bar.setVisibility(View.GONE);
// loginButton.setText(DEFAULT_LOGIN_NAME);
//
// sheetDialog.setCancelable(true);
//
// final View customLayout = getLayoutInflater()
// .inflate(R.layout.alert_dialog, null);
//
// // tampilkan alert dialog
// utils = new Utils(customLayout);
// utils.dialog(context, false, customLayout, "Wrong Username or Password",
// "The username or password is incorrect. Please try again!",
// "Try Again")
// .show();
// utils.setListener(Dialog::dismiss);
//
// username.setEnabled(true);
// password.setEnabled(true);
// loginButton.setEnabled(true);
// closeBtn.setEnabled(true);
//
// }
} else {
bar.setVisibility(View.VISIBLE);
utils.snackBar(v, "Oppss! ログイン中にエラーが発生しました。しばらくしてからもう一度お試しください").show();
......@@ -205,4 +231,31 @@ public class LoginState extends BottomSheetDialogFragment {
}
loginButton.setText(DEFAULT_LOGIN_NAME);
}
private void activateEmail() {
final View customLayout = getLayoutInflater()
.inflate(R.layout.alert_dialog, null);
// tampilkan alert dialog
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Please Verifiy Email",
"Please verify your email before login",
"verify")
.show();
utils.setListener(Dialog::dismiss);
}
private void errUserPass() {
final View customLayout = getLayoutInflater()
.inflate(R.layout.alert_dialog, null);
// tampilkan alert dialog
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Wrong Username or Password",
"The username or password is incorrect. Please try again!",
"Try Again")
.show();
utils.setListener(Dialog::dismiss);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment