コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.LogIn);

            DB_Communicator db = new DB_Communicator();

            Button btnLogin = FindViewById<Button>(Resource.Id.btnLogin);

            btnLogin.Click += async (object sender, EventArgs e) => {
                EditText username = FindViewById<EditText>(Resource.Id.usernameText);
                EditText password = FindViewById<EditText>(Resource.Id.passwordText);

                user = await db.login(username.Text, password.Text);

                if(user != null) {
                    //storing user information for usage in other activities
                    user.StoreUserInPreferences(this, user);

                    Toast.MakeText(this, "Login successful!", ToastLength.Short).Show();
                    Intent i = new Intent(this, typeof(ListEventsActivity));
                    StartActivity(i);
                } else {
                    Toast.MakeText(this, "Login failed!", ToastLength.Long).Show();
                }
            };
        }
コード例 #2
0
 public void StoreUserInPreferences(Context context, MySqlUser user)
 {
     ISharedPreferences prefs = context.GetSharedPreferences("userinformation", FileCreationMode.Private);
     ISharedPreferencesEditor editor = prefs.Edit();
     editor.PutInt("idUser", user.idUser);
     editor.PutString("name", user.name);
     editor.PutString("role", user.role);
     editor.PutString("password", user.password);
     editor.PutInt("number", user.number);
     editor.PutString("position", user.position);
     editor.Commit();
 }
コード例 #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.ListEvents);
            listView = FindViewById<ListView>(Resource.Id.listEvents);

            user = MySqlUser.GetUserFromPreferences(this);

            DB_Communicator db = new DB_Communicator();
            listEvents = db.SelectEventsForUser(user.idUser, null).Result;
            listView.Adapter = new ListEventsAdapter(this, listEvents);

            listView.ItemClick += OnListItemClick;
        }
コード例 #4
0
		protected override void OnCreate(Bundle bundle) {
			base.OnCreate(bundle);
			SetContentView(Resource.Layout.ListEvents);

			//Get all events for the logged in user
			DB_Communicator db = new DB_Communicator();
			user = MySqlUser.GetUserFromPreferences(this);
			listEvents = db.SelectEventsForUser(user.idUser, null).Result;

			if(listEvents.Count == 0) {
				//display text that there are currently no events
			} else {
				listView = FindViewById<ListView>(Resource.Id.listEvents);
				listView.Adapter = new ListEventsAdapter(this, listEvents);
				listView.ItemClick += OnListItemClick;
			}
		}