本文整理汇总了Java中com.firebase.client.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于com.firebase.client包,在下文中一共展示了Query类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: observeOnce
import com.firebase.client.Query; //导入依赖的package包/类
public static Observable<DataSnapshot> observeOnce(final Query ref){
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
subscriber.onCompleted();
}
@Override
public void onCancelled(FirebaseError firebaseError) {
subscriber.onError(new FirebaseException(firebaseError));
}
});
}
});
}
开发者ID:DariusL,项目名称:RxFirebaseAndroid,代码行数:20,代码来源:RxFirebase.java
示例3: setupStoriesAdapter
import com.firebase.client.Query; //导入依赖的package包/类
private void setupStoriesAdapter(Query query) {
InfiniteFireArray<Story> storyFireArray = new InfiniteFireArray<>(Story.class
, query, 10, 10, false, false);
storiesAdapter = new StoriesAdapter(storyFireArray, publicType);
storiesAdapter.setHasStableIds(true);
storiesAdapter.registerAdapterDataObserver(storiesAdapterObserver);
if(needsUserPublish()) storiesAdapter.setUser(user);
storiesAdapter.setOnStoryViewListener(this);
storiesAdapter.setOnNewsViewListener(this);
storiesAdapter.setOnShareNewsListener(this);
storiesAdapter.setOnPublishStoryListener(onPublishStoryListener);
storiesAdapter.setOnUserStartChattingListener(onUserStartChattingListener);
storiesAdapter.setOnNeedUpdateStoryListener(this);
storiesList.setAdapter(storiesAdapter);
storiesList.setInfiniteFireArray(storyFireArray);
if (newsList != null) {
storiesAdapter.addNews(newsList);
}
}
开发者ID:rapidpro,项目名称:ureport-android,代码行数:24,代码来源:StoriesListFragment.java
示例4: loadLastChatMessage
import com.firebase.client.Query; //导入依赖的package包/类
public ValueEventListener loadLastChatMessage(final ChatRoomHolder holder
, final ChatRoomInterface.OnChatLastMessageLoadedListener onChatLastMessageLoadedListener) {
Query query = getDefaultRoot().child(messagesPath).child(holder.chatRoom.getKey()).orderByKey().limitToLast(1);
return query.addValueEventListener(new ValueEventListenerAdapter() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
super.onDataChange(dataSnapshot);
Log.d(TAG, "onDataChange() called with: " + "dataSnapshot = [" + dataSnapshot + "]");
if (dataSnapshot.exists() && dataSnapshot.getChildrenCount() > 0) {
ChatMessage lastChatMessage = dataSnapshot.getChildren().iterator().next().getValue(ChatMessage.class);
if (lastChatMessage != null) {
lastChatMessage.setKey(dataSnapshot.getKey());
int indexOfUser = holder.members.getUsers().indexOf(lastChatMessage.getUser());
if (indexOfUser >= 0) {
lastChatMessage.setUser(holder.members.getUsers().get(indexOfUser));
}
holder.lastMessage = lastChatMessage;
}
onChatLastMessageLoadedListener.onChatLastMessageLoaded(lastChatMessage);
} else {
onChatLastMessageLoadedListener.onChatLastMessageLoadFailed();
}
}
});
}
开发者ID:rapidpro,项目名称:ureport-android,代码行数:27,代码来源:ChatRoomServices.java
示例5: observe
import com.firebase.client.Query; //导入依赖的package包/类
public static Observable<DataSnapshot> observe(final Query ref) {
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
}
@Override
public void onCancelled(FirebaseError error) {
// Turn the FirebaseError into a throwable to conform to the API
subscriber.onError(new FirebaseException(error.getMessage()));
}
});
// When the subscription is cancelled, remove the listener
subscriber.add(Subscriptions.create(() -> ref.removeEventListener(listener)));
}
});
}
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:25,代码来源:RxFirebase.java
示例6: observeOnce
import com.firebase.client.Query; //导入依赖的package包/类
public static Observable<DataSnapshot> observeOnce(final Query ref) {
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
ref.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
subscriber.onCompleted();
}
@Override
public void onCancelled(FirebaseError error) {
// Turn the FirebaseError into a throwable to conform to the API
subscriber.onError(new FirebaseException(error.getMessage()));
subscriber.onCompleted();
}
});
}
});
}
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:24,代码来源:RxFirebase.java
示例7: 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
示例8: 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
示例9: FirebaseSource
import com.firebase.client.Query; //导入依赖的package包/类
/**
* @param clazz Class Reference for the type to deserialize {@link DataSnapshot}s into.
* @param auther Authenticator
* @param query Any {@link Query} reference.
* @param listenForChildEvents Adds a {@link ChildEventListener} during runtime
* @param listenForValueEvents Adds a {@link ValueEventListener} during runtime
*/
protected FirebaseSource(
Class<T> clazz,
FirebaseAuthenticator auther,
Query query,
boolean listenForChildEvents,
boolean listenForValueEvents){
if (query.toString().equals(query.getRef().getRoot().toString())){
throw new IllegalArgumentException("Cannot use a reference to the root of a Firebase "
+ "repository. Since FirebaseSource uses a ref at the root of the repository to store"
+ "timestamps, this will result in an endless event loop, which will livelock your"
+ "pipeline.");
}
this.clazz = clazz;
this.auther = auther;
this.queryString = query.getRef().toString();
this.listenForChildEvents = listenForChildEvents;
this.listenForValueEvents = listenForValueEvents;
}
开发者ID:fhoffa,项目名称:bqpipeline,代码行数:26,代码来源:FirebaseSource.java
示例10: FirebaseRecyclerAdapter
import com.firebase.client.Query; //导入依赖的package包/类
/**
* @param query The Firebase location to watch for data changes.
* Can also be a slice of a location, using some combination of
* <code>limit()</code>, <code>startAt()</code>, and <code>endAt()</code>.
* @param itemClass The class of the items.
* @param items List of items that will load the adapter before starting the listener.
* Generally null or empty, but this can be useful when dealing with a
* configuration change (e.g.: reloading the adapter after a device rotation).
* Be careful: keys must be coherent with this list.
* @param keys List of keys of items that will load the adapter before starting the listener.
* Generally null or empty, but this can be useful when dealing with a
* configuration change (e.g.: reloading the adapter after a device rotation).
* Be careful: items must be coherent with this list.
*/
public FirebaseRecyclerAdapter(Query query, Class<T> itemClass,
@Nullable ArrayList<T> items,
@Nullable ArrayList<String> keys) {
this.mQuery = query;
if (items != null && keys != null) {
this.mItems = items;
this.mKeys = keys;
} else {
mItems = new ArrayList<T>();
mKeys = new ArrayList<String>();
}
this.mItemClass = itemClass;
query.addChildEventListener(mListener);
}
开发者ID:benslamajihed,项目名称:GalleryPictureFirebaseAndroid,代码行数:29,代码来源:FirebaseRecyclerAdapter.java
示例11: getQuery
import com.firebase.client.Query; //导入依赖的package包/类
private Query getQuery() {
if (query == null) {
query = createQuery(firebaseRef);
}
return query;
}
开发者ID:aluxian,项目名称:Codementor,代码行数:8,代码来源:QueryEventListener.java
示例12: observe
import com.firebase.client.Query; //导入依赖的package包/类
public static Observable<DataSnapshot> observe(final Query ref) {
return Observable.create(new Observable.OnSubscribe<DataSnapshot>() {
@Override
public void call(final Subscriber<? super DataSnapshot> subscriber) {
final ValueEventListener listener = ref.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
subscriber.onNext(dataSnapshot);
}
@Override
public void onCancelled(FirebaseError error) {
subscriber.onError(new FirebaseException(error));
}
});
subscriber.add(Subscriptions.create(new Action0() {
@Override
public void call() {
ref.removeEventListener(listener);
}
}));
}
});
}
开发者ID:DariusL,项目名称:RxFirebaseAndroid,代码行数:28,代码来源:RxFirebase.java
示例13: onViewCreated
import com.firebase.client.Query; //导入依赖的package包/类
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
setupObjects();
setupView(view);
Query query = loadData();
setupStoriesAdapter(query);
}
开发者ID:rapidpro,项目名称:ureport-android,代码行数:10,代码来源:StoriesListFragment.java
示例14: setupMessagesAdapter
import com.firebase.client.Query; //导入依赖的package包/类
private void setupMessagesAdapter() {
Query query = chatRoomServices.getChatMessagesQuery(chatRoom.getKey());
chatMessageArray = new InfiniteFireArray<>(ChatMessage.class, query, 20, 20, false, false);
adapter = new ChatMessagesAdapter(user, chatMessageArray);
adapter.setOnChatMessageSelectedListener(this);
adapter.registerAdapterDataObserver(adapterDataObserver);
messagesList.setAdapter(adapter);
messagesList.setInfiniteFireArray(chatMessageArray);
}
开发者ID:rapidpro,项目名称:ureport-android,代码行数:11,代码来源:ChatRoomFragment.java
示例15: loadUsers
import com.firebase.client.Query; //导入依赖的package包/类
private ValueEventListener loadUsers(final OnLoadAllUsersListener onLoadAllUsersListener, Query query) {
ValueEventListener listener = new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
handleDataResponse(dataSnapshot, onLoadAllUsersListener);
}
@Override
public void onCancelled(FirebaseError firebaseError) {}
};
query.addValueEventListener(listener);
return listener;
}
开发者ID:rapidpro,项目名称:ureport-android,代码行数:14,代码来源:UserServices.java
示例16: SimpleListAdapter
import com.firebase.client.Query; //导入依赖的package包/类
/**
* Public constructor that initializes private instance variables when adapter is created
*/
public SimpleListAdapter(Activity activity, Class<SimpleList> modelClass, int modelLayout,
Query ref, String encodedEmail) {
super(activity, modelClass, modelLayout, ref);
this.mEncodedEmail = encodedEmail;
this.mActivity = activity;
}
开发者ID:cs493f15-1,项目名称:PaperOrPlastic,代码行数:10,代码来源:SimpleListAdapter.java
示例17: SimpleListItemAdapter
import com.firebase.client.Query; //导入依赖的package包/类
public SimpleListItemAdapter(Activity activity, Class<SimpleListItem> modelClass, int modelLayout,
Query ref, String listId, String encodedEmail, boolean grocery)
{
super(activity, modelClass, modelLayout, ref);
this.mActivity = activity;
this.mListId = listId;
this.mEncodedEmail = encodedEmail;
this.bIsGrocery = grocery;
}
开发者ID:cs493f15-1,项目名称:PaperOrPlastic,代码行数:10,代码来源:SimpleListItemAdapter.java
示例18: 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
示例19: getCommentsByUser
import com.firebase.client.Query; //导入依赖的package包/类
@Override
public Comment[] getCommentsByUser(String authorId) {
Query query = commentsFirebaseRef.orderByChild("authorId").equalTo
(authorId);
return executeCommentQuerySynchronously(query);
}
开发者ID:git-mad,项目名称:Bitter,代码行数:8,代码来源:FirebaseCommentProvider.java
示例20: getCommentsOnPost
import com.firebase.client.Query; //导入依赖的package包/类
@Override
public Comment[] getCommentsOnPost(String postId) {
Query query = commentsFirebaseRef.orderByChild("postId").equalTo
(postId);
return executeCommentQuerySynchronously(query);
}
开发者ID:git-mad,项目名称:Bitter,代码行数:8,代码来源:FirebaseCommentProvider.java
注:本文中的com.firebase.client.Query类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论