Ejemplo n.º 1
0
        private void OnTripSaveComplete(bool success)
        {
            activity.sendGaEvent("ui_action", "save trip", "save trip", Convert.ToInt16(success));

            if (success)
            {
                Intent        alarmIntent = new Intent(activity, typeof(LocationAlarmReceiver));
                PendingIntent pi          = PendingIntent.GetBroadcast(activity.ApplicationContext, 0, alarmIntent, 0);

                DateTime dtNow   = DateTime.Now.ToLocalTime();
                DateTime dtStart = this.itinerary.GetStartDate().ToLocalTime();

                TimeSpan diffTS = dtStart - dtNow;

                long ms = (long)diffTS.TotalMilliseconds;

                if (((int)Build.VERSION.SdkInt) >= 19)
                {
                    mAlarmManager.SetExact(AlarmType.ElapsedRealtimeWakeup, ms, pi);
                }
                else
                {
                    mAlarmManager.Set(AlarmType.ElapsedRealtimeWakeup, ms, pi);
                }
                view.OnSaveComplete();
                activity.SetResult(Result.Ok);
                activity.Finish();
            }
            else
            {
                view.OnSaveError();
                activity.SetResult(Result.Canceled);
            }
        }
Ejemplo n.º 2
0
        public async void SearchAndDisplayResults(SearchIntent searchIntent)
        {
            this.view.ShowBusy(true);

            try{
                searchResult = await searchIntent.Search();
            }catch (Exception e) {
                Console.WriteLine(e.Message);
                searchResult = null;
            }

            if (searchResult != null)
            {
                activity.sendGaEvent("ui_action", "search trips", "search results", searchResult.itineraries.Count);
            }
            else
            {
                activity.sendGaEvent("ui_action", "search trips", "search results", -1);
            }
            this.view.ShowSearchResult(searchResult);
            this.view.ShowBusy(false);
        }
Ejemplo n.º 3
0
 public void OnTripCancelComplete(bool success)
 {
     activity.sendGaEvent("ui_action", "cancel trip", "cancel trip", Convert.ToInt16(success));
     if (success)
     {
         view.OnCancelComplete();
         activity.SetResult(Result.Ok);
         activity.Finish();
     }
     else
     {
         view.OnCancelError();
         activity.SetResult(Result.Canceled);
     }
 }
Ejemplo n.º 4
0
        private async Task Register(string username, string password, string password_verify, string firstname, string lastname)
        {
            AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
            //LoginResult loginResult = await loginManager.Register (username, password, firstname, lastname);
            LoginResult loginResult = await new RegistrationApplicant(username, password, password_verify, firstname, lastname).Register(loginManager);

            activity.sendGaEvent("ui_action", "register user", "register result", Convert.ToInt16(loginResult.Success));

            if (loginResult.Success)
            {
                LoginAndGoHome(username, password);
            }
            else
            {
                view.OnRegistrationError(loginResult.ErrorString);
            }
        }
Ejemplo n.º 5
0
        public async void OnAttemptLogin(string email, string password)
        {
            try{
                if (string.IsNullOrEmpty(email) || string.IsNullOrEmpty(password))
                {
                    view.OnLoginError("You must enter a username and password");
                }
                else
                {
                    AndroidLoginManager loginManager = AndroidLoginManager.Instance(activity.ApplicationContext);
                    LoginResult         loginResult  = await loginManager.Login(email, password);

                    view.ShowBusy(false);

                    activity.sendGaEvent("ui_action", "user login", "login result", Convert.ToInt16(loginResult.Success));
                    if (loginResult.Success)
                    {
                        AccountManager acm      = new AccountManager();
                        TravelerModel  traveler = await acm.GetTravelerByEmail(email);

                        if (traveler.InformedConsent)
                        {
                            Intent intent = new Intent(activity.ApplicationContext, typeof(HomeActivity));
                            activity.StartActivity(intent);
                            activity.Finish();
                        }
                        else
                        {
                            view.showTerms();
                        }
                    }
                    else
                    {
                        view.OnLoginError(loginResult.ErrorString);
                    }
                }
            }catch (Exception e) {
                Console.WriteLine(e);
                view.OnLoginError("Login failed");
            }
        }