-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsignup.patch
86 lines (76 loc) · 3.35 KB
/
signup.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Index: app/src/main/java/com/example/mp23_termproject_voldemorp/SignUpDialog.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/app/src/main/java/com/example/mp23_termproject_voldemorp/SignUpDialog.java b/app/src/main/java/com/example/mp23_termproject_voldemorp/SignUpDialog.java
--- a/app/src/main/java/com/example/mp23_termproject_voldemorp/SignUpDialog.java (revision ed8a5c85fef0209e90361d5f2ae9bd4572b187f1)
+++ b/app/src/main/java/com/example/mp23_termproject_voldemorp/SignUpDialog.java (revision d9ad430c5e80875b9580a47408162aa25261434b)
@@ -26,6 +26,14 @@
import android.widget.TextView;
import android.widget.Toast;
+import com.google.android.gms.tasks.OnCompleteListener;
+import com.google.android.gms.tasks.Task;
+import com.google.firebase.auth.AuthResult;
+import com.google.firebase.auth.FirebaseAuth;
+import com.google.firebase.database.FirebaseDatabase;
+
+import java.util.concurrent.Executor;
+
public class SignUpDialog extends Dialog {
//이메일 형식 확인
@@ -46,6 +54,13 @@
//닉네임 중복확인 버튼 눌렀는지 유무
private boolean nicknameCheckButtonClicked=false;
+ private FirebaseAuth firebaseAuth;
+ private FirebaseDatabase mDatabase;
+
+ public class UserModel{
+ public String userName;
+ }
+
//화면 터치시 키보드 내리기
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
@@ -71,7 +86,9 @@
}
});
-
+ //파이어베이스 설정
+ firebaseAuth = FirebaseAuth.getInstance();
+ mDatabase = FirebaseDatabase.getInstance();
//-------------이메일-------------
@@ -297,6 +314,7 @@
//위치정보ㅁ
CheckBox locationCheckBox=(CheckBox) findViewById(R.id.signUpAgreeLocationCheckBox);
+
//---------가입하기-----------
Button signUpBtn = (Button) findViewById(R.id.signUpBtn);
@@ -331,12 +349,27 @@
//회원가입 성공
else {
//[서버] 가입하기 버튼 누를시에 입력한 정보들 데이터에 저장(메일:email, 닉네임:nickname, 비밀번호:password)
+ firebaseAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener
+ ((Executor) SignUpDialog.this, new OnCompleteListener<AuthResult>() {
+ @Override
+ public void onComplete(@NonNull Task<AuthResult> task) {
+ if (task.isSuccessful()) {
+ UserModel userModel = new UserModel();
+
+ userModel.userName = nickname;
+
+ mDatabase.getReference().child("users")
+ .setValue(userModel);
+ }
+ }
+ });
+
Toast.makeText(context.getApplicationContext(), "회원가입이 완료되었습니다", Toast.LENGTH_SHORT).show();
dismiss();
}
}
});
+ }
- }
}
\ No newline at end of file