Skip to content

Instantly share code, notes, and snippets.

@benhysell
Created June 9, 2014 14:15
Show Gist options
  • Save benhysell/816089bfbeb02941fcfc to your computer and use it in GitHub Desktop.
Save benhysell/816089bfbeb02941fcfc to your computer and use it in GitHub Desktop.
OnCreateView Timer
public override Android.Views.View OnCreateView(Android.Views.LayoutInflater inflater, Android.Views.ViewGroup container, Android.OS.Bundle savedInstanceState)
{
this.HasOptionsMenu = true;
var ignored = base.OnCreateView(inflater, container, savedInstanceState);
var view = this.BindingInflate(Resource.Layout.TimerView, null);
var leftButton = view.FindViewById<Button>(Resource.Id.LeftButton);
leftButton.Text = "\U000025C0\U0000FE0E";
var rightButton = view.FindViewById<Button>(Resource.Id.RightButton);
rightButton.Text = "\U000025B6\U0000FE0E";
var datePickerText = view.FindViewById<EditText>(Resource.Id.DatePickerEditText);
datePickerText.Focusable = false;
datePickerText.Click += delegate
{
var dialog = new DatePickerDialogFragment(Activity, Convert.ToDateTime(datePickerText.Text), this);
dialog.Show(FragmentManager, "date");
};
var totalHours = view.FindViewById<TextView>(Resource.Id.TotalHours);
var refresher = view.FindViewById<MvxSwipeRefreshLayout>(Resource.Id.refresher);
refresher.SetColorScheme(Resource.Color.DarkBlue,
Resource.Color.Purple,
Resource.Color.Blue,
Resource.Color.Green);
refresher.RefreshCommand = ViewModel.ReloadCommand;
var set = this.CreateBindingSet<TimerView, TimerViewModel>();
set.Bind(datePickerText).To("Format('{0:dddd dd MMM yyyy}', Date)");
set.Bind(leftButton).To("BackCalendarDateCommand");
set.Bind(rightButton).To("ForwardCalendarDateCommand");
set.Bind(totalHours).To(vm => vm.ElapsedTime).WithConversion("TimeSpanMinutesHours");
set.Apply();
var tableListView = view.FindViewById<MvxListView>(Resource.Id.timerListView);
tableListView.ItemLongClick = ViewModel.StartTimerForEntryCommand;
return view;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment