-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFireStoreClass.kt
41 lines (29 loc) · 1.1 KB
/
FireStoreClass.kt
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
package com.example.projectmanag
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
import com.google.firebase.firestore.SetOptions
class FireStoreClass {
val mFireStore=FirebaseFirestore.getInstance()
fun registerUser(Activity:SignUpActivity,UserInfo:user){
mFireStore.collection("USERS").document(getCurrentUserId()).set(UserInfo, SetOptions.merge()).addOnSuccessListener {
Activity.UserRegisterSucess()
}
}
fun getCurrentUserId():String {
var currentUser= FirebaseAuth.getInstance().currentUser
var currentUserId=" "
if(currentUser!=null){
return currentUser.uid
}
else{
return currentUserId
}
}
fun signInUser(Activity: Sign_in_Activity){
mFireStore.collection("USERS").document(getCurrentUserId()).get().addOnSuccessListener {
document->
val loggedinUser=document.toObject(user::class.java)!!
Activity.signedInUser(loggedinUser)
}
}
}