firebase-realtime-database

Returning a value in Firebase onDataChange

安稳与你 提交于 2019-12-21 23:14:31
问题 I am trying to write a firebase app that contains a simple ArrayList that will serve as feed for a list view. In order to do so I have a singleton that takes care of FirebaseConnection and will fetch the data. This data is then feeded to the list. The problem is the data is first feeded to the list as null then the data is finished retrieving. Any solutions you might have for me? Here is my code: public ArrayList< Event > getAllEventsOnFirebase() { final ArrayList< Event > events = new

best practice data design in firebase

做~自己de王妃 提交于 2019-12-21 21:39:33
问题 How could i structure data for following scenario? There is an app called Food Ordering System. It contains Username(Who is registering this restaurant menus for online order) Restaurant_name Description Location Estimated Delivery Menu(Has multiple menus for one restaurant) My design "restaurant":{ "username":{ "restaurant_name":"KFC Restaurant", "description":"short description on restaurant", "estimated delivery":"1hour/km", "distance":"20km away", "location":"Kathmandu", "rating":"rating

In a firebase animated list, is there a way to let firebase list know the expected height of a widget before it loads?

强颜欢笑 提交于 2019-12-21 21:32:43
问题 Is there a way to explicitly tell a firebase animated list what the height of a specific widget should be? In my case, each item in the firebase list has a variable size based on a number of children (it's a comment thread). Whenever a large thread is out (above) of the viewport it is disposed of and the height is forgotten, this leads to annoying blocking and failure when trying to scroll back up. Here is my thread: new FirebaseAnimatedList( defaultChild: new DefaultThreadView(), query: ref

Firebase on service, will stop working afer leaving the app on background for a while

人走茶凉 提交于 2019-12-21 21:26:40
问题 Here's the thing, my app has a service (extends Service) in charge of establishing a socket connection and listen for incomming network trafic using firebase native android framework. Here's what it looks like public class SocketService extends Service { private Firebase firebase; @Override public void onCreate() { super.onCreate(); firebase = AppHelper.getInstance().getFirebase().child(AppHelper.getInstance().getFirebase().getAuth().getUid()); AppHelper.getInstance().categoriesController

Firebase results range using startAt and endAt

寵の児 提交于 2019-12-21 17:53:15
问题 I'm trying to get the first 100 results from my Firebase data, then the next 100, then the next 100 etc. I've tried multiple ways. Version 1 ref.child('products').orderByChild('domain').startAt(0).endAt(100).once('value').then(function(snapshot) {}); Version 2 ref.child('products').orderByChild('domain').startAt(0).limitToFirst(100).once('value').then(function(snapshot) {}); Version 3 ref.child('products').startAt(0).endAt(100).once('value').then(function(snapshot) {}); Every time the

Firebase, get immediate parent of a child with specific value

痴心易碎 提交于 2019-12-21 17:36:25
问题 I am working on an ios app with firebase backend. As users register, user node is created in firebase under which there are different children like email, name, avatar etc. What I am doing is that I am searching for some email in user nodes and if I find that email in some node, I want to get its parent key i.e -Ksdd23d2djhsdgjhs. See the image: I want to get the value with upper arrow if the email matches with the one I have. I have an email address and I am searching through all of the

Android: wait for firebase valueEventListener

浪子不回头ぞ 提交于 2019-12-21 17:24:06
问题 I am trying to use Semaphore to wait for my firebase valueEventListener. I have an user info activity with 6 different fields that the user must fill out. When the user saves his/her info, I want to do an "all or nothing" type of check. Certain user info cannot be duplicated...for example user name, email, and phonenumber. I am using firebase and currently the general idea is of the format: void saveUserInfo(){ if(field1 exist in database){ return; } . . . if(field6 exist in database){ return

Firebase Firestore - relational data design approaches

戏子无情 提交于 2019-12-21 16:59:26
问题 I'm totally new to Firebase, and I'm trying to get my head round the best db model design for 'relational' data, both 1-1 and 1-many. We are using the Firestore db (not the realtime db). Say we have Projects which can contain many Users , and a User can be in multiple Projects The UI needs to show a list of Users in a Project which shows things like email , firstname , lastname and department . What is the best way to store the relationship? An array of User ids in the Project document? A map

Firebase OrderByKey with startAt and endAt giving wrong results

▼魔方 西西 提交于 2019-12-21 16:54:04
问题 I have 3 objects with the keys as it looks like this: They are in format of YYYYMMDD. I am trying to get data of a month. But I am not getting the desired output. When I query it like this: var ref = db.child("-KPXECP6a1pXaM4gEYe0"); ref.orderByKey().startAt("20160901").once("value", function (snapshot) { console.log("objects: " + snapshot.numChildren()); snapshot.forEach(function(childSnapshot) { console.log(childSnapshot.key); }); }); I get the following output: objects: 3 20160822

Firebase one to one chat

吃可爱长大的小学妹 提交于 2019-12-21 16:48:12
问题 I am building a simple chat application in android with Firebase as backend. ref3.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snapshot) { Map<String, Object> users = (Map<String, Object>) snapshot.getValue(); System.out.println(users.values().toString()); Set s = users.entrySet(); Iterator itr = s.iterator(); while (itr.hasNext()) { Map.Entry m = (Map.Entry) itr.next(); m.getKey(); String myval = m.getValue().toString(); String spmyval[] =