Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
protected class SelfChallengeManager implements Transaction.Handler, ValueEventListener {
protected final Challenge mUploadedChallenge;
protected DatabaseReference mChallengeRef;
protected DatabaseReference mGameRecordRef;
protected SelfChallengeManager() {
mUploadedChallenge = new Challenge(
FirebaseAuth.getInstance().getCurrentUser().getUid(), null);
public Transaction.Result doTransaction(@NonNull MutableData mutableData) {
mGameRecordRef = FirebaseDatabase.getInstance().getReference()
mUploadedChallenge.gameRef =
GAMES_RECORD + "/" + mGameRecordRef.getKey();
mGamePath = mUploadedChallenge.gameRef;
mChallengeRef = mUserRoomRef.push();
return Transaction.success(mutableData);
public void onComplete(@Nullable DatabaseError databaseError, boolean b,
@Nullable DataSnapshot dataSnapshot) {
Log.d("MatchMaker", "Published player challenge");
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
if (dataSnapshot.getValue() == null) {
mChallengeRef = null;
mGameRecordRef = null;
mSelfChallengeManager = null;
public void onCancelled(@NonNull DatabaseError databaseError) {
Log.d("MatchMaker", "Cancelled: " + databaseError.getMessage());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.