Commit 64f8dc9a authored by fauzi's avatar fauzi

fix utils

parent 3bbcccda
......@@ -173,7 +173,6 @@ public class CartActivity extends AppCompatActivity {
}else{
utils.dialog(CartActivity.this,
true,
getLayoutInflater().inflate(R.layout.alert_dialog, null),
"Warning",
"Item stock does not meet").show();
}
......
......@@ -3,8 +3,11 @@ package com.yono.messeripos;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageButton;
public class ForgotPasswordActivity extends AppCompatActivity {
......@@ -16,6 +19,11 @@ public class ForgotPasswordActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_forgot_password);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
btnReset = findViewById(R.id.btn_reset_password);
btnReset.setOnClickListener(new View.OnClickListener() {
@Override
......
......@@ -144,19 +144,17 @@ public class LoginState extends BottomSheetDialogFragment {
.observe((LifecycleOwner) context, usersModelsDataResponse -> {
if (usersModelsDataResponse != null) {
final View customLayout = getLayoutInflater()
.inflate(R.layout.alert_dialog, null);
switch (usersModelsDataResponse.getMessageData().toLowerCase()) {
case "invalid username or password":
setAllLayoutToTrue();
errUserPass(customLayout);
errUserPass();
break;
case "please activate your email first":
setAllLayoutToTrue();
activateEmail(customLayout);
activateEmail();
default:
break;
......@@ -206,10 +204,10 @@ public class LoginState extends BottomSheetDialogFragment {
closeBtn.setEnabled(false);
}
private void activateEmail(View customLayout) {
private void activateEmail() {
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Please Verify Email",
utils = new Utils();
utils.dialog(context, false, "Please Verify Email",
"Please verify your email before login",
"close", "verify")
.show();
......@@ -230,10 +228,10 @@ public class LoginState extends BottomSheetDialogFragment {
});
}
private void errUserPass(View customLayout) {
private void errUserPass() {
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Wrong Username or Password",
utils = new Utils();
utils.dialog(context, false, "Wrong Username or Password",
"The username or password is incorrect. Please try again!",
"Try Again")
.show();
......
......@@ -193,10 +193,10 @@ public class RegisterState extends BottomSheetDialogFragment {
return sheetDialog2;
}
private void activateEmail(View customLayout) {
private void activateEmail() {
utils = new Utils(customLayout);
utils.dialog(context, false, customLayout, "Please Verifiy Email",
utils = new Utils();
utils.dialog(context, false, "Please Verifiy Email",
"Please verify your email before login",
"close", "verify")
.show();
......
......@@ -8,6 +8,7 @@ import android.graphics.BitmapFactory;
import android.os.Build;
import android.util.Base64;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
......@@ -223,12 +224,13 @@ public class Utils {
* Alert Dialog
* @param context
* @param cancelable
* @param view
* @return
*/
public AlertDialog dialog(Context context, Boolean cancelable, View view) {
public AlertDialog dialog(Context context, Boolean cancelable) {
CardView btCard = view.findViewById(R.id.cvAlertOnClick);
final View view = View.inflate(context, R.layout.alert_dialog, null);
CardView btnCard = view.findViewById(R.id.cvAlertOnClick);
AlertDialog.Builder builder = new AlertDialog.Builder(context)
.setCancelable(cancelable)
......@@ -241,10 +243,14 @@ public class Utils {
}
public AlertDialog dialog(Context context, Boolean cancelable, View view, @Nullable String titles) {
public AlertDialog dialog(Context context,
Boolean cancelable,
@Nullable String titles) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles);
CardView btCard = view.findViewById(R.id.cvAlertOnClick);
CardView btnCard = view.findViewById(R.id.cvAlertOnClick);
// set title and message
if (titles != null){
......@@ -262,7 +268,12 @@ public class Utils {
}
public AlertDialog dialog(Context context, Boolean cancelable, View view, @Nullable String titles, @Nullable String messages) {
public AlertDialog dialog(Context context,
Boolean cancelable,
@Nullable String titles,
@Nullable String messages) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody);
......@@ -289,16 +300,18 @@ public class Utils {
public AlertDialog dialog(Context context,
Boolean cancelable,
View view,
@Nullable String titles,
@Nullable String messages,
@Nullable String dismiss) {
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody);
TextView button2 = view.findViewById(R.id.tvTextBtn2);
CardView btnCard2 = view.findViewById(R.id.cvAlertOnClick2);
// set title and message
if (titles != null){
title.setText(titles);
......@@ -327,7 +340,6 @@ public class Utils {
public AlertDialog dialog(Context context,
Boolean cancelable,
View view,
@Nullable String titles,
@Nullable String messages,
@Nullable String dismiss,
......@@ -338,6 +350,8 @@ public class Utils {
* Button2 untuk link
*/
final View view = View.inflate(context, R.layout.alert_dialog, null);
TextView title = view.findViewById(R.id.alertTitles);
TextView message = view.findViewById(R.id.alertBody);
TextView button = view.findViewById(R.id.tvTextBtn);
......
......@@ -21,6 +21,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingVertical="20dp"
android:orientation="vertical">
<TextView
......
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