Commit fa9278fd authored by fauzi's avatar fauzi

🐛 fix bug

parent 3c5e6bc5
......@@ -31,10 +31,8 @@ import com.yono.messeripos.utils.Utils;
public class LoginActivity extends AppCompatActivity {
TextInputEditText username, password;
MainViewModels mainViewModels;
SharedPreferences sharedPreferences;
Utils utils = new Utils();
//State
LoginState loginState;
......@@ -42,9 +40,6 @@ public class LoginActivity extends AppCompatActivity {
MaterialButton btnSignin;
MaterialButton btnSignup, btnSignIn;
ConstraintLayout loginSheetLayout, registerSheetLayout;
int height, width;
ImageButton closeBtn;
private String TAG = "MainActivity";
......@@ -110,7 +105,6 @@ public class LoginActivity extends AppCompatActivity {
@Override
public void onClick(View view) {
registerState = new RegisterState(LoginActivity.this,mainViewModels);
registerState.setCancelable(false);
registerState.show(getSupportFragmentManager(),registerState.getTag());
}
});
......
......@@ -94,22 +94,14 @@ public class LoginState extends BottomSheetDialogFragment {
sheetBehavior = BottomSheetBehavior.from((View) (view.getParent()));
// get Window size
int getHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
int setHeight = getHeight - (getHeight * 5) / 100;
int setHeight = utils.getWindowHeight() - (utils.getWindowHeight() * 5) / 100;
// set max height
sheetBehavior.setPeekHeight(setHeight);
loginLayout.setMinimumHeight(setHeight);
// loginButton on click
loginButton.setOnClickListener(view1 -> {
if (sheetBehavior.getState() != BottomSheetBehavior.STATE_EXPANDED) {
bar.setVisibility(View.VISIBLE);
loginButton.setText("");
sheetDialog.setCancelable(false);
loginAuth(view1);
}
});
loginButton.setOnClickListener(this::loginAuth);
// close btn is clicked
closeBtn.setOnClickListener(view12 -> {
......@@ -120,7 +112,6 @@ public class LoginState extends BottomSheetDialogFragment {
}
private void loginAuth(View v) {
if (TextUtils.isEmpty(username.getText().toString()) &&
TextUtils.isEmpty(password.getText().toString())){
username.setError("This field can't empty");
......@@ -134,6 +125,10 @@ public class LoginState extends BottomSheetDialogFragment {
* Jika tombol sign in ditekan
*
* nonaktifkan semua form */
bar.setVisibility(View.VISIBLE);
loginButton.setText("");
sheetDialog.setCancelable(false);
username.setEnabled(false);
password.setEnabled(false);
loginButton.setEnabled(false);
......@@ -183,9 +178,7 @@ public class LoginState extends BottomSheetDialogFragment {
sheetDialog.setCancelable(true);
final View customLayout = getLayoutInflater()
.inflate(
R.layout.alert_dialog,
null);
.inflate(R.layout.alert_dialog, null);
// tampilkan alert dialog
utils = new Utils(customLayout);
......
......@@ -78,8 +78,7 @@ public class RegisterState extends BottomSheetDialogFragment {
sheetBehavior2 = BottomSheetBehavior.from((View) (view.getParent()));
// get Window size
int getHeight = Resources.getSystem().getDisplayMetrics().heightPixels;
int setHeight = getHeight - (getHeight * 5) / 100;
int setHeight = utils.getWindowHeight() - (utils.getWindowHeight() * 5) / 100;
// set max height
sheetBehavior2.setPeekHeight(setHeight);
......
......@@ -290,4 +290,11 @@ public class Utils {
}
// get window size
public int getWindowHeight() {
return Resources.getSystem().getDisplayMetrics().heightPixels;
}
public int getWindowWidth() {
return Resources.getSystem().getDisplayMetrics().widthPixels;
}
}
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