protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            progressBar = FindViewById <ProgressBar>(Resource.Id.progressBar);

            viewModel = ServiceContainer.Resolve <ExpensesViewModel>();
            viewModel.IsBusyChanged = (busy) =>
            {
                progressBar.Visibility = busy ? ViewStates.Visible : ViewStates.Gone;
            };

            ListAdapter = new ExpenseAdapter(this, viewModel);

            ListView.ItemLongClick += async(sender, args) =>
            {
                await viewModel.ExecuteDeleteExpenseCommand(viewModel.Expenses[args.Position]);

                RunOnUiThread(() => ((ExpenseAdapter)ListAdapter).NotifyDataSetChanged());
            };

            if (!viewModel.IsSynced)
            {
                await Authenticate();

                await viewModel.ExecuteSyncExpensesCommand();

                RunOnUiThread(() => ((ExpenseAdapter)ListAdapter).NotifyDataSetChanged());
            }
        }
            public async override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
            {
                var expense = viewModel.Expenses[indexPath.Row];
                await viewModel.ExecuteDeleteExpenseCommand(expense);

                tableView.ReloadData();
            }
示例#3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            viewModel = ServiceContainer.Resolve <ExpensesViewModel>();
            viewModel.IsBusyChanged = (busy) =>
            {
                if (busy)
                {
                    AndHUD.Shared.Show(this, "Loading...");
                }
                else
                {
                    AndHUD.Shared.Dismiss(this);
                }
            };

            ListAdapter = new ExpenseAdapter(this, viewModel);

            ListView.ItemLongClick += async(sender, args) =>
            {
                await viewModel.ExecuteDeleteExpenseCommand(viewModel.Expenses[args.Position]);

                RunOnUiThread(() => ((ExpenseAdapter)ListAdapter).NotifyDataSetChanged());
            };
        }
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.view_expenses);
            var toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);

            //Toolbar will now take on default actionbar characteristics
            SetSupportActionBar(toolbar);
            refresher = FindViewById <SwipeRefreshLayout>(Resource.Id.refresher);
            refresher.SetProgressBackgroundColorSchemeResource(Resource.Color.pop);

            refresher.Refresh += async delegate
            {
                if (viewModel.IsBusy)
                {
                    return;
                }

                await viewModel.ExecuteLoadExpensesCommand();

                RunOnUiThread(listAdapter.NotifyDataSetChanged);
            };

            viewModel = ServiceContainer.Resolve <ExpensesViewModel>();
            viewModel.IsBusyChanged = (busy) =>
            {
                refresher.Refreshing = busy;
            };

            listView = FindViewById <ListView>(Resource.Id.list);

            listAdapter             = new ExpenseAdapter(this, viewModel);
            listView.Adapter        = listAdapter;
            listView.ItemLongClick += async(sender, args) =>
            {
                await viewModel.ExecuteDeleteExpenseCommand(viewModel.Expenses[args.Position]);

                RunOnUiThread(listAdapter.NotifyDataSetChanged);
            };

            listView.ItemClick += OnListViewItemClick;

            var typed_value = new TypedValue();

            Theme.ResolveAttribute(Resource.Attribute.actionBarSize, typed_value, true);
            refresher.SetProgressViewOffset(false, 0, Resources.GetDimensionPixelSize(typed_value.ResourceId));

            await Authenticate();

            await viewModel.ExecuteLoadExpensesCommand();

            RunOnUiThread(listAdapter.NotifyDataSetChanged);
        }