Skip to content

Instantly share code, notes, and snippets.

@SukantPal SukantPal/
Last active Feb 10, 2019

What would you like to do?
protected class Matcher implements Transaction.Handler {
private Challenge mSelectedChallenge = null;
private final OnFailCallback mFailCallback;
protected Matcher(@Nullable OnFailCallback failCallback) {
mFailCallback = failCallback;
public Transaction.Result doTransaction(@NonNull MutableData mutableData) {
for (MutableData challengeData : mutableData.getChildren()) {
final Challenge postedChallenge = challengeData.getValue(Challenge.class);
if (isChallengeCompat(postedChallenge)) {
mSelectedChallenge = postedChallenge;
return Transaction.success(mutableData);
Log.d("MatchMaker.Matcher", "Didn't find any matching challenge");
return Transaction.success(mutableData);
public void onComplete(@Nullable DatabaseError databaseError,
boolean b, @Nullable DataSnapshot dataSnapshot) {
if (mSelectedChallenge != null) {
mOpener = mSelectedChallenge.opener;
mGamePath = mSelectedChallenge.gameRef;
Log.d("MatchMaker.Matcher", "Found match, onComplete");
} else if (mFailCallback != null) {
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.