예제 #1
0
        public void OnItemSelected(AdapterView parent, View view, int position, long id)
        {
            var selected         = assignmentViewModel.AvailableStatuses.ElementAtOrDefault(position);
            var spinnerImage     = ((View)parent.Parent).FindViewById <ImageView> (Resource.Id.assignmentStatusImage);
            var index            = (int)parent.Tag;
            var activeAssignment = GetItem(index);

            if (activeAssignment.Status != selected)
            {
                switch (selected)
                {
                case AssignmentStatus.Active: {
                    spinnerImage.SetImageResource(Resource.Drawable.EnrouteImage);
                    spinnerImage.InvalidateDrawable(spinnerImage.Drawable);
                    activeAssignment.Status = AssignmentStatus.Active;
                    SaveAssignment(activeAssignment, index);
                }
                break;

                case AssignmentStatus.Complete: {
                    //go to confirmations
                    activeAssignment.Status = selected;
                    var activity = (AssignmentTabActivity)this.activity.Parent;
                    var intent   = new Intent(activity, typeof(SummaryActivity));
                    menuViewModel.MenuIndex = Constants.Navigation.IndexOf(Constants.Confirmations);
                    assignmentViewModel.SelectedAssignment = activeAssignment;
                    activity.StartActivity(intent);
                }
                break;

                default: {
                    spinnerImage.SetImageResource(Resource.Drawable.HoldImage);
                    spinnerImage.InvalidateDrawable(spinnerImage.Drawable);
                    parent.SetBackgroundResource(Resource.Drawable.trianglewhite);
                    activeAssignment.Status = selected;
                    SaveAssignment(activeAssignment, index);
                }
                break;
                }
            }
        }