當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。