0
什麼是正確的方式來查詢附加到Android中的照片(POJO)的每個評論(POJO)。在火力地堡,我有一個照片集的結構如下:Firebase - 從Android中的FirebaseListAdapter查詢
"photos" : {
"-KaeuYf9jXcy4oqpRqbi" : {f
"entities" : {
"type" : {
"image" : {
"bucket" : "bucket",
"prefix" : "https://s3-us-west-2.amazonaws.com/",
"suffix" : "image.jpg"
}
}
},
"stats" : {
"liked" : 0
},
"text" : "Person Detected!",
"timestamp" : 1484631194257
}
}
和意見收集:
"comments" : {
"-KdE6Hwua8d6sBQimPos" : {
"attachphoto" : {
"-KaeuYf9jXcy4oqpRqbi" : true
},
"attachuser" : {
"-KaeuYHjkdf9okflslf" : true
},
"displayName" : "Gary",
"text" : "ok",
"timestamp" : 1487385995844
},
"-KdE6IPc-NL-6zGkwXq3" : {
"attachphoto" : {
"-KaeuYf9jXcy4oqpRqbi" : true
},
"attachuser" : {
"-KaeuYHjkdf9okflslf" : true
},
"displayName" : "Thomas",
"text" : "ok",
"timestamp" : 1487385997735
}
}
在Android中我使用的是FirebaseAdapter,但我有一個定義適當的查詢麻煩那隻會檢索附加到特定照片的評論。我的照片
FirebaseListAdapter adapter = new CommentAdapter(this, Comment.class, R.layout.item_comment, QUERY){
@Override
protected void populateView(View v, Comment model, int position) {
if(model.getDisplayName()!=null) {
String[] name = model.getDisplayName().split(" ");
((TextView) v.findViewById(R.id.id)).setText(name[0]);
}
((TextView) v.findViewById(R.id.content)).setText(model.getText());
}
};
的關鍵,我想我可以定義是這樣的:
final FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference commentsRef = database.getReference("comments");
Query query = commentsRef.orderByChild("attachphoto").equalTo()
但我有一個關於如何完成這個有些脫節。首先使用Firebase的項目,所以任何幫助/技巧將非常感謝!
看起來好像你正試圖將評論分類。見http://stackoverflow.com/questions/40656589/firebase-query-if-child-of-child-contains-a-value –
謝謝你的工作! StringBuilder child = new StringBuilder(「attachphoto /」); child.append(imageKey); Query query = commentsRef.orderByChild(child.toString())。equalTo(Boolean.TRUE); – gareoke