确定Firebase是否不使用startAt和endAT下载数据 [英] Determining if Firebase didn't download data with startAt and endAT

查看:79
本文介绍了确定Firebase是否不使用startAt和endAT下载数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Firebase下载数据.问题是我要根据时间戳下载数据.如果它们只是我正在填充的ListView中的一项,我想从Firebase获取接下来两个小时的数据,如果最近两个小时没有任何数据,我想获取下一个两个小时的数据,依此类推,直到获得其他数据为止.问题是我不完全了解如何确定Firebase是否实际下载了数据.因为如果下载了数据,我可以在listView中使用OnScrollListener来下载更多数据,因为在那之后它将可以滚动.任何帮助将不胜感激.

I'm trying to download data with Firebase. The issue is that I'm downloading the data based off of a timestamp. If their is only one item in my ListView that I'm populating, I want to get the next two hours worth of data from Firebase and if there isn't any data from the last two hours, I want to get the next two hours of data and so on until I get some additional data. The issue is that I don't exactly know how to determine if Firebase actually downloaded data. Because if data was downloaded, I can use an OnScrollListener for my listView to download more data since it will be scrollable after that point. Any help would be appreciated.

推荐答案

Firebase is a real-time database为例,您不知道何时从数据库获取数据完成,并且获取数据可能永远不会完成.这就是为什么将其命名为实时数据库的原因,因为在任何内存中都可以更改数据库,可以添加或删除项目.

You cannot know when getting the data from the database is completed becase Firebase is a real-time database and getting data might never complete. That's why is named a realtime database because in any momemnt the database can be changed, items can be added or deleted.

部分知道您是否在特定位置拥有所有数据的唯一方法是对其执行单个值"类型查询.即使那样,在调用该侦听器之后数据也可能会发生变化,因此您真正拥有的只是在特定时间的snapshot.

The only way to partially know if you have all the data at a particular location is to perform a single 'value' type query on it. Even then, the data may change after that listener is invoked, so all you really have is a snapshot at a particular moment in time.

仅当您在数据库中写入更新数据时才能使用CompletionListener,并且当Firebase服务器确认该操作后,您将收到通知但是在读取数据时不能使用此界面.

You can use a CompletionListener only when you write or update data in your database and you'll be notified when the operation has been acknowledged by the Firebase servers but you cannot use this interface when reading data.

这篇关于确定Firebase是否不使用startAt和endAT下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆