本文整理汇总了Java中com.firebase.client.DataSnapshot.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java DataSnapshot.getChildren方法的具体用法?Java DataSnapshot.getChildren怎么用?Java DataSnapshot.getChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.firebase.client.DataSnapshot
的用法示例。
在下文中一共展示了DataSnapshot.getChildren方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataPresenter
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
/**
* Creates a data presenter.
*
* @param dataView The view which will display the data.
* @param configUrl The firebase endpoint url.
*/
DataPresenter(@NonNull DataView<T> dataView, @NonNull String configUrl) {
mFirebase = new Firebase(configUrl);
mData = new ArrayList<>();
mDataView = dataView;
mValueEventListener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
mData.clear();
for (DataSnapshot data : dataSnapshot.getChildren()) {
// Data parsing is being done within the extending classes.
mData.add(parseData(data));
}
mDataView.showData(mData);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
Log.d(TAG, "onCancelled: " + firebaseError.getMessage());
// Deliberately swallow the firebase error here.
mDataView.showError();
}
};
}
示例2: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
protected CollaborativeMenuAnswer convert(DataSnapshot data) {
if (data == null) return null;
CollaborativeMenuAnswer collaborativeMenuAnswer = new CollaborativeMenuAnswer();
collaborativeMenuAnswer.setId(data.getKey());
for (DataSnapshot d : data.getChildren()) {
if ("guest".equals(d.getKey())) {
collaborativeMenuAnswer.setGuest(d.getValue(String.class));
} else if ("date".equals(d.getKey())) {
collaborativeMenuAnswer.setDate(d.getValue(Date.class));
} else if ("offeredDishes".equals(d.getKey())) {
List<String> dishes = new ArrayList<>();
for (DataSnapshot dish : d.getChildren()) {
dishes.add(dish.getKey());
}
collaborativeMenuAnswer.setOfferedDishes(dishes);
}else if ("menuId".equals(d.getKey())) {
collaborativeMenuAnswer.setMenuId(d.getValue(String.class));
}
}
return collaborativeMenuAnswer;
}
示例3: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
protected Valoration convert(DataSnapshot data) {
if (data == null) return null;
Valoration valoration = new Valoration();
valoration.setId(data.getKey());
for (DataSnapshot d : data.getChildren()) {
if ("points".equals(d.getKey())) {
valoration.setPoints(d.getValue(Double.class));
}else if ("comment".equals(d.getKey())) {
valoration.setComment(d.getValue(String.class));
}else if ("menu".equals(d.getKey())) {
valoration.setMenu(d.getValue(String.class));
}else if ("host".equals(d.getKey())) {
valoration.setHost(d.getValue(String.class));
}else if ("guest".equals(d.getKey())) {
valoration.setGuest(d.getValue(String.class));
}
}
return valoration;
}
示例4: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
protected Dish convert(DataSnapshot data) {
if (data == null) return null;
Dish dish = new Dish();
dish.setId(data.getKey());
for (DataSnapshot d : data.getChildren()) {
if (d.getKey().equals("name")) {
dish.setName(d.getValue(String.class));
} else if (d.getKey().equals("price")) {
dish.setPrice(d.getValue(Double.class));
} else if (d.getKey().equals("author")) {
dish.setAuthor(d.getValue(String.class));
}
}
return dish;
}
示例5: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
protected PaymentMenuAnswer convert(DataSnapshot data) {
if (data == null) return null;
PaymentMenuAnswer answer = new PaymentMenuAnswer();
answer.setId(data.getKey());
for (DataSnapshot d : data.getChildren()) {
if (d.getKey().equals("idMenu"))
answer.setIdMenu(d.getValue(String.class));
else if (d.getKey().equals("guest"))
answer.setGuest(d.getValue(String.class));
else if (d.getKey().equals("choosenDishes")) {
List<String> dishes = new ArrayList<>();
for (DataSnapshot dish : d.getChildren()) {
dishes.add(dish.getKey());
}
answer.setChoosenDishesKeys(dishes);
}
}
return answer;
}
示例6: parse
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
private TreeSet<Message> parse(DataSnapshot dataSnapshot) {
TreeSet<Message> messages = new TreeSet<>();
for (DataSnapshot child : dataSnapshot.getChildren()) {
Message message = child.getValue(Message.class);
message.setKey(child.getKey());
messages.add(message);
}
return messages;
}
示例7: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
protected PaymentMenu convert(DataSnapshot data) {
if (data == null) return null;
PaymentMenu paymentMenu = new PaymentMenu();
paymentMenu.setId(data.getKey());
for (DataSnapshot d : data.getChildren()) {
if (d.getKey().equals("name")) {
paymentMenu.setName(d.getValue(String.class));
} else if (d.getKey().equals("author")) {
paymentMenu.setAuthor(d.getValue(String.class));
} else if (d.getKey().equals("description")) {
paymentMenu.setDescription(d.getValue(String.class));
} else if (d.getKey().equals("localization")) {
paymentMenu.setLocalization(d.getValue(String.class));
} else if (d.getKey().equals("dateStart")) {
paymentMenu.setDateStart(d.getValue(Date.class));
} else if (d.getKey().equals("dateEnd")) {
paymentMenu.setDateEnd(d.getValue(Date.class));
} else if (d.getKey().equals("dishes")) {
List<String> dishes = new ArrayList<>();
for (DataSnapshot dish : d.getChildren()) {
dishes.add(dish.getKey());
}
paymentMenu.setDishes(dishes);
} else if (d.getKey().equals("dietTags")) {
paymentMenu.setDietTagsString(d.getValue(String.class));
}
}
return paymentMenu;
}
示例8: convert
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override
public Person convert(DataSnapshot child) {
Person person = new Person();
person.setId(child.getKey());
for (DataSnapshot d : child.getChildren()) {
if (d.getKey().equals("name")) {
person.setName(d.getValue().toString());
} else if (d.getKey().equals("age")) {
person.setAge((Integer) d.getValue());
}
}
return person;
}
示例9: onDataChange
import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override public void onDataChange(DataSnapshot dataSnapshot) {
nearestHourScheduler = new NearestHourScheduler(dataSnapshot.getChildren());
}