Skip to content

Commit

Permalink
Merge branch 'feat/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
gleb7499 committed Nov 23, 2024
2 parents 6ffa436 + 724b889 commit 056d523
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {

mAuth = FirebaseAuth.getInstance();

nextButton.setOnClickListener(v -> {
nextButtonClick();
});
nextButton.setOnClickListener(v -> nextButtonClick());

if (savedInstanceState == null) {
nextFragment(fragments.get(counterFragments++));
Expand All @@ -64,15 +62,15 @@ protected void onCreate(Bundle savedInstanceState) {

private void nextButtonClick() {
if (counterFragments == fragments.size()) {
if (password.isEmpty()) {
if (password == null || password.isEmpty()) {
Toast.makeText(AuthHelloActivity.this, "Введите пароль", Toast.LENGTH_SHORT).show();
}
else if (isRegister) {
registerUser();
} else {
loginUser();
}
} else if (counterFragments == fragments.size() - 1 && (email.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(email).matches())) {
} else if (counterFragments == fragments.size() - 1 && (email == null || email.isEmpty() || !Patterns.EMAIL_ADDRESS.matcher(email).matches())) {
Toast.makeText(AuthHelloActivity.this, "Неверный email", Toast.LENGTH_SHORT).show();
} else {
nextFragment(fragments.get(counterFragments++));
Expand All @@ -86,9 +84,7 @@ protected void addFragmentsInList(boolean isHelloFragment) {
fragments.add(new YouIsHeroFragment());
fragments.add(new ThanksFragment());
}
fragments.add(EmailFragment.newInstance((data) -> {
email = data;
}));
fragments.add(EmailFragment.newInstance(data -> email = data));
fragments.add(SignFragment.newInstance((data, isRegister) -> {
password = data;
AuthHelloActivity.this.isRegister = isRegister;
Expand Down Expand Up @@ -116,7 +112,6 @@ private void loginUser() {
mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Вход успешен
FirebaseUser user = mAuth.getCurrentUser();
Toast.makeText(AuthHelloActivity.this, "Вход успешен", Toast.LENGTH_LONG).show();
Intent intent = new Intent(AuthHelloActivity.this, DashboardActivity.class);
startActivity(intent);
Expand Down Expand Up @@ -150,7 +145,6 @@ private void registerUser() {
mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(this, task -> {
if (task.isSuccessful()) {
// Регистрация успешна
FirebaseUser user = mAuth.getCurrentUser();
Toast.makeText(AuthHelloActivity.this, "Регистрация успешна", Toast.LENGTH_LONG).show();
Intent intent = new Intent(AuthHelloActivity.this, DashboardActivity.class);
startActivity(intent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;

import com.example.lifeline.authentication.AuthActivity;
import com.google.firebase.auth.FirebaseAuth;

public class DashboardActivity extends AppCompatActivity {
Expand All @@ -20,7 +21,7 @@ protected void onCreate(Bundle savedInstanceState) {
Button buttonOutOfSystem = findViewById(R.id.buttonOutOfSystem);
buttonOutOfSystem.setOnClickListener(v -> {
FirebaseAuth.getInstance().signOut();
Intent intent = new Intent(DashboardActivity.this, MainActivity.class);
Intent intent = new Intent(DashboardActivity.this, AuthActivity.class);
startActivity(intent);
finish();
});
Expand Down

0 comments on commit 056d523

Please sign in to comment.