Beispiel #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.UserRegister);
            // Create your application here
            var user = new DataModels.DataModels();

            currentUser = AuthService.GetCredentials();//user.GetUser(AuthService.Alias, AuthService.Password);

            SetUserData();

            btnRegister.Click += BtnRegister_Click;
            btnReturn.Click   += BtnReturn_Click;
        }
        private void BtnRegister_Click(object sender, EventArgs e)
        {
            var user        = GetFormData();
            var data        = new DataModels.DataModels();
            var isValidForm = !string.IsNullOrEmpty(user.alias);
            var isValidUser = false;

            if (isValidForm)
            {
                isValidUser = !data.UserExist(user.alias, user.nombre, user.apellido);
            }

            progressBar = new ProgressDialog(this);
            if (isValidForm)
            {
                progressBar.SetCancelable(false);
                progressBar.SetMessage("Validando Cuenta...");
                progressBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                progressBar.Show();
            }

            new Thread(new ThreadStart(delegate()
            {
                Thread.Sleep(2000);//timer for loading  loading de 1000ms (1 seg)
                RunOnUiThread(() => { progressBar.Hide(); });
                RunOnUiThread(() => {
                    if (isValidUser)
                    {
                        data.SetUser(user);
                        AuthService.SaveCredentials(user);
                    }
                    Toast.MakeText(this, !isValidForm ?
                                   "Complete los datos del formulario":
                                   isValidUser? "Registro Exitoso":"El alias y/o usuario ya existe",
                                   ToastLength.Long).Show();
                });
            })).Start();

            if (isValidForm && isValidUser)
            {
                new Thread(new ThreadStart(delegate()
                {
                    Thread.Sleep(2000);//timer for loading  loading de 1000ms (1 seg)
                    RunOnUiThread(() => { progressBar.Hide(); });
                    Intent nextScreen = new Intent(this, typeof(MainActivity));
                    StartActivity(nextScreen);
                })).Start();
            }
        }
        //Modal for show  loading...
        private void DisplayProgressLoading(string user, string pass)
        {
            try
            {
                bool check = true;//NetworkInterface.GetIsNetworkAvailable(); comment this line because
                if (check)
                {
                    progressBar = new ProgressDialog(this);
                    progressBar.SetCancelable(false);
                    progressBar.SetMessage("Accediendo...");
                    progressBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                    progressBar.Show();

                    var dataModels = new DataModels.DataModels();
                    var userValid  = dataModels.UserExist(user, string.Empty, string.Empty);
                    var userData   = dataModels.GetUser(user, pass);
                    new Thread(new ThreadStart(delegate()
                    {
                        Thread.Sleep(2000);//timer for loading of 2000ms
                        RunOnUiThread(() => { progressBar.Hide(); });
                        RunOnUiThread(() => { Toast.MakeText(this, userValid && userData != null && !string.IsNullOrEmpty(userData.alias) ? "Acceso Exitoso":"Usuario y/o Contraseña incorrecto", ToastLength.Long).Show(); });
                    })).Start();

                    if (userValid && userData != null && !string.IsNullOrEmpty(userData.alias))
                    {
                        new Thread(new ThreadStart(delegate()
                        {
                            Thread.Sleep(2000);//timer for loading of 23000ms
                            RunOnUiThread(() => { progressBar.Hide(); });
                            RunOnUiThread(() => {
                                //Sending data to another Activity
                                //TODO: here add service conection for user validation
                                //if is correct then save the credencials in app
                                AuthService.SaveCredentials(userData);

                                Intent nextScreen = new Intent(this, typeof(LoginUserActivity));
                                StartActivity(nextScreen);
                            });
                        })).Start();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.PerformedCargoesMain);

            typeOfUser = int.Parse(AuthService.UserType);

            mListView = FindViewById <ListView>(Resource.Id.lstPcPerformed);


            var originValue     = Intent.GetStringExtra("originValue");
            var destinyValue    = Intent.GetStringExtra("destinyValue");
            var cargoTypeValue  = Intent.GetStringExtra("cargoTypeValue");
            var priceRangeValue = Intent.GetStringExtra("priceRangeValue");


            LayoutInflater inflater      = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            View           headerView    = inflater.Inflate(Resource.Layout.CargoesHeader, null);
            TextView       lblTextHeader = (TextView)headerView.FindViewById <TextView>(Resource.Id.lblChTitleList);

            lblTextHeader.SetText(typeOfUser == 1 ?Resource.String.PublishedTripTitle : Resource.String.PublishedCargoesTitle);

            View footerView = inflater.Inflate(Resource.Layout.CargoesFooter, null);
            var  data       = new DataModels.DataModels();

            var mItems = GetTrips(originValue, destinyValue, cargoTypeValue, priceRangeValue);
            PerformedCargoesAdapter adapter = new PerformedCargoesAdapter(this, mItems);

            mListView.AddHeaderView(headerView);
            mListView.AddFooterView(footerView);
            mListView.Adapter = adapter;

            btnVolver            = FindViewById <Button>(Resource.Id.btnCfReturn);
            lblName              = FindViewById <TextView>(Resource.Id.txtPcUser);
            mListView.ItemClick += MListView_ItemClick;

            btnVolver.Click += delegate
            {
                Intent nextScreen = new Intent(this, typeof(SearchCargoesActivity));
                StartActivity(nextScreen);
            };
        }
Beispiel #5
0
        private void BtnRegister_Click(object sender, EventArgs e)
        {
            var user        = GetFormData();
            var data        = new DataModels.DataModels();
            var isValidForm = !string.IsNullOrEmpty(user.alias);
            var isValidUser = false;

            if (isValidForm)
            {
                isValidUser = data.UserExist(user.alias, user.nombre, user.apellido);
            }

            progressBar = new ProgressDialog(this);
            if (isValidForm)
            {
                progressBar.SetCancelable(false);
                progressBar.SetMessage("Validando Cuenta...");
                progressBar.SetProgressStyle(ProgressDialogStyle.Spinner);
                progressBar.Show();
            }

            new Thread(new ThreadStart(delegate()
            {
                Thread.Sleep(2000);//timer for loading  loading de 2000ms (1 seg)
                RunOnUiThread(() => { progressBar.Hide(); });
                RunOnUiThread(() => {
                    data.SetUser(user);
                    user.cantidadEvaluaciones = currentUser.cantidadEvaluaciones;
                    user.ranking = currentUser.ranking;
                    AuthService.SaveCredentials(user);

                    if (!isValidUser)
                    {
                        Toast.MakeText(this, "Complete los datos del formulario", ToastLength.Long).Show();
                    }
                    else
                    {
                        ShowAlert("¡Felicidades!", "Ha actualizado sus datos correctamente");
                    }
                });
            })).Start();
        }