/// <summary> /// This method is called when the activity is starting. /// It contains the logic for the buttons shown in this activity. /// </summary> /// <param name="savedInstanceState"> a Bundle that contains the data the activity most recently /// supplied if the activity is being re-initialized after previously being shut down. </param> protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.MyProfile); userJson = Intent.GetStringExtra("User"); _loggedUser = JsonConvert.DeserializeObject <User>(userJson); _nameView = FindViewById <TextView>(Resource.Id.myNameView); _ageView = FindViewById <TextView>(Resource.Id.myAgeView); _chefView = FindViewById <TextView>(Resource.Id.chefText); _scoreText = FindViewById <TextView>(Resource.Id.scoreText); _pfp = FindViewById <ImageView>(Resource.Id.profilePic); _btnFollowers = FindViewById <Button>(Resource.Id.btnMyFollowers); _btnFollowing = FindViewById <Button>(Resource.Id.btnMyFollowing); _btnSettings = FindViewById <Button>(Resource.Id.btnSettings); _btnNewsfeed = FindViewById <Button>(Resource.Id.btnNewsfeed); _btnNotif = FindViewById <Button>(Resource.Id.btnNotif); _btnDate = FindViewById <Button>(Resource.Id.btnDate); _btnScore = FindViewById <Button>(Resource.Id.btnScore); _btnDiff = FindViewById <Button>(Resource.Id.btnDiff); _btnRecipe = FindViewById <Button>(Resource.Id.btnRecipe); _btnChef = FindViewById <Button>(Resource.Id.btnChef); _btnBusiness = FindViewById <Button>(Resource.Id.btnCreateBsns); _myMenuListView = FindViewById <ListView>(Resource.Id.myMenuListView); _nameView.Text = "Name: " + _loggedUser.firstName + " " + _loggedUser.lastName; _ageView.Text = "Age: " + _loggedUser.age; if (!string.IsNullOrEmpty(_loggedUser.photo)) { pictureUrl = $"http://{MainActivity.Ipv4}:8080/CookTime_war/cookAPI/resources/getPicture?id={_loggedUser.photo}"; Bitmap bitmap = GetImageBitmapFromUrl(pictureUrl); _pfp.SetImageBitmap(bitmap); } if (_loggedUser.chef) { _chefView.Text = "Chef: yes"; _scoreText.Text = "Score : " + _loggedUser.chefScore; } else { _chefView.Text = "Chef: no"; _scoreText.Text = ""; } _btnFollowers.Text = "FOLLOWERS: " + _loggedUser.followerEmails.Count; _btnFollowing.Text = "FOLLOWING: " + _loggedUser.followingEmails.Count; using var webClient = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; var url = "resources/myMenu?email=" + _loggedUser.email + "&filter=date"; webClient.Headers[HttpRequestHeader.ContentType] = "application/json"; var send = webClient.DownloadString(url); _myMenuList = JsonConvert.DeserializeObject <IList <string> >(send); _adapter = new RecipeAdapter(this, _myMenuList); _myMenuListView.Adapter = _adapter; _myMenuListView.ItemClick += ListClick; _btnNewsfeed.Click += (sender, args) => { using var webClient2 = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; var url2 = "resources/getUser?id=" + _loggedUser.email; webClient2.Headers[HttpRequestHeader.ContentType] = "application/json"; var request = webClient2.DownloadString(url2); var intent = new Intent(this, typeof(NewsfeedActivity)); intent.PutExtra("User", request); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); Finish(); }; _btnSettings.Click += (sender, args) => { //Brings dialog fragment forward var transaction = SupportFragmentManager.BeginTransaction(); var dialogSettings = new DialogSettings(); dialogSettings.Show(transaction, "settings"); dialogSettings.Email = _loggedUser.email; dialogSettings.EventHandlerPass += PassResult; }; _btnFollowers.Click += (sender, args) => { var intent = new Intent(this, typeof(FollowActivity)); intent.PutExtra("Title", "Followers"); intent.PutExtra("LoggedId", _loggedUser.email); intent.PutStringArrayListExtra("FollowList", _loggedUser.followerEmails); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); }; _btnFollowing.Click += (sender, args) => { var intent = new Intent(this, typeof(FollowActivity)); intent.PutExtra("Title", "Following"); intent.PutExtra("LoggedId", _loggedUser.email); intent.PutStringArrayListExtra("FollowList", _loggedUser.followingEmails); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); }; _btnNotif.Click += (sender, args) => { var intent = new Intent(this, typeof(NotifActivity)); intent.PutStringArrayListExtra("NotifList", _loggedUser.notifications); intent.PutExtra("LoggedId", _loggedUser.email); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); }; _btnDate.Click += (sender, args) => { sortStr = "date"; SortMenu(); }; _btnScore.Click += (sender, args) => { sortStr = "score"; SortMenu(); }; _btnDiff.Click += (sender, args) => { sortStr = "difficulty"; SortMenu(); }; _btnRecipe.Click += (sender, args) => { var intent = new Intent(this, typeof(CreateRActivity)); intent.PutExtra("LoggedId", _loggedUser.email); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); }; _btnChef.Click += (sender, args) => { if (_loggedUser.chef) { var toast = Toast.MakeText(this, "You're already a chef", ToastLength.Short); toast.Show(); } else { //Brings dialog fragment forward var transaction = SupportFragmentManager.BeginTransaction(); var dialogChef = new DialogChef(); dialogChef.LoggedId = _loggedUser.email; dialogChef.Show(transaction, "chef"); dialogChef.EventHandlerChef += ChefResult; } }; _btnBusiness.Click += (sender, args) => { if (_loggedUser.business == 0) { var intent = new Intent(this, typeof(CreateBActivity)); intent.PutExtra("LoggedId", _loggedUser.email); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } else { using var webClient3 = new WebClient { BaseAddress = "http://" + MainActivity.Ipv4 + ":8080/CookTime_war/cookAPI/" }; var url3 = "resources/getBusiness?id=" + _loggedUser.business; webClient3.Headers[HttpRequestHeader.ContentType] = "application/json"; var bsnsJson = webClient3.DownloadString(url3); var intent = new Intent(this, typeof(MyBusiness)); intent.PutExtra("Bsns", bsnsJson); intent.PutExtra("LoggedId", _loggedUser.email); StartActivity(intent); OverridePendingTransition(Android.Resource.Animation.SlideInLeft, Android.Resource.Animation.SlideOutRight); } }; _pfp.Click += (sender, args) => { var transaction = SupportFragmentManager.BeginTransaction(); var dialogPicture = new DialogPicture(); dialogPicture.Photo = _loggedUser.photo; dialogPicture.Show(transaction, "choice"); dialogPicture.EventHandlerChoice += PictureAction; }; }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Android.Resource.Id.Home: _navigationView.Menu.Clear(); ConfigureHomeGrid(_homeStrings, _homeImgs); break; case Resource.Id.topMenu_food: _navigationView.Menu.Clear(); _navigationView.InflateMenu(Resource.Menu.menuFood); ClearGridView(); break; case Resource.Id.topMenu_drinks: _navigationView.Menu.Clear(); _navigationView.InflateMenu(Resource.Menu.menuDrinks); ClearGridView(); break; case Resource.Id.topMenu_dessert: _navigationView.Menu.Clear(); ConfigureGridView(_menu.First(kvp => kvp.Key == "dessert").Value); break; case Resource.Id.topMenu_service: Toast.MakeText(this, "Your waiter has been requested!", ToastLength.Long).Show(); ServerRequestWaiter(); break; case Resource.Id.topMenu_bill: if (TotalOrder.Count > 0) { FragmentTransaction trans = FragmentManager.BeginTransaction(); DialogBill dialogBill = new DialogBill(); dialogBill.SetStyle(DialogFragmentStyle.NoFrame, 0); dialogBill.Show(trans, "dialog_bill"); } else { Toast.MakeText(this, "Error! No order was sent!", ToastLength.Short).Show(); } break; case Resource.Id.topMenu_cancel: CanceledCounter++; if (Status == EStatus.Waiting) { Toast.MakeText(this, "Sorry! Too late to cancel your request!", ToastLength.Short).Show(); } break; case Resource.Id.topMenu_order: if (CurrentOrder.Count > 0) { Intent intent = new Intent(this, typeof(OrderActivity)); StartActivity(intent); } else { Toast.MakeText(this, "Your current order is empty!", ToastLength.Long).Show(); } break; case Resource.Id.topMenu_about: FragmentTransaction transaction = FragmentManager.BeginTransaction(); DialogAbout dialogAbout = new DialogAbout(); dialogAbout.SetStyle(DialogFragmentStyle.NoFrame, 0); dialogAbout.Show(transaction, "dialog_about"); break; case Resource.Id.topMenu_admin: FragmentTransaction transactionSettings = FragmentManager.BeginTransaction(); DialogSettings dialogSettings = new DialogSettings(); dialogSettings.SetStyle(DialogFragmentStyle.NoFrame, 0); dialogSettings.Show(transactionSettings, "dialog_settings"); break; default: return(base.OnOptionsItemSelected(item)); } return(base.OnOptionsItemSelected(item)); }