Last active
October 13, 2016 20:51
-
-
Save rounaksalim95/a5cba332400c6caf8320f15b0cbf06e8 to your computer and use it in GitHub Desktop.
This file contains 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
// The user already has an account and is signed in | |
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); | |
if (user != null) { | |
mDatabase.child("userData").runTransaction(new com.google.firebase.database.Transaction.Handler() { | |
@Override | |
public com.google.firebase.database.Transaction.Result doTransaction(com.google.firebase.database.MutableData mutableData) { | |
Object value = mutableData.child(user.getUid()).getValue(); | |
System.out.println("New value : " + value); | |
if (value == null) { | |
mDatabase.child("userData").child(user.getUid()).push().setValue(1); | |
return com.google.firebase.database.Transaction.success(mutableData); | |
} | |
return null; | |
} | |
@Override | |
public void onComplete(DatabaseError databaseError, boolean b, com.google.firebase.database.DataSnapshot dataSnapshot) { | |
System.out.println("[DEBUG]: inside onComplete!"); | |
System.out.println("[DEBUG]: message" + databaseError.getMessage()); | |
System.out.println("[DEBUG]: details" + databaseError.getDetails()); | |
System.out.println("[DEBUG]: code" + databaseError.getCode()); | |
System.out.println("[DEBUG]: boolean b" + b); | |
System.out.println("[DEBUG]: DataS dataSnapshot" + dataSnapshot); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment