当前位置: 首页>>代码示例>>Java>>正文


Java DataSnapshot.getChildren方法代码示例

本文整理汇总了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();
        }
    };
}
 
开发者ID:googlesamples,项目名称:android-OurStreets,代码行数:31,代码来源:DataPresenter.java

示例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;

}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:26,代码来源:CollaborativeMenuAnswerRepository.java

示例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;

}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:24,代码来源:ValorationRepository.java

示例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;
}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:18,代码来源:DishRepository.java

示例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;
}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:22,代码来源:PaymentMenuAnswerRepository.java

示例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;
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:11,代码来源:MessagesEventListener.java

示例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;
}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:32,代码来源:PaymentMenuRepository.java

示例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;
}
 
开发者ID:BlunchDev,项目名称:blunch_android,代码行数:14,代码来源:PersonRepository.java

示例9: onDataChange

import com.firebase.client.DataSnapshot; //导入方法依赖的package包/类
@Override public void onDataChange(DataSnapshot dataSnapshot) {
  nearestHourScheduler = new NearestHourScheduler(dataSnapshot.getChildren());
}
 
开发者ID:Eric-Gonzalez,项目名称:marclay,代码行数:4,代码来源:MediaDispatcher.java


注:本文中的com.firebase.client.DataSnapshot.getChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。