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());
            }
        }
示例#2
0
    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());
      }
      
    }
示例#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);
        }
示例#5
0
        public bool ImportData(string email, ref ResultDTO resultDTO)
        {
            var expense = GetExpense(email);

            if (expense == null)
            {
                Notify("Expense not found");

                return(false);
            }

            if (!ExecuteValidation(new ExpenseValidation(), expense))
            {
                return(false);
            }

            resultDTO.MessageResult = "Data successfully imported";
            resultDTO.Expense       = ExpenseAdapter.ToExpenseDTO(expense);

            return(true);
        }
示例#6
0
        private Expense GetExpense(string email)
        {
            var expenseDTO = XMLHelper.GetExpenseFromXML(email);

            return(ExpenseAdapter.ToExpense(expenseDTO));
        }