What I want to do is check first if The referral code inserted by the user exist. But the problem is, it is always going on the addOnSuccessListener even though I had entered text which are not included in the database.
//Dont mind the next paragraph. I just need to add some more descriptions to save the edit//
What I want to do is check first if The referral code inserted by the user exist. But the problem is, it is always going on the addOnSuccessListener even though I had entered text which are not included in the database.
What I want to do is check first if The referral code inserted by the user exist. But the problem is, it is always going on the addOnSuccessListener even though i had entered text which are not included in the database.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
FirebaseFirestore db = FirebaseFirestore.getInstance();
CollectionReference collectionReference = db.collection("Buyers");
Query usersDataQuery = collectionReference.whereEqualTo("referrals.userReferralCOde", referalCode);
usersDataQuery.get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
Users users = new Users();
String referedByID = users.getBuyerID();
loadingBar = KProgressHUD.create(FirstTimeUserActivity.this)
.setStyle(KProgressHUD.Style.SPIN_INDETERMINATE)
.setLabel("Please wait")
.setDetailsLabel("Creating your Account...")
.show();
//withReferrals(cfn, cln, referedByID, email, status, id);
StyleableToast.makeText(FirstTimeUserActivity.this, "Pumasok.", Toast.LENGTH_LONG, R.style.successtoast).show();
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
StyleableToast.makeText(FirstTimeUserActivity.this, "Please enter a Valid Referral Code.", Toast.LENGTH_LONG, R.style.errortoast).show();
}
public class Users {
private String BuyerID, Email, FirstName, LastName, ImageUrl, AccountType, CPoints, WalletAccount;
private double Latitude, Longitude;
private @ServerTimestamp Date timestamp;
private ReferralModel Referrals;
public Users(){
}
public Users(String buyerID, String email, String firstName, String lastName, String imageUrl, String accountType, String CPoints, String walletAccount, double latitude, double longitude, Date timestamp, ReferralModel referrals) {
BuyerID = buyerID;
Email = email;
FirstName = firstName;
LastName = lastName;
ImageUrl = imageUrl;
AccountType = accountType;
this.CPoints = CPoints;
WalletAccount = walletAccount;
Latitude = latitude;
Longitude = longitude;
this.timestamp = timestamp;
Referrals = referrals;
}
public String getBuyerID() {
return BuyerID;
}
public void setBuyerID(String buyerID) {
BuyerID = buyerID;
}
public String getEmail() {
return Email;
}
public void setEmail(String email) {
Email = email;
}
public String getFirstName() {
return FirstName;
}
public void setFirstName(String firstName) {
FirstName = firstName;
}
public String getLastName() {
return LastName;
}
public void setLastName(String lastName) {
LastName = lastName;
}
public String getImageUrl() {
return ImageUrl;
}
public void setImageUrl(String imageUrl) {
ImageUrl = imageUrl;
}
public String getAccountType() {
return AccountType;
}
public void setAccountType(String accountType) {
AccountType = accountType;
}
public String getCPoints() {
return CPoints;
}
public void setCPoints(String CPoints) {
this.CPoints = CPoints;
}
public String getWalletAccount() {
return WalletAccount;
}
public void setWalletAccount(String walletAccount) {
WalletAccount = walletAccount;
}
public double getLatitude() {
return Latitude;
}
public void setLatitude(double latitude) {
Latitude = latitude;
}
public double getLongitude() {
return Longitude;
}
public void setLongitude(double longitude) {
Longitude = longitude;
}
public Date getTimestamp() {
return timestamp;
}
public void setTimestamp(Date timestamp) {
this.timestamp = timestamp;
}
public ReferralModel getReferrals() {
return Referrals;
}
public void setReferrals(ReferralModel referrals) {
Referrals = referrals;
}
});[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/Jr9Vm.png