public void CreateRequest() { newTripRef = database.GetReference("RiderRequest").Push(); HashMap location = new HashMap(); location.Put("latitude", newTrip.PickupLat); location.Put("longitude", newTrip.PickupLng); HashMap destination = new HashMap(); destination.Put("latitude", newTrip.DestinationLat); destination.Put("longitude", newTrip.DestinationLng); HashMap myTrip = new HashMap(); newTrip.RideID = newTripRef.Key; myTrip.Put("rider_id", AppDataHelper.GetCurrentUser().Uid); myTrip.Put("location", location); myTrip.Put("destination", destination); myTrip.Put("destination_address", newTrip.DestinationAddress); myTrip.Put("pickup_address", newTrip.PickupAddress); myTrip.Put("payment_method", newTrip.Paymentmethod); myTrip.Put("created_at", newTrip.Timestamp.ToString()); myTrip.Put("driver_id", "waiting"); myTrip.Put("rider_name", AppDataHelper.GetFullName()); myTrip.Put("rider_phone", AppDataHelper.GetPhone()); //myTrip.Put("Imgurl",) newTripRef.AddValueEventListener(this); newTripRef.SetValue(myTrip); }
void Accept() { tripRef.Child("status").SetValue("accepted"); tripRef.Child("driver_name").SetValue(AppDataHelper.GetFullName()); tripRef.Child("driver_phone").SetValue(AppDataHelper.GetPhone()); tripRef.Child("driver_location").Child("latitude").SetValue(mLastlocation.Latitude); tripRef.Child("driver_location").Child("longitude").SetValue(mLastlocation.Longitude); tripRef.Child("driver_id").SetValue(AppDataHelper.GetCurrentUser().Uid); }
private void SubmitButton_Click(object sender, EventArgs e) { HashMap postMap = new HashMap(); postMap.Put("author", AppDataHelper.GetFullName()); postMap.Put("owner_id", AppDataHelper.GetFirebaseAuth().CurrentUser.Uid); postMap.Put("post_date", DateTime.Now.ToString()); postMap.Put("post_body", postEditText.Text); DocumentReference newPostRef = AppDataHelper.GetFirestore().Collection("posts").Document(); string postKey = newPostRef.Id; postMap.Put("image_id", postKey); ShowProgressDialogue("Saving Information ..."); // Save Post Image to Firebase Storaage StorageReference storageReference = null; if (fileBytes != null) { storageReference = FirebaseStorage.Instance.GetReference("postImages/" + postKey); storageReference.PutBytes(fileBytes) .AddOnSuccessListener(taskCompletionListeners) .AddOnFailureListener(taskCompletionListeners); } // Image Upload Success Callback taskCompletionListeners.Sucess += (obj, args) => { if (storageReference != null) { storageReference.DownloadUrl.AddOnSuccessListener(downloadUrlListener); } }; // Image Download URL Callback downloadUrlListener.Sucess += (obj, args) => { string downloadUrl = args.Result.ToString(); postMap.Put("download_url", downloadUrl); // Save post to Firebase Firestore newPostRef.Set(postMap); CloseProgressDialogue(); Finish(); }; // Image Upload Failure Callback taskCompletionListeners.Failure += (obj, args) => { Toast.MakeText(this, "Upload was not completed", ToastLength.Short).Show(); }; }
public void Accept() { var locationCordinate = new NSDictionary ( "latitude", currentLocation.Latitude.ToString(), "longitude", currentLocation.Longitude.ToString() ); tripRef.GetChild("driver_location").SetValue <NSDictionary>(locationCordinate); tripRef.GetChild("driver_name").SetValue((NSString)AppDataHelper.GetFullName()); tripRef.GetChild("driver_id").SetValue((NSString)AppDataHelper.GetDriverID()); tripRef.GetChild("driver_phone").SetValue((NSString)AppDataHelper.GetPhone()); tripRef.GetChild("status").SetValue((NSString)"accepted"); }
public void CreateRequest() { requestReference = Database.DefaultInstance.GetRootReference().GetChild("rideRequest").GetChildByAutoId(); newTripDetails.RideID = requestReference.Key; var locationNode = new NSDictionary ( "latitude", newTripDetails.PickupLat.ToString(), "longitude", newTripDetails.PickupLng.ToString() ); var destinationNode = new NSDictionary ( "latitude", newTripDetails.DestinationLat.ToString(), "longitude", newTripDetails.DestinationLng.ToString() ); var tripDetailsNode = new NSDictionary ( "location", locationNode, "destination", destinationNode, "destination_address", newTripDetails.DestinationAddress, "pickup_address", newTripDetails.PickupAddress, "rider_id", AppDataHelper.GetUserID(), "rider_name", AppDataHelper.GetFullName(), "rider_phone", AppDataHelper.GetPhone(), "created_at", newTripDetails.TimeStamp.ToString() ); requestReference.SetValue <NSDictionary>(tripDetailsNode); requestReference.ObserveEvent(DataEventType.Value, (DataSnapshot snapshot) => { //Driver has been assigned if (snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>() != NSNull.Null) { if (snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>().ToString() != "waiting") { if (!isDriverAccepted) { // Fetch Driver Details from the snapshot AcceptedDriver acceptedDriver = new AcceptedDriver(); acceptedDriver.ID = snapshot.GetChildSnapshot("driver_id").GetValue <NSObject>().ToString(); acceptedDriver.Fullname = snapshot.GetChildSnapshot("driver_name").GetValue <NSObject>().ToString(); acceptedDriver.phone = snapshot.GetChildSnapshot("driver_phone").GetValue <NSObject>().ToString(); isDriverAccepted = true; DriverAccepted?.Invoke(this, new DriverAcceptedEventArgs { acceptedDriver = acceptedDriver }); } // Gets Trip Status if (snapshot.GetChildSnapshot("status").GetValue <NSObject>() != NSNull.Null) { status = snapshot.GetChildSnapshot("status").GetValue <NSObject>().ToString(); } // Get fares if (snapshot.GetChildSnapshot("fares").GetValue <NSObject>() != NSNull.Null) { fares = double.Parse(snapshot.GetChildSnapshot("fares").GetValue <NSObject>().ToString()); } if (isDriverAccepted) { // Get driver location upadtes double driverLatitude = 0; double driverLongitude = 0; driverLatitude = double.Parse(snapshot.GetChildSnapshot("driver_location").GetChildSnapshot("latitude").GetValue <NSObject>().ToString()); driverLongitude = double.Parse(snapshot.GetChildSnapshot("driver_location").GetChildSnapshot("longitude").GetValue <NSObject>().ToString()); CLLocationCoordinate2D driverLocationLatLng = new CLLocationCoordinate2D(driverLatitude, driverLongitude); TripUpdates?.Invoke(this, new TripUpdatesEventArgs { DriverLocation = driverLocationLatLng, Status = status, Fares = fares }); } } } }); }
void ConnectControl() { // Drawer Layout drawerLayout = (Android.Support.V4.Widget.DrawerLayout)FindViewById(Resource.Id.drawerLayout); // ToolBar mainToolbar = (Android.Support.V7.Widget.Toolbar)FindViewById(Resource.Id.mainToolbar); SetSupportActionBar(mainToolbar); SupportActionBar.Title = ""; Android.Support.V7.App.ActionBar actionBar = SupportActionBar; actionBar.SetHomeAsUpIndicator(Resource.Mipmap.ic_menu_action); actionBar.SetDisplayHomeAsUpEnabled(true); //TextView PickUpLocationtext = (EditText)FindViewById(Resource.Id.PickupLocationText); Destinationtext = (EditText)FindViewById(Resource.Id.DestinationLocationText); // TextView // UserName = (TextView)FindViewById(Resource.Id.UserName); // Radio Buttons pickupRedio = (RadioButton)FindViewById(Resource.Id.pickupRedio); DestinationRedio = (RadioButton)FindViewById(Resource.Id.DestinationRedio); //Buttons favouritePlacebtn = (Button)FindViewById(Resource.Id.favouritePlacesButton); locationSetbtn = (Button)FindViewById(Resource.Id.locationsetBtn); RequestDriverbtn = (Button)FindViewById(Resource.Id.RequestDriverbtn); RequestDriverbtn.Click += RequestDriverbtn_Click; pickupRedio.Click += PickupRedio_Click; DestinationRedio.Click += DestinationRedio_Click; favouritePlacebtn.Click += FavouritePlacebtn_Click; locationSetbtn.Click += LocationSetbtn_Click; // Image View CenterMarker = (ImageView)FindViewById(Resource.Id.centerMarker); //layoutPickup layoutPickup = (RelativeLayout)FindViewById(Resource.Id.layoutPickup); layoutDestination = (RelativeLayout)FindViewById(Resource.Id.layoutDestination); layoutPickup.Click += LayoutPickUp_Click; layoutDestination.Click += LayoutDestination_Click; //BottomSheet FrameLayout TripDetailsView = (FrameLayout)FindViewById(Resource.Id.tripdetails_bottomsheet); tripDetailsBottomsheetbehavior = BottomSheetBehavior.From(TripDetailsView); // NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.navView); navigationView.SetNavigationItemSelectedListener(null); View header = navigationView.GetHeaderView(0); TextView name = (TextView)header.FindViewById(Resource.Id.UserName); name.Text = AppDataHelper.GetFullName(); // Get From Prefrences myuserInfo = new CreateuserListener(); myuserInfo.Create(); myuserInfo.DataRetrived += MyuserInfo_DataRetrived; }