'Android firestore variable not defined related to callback method

I apply (Callback method to fix the asynchronous problem)the https://www.youtube.com/watch?v=0ofkvm97i0s video. But I have problems.

Hear are readData and interface.

    private void readData(FirestoreCallback firestorecallback){
    String currentUserId = firebaseAuth.getCurrentUser().getUid();
    DocumentReference docRef = firestore.collection("Users").document(currentUserId);
    docRef.get().addOnCompleteListener(new OnCompleteListener<DocumentSnapshot>() {
        @Override
        public void onComplete(@NonNull Task<DocumentSnapshot> task) {
            if(task.isSuccessful()){
                DocumentSnapshot document = task.getResult();
                if(document.exists()){
                    a = document.getString('gender');
                }
                firestorecallback.onCallback(a);
            }

        }
    });
}
private interface FirestoreCallback{
    void onCallback(String b);
}

And in onCreate method

readData(new FirestoreCallback() {
        @Override
        public void onCallback(String b) {
            String c;
            if(b=='남자'){
                c ='여자';
            }
            if(b=='여자'){
                c = '남자';
            }
            EventChangeListener(b);
            Log.d('',b);
            Log.d('',c);
        }
    });

EventChangeListener function's code

private void EventChangeListener(String a) {

    //firestore.collection('Users').orderBy('time',Query.Direction.DESCENDING).limit(50)
    // 
    firestore.collection('Users')
            //.whereEqualTo('mbti','ENTP')
            //.whereEqualTo('region','')
            .whereEqualTo('gender',a)
            .orderBy('time',Query.Direction.DESCENDING).limit(50)
            .addSnapshotListener(new EventListener<QuerySnapshot>() {
                @Override
                public void onEvent(@Nullable QuerySnapshot value, @Nullable FirebaseFirestoreException error) {
                    if(error != null){

                        if(progressDialog.isShowing()){
                            progressDialog.dismiss();
                        }

                        Log.e("Firestore error",error.getMessage());
                        return;

                    }

                    for (DocumentChange dc : value.getDocumentChanges()){

                        if (dc.getType() == DocumentChange.Type.ADDED){
                            userArrayList.add(dc.getDocument().toObject(User.class));
                        }

                        myAdapter.notifyDataSetChanged();
                        if(progressDialog.isShowing()){
                            progressDialog.dismiss();
                        }

                    }

                }
            });
}

As you can see, I can get the variable 'b' but I want to when users' 'b' is male c-> male, 'b' is female c-> male. So I define the variable 'c' but android said variable c is not defined

public void onCallback(String b) {
        String c;
        if(b=='female'){
            c ='male';
        }
        if(b=='male'){
            c = 'female';
        }
        EventChangeListener(b);
        Log.d('',b);
        Log.d('',c);
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source