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 // 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 PushClient.CheckDevice(this); PushClient.CheckManifest(this); // Register for push notifications System.Diagnostics.Debug.WriteLine("Registering..."); PushClient.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"); } }
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, Constants.ApplicationKey, 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"); } }
public static IEnumerable <On <TodoListState> > CreateReducers() { return(new List <On <TodoListState> > { On <SetFilterAction, TodoListState>( (state, action) => state.With(new { action.Filter }) ), On <CreateTodoItemAction, TodoListState>( state => { int newId = state.Items.Collection.Any() ? state.Items.Ids.Max() + 1 : 1; return state.With(new { Items = TodoItemAdapter.UpsertOne(new TodoItem { Id = newId }, state.Items) }); } ), On <CompleteTodoItemAction, TodoListState>( (state, action) => { return state.With(new { Items = TodoItemAdapter.UpsertOne(new { action.Id, Completed = true }, state.Items) }); } ), On <RevertCompleteTodoItemAction, TodoListState>( (state, action) => { return state.With(new { Items = TodoItemAdapter.UpsertOne(new { action.Id, Completed = false }, state.Items) }); } ), On <UpdateTodoItemAction, TodoListState>( (state, action) => { return state.With(new { Items = TodoItemAdapter.UpsertOne(new { action.Id, action.Content }, state.Items) }); } ), On <RemoveTodoItemAction, TodoListState>( (state, action) => { return state.With(new { Items = TodoItemAdapter.RemoveOne(action.Id, state.Items) }); } ) }); }
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"); } }
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(); }