SimCoderYoutube / UberClone

Uber Clone Android App 👨‍💻 I'll show you how you can do this in the simplest way and terms possible. By the end of this series you'll have learned how the big companies do it and will be able to do the same, you not only will be able to do this app, but you'll be able to put what you learn into your very own projects! In this series, we use Android Native with java to build the project. We use firebase for all our microservice needs like the auth system, database, storage, amongst others. firebase, android studio, and java. In this series, we'll use all of them and you'll learn them by doing an iconic app. Welcome to this Simcoder project and make a Uber Clone!
MIT License
1.02k stars 712 forks source link

How to handle getRequestsAround()t and //TODO getAssignedCustomer(); in DriverMapActivity? Problem also with toolbar Id #41

Open Coco0185 opened 2 years ago

Coco0185 commented 2 years ago

Hi , 1) Concerning : getRequestsAround()

there is an error I think in the listener in DriverMapActivity

It never enter in the geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() since there is no GeoFirelocation put in the CustomerMapActivity at "customer_requests":

in DriverMapActivity : private void getRequestsAround() { if (mLastLocation == null) { return; }

    DatabaseReference requestLocation = FirebaseDatabase.getInstance().getReference().child("customer_requests");

    GeoFire geoFire = new GeoFire(requestLocation);
    geoQuery = geoFire.queryAtLocation(new GeoLocation(mLastLocation.getLatitude(), mLastLocation.getLongitude()), MAX_SEARCH_DISTANCE);
    geoQuery.removeAllListeners();

    geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
        @Override
        public void onKeyEntered(String key, GeoLocation location) {
            if(!mWorkingSwitch.isChecked()){
                return;
            }

            if (mCurrentRide == null) {
                for (RideObject mRideIt : requestList) {
                    if (mRideIt.getId().equals(key)) {
                        return;
                    }
                }

                getRequestInfo(key);

            }else{
                requestList.clear();
            }
        }

        @Override
        public void onKeyExited(String key) {
        }

        @Override
        public void onKeyMoved(String key, GeoLocation location) {
        }

        @Override
        public void onGeoQueryReady() {
        }

        @Override
        public void onGeoQueryError(DatabaseError error) {
        }
    });
}

Should We listen to the "ride_info" node? If so , how to handle the rest of the code ( the request itself)?

2) I broke my head to understand this also but since we handle request now ,. Here is what I did :

private void getAssignedCustomer(){ String driverId = FirebaseAuth.getInstance().getCurrentUser().getUid(); DatabaseReference assignedCustomerRef = FirebaseDatabase.getInstance().getReference().child("ride_info"); assignedCustomerRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { if(dataSnapshot.exists()){

                mCurrentRide.confirmDriver();
                mCurrentRide.parseData(dataSnapshot);
                requestList.add(mCurrentRide);

            }else{
                endRide();
            }
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {
        }
    });
}

3) I 've never found the toolbar id in the code in the Driver & Customer Maps Activity :
image Ive checked on the corresponding .xml layout file there is no mention of @+id/toolbar neither in the string.xml ressource file

Please Help ;)