/// <summary>
        /// Sets the current active assignment
        /// </summary>
        /// <param name="visible"></param>
        private void SetAssignment(bool visible)
        {
            if (visible)
            {
                assignmentMapViewLayout.Visibility = ViewStates.Visible;
                assignment = assignmentViewModel.ActiveAssignment;

                buttonLayout.Visibility = ViewStates.Gone;
                timerLayout.Visibility  = ViewStates.Visible;

                var adapter = new SpinnerAdapter <AssignmentStatus> (assignmentViewModel.AvailableStatuses, this, Resource.Layout.SimpleSpinnerItem);
                adapter.TextColor     = Resources.GetColor(Resource.Color.greyspinnertext);
                adapter.Background    = Resources.GetColor(Resource.Color.assignmentblue);
                activeSpinner.Adapter = adapter;
                activeSpinner.SetSelection(assignmentViewModel.AvailableStatuses.ToList().IndexOf(assignment.Status));
                activeSpinner.SetBackgroundResource(Resource.Drawable.triangleblue);
                spinnerImage.SetImageResource(Resource.Drawable.EnrouteImage);

                number.Text    = assignment.Priority.ToString();
                job.Text       = string.Format("#{0} {1}\n{2}", assignment.JobNumber, assignment.StartDate.ToShortDateString(), assignment.CompanyName);
                name.Text      = assignment.ContactName;
                phone.Text     = assignment.ContactPhone;
                address.Text   = string.Format("{0}\n{1}, {2} {3}", assignment.Address, assignment.City, assignment.State, assignment.Zip);
                timerText.Text = assignmentViewModel.Hours.ToString(@"hh\:mm\:ss");
            }
            else
            {
                assignmentMapViewLayout.Visibility = ViewStates.Gone;
            }
        }
Beispiel #2
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            Assignment assignment = null;
            var        view       = convertView;

            if (view == null)
            {
                LayoutInflater inflator = (LayoutInflater)Context.GetSystemService(Context.LayoutInflaterService);
                view = inflator.Inflate(resourceId, null);
            }

            if (assignments.Count > position)
            {
                assignment = assignments [position];
            }

            if (assignment == null)
            {
                return(view);
            }

            var number            = view.FindViewById <TextView> (Resource.Id.assignmentItemNumber);
            var job               = view.FindViewById <TextView> (Resource.Id.assignmentJob);
            var name              = view.FindViewById <TextView> (Resource.Id.assignmentName);
            var phone             = view.FindViewById <TextView> (Resource.Id.assignmentPhone);
            var address           = view.FindViewById <TextView> (Resource.Id.assignmentAddress);
            var buttonLayout      = view.FindViewById <LinearLayout> (Resource.Id.assignmentButtonLayout);
            var timerLayout       = view.FindViewById <LinearLayout> (Resource.Id.assignmentTimerLayout);
            var timerlinearLayout = view.FindViewById <LinearLayout> (Resource.Id.timerLinearLayout);
            var spinner           = view.FindViewById <Spinner> (Resource.Id.assignmentStatus);
            var spinnerImage      = view.FindViewById <ImageView> (Resource.Id.assignmentStatusImage);
            var accept            = view.FindViewById <Button> (Resource.Id.assignmentAccept);
            var decline           = view.FindViewById <Button> (Resource.Id.assignmentDecline);
            var phoneButton       = view.FindViewById <RelativeLayout> (Resource.Id.assignmentPhoneLayout);
            var mapButton         = view.FindViewById <RelativeLayout> (Resource.Id.assignmentAddressLayout);

            mapButton.SetOnClickListener(this);
            phoneButton.SetOnClickListener(this);
            accept.SetOnClickListener(this);
            decline.SetOnClickListener(this);

            accept.Tag    = position;
            decline.Tag   = position;
            mapButton.Tag = position;

            if (assignment.Status == AssignmentStatus.New)
            {
                buttonLayout.Visibility = ViewStates.Visible;
                timerLayout.Visibility  = ViewStates.Gone;
            }
            else
            {
                buttonLayout.Visibility      = ViewStates.Gone;
                timerLayout.Visibility       = ViewStates.Visible;
                timerlinearLayout.Visibility = Context.Resources.Configuration.Orientation == Orientation.Landscape ? ViewStates.Invisible : ViewStates.Gone;

                spinner.Focusable = false;
                spinner.Tag       = position;
                var adapter = new SpinnerAdapter <AssignmentStatus> (assignmentViewModel.AvailableStatuses, Context, Resource.Layout.SimpleSpinnerItem);
                adapter.TextColor  = Context.Resources.GetColor(Resource.Color.greyspinnertext);
                adapter.Background = Color.White;
                spinner.Adapter    = adapter;

                spinner.SetSelection(assignmentViewModel.AvailableStatuses.ToList().IndexOf(assignment.Status));
                spinner.SetBackgroundResource(Resource.Drawable.trianglewhite);
                spinnerImage.SetImageResource(Resource.Drawable.HoldImage);

                spinner.OnItemSelectedListener = this;
            }

            number.Text  = assignment.Priority.ToString();
            job.Text     = string.Format("#{0} {1}\n{2}", assignment.JobNumber, assignment.StartDate.ToShortDateString(), assignment.CompanyName);
            name.Text    = assignment.ContactName;
            phone.Text   = assignment.ContactPhone;
            address.Text = string.Format("{0}\n{1}, {2} {3}", assignment.Address, assignment.City, assignment.State, assignment.Zip);

            return(view);
        }