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


Java Query.addListenerForSingleValueEvent方法代码示例

本文整理汇总了Java中com.firebase.client.Query.addListenerForSingleValueEvent方法的典型用法代码示例。如果您正苦于以下问题:Java Query.addListenerForSingleValueEvent方法的具体用法?Java Query.addListenerForSingleValueEvent怎么用?Java Query.addListenerForSingleValueEvent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.firebase.client.Query的用法示例。


在下文中一共展示了Query.addListenerForSingleValueEvent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderData

import com.firebase.client.Query; //导入方法依赖的package包/类
private void renderData() {
    Query queryRef = mRootRef.child("users").orderByChild(getOrderBy()).limitToLast(100);//we need to iterate them backwards
    queryRef.addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {

            for (DataSnapshot userSnapshot : snapshot.getChildren()) {
                mUsersDataset.add(userSnapshot.getValue(User.class));
            }
            Collections.reverse(mUsersDataset);
            mAdapter = new UserListAdapter(mUsersDataset, getActivity(), getmTabType());
            mRecyclerView.setAdapter(mAdapter);
            mLoadingWrapper.setVisibility(View.GONE);
            mRecyclerView.setVisibility(View.VISIBLE);
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {

        }
    });
}
 
开发者ID:silva96,项目名称:guessthehashtag,代码行数:23,代码来源:WeeklyFragment.java

示例2: getPosts

import com.firebase.client.Query; //导入方法依赖的package包/类
@Override
public Post[] getPosts(int numPosts) {
    Query query = firebasePostsRef.orderByChild("timestamp").limitToLast
            (numPosts);

    countDownLatch = new CountDownLatch(1);

    ValueEventListener callbackListener =
            newValueEventListenerForSynchronizingCallback();
    query.addListenerForSingleValueEvent(callbackListener);

    waitForCallback();

    if (dataFromCallback != null) {
        return parsePostsFromDataSnapshot(dataFromCallback.get());
    } else {
        return new Post[0];
    }
}
 
开发者ID:git-mad,项目名称:Bitter,代码行数:20,代码来源:FirebasePostProvider.java

示例3: getPostsByUser

import com.firebase.client.Query; //导入方法依赖的package包/类
@Override
public Post[] getPostsByUser(String userId) {
    Query query = firebasePostsRef.orderByChild("authorId").equalTo(userId);

    countDownLatch = new CountDownLatch(1);

    ValueEventListener callbackListener =
            newValueEventListenerForSynchronizingCallback();
    query.addListenerForSingleValueEvent(callbackListener);

    waitForCallback();

    if (dataFromCallback != null) {
        return parsePostsFromDataSnapshot(dataFromCallback.get());
    } else {
        return new Post[0];
    }
}
 
开发者ID:git-mad,项目名称:Bitter,代码行数:19,代码来源:FirebasePostProvider.java

示例4: getImagesByUser

import com.firebase.client.Query; //导入方法依赖的package包/类
@Override
public FirebaseImage[] getImagesByUser(String ownerUid) {
    Query userImagesQuery = imagesRef
            .orderByChild("ownerUid")
            .equalTo(ownerUid);

    final AtomicReference<DataSnapshot> snapshotAtomicRef = new
            AtomicReference<>();
    final CountDownLatch latch = new CountDownLatch(1);

    userImagesQuery.addListenerForSingleValueEvent(new ValueEventListener
            () {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            snapshotAtomicRef.set(dataSnapshot);
            latch.countDown();
        }

        @Override
        public void onCancelled(FirebaseError firebaseError) {
            throw firebaseError.toException();
        }
    });

    awaitLatch(latch);
    return parsePostsFromDataSnapshot(snapshotAtomicRef.get());
}
 
开发者ID:git-mad,项目名称:Bitter,代码行数:28,代码来源:FirebaseImageProvider.java

示例5: executeCommentQuerySynchronously

import com.firebase.client.Query; //导入方法依赖的package包/类
@NonNull
private Comment[] executeCommentQuerySynchronously(Query query) {
    countDownLatch = new CountDownLatch(1);

    query.addListenerForSingleValueEvent
            (getValueEventListenerForSynchronizingCallbacks());

    waitForCallback();

    return parseCommentsFromCallbackData();
}
 
开发者ID:git-mad,项目名称:Bitter,代码行数:12,代码来源:FirebaseCommentProvider.java

示例6: set

import com.firebase.client.Query; //导入方法依赖的package包/类
@Override
protected void set(Query query) {
    query.addListenerForSingleValueEvent(this);
}
 
开发者ID:aluxian,项目名称:Codementor,代码行数:5,代码来源:OldMessagesEventListener.java


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