Example #1
0
        public void RegisterUser()
        {
            if (ValidateInput())
            {
                DismissKeyboard();

                AppController.Utility.ExecuteDelayedAction(300, default(System.Threading.CancellationToken),
                                                           () =>
                {
                    if (_isRegisteringUser)
                    {
                        return;
                    }

                    _isRegisteringUser = true;

                    _password = this.PasswordText.Text;

                    // Prevent user form tapping views while logging
                    ((MainActivity)this.Activity).BlockUI();

                    // Create a new cancellation token for this request
                    _cts = new CancellationTokenSource();
                    AppController.RegisterUser(_cts,
                                               _email,
                                               _password,
                                               // Service call success
                                               (data) =>
                    {
                        var f = new RegistrationDoneFragment();
                        this.FragmentManager.PopBackStack("BeforeRegistration0Fragment", (int)PopBackStackFlags.Inclusive);
                        this.FragmentManager.BeginTransaction()
                        .AddToBackStack("BeforeRegistrationDoneFragment")
                        .Replace(Resource.Id.ContentLayout, f, "RegistrationDoneFragment")
                        .Commit();
                    },
                                               // Service call error
                                               (error) =>
                    {
                        this.PasswordText.RequestFocus();

                        Toast.MakeText(this.Activity.Application, error, ToastLength.Long).Show();
                    },
                                               // Service call finished
                                               () =>
                    {
                        _isRegisteringUser = false;

                        // Allow user to tap views
                        ((MainActivity)this.Activity).UnblockUI();
                    });
                });
            }
        }
Example #2
0
        public override void OnCreate()
        {
            base.OnCreate();

            // Setup Application
            AppController.EnableSettings(new AdMaiora.AppKit.Data.UserSettingsPlatformAndroid());
            AppController.EnableUtilities(new AdMaiora.AppKit.Utils.ExecutorPlatformAndroid());
            AppController.EnableFileSystem(new AdMaiora.AppKit.IO.FileSystemPlatformAndroid());
            AppController.EnableDataStorage(new AdMaiora.AppKit.Data.DataStoragePlatformAndroid());
            AppController.EnableServices(new AdMaiora.AppKit.Services.ServiceClientPlatformAndroid());
        }
Example #3
0
        private void LoginUser()
        {
            if (ValidateInput())
            {
                if (_isLogginUser)
                {
                    return;
                }

                _isLogginUser = true;

                _email    = this.EmailText.Text;
                _password = this.PasswordText.Text;

                // Prevent user form tapping views while logging
                ((MainViewController)this.MainViewController).BlockUI();

                // Create a new cancellation token for this request
                _cts1 = new CancellationTokenSource();
                AppController.LoginUser(_cts1, _email, _password,
                                        // Service call success
                                        (data) =>
                {
                    AppController.Settings.LastLoginUsernameUsed = _email;
                    AppController.Settings.AuthAccessToken       = data.AuthAccessToken;
                    AppController.Settings.AuthExpirationDate    = data.AuthExpirationDate.GetValueOrDefault().ToLocalTime();

                    var c       = new AgendaViewController();
                    c.Arguments = new UIBundle();
                    c.Arguments.PutInt("UserId", data.UserId);
                    this.NavigationController.PushViewController(c, true);
                },
                                        // Service call error
                                        (error) =>
                {
                    if (error.Contains("confirm"))
                    {
                        this.VerifyButton.Hidden = false;
                    }

                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                        // Service call finished
                                        () =>
                {
                    _isLogginUser = false;

                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
        }
Example #4
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Setup Application
            AppController.EnableSettings(new AdMaiora.AppKit.Data.UserSettingsPlatformiOS());
            AppController.EnableUtilities(new AdMaiora.AppKit.Utils.ExecutorPlatformiOS());
            AppController.EnableFileSystem(new AdMaiora.AppKit.IO.FileSystemPlatformiOS());
            AppController.EnableDataStorage(new AdMaiora.AppKit.Data.DataStoragePlatformiOS());
            AppController.EnableServices(new AdMaiora.AppKit.Services.ServiceClientPlatformiOS());

            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method
            return(RegisterMainLauncher(new SplashViewController(), launchOptions));
        }
Example #5
0
        public void RegisterUser()
        {
            if (ValidateInput())
            {
                DismissKeyboard();

                AppController.Utility.ExecuteDelayedAction(300, default(System.Threading.CancellationToken),
                                                           () =>
                {
                    if (_isRegisteringUser)
                    {
                        return;
                    }

                    _isRegisteringUser = true;

                    _password = this.PasswordText.Text;

                    // Prevent user form tapping views while logging
                    ((MainViewController)this.MainViewController).BlockUI();

                    // Create a new cancellation token for this request
                    _cts = new CancellationTokenSource();
                    AppController.RegisterUser(_cts,
                                               _email,
                                               _password,
                                               // Service call success
                                               (data) =>
                    {
                        var c = new RegistrationDoneViewController();
                        this.NavigationController.PopToViewController(this.NavigationController.ViewControllers.Single(x => x is LoginViewController), false);
                        this.NavigationController.PushViewController(c, true);
                    },
                                               // Service call error
                                               (error) =>
                    {
                        this.PasswordText.RequestUserInput();

                        UIToast.MakeText(error, UIToastLength.Long).Show();
                    },
                                               // Service call finished
                                               () =>
                    {
                        _isRegisteringUser = false;

                        // Allow user to tap views
                        ((MainViewController)this.MainViewController).UnblockUI();
                    });
                });
            }
        }
Example #6
0
        private void VerifyUser()
        {
            if (ValidateInput())
            {
                if (_isConfirmingUser)
                {
                    return;
                }

                _isConfirmingUser = true;

                _email    = this.EmailText.Text;
                _password = this.PasswordText.Text;

                // Prevent user form tapping views while logging
                ((MainViewController)this.MainViewController).BlockUI();

                this.VerifyButton.Hidden = true;

                // Create a new cancellation token for this request
                _cts1 = new CancellationTokenSource();
                AppController.VerifyUser(_cts1, _email, _password,
                                         // Service call success
                                         () =>
                {
                    UIToast.MakeText("You should receive a new mail!", UIToastLength.Long).Show();
                },
                                         // Service call error
                                         (error) =>
                {
                    UIToast.MakeText(error, UIToastLength.Long).Show();
                },
                                         // Service call finished
                                         () =>
                {
                    _isConfirmingUser = false;

                    // Allow user to tap views
                    ((MainViewController)this.MainViewController).UnblockUI();
                });
            }
        }
Example #7
0
        private void UpdateTodoItem()
        {
            if (_isSendingTodoItem)
            {
                return;
            }

            if (!ValidateInput())
            {
                return;
            }

            string title       = this.TitleText.Text;
            string description = this.DescriptionText.Text;
            string tags        = this.TagsText.Text;

            _isSendingTodoItem = true;
            ((MainViewController)this.MainViewController).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.UpdateTodoItem(_cts0,
                                         _item.TodoItemId,
                                         title,
                                         description,
                                         _willDoIn,
                                         tags,
                                         (todoItem) =>
            {
                this.NavigationController.PopViewController(true);
            },
                                         (error) =>
            {
                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                         () =>
            {
                _isSendingTodoItem = false;
                ((MainViewController)this.MainViewController).UnblockUI();
            });
        }
Example #8
0
        private void UpdateTodoItem()
        {
            if (_isSendingTodoItem)
            {
                return;
            }

            if (!ValidateInput())
            {
                return;
            }

            string title       = this.TitleText.Text;
            string description = this.DescriptionText.Text;
            string tags        = this.TagsText.Text;

            _isSendingTodoItem = true;
            ((MainActivity)this.Activity).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.UpdateTodoItem(_cts0,
                                         _item.TodoItemId,
                                         title,
                                         description,
                                         _willDoIn,
                                         tags,
                                         (todoItem) =>
            {
                this.FragmentManager.PopBackStack();
            },
                                         (error) =>
            {
                Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show();
            },
                                         () =>
            {
                _isSendingTodoItem = false;
                ((MainActivity)this.Activity).UnblockUI();
            });
        }
Example #9
0
        private bool RestoreUser()
        {
            if (!AppController.IsUserRestorable)
            {
                return(false);
            }

            if (_isLogginUser)
            {
                return(true);
            }

            _isLogginUser = true;

            // Create a new cancellation token for this request
            _cts = new CancellationTokenSource();
            AppController.RestoreUser(_cts, AppController.Settings.AuthAccessToken,
                                      // Service call success
                                      (data) =>
            {
                UIBundle b = new UIBundle();
                b.PutBoolean("UserRestored", true);
                b.PutInt("UserId", data.UserId);
                MakeRoot(typeof(MainViewController), b);
            },
                                      // Service call error
                                      (error) =>
            {
                MakeRoot(typeof(MainViewController));

                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                      // Service call finished
                                      () =>
            {
                _isLogginUser = false;
            });

            return(true);
        }
Example #10
0
        private void RefreshTodoItems()
        {
            if (_isRefreshingItems)
            {
                return;
            }

            this.TaskList.Visibility = ViewStates.Gone;

            _isRefreshingItems = true;
            ((MainActivity)this.Activity).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.RefreshTodoItems(_cts0,
                                           _userId,
                                           (items) =>
            {
                items = items
                        .OrderBy(x => (x.CreationDate.GetValueOrDefault().Date.AddDays(x.WillDoIn).Date - DateTime.Now.Date).Days)
                        .ToArray();

                _adapter.Refresh(items);
                this.TaskList.ReloadData();
            },
                                           (error) =>
            {
                Toast.MakeText(this.Activity.ApplicationContext, error, ToastLength.Long).Show();
            },
                                           () =>
            {
                this.TaskList.Visibility = ViewStates.Visible;

                _isRefreshingItems = false;
                ((MainActivity)this.Activity).UnblockUI();
            });
        }
Example #11
0
        private void RefreshTodoItems()
        {
            if (_isRefreshingItems)
            {
                return;
            }

            this.TaskList.Hidden = true;

            _isRefreshingItems = true;
            ((MainViewController)this.MainViewController).BlockUI();

            _cts0 = new CancellationTokenSource();
            AppController.RefreshTodoItems(_cts0,
                                           _userId,
                                           (items) =>
            {
                items = items
                        .OrderBy(x => (x.CreationDate.GetValueOrDefault().Date.AddDays(x.WillDoIn).Date - DateTime.Now.Date).Days)
                        .ToArray();

                _source.Refresh(items);
                this.TaskList.ReloadData();
            },
                                           (error) =>
            {
                UIToast.MakeText(error, UIToastLength.Long).Show();
            },
                                           () =>
            {
                this.TaskList.Hidden = false;

                _isRefreshingItems = false;
                ((MainViewController)this.MainViewController).UnblockUI();
            });
        }