Created
          November 15, 2019 17:48 
        
      - 
      
 - 
        
Save gastsail/99a5c5063cc31b90fbfc8b8dae555ed4 to your computer and use it in GitHub Desktop.  
    UserDao
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class UserDao { | |
| fun getUserName(userId:String): LiveData<Resource<String>> { | |
| var userName = MutableLiveData<Resource<String>>() | |
| FirebaseFirestore.getInstance() | |
| .collection("users") | |
| .document(userId) | |
| .get() | |
| .addOnSuccessListener { | |
| userName.value = Resource.success(it.getString("name")) | |
| }.addOnFailureListener { | |
| userName.value = Resource.error("Error",it.message!!) | |
| } | |
| return userName | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment