public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
			user = VBUser.GetUserFromPreferences();

			View view = inflater.Inflate(Resource.Layout.EventDetails, container, false);

			string eventState = (getLoggedInUser(user.idUser, listUser) != null) 
								? "(" + getLoggedInUser(user.idUser, listUser).getEventState() + ")" : "";

			view.FindViewById<TextView>(Resource.Id.eventTitle).Text = _event.name;
			view.FindViewById<TextView>(Resource.Id.eventState).Text = eventState;
			view.FindViewById<TextView>(Resource.Id.eventLocation).Text = _event.location;
			view.FindViewById<TextView>(Resource.Id.eventTime).Text = _event.convertDateForLayout(_event);

			if(_event.description != null && !_event.description.Equals("")) {
				view.FindViewById<LinearLayout>(Resource.Id.eventDetailsEventDescriptionLine).Visibility = ViewStates.Visible;
				view.FindViewById<TextView>(Resource.Id.eventDetailsEventDescriptionValue).Text = _event.description.Replace("\\n", "\n");
			}

			ImageView btnInvite = this.Activity.FindViewById<ImageView>(Resource.Id.btnAddInToolbar);
			ImageView btnEdit = this.Activity.FindViewById<ImageView>(Resource.Id.btnEditInToolbar);
			ImageView btnDelete = this.Activity.FindViewById<ImageView>(Resource.Id.btnDeleteInToolbar);

			if(!this.isEditable(_event.startDate, _event.endDate)) {
				btnInvite.Visibility = ViewStates.Gone;
				btnEdit.Visibility = ViewStates.Gone;
				btnDelete.Visibility = ViewStates.Gone;

				view.FindViewById<Button>(Resource.Id.btnEventAbsagen).Visibility = ViewStates.Gone;
				view.FindViewById<Button>(Resource.Id.btnEventZusagen).Visibility = ViewStates.Gone;
			} else {
				if(DB_Communicator.getInstance().isAtLeast(user.getUserType(), UserType.Coremember)) {
					btnInvite.Visibility = ViewStates.Visible;
					btnEdit.Visibility = ViewStates.Visible;
					btnDelete.Visibility = ViewStates.Visible;
				}
			}

			//zusagen
			initalizeLinearLayout(view.FindViewById<LinearLayout>(Resource.Id.EventDetails_ListUser_Zugesagt), listUser,
				DB_Communicator.State.Accepted, view.FindViewById<TextView>(Resource.Id.EventDetails_Count_Zugesagt), inflater);
			//absagen
			initalizeLinearLayout(view.FindViewById<LinearLayout>(Resource.Id.EventDetails_ListUser_Abgesagt), listUser,
				DB_Communicator.State.Denied, view.FindViewById<TextView>(Resource.Id.EventDetails_Count_Abgesagt), inflater);
			//eingeladen
			initalizeLinearLayout(view.FindViewById<LinearLayout>(Resource.Id.EventDetails_ListUser_Eingeladen), listUser,
				DB_Communicator.State.Invited, view.FindViewById<TextView>(Resource.Id.EventDetails_Count_Eingeladen), inflater);

			#region buttons
			btnAccept = view.FindViewById<Button>(Resource.Id.btnEventZusagen);
			btnAccept.SetOnClickListener(new EventDetailsClickListener(EventDetailsClickListener.ON_ANSWER_INVITE, this, "G"));

			btnDenie = view.FindViewById<Button>(Resource.Id.btnEventAbsagen);
			btnDenie.SetOnClickListener(new EventDetailsClickListener(EventDetailsClickListener.ON_ANSWER_INVITE, this, "D"));

			if(getEventStateOfLoggedInUser().Equals(VBUser.ACCEPTED)) {
				btnAccept.Enabled = false;
				btnDenie.Enabled = true;
			}
			if(getEventStateOfLoggedInUser().Equals(VBUser.DENIED)) {
				btnAccept.Enabled = true;
				btnDenie.Enabled = false;
			}
			#endregion

			#region toolbar
			btnInvite.SetOnClickListener(new EventDetailsClickListener(EventDetailsClickListener.ON_INVITE, this));

			btnEdit.SetOnClickListener(new EventDetailsClickListener(EventDetailsClickListener.ON_EDIT, this));

			btnDelete.SetOnClickListener(new EventDetailsClickListener(EventDetailsClickListener.ON_DELETE, this));
			#endregion

			return view;
		}
Esempio n. 2
0
		public void StoreUserInPreferences(Context context, VBUser user) {
			VBUser.context = context;
			ISharedPreferences prefs = context.GetSharedPreferences("userinformation", FileCreationMode.Private);
			ISharedPreferencesEditor editor = prefs.Edit();
			editor.PutInt("idUser", user.idUser);
			editor.PutString("name", user.name);
			editor.PutString("email", user.email);
			editor.PutString("state", user.state);
			if(user.password != null && !user.password.Equals(""))
				editor.PutString("password", user.password);
			editor.PutString("userType", user.getUserType().ToString().Substring(0,1));
			for(int i = 0; i < listTeamRole.Count; i++) {
				editor.PutInt("teamId"+i, user.listTeamRole[i].teamId);
				editor.PutString("role"+i, user.listTeamRole[i].role);
				editor.PutInt("number"+i, user.listTeamRole[i].number);
				editor.PutString("position"+i, user.listTeamRole[i].position);
				editor.PutString("userType"+i, user.listTeamRole[i].getUserType().ToString().Substring(0,1));
			}
			count = listTeamRole.Count;
			editor.Commit();
		}