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);
        }
Ejemplo n.º 2
0
 private void InitSwipeRefreshLayout()
 {
     SwipeRefreshLayout.SetProgressViewOffset(false, Toolbar.Height, Resources.DisplayMetrics.DipsToPix(64) + Toolbar.Height);
     SwipeRefreshLayout.SetColorSchemeColors(Resource.Color.colorAccent);
     //SwipeRefreshLayout.Refresh += (sender, args) => ViewModel.RefreshCommand.Execute(null);
 }