private async void NetworkList_ItemClick(object sender, AdapterView.ItemClickEventArgs e) { var listView = sender as ListView; var position = e.Position; string selected = WifiNetworks.ElementAt <string>(position); //Send new location information to database DB_Singleton db = DB_Singleton.Instance; var group = db.GetActiveGroup(); //adds location to the db using the db_singleton active groupID FragmentTransaction transaction = FragmentManager.BeginTransaction(); List <string> locations = await GetLocations(); if (locations.Contains(selected)) { SsidTaken(); } else { LocationAddName AddLocationNameDialog = new LocationAddName(db.Retrieve("Token"), selected, group.GroupID); AddLocationNameDialog.Show(transaction, "dialog fragment AddLocationName"); } }
private async Task DeleteItem(int position) { RequestHandler request = new RequestHandler(this); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); var response = await request.DeleteMessageReply(token, db.GetActiveGroup().GroupID, comment_objs[position].Topicid); }
private async void M_Bconfirm_Click(object sender, EventArgs e) { string user = ""; string userid = ""; string category = (string)m_select_user.SelectedItem; string title = m_title.Text; string amount = m_amount.Text; for (int i = 0; i < m_listview.Count; ++i) { if (m_listview.IsItemChecked(i)) { //only used for testing user = (string)m_listview.GetItemAtPosition(i); } //users.Add((string)m_listview.GetItemAtPosition(i)); } //get userid if (users.Contains(user)) { userid = userIDs.ElementAt(users.IndexOf(user)); } //Dismiss(); //if the bill is not split equally, start the dialog that asks for splits if (!m_checkbox.Checked) { FragmentTransaction transaction = FragmentManager.BeginTransaction(); BillsNewSpecifyAmounts Dialog = new BillsNewSpecifyAmounts(); Dialog.Show(transaction, "dialog fragment specify bill amounts"); } DB_Singleton db = DB_Singleton.Instance; if (category == "Rent") { category = "2"; } else if (category == "Utilities") { category = "3"; } else if (category == "Groceries") { category = "4"; } else { category = "1"; } RequestHandler request = new RequestHandler(Context); await request.PutBill(db.Retrieve("Token"), db.GetActiveGroup().GroupID, userid, category, title, "description", amount, DateTime.Now.ToString()); await((Bills)Activity).UpdateAllBills(); Dismiss(); }
private async void NewBillReq(BillObj bill) { DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; RequestHandler request = new RequestHandler(Context); var response = await request.PutBill(token, groupid, bill.Recipientname, bill.Categoryid, bill.Title, bill.Description, bill.Amount, bill.Date); }
private async Task GetLocations() { DB_Singleton db = DB_Singleton.Instance; RequestHandler request = new RequestHandler(this); //get locations from database var response = await request.GetLocations(db.Retrieve("Token"), db.GetActiveGroup().GroupID); //convert locations from json format db_locations = ConvertJson(response); //add locations into list adapter //LocationList.Adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, db_locations); await UpdateLocation(); }
public async Task UpdateAllBills() { DB_Singleton db = DB_Singleton.Instance; RequestHandler request = new RequestHandler(this); var response = await request.GetBills(db.Retrieve("Token"), db.GetActiveGroup().GroupID); Console.WriteLine("!!!!!!!!!!!!!!!!!!!BILLS!!!!!!!!!!!!!!!!!!!!!!"); JArray allbills = JArray.Parse(response.Content); foreach (JToken token in allbills) { all_bill_objs.Add(new BillObj(token)); Console.WriteLine(new BillObj(token).ToString()); } listview.Adapter = new BillsListAdapter(this, all_bill_objs); }
private async Task PostItem() { RequestHandler request = new RequestHandler(Context); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; var response = await request.PostNewListItem(token, groupid, m_list.Topicid, editText.Text); if ((int)response.StatusCode == 200) { Toast.MakeText(Context, "Item Posted", ToastLength.Long); } else { Toast.MakeText(Context, "Post Failed", ToastLength.Long); } //JArray preParse = JArray.Parse(response.Content); }
//This may need to change. If selecting multiple times is an issue private async void FireCheckItem(string itemid, bool selected) { List <ItemObj> groupLists = new List <ItemObj>(); RequestHandler request = new RequestHandler(this); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; var response = await request.PutListItem(token, groupid, list.Topicid, itemid, selected); if ((int)response.StatusCode == 200) { Toast.MakeText(this, "Item Updated", ToastLength.Long); } else { Toast.MakeText(this, "Connection Failed", ToastLength.Long); } }
private async void MakeReq() { //submit comment logic RequestHandler request = new RequestHandler(Context); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; var response = await request.PostMessageReply(token, groupid, post.Topicid, message); if ((int)response.StatusCode == 200) { Toast.MakeText(Context, "Post Succesful", ToastLength.Long); } else { } Dismiss(); }
public async Task UpdateComments() { List <string> comments = new List <string>(); List <string> usernames = new List <string>(); //deserializes the title and message that were converted to json in the messageboard.cs //title = JsonConvert.DeserializeObject<string>(Intent.GetStringExtra("Title")); //msg = JsonConvert.DeserializeObject<string>(Intent.GetStringExtra("Message")); comment_objs = new List <CommentObj>(); DB_Singleton db = DB_Singleton.Instance; RequestHandler request = new RequestHandler(this); string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; var response = await request.GetMessageReplies(token, groupid, post.Topicid); if ((int)response.StatusCode == 200) { if (response.Content != "[]") { JArray JPosts = JArray.Parse(response.Content); foreach (JToken Jpost in JPosts) { comment_objs.Add(new CommentObj(Jpost)); } } } else { Toast.MakeText(this, "Error getting comments", ToastLength.Long); } var minus_first_comment = comment_objs; minus_first_comment.RemoveAt(0); commentlistview.Adapter = new BulletinCommentListAdapter(this, minus_first_comment); //set onClick method for message that will open the full message text in another window }
public async void PostBulletin(object sender, EventArgs e) { string MsgTitle = View.FindViewById <EditText>(Resource.Id.edittexttitle).Text; string MsgBody = View.FindViewById <EditText>(Resource.Id.edittextmessage).Text; //create dialog to show data that was taken from text fields //Currently serves a purpose in testing, may be left in as confirmation to the user AlertDialog.Builder alert = new AlertDialog.Builder(this.Context); alert.SetTitle("New Message Submitted:"); alert.SetMessage(string.Format("Subject: " + MsgTitle + "\nMessage:\n" + MsgBody)); Dialog dialog = alert.Create(); dialog.Show(); Intent intent = new Intent(this.Activity.ApplicationContext, typeof(BulletinBoard)); Notification(intent, "A new message has been posted in ", "groupname", 0, 0); RequestHandler request = new RequestHandler(Context); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; //set private values equal to equal values from dialog box title = MsgTitle; message = MsgBody; var response = await request.PostMessages(token, groupid, title, message); if ((int)response.StatusCode == 200) { Toast.MakeText(Context, "Succesfully Posted", ToastLength.Long); } else { Toast.MakeText(Context, "Post Failed", ToastLength.Long); } //closes message dialog box await((BulletinBoard)Activity).UpdatePosts(); Dismiss(); }
private async Task PostNewList() { RequestHandler request = new RequestHandler(Context); DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); string groupid = db.GetActiveGroup().GroupID; var response = await request.PostNewList(token, groupid, editText.Text); if ((int)response.StatusCode == 200) { Toast.MakeText(Context, "Succesfully posted", ToastLength.Long); } else { Toast.MakeText(Context, "Error posting message", ToastLength.Long); } Dismiss(); }
public async void UpdateGroups() { DB_Singleton db = DB_Singleton.Instance; string token = db.Retrieve("Token"); List <UserGroup> userGroupList = await PullGroups(token); foreach (UserGroup group in userGroupList) { //number of members in each group also needs to be added here groupnames.Add(group.GroupName); } listView = FindViewById <ListView>(Resource.Id.listviewGroups); listView.Adapter = new GroupListAdapter(this, groupnames, nummembers); textView = FindViewById <TextView>(Resource.Id.textviewGroups); try { textView.Text = "Current Group: " + db.GetActiveGroup().GroupName; } catch { Console.WriteLine("No active group selected: Groups"); } //Set itemclick function for when a group is selected listView.ItemClick += OnGroupItemClick; }
private async void InitializeFormat() { AddLocation = FindViewById <Button>(Resource.Id.NewLocationButton); AddLocation.Click += AddLocation_Click; LocationList = FindViewById <ListView>(Resource.Id.locationlistview); CurrentLocation = FindViewById <TextView>(Resource.Id.textCurrentLocation); //This block asks the user for location permissions //Or checks if the user already gave permissions string permission = Manifest.Permission.AccessFineLocation; if (CheckSelfPermission(permission) != (int)Permission.Granted) { string[] request_permissions = new string[1]; request_permissions[0] = Manifest.Permission.AccessFineLocation; ActivityCompat.RequestPermissions(this, request_permissions, 0); } DB_Singleton db = DB_Singleton.Instance; try { db.GetActiveGroup(); } catch { Console.WriteLine("No active group selected: Locations"); } await GetLocations(); var GroupMemberLocs = await GetActiveUsers(); LocationList.Adapter = new LocationsListAdapter(this, GroupMemberLocs); }
private async Task <List <Tuple <string, string> > > GetActiveUsers() { DB_Singleton db = DB_Singleton.Instance; RequestHandler request = new RequestHandler(this); List <Tuple <string, string> > tup_list = new List <Tuple <string, string> >(); var response = await request.GetUserLocations(db.Retrieve("Token"), db.GetActiveGroup().GroupID); if (response.Content != "" && response.Content != "[]") { JArray members = JArray.Parse(response.Content); foreach (JToken member in members) { string username = (string)member["UserName"]; string locationname = (string)member["NetName"]; tup_list.Add(new Tuple <string, string>(username, locationname)); } } return(tup_list); }
private void ListView_LongClick(object sender, AdapterView.ItemLongClickEventArgs e) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle("Are you sure you want to delete this list?"); alert.SetPositiveButton("Yes", async(senderAlert, args) => { DB_Singleton db = DB_Singleton.Instance; //TODO Test this when fixed on the server var response = await new RequestHandler(this).DeleteList(db.Retrieve("Token"), db.GetActiveGroup().GroupID, listoflists[e.Position].Topicid); if ((int)response.StatusCode == 200) { Toast.MakeText(this, "Succesfully Deleted", ToastLength.Long); } else { Toast.MakeText(this, "Error Deleting", ToastLength.Long); } await UpdateLists(); }); alert.SetNegativeButton("No", (senderAlert, args) => { }); Dialog dialog = alert.Create(); dialog.Show(); }
private async Task <List <string> > GetUsers() { DB_Singleton db = DB_Singleton.Instance; RequestHandler request = new RequestHandler(Context); List <string> users = new List <string>(); var response = await request.GetUserLocations(db.Retrieve("Token"), db.GetActiveGroup().GroupID); if (response.Content != "" && response.Content != "[]") { JArray members = JArray.Parse(response.Content); foreach (JToken member in members) { string username = (string)member["UserName"]; string userid = (string)member["UserID"]; users.Add((username)); userIDs.Add(userid); } } return(users); }