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

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

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

Query.limitToLast介绍

[英]Create a query with limit and anchor it to the end of the window.
[中]使用limit创建一个查询,并将其锚定到窗口的末尾。

代码示例

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

.limitToLast(numberOfMessages + 1);

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

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

代码示例来源: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: TomGrill/gdx-firebase

@Override
public Query limitToLast(int limit) {
  return new DesktopQuery(query.limitToLast(limit));
}

代码示例来源: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: firebase/quickstart-java

public void doRun() throws JobInterruptException {
  DatabaseReference ref = FirebaseDatabase.getInstance().getReference();
  // Top 5 Posts in the database, ordered by stars
  // [START top_posts_query]
  Query topPostsQuery = ref.child("posts").orderByChild("starCount").limitToLast(5);
  // [END top_posts_query]
  // All Users
  final DatabaseReference allUsersRef = ref.child("users");
  topPostsQuery.addListenerForSingleValueEvent(new ValueEventListener() {
    public void onDataChange(final DataSnapshot topPostsSnapshot) {
      allUsersRef.addListenerForSingleValueEvent(new ValueEventListener() {
        public void onDataChange(DataSnapshot allUsersSnapshot) {
          // Get users and posts as lists
          Map<String,User> users = allUsersSnapshot.getValue(new GenericTypeIndicator<Map<String, User>>() {});
          List<Post> posts = topPostsSnapshot.getValue(new GenericTypeIndicator<List<Post>>() {});
          // Send email to all users about the top 5 posts
          MyEmailer.sendWeeklyEmail(users, posts);
        }
        public void onCancelled(DatabaseError databaseError) {
          System.out.println("WeeklyEmailJob: could not get all users");
          System.out.println("WeeklyEmailJob: " + databaseError.getMessage());
        }
      });
    }
    public void onCancelled(DatabaseError databaseError) {
      System.out.println("WeeklyEmailJob: could not get top posts");
      System.out.println("WeeklyEmailJob: " + databaseError.getMessage());
    }
  });
}

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

Query messageQuery = messageRef.orderByKey().endAt(mLastKey).limitToLast(10);

相关文章