Пример #1
0
        public void Create()
        {
            FirebaseDatabase  database      = AppDataHelper.GetDatabase();
            DatabaseReference findDriverRef = database.GetReference("driversAvailable");

            findDriverRef.AddListenerForSingleValueEvent(this);
        }
Пример #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            View view = inflater.Inflate(Resource.Layout.Account, container, false);

            mTxtEmail   = (TextView)view.FindViewById(Resource.Id.profileEmail);
            mTxtName    = (TextView)view.FindViewById(Resource.Id.profileName);
            mTxtPhone   = (TextView)view.FindViewById(Resource.Id.profileNumber);
            mBtnSignOut = (Button)view.FindViewById(Resource.Id.dashboardLogout);



            if (AppDataHelper.GetCurrentUser() != null)
            {
                var user = AppDataHelper.GetCurrentUser();
                mTxtEmail.Text = user.Email;
            }
            ;

            database    = AppDataHelper.GetDatabase();
            mAuth       = AppDataHelper.GetFirebaseAuth();
            currentUser = AppDataHelper.GetCurrentUser();

            string driverID = AppDataHelper.GetCurrentUser().Uid;

            FirebaseDatabase.Instance.Reference.Child("drivers/" + driverID)
            .AddListenerForSingleValueEvent(new DataValueEventListener());

            mBtnSignOut.Click += MBtnSignOut_Click;

            return(view);
        }
Пример #3
0
        public string saveFoodDB(Entity.Food foodEntity)
        {
            string returnValue = "";

            try
            {
                HashMap aluminiInfo = new HashMap();
                aluminiInfo.Put("ID", foodEntity.ID);
                aluminiInfo.Put("Name", foodEntity.Name);
                aluminiInfo.Put("Location", foodEntity.Location);
                aluminiInfo.Put("ImageUrl", foodEntity.ImageUrl);
                aluminiInfo.Put("Details", foodEntity.Details);
                aluminiInfo.Put("CostPerUnit", foodEntity.CostPerUnit.ToString());
                aluminiInfo.Put("Quantity", foodEntity.Quantity);



                DatabaseReference newAluminRef = AppDataHelper.GetDatabase().GetReference("foodMini").Push();
                newAluminRef.SetValue(aluminiInfo);
                //this.Dismiss();
            }
            catch (Exception ee) {
                returnValue = "Error" + ee.Message;
            }
            return(returnValue);
        }
Пример #4
0
 private void SaveCarDetailsToDb(HashMap carMap)
 {
     if (AppDataHelper.GetCurrentUser() != null)
     {
         var vehicleRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}/MyCars");
         vehicleRef.SetValue(carMap)
         .AddOnSuccessListener(new OnSuccessListener(result =>
         {
             var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}/{StringConstants.StageofRegistration}");
             driverRef.SetValue($"{RegistrationStage.Agreement}")
             .AddOnSuccessListener(new OnSuccessListener(result2 =>
             {
                 CarRegComplete.Invoke(this, new EventArgs());
                 OnboardingActivity.CloseProgressDialog();
             })).AddOnFailureListener(new OnFailureListener(e2 =>
             {
                 OnboardingActivity.CloseProgressDialog();
                 Toast.MakeText(Activity, e2.Message, ToastLength.Short).Show();
             }));
         }))
         .AddOnFailureListener(new OnFailureListener(e1 =>
         {
             OnboardingActivity.CloseProgressDialog();
             Toast.MakeText(Activity, e1.Message, ToastLength.Short).Show();
         }));
     }
     else
     {
         return;
     }
 }
Пример #5
0
        private void CheckStatus(string uid)
        {
            var fireDataRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{uid}/{StringConstants.StageofRegistration}");

            fireDataRef.AddValueEventListener(new SingleValueListener(snapshot =>
            {
                if (snapshot.Exists())
                {
                    var stage = snapshot.Value.ToString();

                    var intentSub = new Intent(this, typeof(OnboardingActivity));
                    intentSub.PutExtra("stage", stage);
                    StartActivity(intentSub);
                    Finish();
                }
                else
                {
                    StartActivity(typeof(OnboardingActivity));
                    Finish();
                }
            }, error =>
            {
                Toast.MakeText(this, error.Message, ToastLength.Short).Show();
            }));
        }
Пример #6
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            string fullname   = fullnameText.EditText.Text;
            string department = departmentText.EditText.Text;
            string set        = setText.EditText.Text;

            HashMap aluminiInfo = new HashMap();

            aluminiInfo.Put("fullname", fullname);
            aluminiInfo.Put("department", department);
            aluminiInfo.Put("set", set);
            aluminiInfo.Put("status", status);

            SupportV7.AlertDialog.Builder saveDataAlert = new SupportV7.AlertDialog.Builder(Activity);
            saveDataAlert.SetTitle("SAVE ALUMINI INFORMATION");
            saveDataAlert.SetMessage("Are you sure?");
            saveDataAlert.SetPositiveButton("Continue", (senderAlert, args) =>
            {
                DatabaseReference newAluminRef = AppDataHelper.GetDatabase().GetReference("alumini").Push();
                newAluminRef.SetValue(aluminiInfo);
                this.Dismiss();
            });
            saveDataAlert.SetNegativeButton("Cancel", (senderAlert, args) =>
            {
                saveDataAlert.Dispose();
            });

            saveDataAlert.Show();
        }
Пример #7
0
        public static void StoreTodaysData()
        {
            HashMap mo      = new HashMap();
            HashMap dy      = new HashMap();
            HashMap metrics = new HashMap();

            metrics.Put("items", App.Items);
            metrics.Put("score", App.Score);
            dy.Put(DateTime.Now.Day + "", metrics);
            mo.Put(DateTime.Now.Month + "", dy);

            if (!(App.OYear.Equals(DateTime.Now.Year)))
            {
                DatabaseReference dr = AppDataHelper.GetDatabase().GetReference("users").Child(App.ThisUser.Id).Child(DateTime.Now.Year + "");
                dr.SetValue(mo);
            }
            else if (!(App.OMonth.Equals(DateTime.Now.Month)))
            {
                DatabaseReference dr = AppDataHelper.GetDatabase().GetReference("users").Child(App.ThisUser.Id).Child(DateTime.Now.Year + "").Child(DateTime.Now.Month + "");
                dr.SetValue(dy);
            }
            else if (!(App.ODate.Equals(DateTime.Now.Day)))
            {
                DatabaseReference dr = AppDataHelper.GetDatabase().GetReference("users").Child(App.ThisUser.Id).Child(DateTime.Now.Year + "").Child(DateTime.Now.Month + "").Child(DateTime.Now.Day + "");
                dr.SetValue(metrics);
            }
        }
Пример #8
0
 public override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     CreateLocationRequest();
     if (AppDataHelper.GetCurrentUser() != null)
     {
         var dbRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
         dbRef.AddValueEventListener(new SingleValueListener(snapshot =>
         {
             if (snapshot.Exists())
             {
                 profileUrl = snapshot.Child("profile_img_url").Value.ToString();
                 Glide.With(Context)
                 .Load(profileUrl)
                 .Into(profileImg)
                 .WaitForLayout();
             }
         }, error =>
         {
         }));
     }
     else
     {
         return;
     }
 }
Пример #9
0
        public void Create(string ride_id)
        {
            FirebaseDatabase  database       = AppDataHelper.GetDatabase();
            DatabaseReference rideDetailsRef = database.GetReference("rideRequest/" + ride_id);

            rideDetailsRef.AddListenerForSingleValueEvent(this);
        }
Пример #10
0
        public void Create()
        {
            mAuth = FirebaseAuth.Instance;
            DatabaseReference workoutRef = AppDataHelper.GetDatabase().GetReference("workouts");

            workoutRef.AddValueEventListener(this);
        }
Пример #11
0
        public CreateRequestEventListener(NewTripDetails mNewTrip)
        {
            newTrip  = mNewTrip;
            database = AppDataHelper.GetDatabase();

            RequestTimer.Interval = 1000; // seconds
            RequestTimer.Elapsed += RequestTimer_Elapsed;
        }
Пример #12
0
        private void SetDb()
        {
            switch (AppDataHelper.GetCurrentUser())
            {
            case null:
                return;

            default:
            {
                var compliRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
                compliRef.AddValueEventListener(new SingleValueListener(
                                                    snapshot =>
                    {
                        if (snapshot.Exists())
                        {
                            fullNameTv.PostDelayed(() =>
                            {
                                fullNameTv.Text = $"{snapshot.Child("fname").Value} {snapshot.Child("lname").Value}";
                            }, 1000);

                            drivingSinceTv.PostDelayed(() =>
                            {
                                drivingSinceTv.Text = $"Driving since {DateTime.Parse(snapshot.Child("created_at").Value.ToString()).Year}";
                            }, 1000);

                            ratingTv.PostDelayed(() =>
                            {
                                ratingTv.Text = snapshot.Child("ratings").Value.ToString();
                            }, 1000);


                            Glide.With(Context)
                            .Load(snapshot.Child("profile_img_url").Value.ToString())
                            .Into(profileIv);

                            string cool_car      = snapshot.Child("compliments").Child("cool_car") == null ? "" : snapshot.Child("compliments").Child("cool_car").Value.ToString();
                            string awesome_music = snapshot.Child("compliments").Child("awesome_music") == null ? "" : snapshot.Child("compliments").Child("awesome_music").Value.ToString();
                            string friendly      = snapshot.Child("compliments").Child("made_me_laugh") == null ? "" : snapshot.Child("compliments").Child("made_me_laugh").Value.ToString();
                            string nav           = snapshot.Child("compliments").Child("expert_navigation") == null ? "" : snapshot.Child("compliments").Child("expert_navigation").Value.ToString();
                            string neat          = snapshot.Child("compliments").Child("neat_and_tidy") == null ? "" : snapshot.Child("compliments").Child("neat_and_tidy").Value.ToString();

                            compliValues = new string[] { awesome_music, cool_car, friendly, neat, nav };
                            compliValuesSwitcher.PostDelayed(() => { compliValuesSwitcher.SetCurrentText(compliValues[0]); }, 1000);
                        }
                        else
                        {
                            return;
                        }
                    },
                                                    error =>
                    {
                        Toast.MakeText(Activity, error.Message, ToastLength.Short).Show();
                    }));
                compliRef.KeepSynced(true);
                break;
            }
            }
        }
        public void Create()
        {
            _editor = _preferences.Edit();
            FirebaseDatabase  database  = AppDataHelper.GetDatabase();
            string            driverId  = AppDataHelper.GetCurrentUser().Uid;
            DatabaseReference driverRef = database.GetReference("drivers/" + driverId);

            driverRef.AddValueEventListener(this);
        }
Пример #14
0
        public void Create()
        {
            editor = preferences.Edit();
            FirebaseDatabase  database         = AppDataHelper.GetDatabase();
            string            userId           = AppDataHelper.GetCurrentUser().Uid;
            DatabaseReference profileReference = database.GetReference("users/" + userId);

            profileReference.AddValueEventListener(this);
        }
Пример #15
0
        // on create method where we initialize the event handler
        public void Create()
        {
            editor = preferences.Edit();  // initialize the editor
            FirebaseDatabase  database  = AppDataHelper.GetDatabase();
            string            driverID  = AppDataHelper.GetCurrentUser().Uid;
            DatabaseReference driverRef = database.GetReference("drivers/" + driverID);

            driverRef.AddValueEventListener(this);
        }
        private void SaveImage()
        {
            picDisplayFragment.DismissAllowingStateLoss();
            var storeRef = FirebaseStorage.Instance.GetReferenceFromUrl("gs://taxiproject-185a4.appspot.com");

            if (AppDataHelper.GetCurrentUser() != null)
            {
                var stream = new MemoryStream();
                bitmap.Compress(Bitmap.CompressFormat.Webp, 80, stream);
                byte[] bitmapArray = stream.ToArray();

                imageRef = storeRef.Child("driverProfilePics/" + AppDataHelper.GetCurrentUser().Uid);
                imageRef.PutBytes(bitmapArray).ContinueWithTask(new ContinuationTask(t =>
                {
                    if (!t.IsSuccessful)
                    {
                        OnboardingActivity.CloseProgressDialog();
                        Toast.MakeText(Activity, t.Exception.Message, ToastLength.Long).Show();
                    }
                })).AddOnCompleteListener(new OnCompleteListener(t =>
                {
                    if (t.IsSuccessful)
                    {
                        var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
                        driverRef.Child("profile_img_url").SetValue(t.Result.ToString()).AddOnCompleteListener(new OnCompleteListener(t3 =>
                        {
                            if (!t3.IsSuccessful)
                            {
                                Toast.MakeText(Activity, t3.Exception.Message, ToastLength.Long).Show();
                            }
                            OnboardingActivity.CloseProgressDialog();

                            driverRef.Child(StringConstants.StageofRegistration).SetValue($"{RegistrationStage.CarRegistering}")
                            .AddOnSuccessListener(new OnSuccessListener(r2 =>
                            {
                                ProfileCaptured.Invoke(this, new EventArgs());
                                UpdateUiOnCpture(CaptureType.ProfilePic);
                                OnboardingActivity.CloseProgressDialog();
                            })).AddOnFailureListener(new OnFailureListener(e2 =>
                            {
                                OnboardingActivity.CloseProgressDialog();
                                OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
                            }));
                        }));
                    }
                    else
                    {
                        OnboardingActivity.CloseProgressDialog();
                        OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
                    }
                }));
            }
            else
            {
                return;
            }
        }
Пример #17
0
        //User is only assigned an id if the app has never been opened before
        private void InitializeNewUser()
        {
            DatabaseReference eek = AppDataHelper.GetDatabase().GetReference("users").Push();

            ThisUser.Id         = eek.Key;
            ThisUser.beginDate  = DateTime.Now.Day;
            ThisUser.beginMonth = DateTime.Now.Month;
            ThisUser.beginYear  = DateTime.Now.Year;
        }
Пример #18
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            var AccountTypeTGroup = view.FindViewById <MaterialButtonToggleGroup>(Resource.Id.drv_part_tggl_grp);
            var InfoImgSwitcher   = view.FindViewById <ImageSwitcher>(Resource.Id.drv_part_img_swtchr1);
            var InfoTSwitcher     = view.FindViewById <TextSwitcher>(Resource.Id.drv_part_txt_swtchr1);
            var ContinueBtn       = view.FindViewById <MaterialButton>(Resource.Id.drv_part_cnt_btn);

            InitSwitchers(InfoImgSwitcher, InfoTSwitcher);

            AccountTypeTGroup.AddOnButtonCheckedListener(new OnButtonChecked(id =>
            {
                switch (id)
                {
                case Resource.Id.drv_tggl_partner_btn:
                    partner = true;
                    InfoTSwitcher.SetText(GetString(Resource.String.partner_desc_txt));
                    InfoImgSwitcher.SetImageResource(Resource.Drawable.driver_pablo);
                    break;

                case Resource.Id.drv_tggl_driver_btn:
                    partner = false;
                    InfoTSwitcher.SetText(GetString(Resource.String.driving_desc_txt));
                    InfoImgSwitcher.SetImageResource(Resource.Drawable.driver_pablo);
                    break;
                }
            }));


            ContinueBtn.Click += (s1, e1) =>
            {
                if (AppDataHelper.GetCurrentUser() != null)
                {
                    OnboardingActivity.ShowProgressDialog();
                    var driverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{AppDataHelper.GetCurrentUser().Uid}");
                    driverRef.Child("isPartner").SetValue(partner.ToString())
                    .AddOnSuccessListener(new OnSuccessListener(r1 =>
                    {
                        driverRef.Child(StringConstants.StageofRegistration).SetValue(RegistrationStage.Capturing.ToString())
                        .AddOnSuccessListener(new OnSuccessListener(r2 =>
                        {
                            PartnerTypeComplete.Invoke(this, new PartnerEventArgs {
                                IsPartnerComplete = true
                            });
                            OnboardingActivity.CloseProgressDialog();
                        }))
                        .AddOnFailureListener(new OnFailureListener(e1 => { OnboardingActivity.CloseProgressDialog(); }));
                    }))
                    .AddOnFailureListener(new OnFailureListener(e1 => { OnboardingActivity.CloseProgressDialog(); }));
                }
                else
                {
                    Toast.MakeText(Activity, "Something aint right", ToastLength.Short).Show();
                }
            };
        }
Пример #19
0
        void InitializeFirebase()
        {
            //Firebase Init
            database    = AppDataHelper.GetDatabase();
            mAuth       = AppDataHelper.GetFirebaseAuth();
            currentUser = AppDataHelper.GetCurrentUser();

            FirebaseApp.InitializeApp(this);
            //storage = FirebaseStorage.Instance;
        }
Пример #20
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.newMember);
            fullName     = (TextInputLayout)FindViewById(Resource.Id.fullNameText);
            nic          = (TextInputLayout)FindViewById(Resource.Id.NICText);
            selectDate   = (Button)FindViewById(Resource.Id.selectBirthdayButton);
            email        = (TextInputLayout)FindViewById(Resource.Id.emailText);
            telephone    = (TextInputLayout)FindViewById(Resource.Id.phoneNumberText);
            submitButton = (Button)FindViewById(Resource.Id.newMemberSubmitButton);
            cancelButton = (Button)FindViewById(Resource.Id.newMemberSubmitCancelButton);
            selectedDate = (TextView)FindViewById(Resource.Id.selectedDateLabel);

            selectDate.Click   += SelectDate_Click;
            cancelButton.Click += delegate
            {
                StartActivity(typeof(MainActivity));
            };
            submitButton.Click += delegate
            {
                string fullNameText     = fullName.EditText.Text;
                string nicText          = nic.EditText.Text;
                string emailText        = email.EditText.Text;
                string telephoneText    = telephone.EditText.Text;
                string selectedDateText = selectDate.Text;

                HashMap memberInfo = new HashMap();
                memberInfo.Put("fullName", fullNameText);
                memberInfo.Put("NIC", nicText);
                memberInfo.Put("Email", emailText);
                memberInfo.Put("telephone Number", telephoneText);
                memberInfo.Put("Birthday", birthday);

                Android.App.AlertDialog.Builder saveMemberAlert = new Android.App.AlertDialog.Builder(this);
                saveMemberAlert.SetTitle("Save Alumni Info");
                saveMemberAlert.SetMessage("Are you sure?");
                saveMemberAlert.SetPositiveButton("Continue", (senderAlert, args) =>
                {
                    DatabaseReference newMemberRef = AppDataHelper.GetDatabase().GetReference("Member").Push();
                    newMemberRef.SetValue(memberInfo);
                    StartActivity(typeof(MainActivity));
                    this.Dispose();
                });
                saveMemberAlert.SetNegativeButton("Cancel", (senderAlert, args) =>
                {
                    saveMemberAlert.Dispose();
                });

                saveMemberAlert.Show();
            };

            //submitButton.Click += SubmitButton_Click;
            // Create your application here
        }
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_stats);
            this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            this.Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
            this.Window.SetStatusBarColor(Android.Graphics.Color.ParseColor("#204060"));
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbarstats);

            SetSupportActionBar(toolbar);
            toolbar.SetNavigationOnClickListener(this);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            toolbar.NavigationIcon.SetColorFilter(Android.Graphics.Color.ParseColor("#04040C"), PorterDuff.Mode.SrcAtop);
            statstype           = FindViewById <TextView>(Resource.Id.statstype);
            statsdata           = FindViewById <TextView>(Resource.Id.statsdata);
            generatePDF         = FindViewById <Button>(Resource.Id.generatePDF);
            showbarchart        = FindViewById <ImageView>(Resource.Id.showbarchart);
            showbarchart.Click += Showbarchart_Click;
            showpiechart        = FindViewById <ImageView>(Resource.Id.showpiechart);
            showpiechart.Click += Showpiechart_Click;
            analysistype        = FindViewById <TextView>(Resource.Id.analysistype);
            analysistype.Text   = "Category-wise Expenses";
            //chartview = FindViewById<ChartView>(Resource.Id.chartview);
            monthcontainer         = FindViewById <RelativeLayout>(Resource.Id.monthcontainer);
            progressBarStats       = FindViewById <ProgressBar>(Resource.Id.progressBarStats);
            rootView               = FindViewById <CoordinatorLayout>(Resource.Id.rootView);
            monthspinner           = FindViewById <Spinner>(Resource.Id.monthspinner);
            CurrentUserUid         = Intent.GetStringExtra("CurrentUserUid");
            SelectedYear           = Intent.GetStringExtra("SelectedYear");
            SelectedMonth          = Intent.GetStringExtra("SelectedMonth");
            CurrentUserDisplayName = Intent.GetStringExtra("CurrentUserDisplayName");
            prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            //statstype.Text = "Total expense for the year"+"("+ SelectedYear+")";
            piechartStats = FindViewById <MikePhil.Charting.Charts.PieChart>(Resource.Id.piechartStats);
            piechartStats.SetNoDataText("");

            barchartStats = FindViewById <MikePhil.Charting.Charts.BarChart>(Resource.Id.barchartStats);
            barchartStats.SetNoDataText("");
            barchartStats.Description.Enabled = false;
            barchartStats.AxisRight.SetDrawLabels(false);
            database          = AppDataHelper.GetDatabase();
            IsPieChartSeleted = true;
            SetupMonthSpinner();
            //FetchExpensesTableForMonth();

            // await Common.WriteFileToStorageAsync(this, "PlayfairDisplay-Regular.ttf");
            await Common.WriteFileToStorageAsync(this, "nunitosans.ttf");

            Dexter.WithActivity(this).WithPermission(Android.Manifest.Permission.WriteExternalStorage).WithListener(this).Check();
            generatePDF.Click -= GeneratePDF_Click;
            generatePDF.Click += GeneratePDF_Click;
        }
Пример #22
0
        private void SavechangesButton_Click(object sender, EventArgs e)
        {
            string fullname   = fullnameText.EditText.Text;
            string department = departmentText.EditText.Text;
            string set        = setText.EditText.Text;

            AppDataHelper.GetDatabase().GetReference("alumini/" + thisAlunini.ID + "/fullname").SetValue(fullname);
            AppDataHelper.GetDatabase().GetReference("alumini/" + thisAlunini.ID + "/department").SetValue(department);
            AppDataHelper.GetDatabase().GetReference("alumini/" + thisAlunini.ID + "/set").SetValue(set);

            this.Dismiss();
        }
Пример #23
0
        public async void Send(Models.Message message)
        {
            HashMap messageInfo = new HashMap();

            messageInfo.Put("sender", message.Sender);
            messageInfo.Put("content", message.Content);
            messageInfo.Put("time", message.Time);
            messageInfo.Put("date", message.Date);

            DatabaseReference messageReference = AppDataHelper.GetDatabase().GetReference("Chat").Push();
            await messageReference.SetValueAsync(messageInfo);
        }
Пример #24
0
        private void TaskCompletionListener_Success(object sender, EventArgs e)
        {
            Snackbar.Make(rootView, "User Registration was Successful", Snackbar.LengthShort).Show();
            HashMap userMap = new HashMap();

            userMap.Put("email", email);
            userMap.Put("phone", phone);
            userMap.Put("fullname", fullname);


            DatabaseReference userReference = AppDataHelper.GetDatabase().GetReference("users/" + mAuth.CurrentUser.Uid);

            userReference.SetValue(userMap);
        }
Пример #25
0
        public static void SimplifyPrevMonth()
        {
            int pm = DateTime.Now.Month - 1;
            int py = DateTime.Now.Year;

            if (DateTime.Now.Month == 1)
            {
                py--;
            }

            int monthlyTotalItems = 0;
            int monthlyAvgScore   = 0;
            int daysInMonth       = 31;

            //changes daysInMonth depending on the month that pm was
            if (pm == 2)
            {
                daysInMonth = 28;
                if (py % 4 == 0)
                {
                    daysInMonth = 29;
                }
            }
            int[] monthsWith30Days = { 4, 6, 9, 11 };
            foreach (int i in monthsWith30Days)
            {
                if (pm == i)
                {
                    daysInMonth = 30;
                }
            }
            string prevMonth = "" + pm;
            string prevYear  = py + "";

            for (int date = 1; date <= daysInMonth; date++)
            {
                DatabaseReference items = AppDataHelper.GetDatabase().GetReference("users/" + App.ThisUser.Id + "/" + prevYear + "/" + prevMonth + "/" + date + "/items/");
                monthlyTotalItems += (int)items.RemoveValue();
                DatabaseReference scores = AppDataHelper.GetDatabase().GetReference("users/" + App.ThisUser.Id + "/" + prevYear + "/" + prevMonth + "/" + date + "/score/");
                monthlyAvgScore += (int)scores.RemoveValue();
            }
            monthlyAvgScore /= daysInMonth;
            DatabaseReference month = AppDataHelper.GetDatabase().GetReference("users/" + App.ThisUser.Id + "/year/" + prevYear + "/" + prevMonth);
            HashMap           h     = new HashMap();

            h.Put("monthlyAvgScore", monthlyAvgScore);
            h.Put("monthlyTotalItems", monthlyTotalItems);
            month.SetValue(h);
        }
Пример #26
0
        private void TaskCompletionListener_Success(object sender, EventArgs e)
        {
            Snackbar.Make(rootView, "User registration was successful", Snackbar.LengthShort).Show();

            //Creating HashMap to store user information to Firebase
            HashMap userMap = new HashMap();

            userMap.Put("fullname", fullname);
            userMap.Put("email", email);

            //sets user's id to be the unique id in database
            DatabaseReference userReference = AppDataHelper.GetDatabase().GetReference("users/" + mAuth.CurrentUser.Uid);

            userReference.SetValue(userMap);
        }
        private void SaveDriverToDb()
        {
            var DriverRef = AppDataHelper.GetDatabase().GetReference($"Drivers/{ AppDataHelper.GetCurrentUser().Uid}");

            HashMap compliments = new HashMap();

            compliments.Put("cool_car", "0");
            compliments.Put("neat_and_tidy", "0");
            compliments.Put("expert_navigation", "0");
            compliments.Put("awesome_music", "0");
            compliments.Put("made_me_laugh", "0");

            HashMap driverMap = new HashMap();

            driverMap.Put("fname", fname);
            driverMap.Put("lname", lname);
            driverMap.Put("email", email);
            driverMap.Put("phone", phone);
            driverMap.Put("city", city);
            driverMap.Put("invitecode", code);
            driverMap.Put("ratings", "0");
            driverMap.Put("compliments", compliments);
            driverMap.Put("created_at", DateTime.UtcNow.ToString());



            DriverRef.SetValue(driverMap)
            .AddOnSuccessListener(new OnSuccessListener(r =>
            {
                DriverRef.Child(StringConstants.StageofRegistration).SetValue(RegistrationStage.Partnering.ToString())
                .AddOnSuccessListener(new OnSuccessListener(r2 =>
                {
                    OnboardingActivity.CloseProgressDialog();
                    SignUpSuccess.Invoke(this, new SignUpSuccessArgs {
                        IsCompleted = true
                    });
                }))
                .AddOnFailureListener(new OnFailureListener(e1 =>
                {
                    OnboardingActivity.CloseProgressDialog();
                    Toast.MakeText(Activity, e1.Message, ToastLength.Short).Show();
                }));
            }))
            .AddOnFailureListener(new OnFailureListener(e =>
            {
                OnboardingActivity.ShowErrorDialog("Something went wrong, please retry");
            }));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_settings);
            this.Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            this.Window.ClearFlags(WindowManagerFlags.TranslucentStatus);
            this.Window.SetStatusBarColor(Android.Graphics.Color.ParseColor("#204060"));

            var toolbar = FindViewById <Toolbar>(Resource.Id.tbsettings);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);
            toolbar.NavigationIcon.SetColorFilter(Android.Graphics.Color.ParseColor("#04040C"), PorterDuff.Mode.SrcAtop);
            toolbar.SetNavigationOnClickListener(this);

            currencyspinner = FindViewById <Spinner>(Resource.Id.currencyspinner);
            currencyspinner.ItemSelected -= Currencyspinner_ItemSelected;
            currencyspinner.ItemSelected += Currencyspinner_ItemSelected;

            appintro                     = FindViewById <LinearLayout>(Resource.Id.appintro);
            appintro.Click              += Appintro_Click;
            privacy                      = FindViewById <LinearLayout>(Resource.Id.privacy);
            privacy.Click               += Privacy_Click;
            radio_Submission_Date        = FindViewById <RadioButton>(Resource.Id.radio_Submission_Date);
            radio_Expense_Date           = FindViewById <RadioButton>(Resource.Id.radio_Expense_Date);
            radio_Submission_Date.Click += Radio_Submission_Date_Click;
            radio_Expense_Date.Click    += Radio_Expense_Date_Click;
            radiogrp                     = FindViewById <RadioGroup>(Resource.Id.radiogrp);
            database                     = AppDataHelper.GetDatabase();

            FetchCurrencySymbolsTable();
            prefs = PreferenceManager.GetDefaultSharedPreferences(this);
            var mString = prefs.GetString("OrderBySelected", "");

            radiogrp.ClearCheck();
            if (mString == "DateDay")
            {
                radio_Expense_Date.Checked    = true;
                radio_Submission_Date.Checked = false;
            }
            else
            {
                radio_Expense_Date.Checked    = false;
                radio_Submission_Date.Checked = true;
            }
        }
Пример #29
0
        private void SubmitButton_Click(object sender, EventArgs e)
        {
            string Name     = name.EditText.Text;
            string Location = location.EditText.Text;
            string BodyNum  = bodyNum.EditText.Text;

            HashMap driversInfo = new HashMap();

            driversInfo.Put("Name", Name);
            driversInfo.Put("Location", Location);
            driversInfo.Put("BodyNum", BodyNum);

            DatabaseReference newDriversRef = AppDataHelper.GetDatabase().GetReference("Drivers").Push();

            newDriversRef.SetValue(driversInfo);
        }
Пример #30
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.ForgotPassword);

            //Init Firebase
            auth = FirebaseAuth.GetInstance(AppDataHelper.GetDatabase().App);

            //View
            input_email  = (TextInputLayout)FindViewById(Resource.Id.forgot_email);
            btnResetPass = FindViewById <Button>(Resource.Id.forgot_btn_reset);
            btnBack      = FindViewById <TextView>(Resource.Id.forgot_btn_back);


            btnResetPass.SetOnClickListener(this);
            btnBack.SetOnClickListener(this);
        }