예제 #1
0
        // Simulates background work that happens behind the splash screen
        async void SimulateStartup()
        {
            Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
            await Task.Delay(1000); // Simulate a bit of startup work.

            Log.Debug(TAG, "Startup work is finished - starting MainActivity.");


            Context        mContext         = Android.App.Application.Context;
            AppPreferences ap               = new AppPreferences(mContext);
            Dictionary <string, string> key = ap.getAccessKey();

            if (key.Count != 0)
            {
                StartActivity(new Intent(Application.Context, typeof(MainActivity)));
            }
            else
            {
                StartActivity(new Intent(Application.Context, typeof(LoginIntent)));
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            //DECLARACIONES Y ASIGNACIONES

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.preferences_intent);

            AutoCompleteTextView genresSelector = FindViewById <AutoCompleteTextView>(Resource.Id.buscadorGeneros);

            mContext = Android.App.Application.Context;
            ap       = new AppPreferences(mContext);
            key      = ap.getAccessKey();

            ArrayAdapter <String> adapter;
            ProgressBar           progressbar = FindViewById <ProgressBar>(Resource.Id.genresSearchProgresBar);

            btnSavePreferences = FindViewById <Button>(Resource.Id.btnSavePreferences);

            //EVENTOS

            genresSelector.BeforeTextChanged += (sender, args) =>
            {
                progressbar.Visibility = ViewStates.Visible;
            };

            genresSelector.TextChanged += async(sender, args) =>
            {
                try
                {
                    var currentGenres = await clienteHTTP.FindEntriesAsync("tblCustomerPreferences?$filter=customer_id eq 2");

                    allGenresID.Clear();
                    allGenresName.Clear();
                    var genres = await clienteHTTP.FindEntriesAsync("tblGenres?$filter=substringof('" + args.Text + "', name)");

                    foreach (var genre in genres)
                    {
                        allGenresID.Add(genre["genre_id"].ToString());
                        allGenresName.Add(genre["name"].ToString());
                    }
                    adapter = new ArrayAdapter <String>(this, Resource.Layout.list_item, allGenresName);
                    genresSelector.Adapter = adapter;
                    progressbar.Visibility = ViewStates.Invisible;
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
                }
            };

            genresSelector.ItemClick += (sender, args) =>
            {
                Toast.MakeText(this, genresSelector.Text, ToastLength.Long).Show();
                currentGenresID.Add(allGenresID[allGenresName.FindIndex(x => x.Equals(genresSelector.Text))]);
                currentGenresName.Add(genresSelector.Text);
                adaptador.Add(genresSelector.Text);
                genresSelector.Text = "";
            };

            btnSavePreferences.Click += async(sender, args) =>
            {
                string preferences = string.Join(",", currentGenresID.ToArray());
                var    registry    = new
                {
                    preference_value = preferences,
                    //create_time = Convert.ToDateTime(DateTime.Now),
                    update_time = Convert.ToDateTime(DateTime.Now)
                };

                try
                {
                    var result = await clienteHTTP.For("tblCustomerPreferences").Key(int.Parse(key["userID"]), 9).Set(registry).UpdateEntryAsync();

                    //var result = await clienteHTTP.For("tblCustomerPreferences").Key(suma).Set(registry).UpdateEntryAsync();
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, ex.Message, ToastLength.Long).Show();
                }
            };
        }