com.google.firebase.database.Query.addChildEventListener()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中com.google.firebase.database.Query.addChildEventListener方法的一些代码示例,展示了Query.addChildEventListener的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Query.addChildEventListener方法的具体详情如下:
包路径:com.google.firebase.database.Query
类名称:Query
方法名:addChildEventListener

Query.addChildEventListener介绍

[英]Add a listener for child events occurring at this location. When child locations are added, removed, changed, or moved, the listener will be triggered for the appropriate event.
[中]为在此位置发生的子事件添加侦听器。当添加、删除、更改或移动子位置时,将触发相应事件的侦听器。

代码示例

代码示例来源:origin: chat-sdk/chat-sdk-android

ChildEventListener listener = query.addChildEventListener(new FirebaseEventListener().onChildAdded((snapshot, s, hasValue) -> {
  if (hasValue) {

代码示例来源:origin: chat-sdk/chat-sdk-android

public Observable<Message> messageRemovedOn() {
    return Observable.create(e -> {

      Query query = FirebasePaths.threadMessagesRef(model.getEntityID());

      query = query.orderByChild(Keys.Date);
      query = query.limitToLast(ChatSDK.config().messageDeletionListenerLimit);

      ChildEventListener removedListener = query.addChildEventListener(new FirebaseEventListener().onChildRemoved((snapshot, hasValue) -> {
        if(hasValue) {
          MessageWrapper message = new MessageWrapper(snapshot);
          this.model.removeMessage(message.getModel());
//                    updateLastMessage().subscribe(new CrashReportingCompletableObserver());
          e.onNext(message.getModel());
        }
      }));
      FirebaseReferenceManager.shared().addRef(query, removedListener);
    });
  }

代码示例来源:origin: FrangSierra/RxFirebase

query.addChildEventListener(childEventListener);

代码示例来源:origin: yongjhih/rxfirebase

private void verifyQueryAddChildEventListener() {
  verify(mockQuery)
      .addChildEventListener(childEventListener.capture());
}

代码示例来源:origin: firebase/snippets-android

public void orderByNested() {
  // [START rtdb_order_by_nested]
  // Most viewed posts
  Query myMostViewedPostsQuery = databaseReference.child("posts")
      .orderByChild("metrics/views");
  myMostViewedPostsQuery.addChildEventListener(new ChildEventListener() {
    // TODO: implement the ChildEventListener methods as documented above
    // [START_EXCLUDE]
    @Override
    public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {}
    @Override
    public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {}
    @Override
    public void onChildRemoved(@NonNull DataSnapshot dataSnapshot) {}
    @Override
    public void onChildMoved(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {}
    @Override
    public void onCancelled(@NonNull DatabaseError databaseError) {}
    // [END_EXCLUDE]
  });
  // [END rtdb_order_by_nested]
}

代码示例来源:origin: TomGrill/gdx-firebase

@Override
public ChildEventListener addChildEventListener(final ChildEventListener listener) {
  com.google.firebase.database.ChildEventListener fbListener = new com.google.firebase.database.ChildEventListener() {
    @Override
    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
      listener.onChildAdded(new DesktopDataSnapshot(dataSnapshot), s);
    }
    @Override
    public void onChildChanged(DataSnapshot dataSnapshot, String s) {
      listener.onChildChanged(new DesktopDataSnapshot(dataSnapshot), s);
    }
    @Override
    public void onChildRemoved(DataSnapshot dataSnapshot) {
      listener.onChildRemoved(new DesktopDataSnapshot(dataSnapshot));
    }
    @Override
    public void onChildMoved(DataSnapshot dataSnapshot, String s) {
      listener.onChildMoved(new DesktopDataSnapshot(dataSnapshot), s);
    }
    @Override
    public void onCancelled(DatabaseError databaseError) {
      listener.onCancelled(new DesktopDatabaseError(databaseError));
    }
  };
  query.addChildEventListener(fbListener);
  fbChildEventListenerList.add(fbListener);
  childEventListenerList.add(listener);
  return listener;
}

代码示例来源:origin: Stoick001/SnapchatClone

Query query = usersDB.orderByChild("username").startAt(searchUsers.getText().toString()).endAt(searchUsers.getText().toString() + "\uf8ff");
query.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

代码示例来源:origin: Stoick001/SnapchatClone

Query query = usersDB.orderByChild("username").startAt(mInput.getText().toString()).endAt(mInput.getText().toString() + "\uf8ff");
query.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {

代码示例来源:origin: firebase/snippets-android

public void basicQuery() {
  // [START basic_query]
  // My top posts by number of stars
  String myUserId = getUid();
  Query myTopPostsQuery = databaseReference.child("user-posts").child(myUserId)
      .orderByChild("starCount");
  myTopPostsQuery.addChildEventListener(new ChildEventListener() {
    // TODO: implement the ChildEventListener methods as documented above
    // [START_EXCLUDE]
    public void onChildAdded(DataSnapshot dataSnapshot, String s) { }
    public void onChildChanged(DataSnapshot dataSnapshot, String s) { }
    public void onChildRemoved(DataSnapshot dataSnapshot) { }
    public void onChildMoved(DataSnapshot dataSnapshot, String s) { }
    public void onCancelled(DatabaseError databaseError) { }
    // [END_EXCLUDE]
  });
  // [END basic_query]
}

代码示例来源:origin: firebase/snippets-android

private void queryRecentScores() {
  scoresRef.orderByValue().limitToLast(4).addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(@NonNull DataSnapshot snapshot, String previousChild) {
  scoresRef.orderByValue().limitToLast(2).addChildEventListener(new ChildEventListener() {
    @Override
    public void onChildAdded(@NonNull DataSnapshot snapshot, String previousChild) {

代码示例来源:origin: hieuapp/android-firebase-chat

listKey.add(friend.idRoom);
mapQuery.get(friend.idRoom).addChildEventListener(mapChildEventListenerMap.get(friend.idRoom));
  listKey.add(group.id);
mapQuery.get(group.id).addChildEventListener(mapChildEventListenerMap.get(group.id));

代码示例来源:origin: hieuapp/android-firebase-chat

mapQuery.get(id).addChildEventListener(mapChildListener.get(id));
  mapMark.put(id, true);
} else {
  mapQuery.get(id).removeEventListener(mapChildListener.get(id));
  mapQuery.get(id).addChildEventListener(mapChildListener.get(id));
  mapMark.put(id, true);

代码示例来源:origin: akshayejh/Lapit---Android-Firebase-Chat-App

messageQuery.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String s) {

代码示例来源:origin: akshayejh/Lapit---Android-Firebase-Chat-App

messageQuery.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String s) {

代码示例来源:origin: dragosholban/AndroidMyInstagramApp

imagesQuery.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String s) {

代码示例来源:origin: akshayejh/Lapit---Android-Firebase-Chat-App

lastMessageQuery.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String s) {

代码示例来源:origin: dragosholban/AndroidMyInstagramApp

likesQuery.addChildEventListener(new ChildEventListener() {
  @Override
  public void onChildAdded(DataSnapshot dataSnapshot, String s) {

相关文章