use of com.google.firebase.database.Query in project FirebaseUI-Android by firebase.
the class FirebaseIndexArray method onChildAdded.
@Override
public void onChildAdded(DataSnapshot keySnapshot, String previousChildKey) {
super.setOnChangedListener(null);
super.onChildAdded(keySnapshot, previousChildKey);
super.setOnChangedListener(mListener);
Query ref = mQuery.getRef().child(keySnapshot.getKey());
mRefs.put(ref, ref.addValueEventListener(new DataRefListener()));
}
use of com.google.firebase.database.Query in project OnlineCanteen by josephgunawan97.
the class SalesReportAdapter method updateStatus.
public void updateStatus(Long date) {
// Update status
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("salesreportrequest");
Query query = ref.orderByChild("requestdate").equalTo(date);
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot snapshot) {
for (DataSnapshot child : snapshot.getChildren()) {
child.getRef().child("requeststatus").setValue(1);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
use of com.google.firebase.database.Query in project OnlineCanteen by josephgunawan97.
the class DeleteProductFragment method deleteProduct.
public void deleteProduct() {
Query data;
for (int i = 0; i < deleteAdapter.getItemCount(); i++) {
data = databaseProducts.orderByChild("name").equalTo(productArrayList.get(i).getName());
final Product product2 = productArrayList.get(i);
data.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot productSnapshot : dataSnapshot.getChildren()) {
if (merchant.getUid().equals(product2.getTokoId()) && product2.isChecked())
productSnapshot.getRef().removeValue();
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
}
use of com.google.firebase.database.Query in project Grupp by tmoronta1208.
the class UserSearchActivity method searchUser.
private void searchUser(String query) {
Query userSearchQuery;
if (query.contains("@")) {
userSearchQuery = searchUserRef.orderByChild("email").startAt(query).endAt(query + "\uf8ff");
} else {
userSearchQuery = searchUserRef.orderByChild("first_name").startAt(query).endAt(query + "\uf8ff");
}
FirebaseRecyclerAdapter<PublicUser, UserSearchViewHolder> contactsListAdapter = new FirebaseRecyclerAdapter<PublicUser, UserSearchViewHolder>(PublicUser.class, R.layout.add_contact_itemview, UserSearchViewHolder.class, userSearchQuery) {
@Override
protected void populateViewHolder(final UserSearchViewHolder viewHolder, final PublicUser model, int position) {
final String contactID = getRef(position).getKey();
final String email = model.getEmail();
final String first = model.getFirst_name();
final String last = model.getLast_name();
final String icon = model.getUser_icon().getIcon_url();
final String zipCode = model.getZip_code();
// final int radius = model.getRadius();
viewHolder.setEmail(email);
viewHolder.setFullName(first, last);
viewHolder.setIcon(icon);
viewHolder.addContactButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String radiusString = "20";
addToContactList(contactID, viewHolder.addContactButton, first, last, email, icon, radiusString, zipCode);
}
});
}
};
searchContactsRecyclerView.setAdapter(contactsListAdapter);
}
use of com.google.firebase.database.Query in project Lets-Chat by kshitiz1007.
the class ChatActivity method loadMoreMessages.
// ---ON REFRESHING 10 MORE MESSAGES WILL LOAD----
private void loadMoreMessages() {
DatabaseReference messageRef = mRootReference.child("messages").child(mCurrentUserId).child(mChatUser);
Query messageQuery = messageRef.orderByKey().endAt(mLastKey).limitToLast(10);
messageQuery.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
Messages message = (Messages) dataSnapshot.getValue(Messages.class);
String messageKey = dataSnapshot.getKey();
if (!mPrevKey.equals(messageKey)) {
messagesList.add(itemPos++, message);
} else {
mPrevKey = mLastKey;
}
if (itemPos == 1) {
String mMessageKey = dataSnapshot.getKey();
mLastKey = mMessageKey;
}
mMessageAdapter.notifyDataSetChanged();
mSwipeRefreshLayout.setRefreshing(false);
mLinearLayoutManager.scrollToPositionWithOffset(10, 0);
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
Aggregations