0
我已經按照Firebase數據庫中的文檔中的建議對數據進行了非標準化。使用用戶是我存儲在:value中的成員的組列表。但是,使用在FirebaseUI中使用此列表的this suggestion,在滾動大型列表時,附加偵聽器會導致性能瓶頸。Firebase中布爾數據列表的性能問題
當用戶滾動列表時,是否有任何方式監聽器沒有連接?或者使用其他方式來減少大量引用數據庫中另一個位置的布爾值表達式的性能問題?
我已經按照Firebase數據庫中的文檔中的建議對數據進行了非標準化。使用用戶是我存儲在:value中的成員的組列表。但是,使用在FirebaseUI中使用此列表的this suggestion,在滾動大型列表時,附加偵聽器會導致性能瓶頸。Firebase中布爾數據列表的性能問題
當用戶滾動列表時,是否有任何方式監聽器沒有連接?或者使用其他方式來減少大量引用數據庫中另一個位置的布爾值表達式的性能問題?
https://firebase.google.com/docs/database/android/retrieve-data#child-events
你應該只需要附加一個監聽器,child_changed
ChildEventListener childEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String previousChildName) { Log.d(TAG, "onChildAdded:" + dataSnapshot.getKey()); // A new comment has been added, add it to the displayed list Comment comment = dataSnapshot.getValue(Comment.class); // ... } @Override public void onChildChanged(DataSnapshot dataSnapshot, String previousChildName) { Log.d(TAG, "onChildChanged:" + dataSnapshot.getKey()); // A comment has changed, use the key to determine if we are displaying this // comment and if so displayed the changed comment. Comment newComment = dataSnapshot.getValue(Comment.class); String commentKey = dataSnapshot.getKey(); // ... } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { Log.d(TAG, "onChildRemoved:" + dataSnapshot.getKey()); // A comment has changed, use the key to determine if we are displaying this // comment and if so remove it. String commentKey = dataSnapshot.getKey(); // ... } @Override public void onChildMoved(DataSnapshot dataSnapshot, String previousChildName) { Log.d(TAG, "onChildMoved:" + dataSnapshot.getKey()); // A comment has changed position, use the key to determine if we are // displaying this comment and if so move it. Comment movedComment = dataSnapshot.getValue(Comment.class); String commentKey = dataSnapshot.getKey(); // ... } @Override public void onCancelled(DatabaseError databaseError) { Log.w(TAG, "postComments:onCancelled", databaseError.toException()); Toast.makeText(mContext, "Failed to load comments.", Toast.LENGTH_SHORT).show(); } }; ref.addChildEventListener(childEventListener);
謝謝您的回答,但不會與布爾值列表和檢索列表幫助它通過在onBindViewHolder/populateViewHolder中將值事件偵聽器附加到firebase用戶界面中,從鍵中獲取項目詳細信息.. – kirtan403