use of com.google.firebase.firestore.FirebaseFirestore in project firebase-android-sdk by firebase.
the class IntegrationTestUtil method testFirestore.
/**
* Initializes a new Firestore instance that uses the default project, customized with the
* provided settings.
*/
public static FirebaseFirestore testFirestore(FirebaseFirestoreSettings settings) {
FirebaseFirestore firestore = testFirestore(provider.projectId(), Level.DEBUG, settings);
primeBackend();
return firestore;
}
use of com.google.firebase.firestore.FirebaseFirestore in project firebase-android-sdk by firebase.
the class IntegrationTestUtil method tearDown.
public static void tearDown() {
try {
for (FirebaseFirestore firestore : firestoreStatus.keySet()) {
Task<Void> result = firestore.terminate();
waitFor(result);
}
} finally {
firestoreStatus.clear();
}
}
use of com.google.firebase.firestore.FirebaseFirestore in project firebase-android-sdk by firebase.
the class FirestoreTest method setShouldTriggerListenerWithNewlySetData.
@Test
public void setShouldTriggerListenerWithNewlySetData() throws Exception {
FirebaseAuth auth = FirebaseAuth.getInstance();
FirebaseFirestore firestore = FirebaseFirestore.getInstance();
auth.signOut();
Task<?> signInTask = auth.signInWithEmailAndPassword("test@mailinator.com", "password");
Tasks2.waitForSuccess(signInTask);
DocumentReference doc = firestore.collection("restaurants").document(TestId.create());
SnapshotListener listener = new SnapshotListener();
ListenerRegistration registration = doc.addSnapshotListener(listener);
try {
HashMap<String, Object> data = new HashMap<>();
data.put("location", "Google NYC");
Task<?> setTask = doc.set(new HashMap<>(data));
Task<DocumentSnapshot> snapshotTask = listener.toTask();
Tasks2.waitForSuccess(setTask);
Tasks2.waitForSuccess(snapshotTask);
DocumentSnapshot result = snapshotTask.getResult();
assertThat(result.getData()).isEqualTo(data);
} finally {
registration.remove();
Tasks2.waitBestEffort(doc.delete());
}
}
use of com.google.firebase.firestore.FirebaseFirestore in project MDA_APP_RESTAURANTE by karlaogh99.
the class FoodListActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_food_list);
FirebaseFirestore db = FirebaseFirestore.getInstance();
// Read from the database
listFood = new ArrayList<>();
recycler_menu = (RecyclerView) findViewById(R.id.recycler_food);
recycler_menu.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
recycler_menu.setLayoutManager(layoutManager);
db.collection("Food").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful() && getIntent() != null) {
Category catId = (Category) getIntent().getSerializableExtra("Categoria");
for (QueryDocumentSnapshot document : task.getResult()) {
if (catId.getName().equals((String) document.get("IdCategoria"))) {
Food food = new Food("", "", "", "", "");
food.setName((String) document.get("Nombre"));
food.setDescripcion((String) document.get("Descripcion"));
food.setId((String) document.get("IdCategoria"));
food.setPrice((String) document.get("Precio"));
food.setImage((String) document.get("Image"));
listFood.add(food);
}
}
AdapterFood adapter = new AdapterFood(listFood);
recycler_menu.setAdapter(adapter);
}
}
});
}
use of com.google.firebase.firestore.FirebaseFirestore in project QRHunt by CMPUT301W22T00.
the class QrCodeProcessor method processQRCode.
/**
* Processes QR code to be added
*/
public void processQRCode() {
FirebaseFirestore db = FirebaseFirestore.getInstance();
// todo check here: is this an internal code
computeHash();
computeScore();
PlayableQrCode qrCode = new PlayableQrCode(playerId, hash, score);
getLocation().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
Location location = task.getResult();
if (location != null) {
qrCode.setLocation(new QrLocation(location));
}
/* this stops listening to the updates that
we didn't actually care about in the first place for; see startPollingLocation
*/
LocationServices.getFusedLocationProviderClient(activity).removeLocationUpdates(hackyLocationCallback);
FragmentAddQrCode addQrCode = FragmentAddQrCode.newInstance(qrCode);
addQrCode.show(frag.getChildFragmentManager(), FragmentAddQrCode.TAG);
}
});
}
Aggregations