I have a recyclerView called "Notes", I'm trying to add an new recylerview called "Assignments" which will be created inside the notes recylerview item. When I click on a recylerview item (notes) it send me to ClassworkActivity in which the assignments' recyclerview will be added to it. So I want to add the assignment recyclerview as a child of the notes recyclerview.
Here's what I tried:
final AssignmentAdapter assignmentAdapter=new AssignmentAdapter(assignlist,this);
recyclerView.setAdapter(assignmentAdapter);
FloatingActionButton fab = findViewById(R.id.fab);
mCurrentUser = FirebaseAuth.getInstance().getCurrentUser();
String userID = mCurrentUser.getUid();
firebaseDatabase=FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference().child("Users").child(userID).child("Notes").child(id).child("Assignments");
databaseReference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot dataSnapshot1: dataSnapshot.getChildren())
{
AssignListdata listdata=dataSnapshot1.getValue(AssignListdata.class);
assignlist.add(listdata);
}
assignmentAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
// fab
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(getApplicationContext(), AddAssignmentActivity.class));
}
});
But I'm getting the error on this line:
databaseReference = firebaseDatabase.getReference().
child("Users").
child(userID).
child("Notes").
child(id).
child("Assignments");
since I didn't create the variable id : child(id).
which is the id of the Notes List
Can anyone tell me how to declare this variable?
Another thing is that the assignments are created as a Notes in the NotesActivity, not in the ClassworkActivity!
Also, this is a github link of my project, Please take a look at it: Notes App