Пример #1
0
        public void showResidents(ImageButton residents)
        {
            //Console.WriteLine("inside the show residentttttttttttttttttttttttttttttttttttttttttt");
            if (checkNetwork())
            {
                residents.Enabled = false;
                string uprn = residents.Tag.ToString();
                if (DataController.fileType == "HALAROSE")
                {
                    //Console.WriteLine ("HALAROSE now");
                    string houseID = residents.Id.ToString();
                    DataController.houseID = houseID;
                }
                else
                {
                    DataController.houseID = "houseID";
                    //Console.WriteLine ("HouseID");
                }

                DataController.uprn = uprn;
                //Console.WriteLine ("Before to the response");
                string response = NetworkCalls.getResidents(DataController.token, DataController.canvassID, uprn);
                //Console.WriteLine ("After of response");

                //			string status = "";
                TableRow tr          = (TableRow)View.FindViewWithTag(uprn);
                TextView addressView = (TextView)tr.GetVirtualChildAt(0);
                string   address     = addressView.Text.ToString();
                string   canvassID   = addressView.Tag.ToString();
                DataController.canvassID = canvassID;
                DataController.address   = address;

                DataController.propertyToChange = tr.Id;

                //Console.WriteLine ("before the note");
                //string note = "";

                /*addresses = DataController.addresses;
                 * propertyDict = addresses [tr.Id];
                 * DataController.propertyToChange = tr.Id;
                 * if (propertyDict ["notes"] != null) {
                 *      note = propertyDict ["notes"].ToString ();
                 * } else {
                 *      note = "";
                 * }
                 * DataController.note = note;
                 * Console.WriteLine (note);*/

                Android.Support.V4.App.Fragment residentsPrevFragment = null;
                residentsPrevFragment = new ResidentsPrevFragment();

                FragmentTransaction ft = FragmentManager.BeginTransaction();

                ft.Add(Resource.Id.content_frame, residentsPrevFragment, "residentsPrevFragment");
                ft.Hide(FragmentManager.FindFragmentByTag("canvassesFragment"));
                ft.AddToBackStack(null);
                ft.Commit();
            }
            else
            {
                showNetworkError();
            }
        }
Пример #2
0
        public void drawTable(View view)
        {
            if (checkNetwork())
            {
                string canvass = NetworkCalls.getJobs(DataController.token);

                string response         = NetworkCalls.getProperties(DataController.token);
                string responseResident = NetworkCalls.getResidents(DataController.token, DataController.canvassID, DataController.uprn);
                //residents = MockingController.getResidentsPrev();
                residents = DataController.residents;
                addresses = DataController.addresses;


                TableLayout tl = (TableLayout)view.FindViewById(Resource.Id.residentstable);
                TableLayout tb = (TableLayout)view.FindViewById(Resource.Id.tableHeaders);
                ScrollView  ts = (ScrollView)view.FindViewById(Resource.Id.tableScroll);

                tl.StretchAllColumns = true;
                tl.BringToFront();
                TableRow headings = new TableRow(this.Activity);
                headings.SetBackgroundColor(Resources.GetColor(Resource.Color.headers));
                headings.Tag = "headers";

                TextView heading0 = new TextView(this.Activity);
                heading0.Text = " ITR";
                float density = this.Activity.Resources.DisplayMetrics.Density;
                heading0.SetWidth((int)(40 * density));
                heading0.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading0.TextSize = 15.0f;



                TextView heading1 = new TextView(this.Activity);
                heading1.Text = " Name";
                heading1.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading1.TextSize = 15.0f;
                heading1.SetWidth((int)(220 * density));
                TextView heading2 = new TextView(this.Activity);
                heading2.Text = "Nationality";
                heading2.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading2.TextSize = 15.0f;
                TextView heading3 = new TextView(this.Activity);
                heading3.Text = "Opt Out";
                heading3.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading3.TextSize = 15.0f;
                TextView heading4 = new TextView(this.Activity);
                heading4.Text = "Absent Vote";
                heading4.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading4.TextSize = 15.0f;
                TextView heading5 = new TextView(this.Activity);
                heading5.Text = "Jury Duty";
                heading5.SetTextColor(Resources.GetColor(Resource.Color.odd));
                heading5.TextSize = 15.0f;
                //			TextView heading6 = new TextView(this.Activity);
                //			heading6.Text = "Residents";

                headings.AddView(heading0);
                headings.AddView(heading1);
                headings.AddView(heading2);
                headings.AddView(heading3);
                headings.AddView(heading4);
                headings.AddView(heading5);
                //headings.AddView(heading6);
                tl.AddView(headings);


                for (int i = 0; i < residents.Count; i++)
                {
                    Dictionary <string, object> residentDict = new Dictionary <string, object> ();
                    //String OptOut, Absent, Jury;


                    residentDict = residents [i];

                    TableRow tr = new TableRow(this.Activity);

                    if (i % 2 == 0)
                    {
                        tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even));
                    }
                    else
                    {
                        tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd));
                    }

                    tr.Tag = residentDict ["id"].ToString();
                    tr.Id  = i;
                    TextView name = new TextView(this.Activity);

                    name.Text = " " + residentDict ["fullName"].ToString();


                    float density1 = this.Activity.Resources.DisplayMetrics.Density;
                    name.SetWidth((int)(200 * density1));
                    name.SetPadding(5, 5, 0, 5);


                    name.Tag      = "name" + i;
                    name.TextSize = 18.0f;
                    name.SetTextColor(Resources.GetColor(Resource.Color.tableText));
                    name.Click += (object sender, EventArgs e) => {
                        nameCorrect(name);
                    };


                    ImageView itr = new ImageView(this.Activity);


                    if (residentDict ["itr_added"] != null)
                    {
                        itr.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.itr6));
                        itr.Background = null;
                    }
                    else
                    {
                        itr.SetImageDrawable(null);
                        itr.Background = null;
                    }

                    itr.SetPadding((int)(-50 * density1), 5, 0, 5);



                    TextView nationality = new TextView(this.Activity);
                    nationality.Text = residentDict ["nationality"].ToString();
                    //residentUpdate[i].Add ("nationality", residentDict ["nationality"].ToString ());
                    nationality.Tag      = i;
                    nationality.TextSize = 18.0f;
                    nationality.SetTextColor(Resources.GetColor(Resource.Color.tableText));
                    nationality.Click += (object sender, EventArgs e) => {
                        nationalityCorrect(nationality);
                    };
                    CheckBox optOut = new CheckBox(this.Activity);
                    optOut.Tag = i;
                    if (residentDict ["optOut"].ToString() == "YES")
                    {
                        optOut.Checked = true;
                        //OptOut = "YES";
                    }
                    else
                    {
                        optOut.Checked = false;
                        //OptOut = "NO";
                    }
                    optOut.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                        checkOptOut(optOut);
                    };
                    //residentUpdate[i].Add ("optOut");
                    CheckBox absentVote = new CheckBox(this.Activity);

                    //absentVote.Enabled = false;
                    absentVote.Tag = i;
                    if (residentDict ["absent"].ToString() == "YES")
                    {
                        absentVote.Checked = true;
                        //Absent = "YES";
                    }
                    else
                    {
                        absentVote.Checked = false;
                        //Absent = "NO";
                    }
                    absentVote.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                        checkAbsentVote(absentVote);
                    };
                    //residentUpdate[i].Add ("absent");
                    CheckBox juryDuty = new CheckBox(this.Activity);
                    juryDuty.Tag = i;
                    if (residentDict ["jury"].ToString() == "YES")
                    {
                        juryDuty.Checked = true;
                        //Jury = "YES";
                    }
                    else
                    {
                        juryDuty.Checked = false;
                        //Jury = "NO";
                    }
                    juryDuty.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => {
                        checkJuryDuty(juryDuty);
                    };
                    //residentUpdate[i].Add ("jury");

                    TableRow.LayoutParams stretchRow = new TableRow.LayoutParams();
                    stretchRow.Width = (int)(10 * density1);


                    tr.AddView(itr, stretchRow);
                    tr.AddView(name);
                    tr.AddView(nationality);
                    tr.AddView(optOut);
                    tr.AddView(absentVote);
                    tr.AddView(juryDuty);
                    tl.AddView(tr);
                }
                View headers = tl.FindViewWithTag("headers");
                tl.RemoveView(tl.FindViewWithTag("headers"));
                tb.RemoveAllViews();
                //					//tb.RemoveView (tl);
                tb.AddView(headers);
                tb.StretchAllColumns = true;
                ts.RemoveAllViews();
                ts.AddView(tl);
                tb.AddView(ts);

                addITR(tl);
            }
        }