So I'm having a project here from an appblog,
Ineedhelpnowtogetthetanned.
mDatabaseLike=FirebaseDatabase.getInstance().getReference().child("Likes");
}
});
viewHolder.mLikeBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mProcessLike = true;
mDatabaseLike.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if (mProcessLike ){
if(dataSnapshot.child(post_key).hasChild(mAuth.getCurrentUser().getUid())){
mDatabaseLike.child(post_key).child(mAuth.getCurrentUser().getUid()).removeValue();
mProcessLike = false;
} else {
mDatabaseLike.child(post_key).child(mAuth.getCurrentUser().getUid()).setValue("RandomValue");
mProcessLike = false;
}
}}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
});
}
};
link
RESOLVED
mDatabaseLike.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//Log.e(String.valueOf(dataSnapshot.child(post_key)),dataSnapshot.getChildrenCount() + "");
for (DataSnapshot snap: dataSnapshot.getChildren()) {
//Log.e(String.valueOf(snap.child(currentUserId).toString()),snap.getChildrenCount() + "");
mCurtidas.setText(dataSnapshot.child(currentUserId).getChildrenCount() + "");
}}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});