private async void UpdateGroups()
        {
            DB_Singleton   db       = DB_Singleton.Instance;
            string         token    = db.Retrieve("Token");
            RequestHandler request  = new RequestHandler(Context);
            IRestResponse  response = await request.PullGroups(token);

            List <UserGroup> userGroupList = ReformatResponse(response.Content);

            foreach (UserGroup user in userGroupList)
            {
                db.AddGroup(user.GroupName, user.GroupID);
            }
            if (userGroupList.Count > 0)
            {
                db.ChangeActiveGroup(userGroupList[0]);
            }
            //CAUTION A NEW USER THAT TRIES TO ACCESS ELEMENTS
            //WITHOUT A GROUP WILL CRASH THE APP
            else
            {
                db.ChangeActiveGroup(new UserGroup(null, null));
            }
        }
示例#2
0
        private void Select_Click(object sender, EventArgs e)
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(this.Context);
            alert.SetTitle("Make " + groupname + " your current group?");

            //Set current group
            alert.SetPositiveButton("Confirm", (senderAlert, args) =>
            {
                //This is where current group is set
                DB_Singleton db  = DB_Singleton.Instance;
                UserGroup active = db.SearchGroup(groupname);
                db.ChangeActiveGroup(active);
            });

            //Close dialog
            alert.SetNegativeButton("Cancel", (senderAlert, args) =>
            {
                Dismiss();
            });
            Dialog dialog = alert.Create();

            dialog.Show();
            Dismiss();
        }