use of com.google.firebase.firestore.FirebaseFirestore in project startup-os by google.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseFirestore db = FirebaseFirestore.getInstance();
}
use of com.google.firebase.firestore.FirebaseFirestore in project noChange by Khalidtoak.
the class AddChangeOrDebt method saveNewRecordOnline.
private void saveNewRecordOnline(Payment payment) {
if (pathForImage != null) {
Uri imageUri = Uri.fromFile(new File(pathForImage));
StorageReference storageRef = FirebaseStorage.getInstance().getReference();
StorageReference imageRef = storageRef.child(Constant.IMAGE_COLLECTION).child(String.format(Locale.getDefault(), "payment_%s.jpg", String.valueOf(System.currentTimeMillis())));
imageRef.putFile(imageUri).continueWithTask(task -> {
if (!task.isSuccessful()) {
showError(Objects.requireNonNull(task.getException()));
}
// Continue with the task to get the download URL
return imageRef.getDownloadUrl();
}).addOnCompleteListener(task -> {
if (task.isSuccessful()) {
Uri downloadUri = task.getResult();
assert downloadUri != null;
setPathForImage(downloadUri.toString());
FirebaseFirestore firestore = FirebaseFirestore.getInstance();
firestore.collection(Constant.USER_COLLECTION).document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection(Constant.PAYMENT_COLLECTION).document(phoneNumber).set(payment, SetOptions.merge()).addOnSuccessListener(aVoid -> {
progressBar.setVisibility(View.INVISIBLE);
save.setEnabled(true);
showToast("Successfully saved!");
// start the DashBoard Activity
Intent intent = new Intent(getApplicationContext(), DashBoard.class);
startActivity(intent);
finish();
}).addOnFailureListener(error -> {
showError(error);
progressBar.setVisibility(View.INVISIBLE);
save.setEnabled(true);
});
} else {
return;
}
});
} else {
progressBar.setVisibility(View.INVISIBLE);
save.setEnabled(true);
(Toast.makeText(this, "Please upload an image to recognize user before continuing", Toast.LENGTH_LONG)).show();
}
}
use of com.google.firebase.firestore.FirebaseFirestore in project noChange by Khalidtoak.
the class AppViewModel method getPayment.
public LiveData<ArrayList<Payment>> getPayment(String type, String searchWord) {
FirebaseFirestore firestore = FirebaseFirestore.getInstance();
MutableLiveData<ArrayList<Payment>> response = new MutableLiveData<>();
firestore.collection(Constant.USER_COLLECTION).document(FirebaseAuth.getInstance().getCurrentUser().getUid()).collection(Constant.PAYMENT_COLLECTION).orderBy("timestamp").whereEqualTo("type", type).whereGreaterThanOrEqualTo("name", searchWord).get().addOnSuccessListener(res -> {
response.postValue((ArrayList<Payment>) res.toObjects(Payment.class));
}).addOnFailureListener(e -> {
e.printStackTrace();
Log.i("Could not fetch data", "Could not fetch data");
response.postValue(null);
});
return response;
}
use of com.google.firebase.firestore.FirebaseFirestore in project startup-os by google.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
FirebaseFirestore db = FirebaseFirestore.getInstance();
}
use of com.google.firebase.firestore.FirebaseFirestore in project DisasterApp by cutmail.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.bind(this);
FirebaseFirestore firestore = FirebaseFirestore.getInstance();
collectionReference = firestore.collection("entries");
setupLayout();
setupRateDialog();
AppRate.showRateDialogIfMeetsConditions(this);
}
Aggregations