Esempio n. 1
0
        private ProgressBar progressBar;                  // Progress spinner to use for table operations

        // Called when the activity initially gets created
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
            progressBar            = FindViewById <ProgressBar>(Resource.Id.loadingProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            try
            {
                // Check to ensure everything's setup right
                GcmClient.CheckDevice(this);
                GcmClient.CheckManifest(this);

                // Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                GcmClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);

                CurrentPlatform.Init();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    Constants.ApplicationURL,
                    Constants.ApplicationKey, progressHandler);

                // Get the Mobile Service Table instance to use
                todoTable = client.GetTable <TodoItem>();

                textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

                // Create an adapter to bind the items with the view
                adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);
                listViewTodo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }
Esempio n. 2
0
        private ProgressBar progressBar; // Progress spinner to use for table operations

        // Called when the activity initially gets created
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
            progressBar            = FindViewById <ProgressBar>(Resource.Id.loadingProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            // TODO:: Uncomment the following code when using a mobile service

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };


            try
            {
                // TODO:: Uncomment the following code to create the mobile services client

                CurrentPlatform.Init();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    Constants.ApplicationURL,
                    Constants.ApplicationKey, progressHandler);

                // Get the Mobile Service Table instance to use
                todoTable = client.GetTable <TodoItem>();

                textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

                // Create an adapter to bind the items with the view
                adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);
                listViewTodo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }
Esempio n. 3
0
        private async Task CreateTable()
        {
            // Get the Mobile Service Table instance to use
            todoTable = client.GetTable <TodoItem>();

            textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

            // Create an adapter to bind the items with the view
            adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
            var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);

            listViewTodo.Adapter = adapter;

            // Load the items from the Mobile Service
            await RefreshItemsFromTableAsync();
        }
Esempio n. 4
0
        private ProgressBar progressBar;                  // Progress spinner to use for table operations

        // Called when the activity initially gets created
        protected override async void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Activity_To_Do);

            // Initialize the progress bar
            progressBar            = FindViewById <ProgressBar>(Resource.Id.loadingProgressBar);
            progressBar.Visibility = ViewStates.Gone;

            // Create ProgressFilter to handle busy state
            var progressHandler = new ProgressHandler();

            progressHandler.BusyStateChange += (busy) => {
                if (progressBar != null)
                {
                    progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
                }
            };

            try
            {
                // PUSH NOTIFICATIONS: Register for push notifications
                System.Diagnostics.Debug.WriteLine("Registering...");
                // Initialize our Gcm Service Hub
                GcmService.Initialize(this);
                GcmService.Register(this);


                // MOBILE SERVICES: Setup azure mobile services - this is separate from push notifications
                CurrentPlatform.Init();
                // Create the Mobile Service Client instance, using the provided
                // Mobile Service URL and key
                client = new MobileServiceClient(
                    Constants.ApplicationURL,
                    progressHandler);

                // Get the Mobile Service Table instance to use
                todoTable = client.GetTable <TodoItem>();


                // USER INTERFACE: setup the Android UI
                textNewTodo = FindViewById <EditText>(Resource.Id.textNewTodo);

                // Create an adapter to bind the items with the view
                adapter = new TodoItemAdapter(this, Resource.Layout.Row_List_To_Do);
                var listViewTodo = FindViewById <ListView>(Resource.Id.listViewTodo);
                listViewTodo.Adapter = adapter;

                // Load the items from the Mobile Service
                await RefreshItemsFromTableAsync();
            }
            catch (Java.Net.MalformedURLException)
            {
                CreateAndShowDialog(new Exception("There was an error creating the Mobile Service. Verify the URL"), "Error");
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e, "Error");
            }
        }