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