这是我数据库的结构: database structure, click to view the image
这是JSON树:
{
"Images": {
"01": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/25018141_523451678022824_7360286065040556032_n.jpg?alt=media&token=8829f210-93d3-4f10-8a82-4a523209c4e9",
"userId": "riazosama"
},
"02": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/25016768_1405603549550272_1874226094777827328_n.jpg?alt=media&token=8622ab00-6bad-4f69-b01e-21eb2202e9d7",
"userId": "riazosama"
},
"03": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/25012591_1984569698483940_6077994085279334400_n.jpg?alt=media&token=1beeac3e-3a68-448b-845a-ae950e98b09a",
"userId": "riazosama"
},
"04": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/24845784_1498412240196703_2260522595910680576_n.jpg?alt=media&token=a10bf237-1716-4bfa-aac2-3a9abb9bb6c9",
"userId": "riazosama"
},
"05": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/24845421_322450898237800_880491097661374464_n.jpg?alt=media&token=d06f1640-8e1f-4b1c-b6c5-8a39854cc474",
"userId": "riazosama"
},
"06": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/24845144_2065724523649789_5632988310377857024_n.jpg?alt=media&token=f8dd5d1c-94f6-47bf-89c4-36866f5be0b5",
"userId": "riazosama"
},
"07": {
"description": "Best Thing",
"link": "https://firebasestorage.googleapis.com/v0/b/build3-9b01e.appspot.com/o/24327898_163605550912688_741693478529925120_n.jpg?alt=media&token=bd8b47bd-94fa-4bfd-955b-ab7982947d1f",
"userId": "riazosama"
}
},
"User": {
"riazosama": {
"name": "Osama Riaz",
"email": "riazosama@gmail.com",
"password": "1122"
},
"arsamriazz": {
"name": "Arsam Riaz",
"email": "arsamriaz@gmail.com",
"password": "1122"
}
}
}
现在我正在尝试从“图像”表中检索所有图像,其中“UserId”与我想要的Id匹配。我们只是说这个例子,UserId匹配“arsamriazz”。
这是我试图用它来检索图像的代码。它没有显示任何内容。
if(getIntent() != null){
userId = getIntent().getStringExtra("UserId");
Log.e("ID", userId);
}
if(!userId.isEmpty()){
loadimages();
}
private void loadimages() {
adapter = new FirebaseRecyclerAdapter<Images, UserImagesViewHolder>(Images.class, R.layout.activity_user_profile_images,
UserImagesViewHolder.class,
table_images.orderByChild("UserId").equalTo(userId)) {
@Override
protected void populateViewHolder(UserImagesViewHolder viewHolder, Images model, int position) {
Picasso.with(getBaseContext()).load(model.getLink())
.into(viewHolder.posted_img);
}
};
adapter.notifyDataSetChanged(); //referesh if data is changend
recyclerView.setAdapter(adapter);
}