public void changePassword() { if (checkNetwork()) { string oldPassword = oldPass.Text; string newPassword = newPass.Text; bool success = NetworkCalls.changePassword(oldPassword, newPassword, DataController.token); if (success) { Toast changed = new Toast(this.Activity); changed = Toast.MakeText(Application.Context, "Password Changed, Password was changed successfully.", ToastLength.Short); changed.Show(); } else { Toast failed = new Toast(this.Activity); failed = Toast.MakeText(Application.Context, "Password not Changed, Password was not changed, try again.", ToastLength.Short); failed.Show(); } oldPass.Text = ""; newPass.Text = ""; } else { showNetworkError(); } }
public void checkEmpty(CheckBox empty) { string status = ""; string uprn = ""; if (empty.Checked) { if (checkNetwork()) { status = "E"; uprn = empty.Tag.ToString(); TableRow tr = (TableRow)View.FindViewWithTag(uprn); CheckBox noAnswer = (CheckBox)tr.GetVirtualChildAt(1); CheckBox derelict = (CheckBox)tr.GetVirtualChildAt(3); CheckBox postalRequest = (CheckBox)tr.GetVirtualChildAt(4); CheckBox delivered = (CheckBox)tr.GetVirtualChildAt(5); noAnswer.Checked = false; derelict.Checked = false; postalRequest.Checked = false; delivered.Checked = false; noAnswer.Text = ""; tr.SetBackgroundColor(Resources.GetColor(Resource.Color.highlight)); //Console.WriteLine("Empty is working"); //Console.WriteLine (tr.ChildCount); NetworkCalls.SendStatus(DataController.token, status, uprn, DataController.canvassID); lockRow(tr); } else { empty.Checked = false; showNetworkError(); } } else if (!empty.Checked) { if (checkNetwork()) { status = "NV"; uprn = empty.Tag.ToString(); TableRow tr = (TableRow)View.FindViewWithTag(uprn); if (tr.Id % 2 == 0) { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even)); } else { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd)); } NetworkCalls.SendStatus(DataController.token, status, uprn, DataController.canvassID); //Console.WriteLine ("Empty: " + empty.Tag); } else { empty.Checked = true; showNetworkError(); } } }
public void checkDeliveredRequest(CheckBox deliveredRequest) { string status = ""; string uprn = ""; if (deliveredRequest.Checked) { if (checkNetwork()) { status = "HEF-D"; uprn = deliveredRequest.Tag.ToString(); TableRow tr = (TableRow)View.FindViewWithTag(uprn); CheckBox noAnswer = (CheckBox)tr.GetVirtualChildAt(1); CheckBox empty = (CheckBox)tr.GetVirtualChildAt(2); CheckBox derelict = (CheckBox)tr.GetVirtualChildAt(3); CheckBox postalRequest = (CheckBox)tr.GetVirtualChildAt(4); ImageButton residents = (ImageButton)tr.GetVirtualChildAt(7); noAnswer.Checked = false; derelict.Checked = false; empty.Checked = false; postalRequest.Checked = false; noAnswer.Text = ""; tr.SetBackgroundColor(Resources.GetColor(Resource.Color.highlight)); NetworkCalls.SendStatus(DataController.token, status, uprn, DataController.canvassID); lockRow(tr); } else { deliveredRequest.Checked = false; showNetworkError(); } } else if (!deliveredRequest.Checked) { if (checkNetwork()) { status = "NV"; uprn = deliveredRequest.Tag.ToString(); TableRow tr = (TableRow)View.FindViewWithTag(uprn); if (tr.Id % 2 == 0) { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even)); } else { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd)); } NetworkCalls.SendStatus(DataController.token, status, uprn, DataController.canvassID); //Console.WriteLine ("Postal Request: " + deliveredRequest.Tag); } else { deliveredRequest.Checked = true; showNetworkError(); } } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); cm = (ConnectivityManager)this.GetSystemService(Context.ConnectivityService); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Login); // Get our button from the layout resource, // and attach an event to it Button LoginBtn = FindViewById <Button> (Resource.Id.loginButton); EditText emailInput = FindViewById <EditText> (Resource.Id.emailInput); EditText passwordInput = FindViewById <EditText> (Resource.Id.passwordInput); LoginBtn.Click += delegate { if (checkNetwork()) { if (emailInput.Text != "" && passwordInput.Text != "") { string email = RemoveSpecialCharacters(emailInput.Text); // string password = RemoveSpecialCharactersPassword (passwordInput.Text); string password = passwordInput.Text; NetworkCalls.getURL(); //Console.WriteLine("URL print"+DataController.url); bool success = NetworkCalls.Login(email, password, ""); //Console.WriteLine("Username " + email); //Console.WriteLine("Password " + password); if (success) { //load next window //Console.WriteLine("Login Successful"); DataController.userEmail = email; StartActivity(typeof(HomeView)); } else { Toast loginFailed = new Toast(this); loginFailed = Toast.MakeText(Application.Context, "Login Failed, Please check details and try again.", ToastLength.Short); loginFailed.Show(); } } else { Toast invalidDetails = new Toast(this); invalidDetails = Toast.MakeText(Application.Context, "Login Failed, Username/Password cannot be empty.", ToastLength.Short); invalidDetails.Show(); } } else { showNetworkError(); } }; }
public void OnLocationChanged(Android.Locations.Location location) { //Console.WriteLine ("Latitude " + location.Latitude); //Console.WriteLine ("Longitude " + location.Longitude); DataController.lat = location.Latitude.ToString(); DataController.lng = location.Longitude.ToString(); DataController.accuracy = location.Accuracy.ToString(); DataController.locationType = location.Provider.ToString(); //Console.WriteLine ("Timestamp " + DateTimeToUnixTimestamp(DateTime.Now)); NetworkCalls.SendLocation(DataController.userID, DataController.lng, DataController.lat, DataController.accuracy, DataController.locationType, DateTimeToUnixTimestamp(DateTime.Now).ToString(), DataController.token); }
public override void OnHiddenChanged(bool hidden) { base.OnHiddenChanged(hidden); if (!hidden) { TableRow row = (TableRow)View.FindViewWithTag(DataController.uprn); ImageButton residents = (ImageButton)row.GetVirtualChildAt(7); residents.Enabled = true; if (DataController.uprn != null && DataController.propertyChange) { TableRow tr = (TableRow)View.FindViewWithTag(DataController.uprn); tr.SetBackgroundColor(Resources.GetColor(Resource.Color.highlight)); lockRow(tr); DataController.uprn = ""; DataController.propertyChange = false; } else if (DataController.propertyReset) { TableRow tr = (TableRow)View.FindViewWithTag(DataController.uprn); CheckBox noAnswer = (CheckBox)tr.GetVirtualChildAt(1); CheckBox empty = (CheckBox)tr.GetVirtualChildAt(2); CheckBox derelict = (CheckBox)tr.GetVirtualChildAt(3); CheckBox postalRequest = (CheckBox)tr.GetVirtualChildAt(4); CheckBox delivered = (CheckBox)tr.GetVirtualChildAt(5); ImageView itr = (ImageView)tr.GetVirtualChildAt(6); noAnswer.Text = ""; noAnswer.Checked = false; noAnswer.Enabled = true; empty.Enabled = true; derelict.Enabled = true; postalRequest.Enabled = true; delivered.Enabled = true; NetworkCalls.SendStatus(DataController.token, "NV", DataController.uprn, DataController.canvassID); if (tr.Id % 2 == 0) { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even)); } else { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd)); } DataController.propertyReset = false; } } }
private void Next_Clicked(object sender, EventArgs e) { Console.WriteLine(!selectedGenre.Any()); Console.WriteLine(selectedGenre.Count()); if (selectedGenre.Count() == 0) { DisplayAlert("Alert!", "No Genre Selected", "Dismiss"); return; } String selectedGenreString = "\""; selectedGenreString += String.Join("\",\"", selectedGenre); selectedGenreString += "\""; Preferences.Set("selectedGenre", selectedGenreString); Navigation.PushAsync(new GenrePage()); NetworkCalls networkcall = new NetworkCalls(); networkcall.saveUserPreferences(assignment1.Properties["token"].ToString(), assignment1.Properties["username"].ToString(), selectedGenreString); DisplayAlert("", "Your preferences have been synchronized", "Proceed"); }
public void updateResidents() { for (int i = 0; i < residents.Count; i++) { Dictionary <string, object> residentDict = new Dictionary <string, object> (); //Dictionary<string, object> residentDictUpdate = new Dictionary<string, object> (); residentDict = residents[i]; //residentDictUpdate = residentUpdate [i]; string nationality = residentDict ["nationality"].ToString(); //residentDictUpdate[i].Add ("nationality", nationality); string optOut = residentDict ["optOut"].ToString(); //residentDictUpdate[i].Add ("optOut", optOut); string jury = residentDict ["jury"].ToString(); //residentDictUpdate[i].Add ("jury", jury); string absent = residentDict ["absent"].ToString(); //residentDictUpdate[i].Add ("absent", absent); string residentID = residentDict ["id"].ToString(); //residentDictUpdate[i].Add ("id", residentID); //residentUpdate.Add (residentDictUpdate[i]); String response = NetworkCalls.updateResidents(nationality, optOut, jury, absent, residentID, DataController.token, DataController.uprn); if (response != null) { Toast newProperties = new Toast(this.Activity); newProperties = Toast.MakeText(Activity.ApplicationContext, "Property confirmed", ToastLength.Long); newProperties.Show(); } } NetworkCalls.updatePropertyNote(DataController.uprn, RemoveSpecialCharacters(note.Text), DataController.token); propertyDict = addresses [DataController.propertyToChange]; propertyDict ["notes"] = RemoveSpecialCharacters(note.Text); addresses [DataController.propertyToChange] = propertyDict; removeFragment(); }
public void checkNoAnswer(CheckBox noAnswer) { string uprn = ""; if (noAnswer.Checked) { if (checkNetwork()) { int i = 0; uprn = noAnswer.Tag.ToString(); TableRow tr = (TableRow)View.FindViewWithTag(uprn); CheckBox empty = (CheckBox)tr.GetVirtualChildAt(2); CheckBox derelict = (CheckBox)tr.GetVirtualChildAt(3); CheckBox postalRequest = (CheckBox)tr.GetVirtualChildAt(4); CheckBox delivered = (CheckBox)tr.GetVirtualChildAt(5); ImageView itr = (ImageView)tr.GetVirtualChildAt(6); ImageButton residents = (ImageButton)tr.GetVirtualChildAt(7); empty.Checked = false; derelict.Checked = false; postalRequest.Checked = false; delivered.Checked = false; itr.Enabled = false; if (noAnswer.Text == "") { noAnswer.Text = "1"; //Console.WriteLine ("uprn"+uprn); //this is for testing lockRow(tr); } else if (Convert.ToInt32(noAnswer.Text) <= 2) { i = Convert.ToInt32(noAnswer.Text); i++; noAnswer.Text = i.ToString(); if (i == 2) { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.secondVisit)); lockRow(tr); } else if (i == 3) { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.thirdVisit)); noAnswer.Enabled = false; empty.Enabled = false; derelict.Enabled = false; postalRequest.Enabled = false; delivered.Enabled = false; //residents.Enabled = false; } } tr.SetBackgroundColor(Resources.GetColor(Resource.Color.highlight)); NetworkCalls.SendStatus(DataController.token, "VNA", uprn, DataController.canvassID); } else { noAnswer.Checked = false; showNetworkError(); } } else if (!noAnswer.Checked) { if (checkNetwork()) { int i = 0; uprn = noAnswer.Tag.ToString(); if (noAnswer.Text != "") { if (Convert.ToInt32(noAnswer.Text) > 0) { i = Convert.ToInt32(noAnswer.Text); i--; noAnswer.Text = i.ToString(); if (i == 0) { noAnswer.Text = ""; } else if (i == 1) { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.tableText)); } else if (i == 2) { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.secondVisit)); noAnswer.Enabled = true; } } } TableRow tr = (TableRow)View.FindViewWithTag(uprn); if (tr.Id % 2 == 0) { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even)); } else { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd)); } //Console.WriteLine("no answer is working"); NetworkCalls.SendStatus(DataController.token, "NV", uprn, DataController.canvassID); //Console.WriteLine ("No Answer: " + noAnswer.Tag); } else { noAnswer.Checked = true; showNetworkError(); } } }
public void drawTable(View view) { //Console.WriteLine ("inside drawable"); TableLayout tl = (TableLayout)view.FindViewById(Resource.Id.table); //TableRow headers = (TableRow)view.FindViewById (Resource.Id.tableHeaders); TableLayout tb = (TableLayout)view.FindViewById(Resource.Id.tableHeaders); ScrollView ts = (ScrollView)view.FindViewById(Resource.Id.tableScroll); string canvass = NetworkCalls.getJobs(DataController.token); if (DataController.canvassID != null) { string response = NetworkCalls.getProperties(DataController.token); //Console.WriteLine ("response got"); addresses = DataController.addresses; //addresses = MockingController.getProperties(); } else { Toast newProperties = new Toast(this.Activity); newProperties = Toast.MakeText(Activity.ApplicationContext, "There isn't an assined canvass!", ToastLength.Short); //Console.WriteLine("assigning canvass"); newProperties.Show(); return; } addresses = DataController.addresses; //Console.WriteLine("sharedPreference1"); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this.Activity); ISharedPreferencesEditor editor = prefs.Edit(); if (prefs.Contains("properties")) { int currProperties = prefs.GetInt("properties", 0); if (currProperties < addresses.Count) { //Console.WriteLine("prefs2"); int difference = addresses.Count - currProperties; editor.PutInt("properties", addresses.Count); Toast newProperties = new Toast(this.Activity); //Console.WriteLine("prefs3"); newProperties = Toast.MakeText(Activity.ApplicationContext, "New Properties, You have " + difference + " new properties!", ToastLength.Short); newProperties.Show(); } else { editor.PutInt("properties", addresses.Count); //Console.WriteLine("prefsElse"); } } else { //Console.WriteLine("prefs4"); if (addresses != null) { editor.PutInt("properties", addresses.Count); Toast newProperties = new Toast(this.Activity); newProperties = Toast.MakeText(Activity.ApplicationContext, "New Properties, You have " + addresses.Count + " new properties!", ToastLength.Short); //Console.WriteLine("prefs5"); newProperties.Show(); } } editor.Apply(); if (addresses != null && addresses.Count > 0) { //tl = (TableLayout)view.FindViewById (Resource.Id.table); tl.StretchAllColumns = true; tl.BringToFront(); TableRow headings = new TableRow(this.Activity); headings.SetBackgroundColor(Resources.GetColor(Resource.Color.headers)); headings.Tag = "headers"; TextView heading1 = new TextView(this.Activity); heading1.Text = " Address"; heading1.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading1.TextSize = 15.0f; float density = this.Activity.Resources.DisplayMetrics.Density; heading1.SetWidth((int)(350 * density)); TextView heading2 = new TextView(this.Activity); heading2.Text = "No Ans"; heading2.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading2.TextSize = 15.0f; TextView heading3 = new TextView(this.Activity); heading3.Text = "Empty"; heading3.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading3.TextSize = 15.0f; TextView heading4 = new TextView(this.Activity); heading4.Text = "Derelict"; heading4.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading4.TextSize = 15.0f; TextView heading5 = new TextView(this.Activity); heading5.Text = "HEF R"; heading5.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading5.TextSize = 15.0f; TextView heading7 = new TextView(this.Activity); heading7.Text = "HEF D"; heading7.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading7.TextSize = 15.0f; TextView heading8 = new TextView(this.Activity); heading8.Text = "ITR"; heading8.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading8.TextSize = 15.0f; TextView heading6 = new TextView(this.Activity); heading6.Text = "Residents"; heading6.SetTextColor(Resources.GetColor(Resource.Color.odd)); heading6.TextSize = 15.0f; headings.AddView(heading1); headings.AddView(heading2); headings.AddView(heading3); headings.AddView(heading4); headings.AddView(heading5); headings.AddView(heading7); headings.AddView(heading8); headings.AddView(heading6); tl.AddView(headings); for (int i = 0; i < addresses.Count; i++) { //Dictionary<string, object> propertyDict = new Dictionary<string, object> (); propertyDict = addresses [i]; //Console.WriteLine("for"); TableRow tr = new TableRow(this.Activity); tr.Tag = propertyDict ["uprn"].ToString(); tr.Id = i; // if (propertyDict ["status"].ToString () != "NV" && propertyDict ["status"].ToString () != "VNA") { // tr.SetBackgroundColor (Resources.GetColor (Resource.Color.highlight)); // rowToLock = tr; // } else if (propertyDict ["visitCount"].ToString() == "3") { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.highlight)); } else if (i % 2 == 0) { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.even)); } else { tr.SetBackgroundColor(Resources.GetColor(Resource.Color.odd)); } TextView address = new TextView(this.Activity); //Console.WriteLine("assign1"); address.Text = propertyDict ["fullAddress"].ToString(); address.Tag = propertyDict ["canvassID"].ToString(); //Console.WriteLine("assign 2"); address.TextSize = 18.0f; address.SetTextColor(Resources.GetColor(Resource.Color.tableText)); float density1 = this.Activity.Resources.DisplayMetrics.Density; address.SetWidth((int)(350 * density1)); address.SetPadding(5, 5, 0, 5); address.LongClick += (object sender, View.LongClickEventArgs e) => { unlockRow(tr.Tag.ToString()); }; CheckBox noAnswer = new CheckBox(this.Activity); noAnswer.Tag = propertyDict ["uprn"].ToString(); noAnswer.Id = 0; string visitCount = propertyDict ["visitCount"].ToString(); noAnswer.Text = propertyDict ["visitCount"].ToString(); if (Convert.ToInt32(noAnswer.Text) == 0) { noAnswer.Text = ""; } else if (Convert.ToInt32(noAnswer.Text) == 2) { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.secondVisit)); } else if (Convert.ToInt32(noAnswer.Text) == 3) { noAnswer.Checked = true; noAnswer.Enabled = false; noAnswer.SetTextColor(Resources.GetColor(Resource.Color.thirdVisit)); } else { noAnswer.SetTextColor(Resources.GetColor(Resource.Color.tableText)); } noAnswer.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => { checkNoAnswer(noAnswer); }; CheckBox empty = new CheckBox(this.Activity); empty.Tag = propertyDict ["uprn"].ToString(); empty.Id = 1; if (propertyDict ["status"].ToString() == "E") { empty.Checked = true; } if (noAnswer.Text == "3") { empty.Enabled = false; } empty.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => { checkEmpty(empty); }; CheckBox derelict = new CheckBox(this.Activity); derelict.Tag = propertyDict ["uprn"].ToString(); derelict.Id = 2; if (propertyDict ["status"].ToString() == "D") { derelict.Checked = true; } if (noAnswer.Text == "3") { derelict.Enabled = false; } derelict.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => { checkDerelict(derelict); }; CheckBox postalRequest = new CheckBox(this.Activity); postalRequest.Tag = propertyDict ["uprn"].ToString(); postalRequest.Id = 3; if (propertyDict ["status"].ToString() == "HEF-R") { postalRequest.Checked = true; } if (noAnswer.Text == "3") { postalRequest.Enabled = false; } postalRequest.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => { checkRequestPostal(postalRequest); }; CheckBox DeliveredRequest = new CheckBox(this.Activity); DeliveredRequest.Tag = propertyDict ["uprn"].ToString(); DeliveredRequest.Id = 4; if (propertyDict ["status"].ToString() == "HEF-D") { DeliveredRequest.Checked = true; } if (noAnswer.Text == "3") { DeliveredRequest.Enabled = false; } DeliveredRequest.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) => { checkDeliveredRequest(DeliveredRequest); }; ImageView itr = new ImageView(this.Activity); itr.Tag = propertyDict ["canvassID"].ToString(); itr.SetPadding(5, 5, 0, 5); if (propertyDict ["itr_added"] != null) { itr.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.itr6)); itr.Background = null; } else { itr.SetImageDrawable(null); itr.Background = null; } ImageButton residents = new ImageButton(this.Activity); residents.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.residents)); residents.Background = null; residents.Tag = propertyDict ["uprn"].ToString(); if (DataController.fileType == "HALAROSE") { residents.Id = Convert.ToInt32(propertyDict ["houseID"].ToString()); } //residents.Id = i; if (noAnswer.Text == "3") { //residents.Enabled = false; } residents.Click += (object sender, EventArgs e) => { showResidents(residents); }; tr.AddView(address); tr.AddView(noAnswer); tr.AddView(empty); tr.AddView(derelict); tr.AddView(postalRequest); tr.AddView(DeliveredRequest); tr.AddView(itr); tr.AddView(residents); tl.AddView(tr); if (rowToLock != null) { lockRow(rowToLock); rowToLock = null; } } 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); //tb.AddView(tl); //tb.AddView (tl); } else { Toast changed = new Toast(this.Activity); changed = Toast.MakeText(Activity.ApplicationContext, "No Properties, You have not been assigned any properties.", ToastLength.Long); changed.Show(); } }
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(); } }
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); } }