public override async void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); _account = AccountStore .Create(Context) .FindAccountsForService(GetString(Resource.String.app_name)) .FirstOrDefault(); _noClubEvents = View.FindViewById <TextView>(Resource.Id.tv_clubEvent_noClubEvents); if (_account.Properties["roles"].Contains(Role.Coach.ToString())) { FloatingActionButton goToCreateClubEventButton = View.FindViewById <FloatingActionButton>(Resource.Id.btn_clubEvent_goToCreateClubEvent); goToCreateClubEventButton.BringToFront(); goToCreateClubEventButton.Click += GoToCreateClubEventButton_Click; goToCreateClubEventButton.Visibility = ViewStates.Visible; } HttpResponseMessage clubHttpResponse = await RestManager.GetMemberClub(_account.Username); string clubResponse = await clubHttpResponse.Content.ReadAsStringAsync(); if (clubResponse != "null") { _clubDetails = JsonConvert.DeserializeObject <ClubDetails>(clubResponse); _clubEventFilterRequest = new ClubEventFilterRequest { MemberId = int.Parse(_account.Properties["memberId"]), ClubId = _clubDetails.Id }; HttpResponseMessage httpResponse = await RestManager.GetClubEvents(_clubEventFilterRequest); string response = await httpResponse.Content.ReadAsStringAsync(); _clubEvents = JsonConvert.DeserializeObject <IEnumerable <ClubEventFilterResult> >(response); if (_clubEvents.Any()) { _timeSpans = View.FindViewById <Spinner>(Resource.Id.spn_clubEvent_timeSpan); var timeSpans = Enum.GetNames(typeof(EventTimeSpan)) .Select(r => Literals.ResourceManager.GetString(r)).ToArray(); _timeSpans.Adapter = new ArrayAdapter <string>(Context, Android.Resource.Layout.SimpleSpinnerDropDownItem, timeSpans); _timeSpans.ItemSelected += TimeSpans_ItemSelected; _eventsFilter = View.FindViewById <LinearLayout>(Resource.Id.ll_clubEvent_clubEventsFilter); _eventsFilter.Visibility = ViewStates.Visible; _adapter = new ClubEventAdapter(Activity, _clubEvents.ToArray(), _clubDetails, _account); _recyclerView = View.FindViewById <RecyclerView>(Resource.Id.rv_clubEvent_clubEvents); _recyclerView.SetAdapter(_adapter); _layoutManager = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); _recyclerView.SetLayoutManager(_layoutManager); } else { _noClubEvents.Visibility = ViewStates.Visible; } } }
protected async override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.SearchPlayers); Typeface tf = Typeface.CreateFromAsset(Assets, "fonts/Font Awesome 5 Free-Solid-900.otf"); _toolbar = FindViewById <Toolbar>(Resource.Id.tbr_searchPlayers_toolbar); _name = FindViewById <EditText>(Resource.Id.et_searchPlayers_name); _positionsSpinner = FindViewById <Spinner>(Resource.Id.spn_searchPlayers_preferedPosition); _heightRange = FindViewById <RangeSliderControl>(Resource.Id.sld_searchPlayers_heightRange); _heightRange.SetSelectedMinValue(0); _heightRange.SetSelectedMaxValue(300); _weightRange = FindViewById <RangeSliderControl>(Resource.Id.sld_searchPlayers_weightRange); _weightRange.SetSelectedMinValue(0); _weightRange.SetSelectedMaxValue(300); _ageRange = FindViewById <RangeSliderControl>(Resource.Id.sld_searchPlayers_ageRange); _ageRange.SetSelectedMinValue(_ageRange.AbsoluteMinValue); _ageRange.SetSelectedMaxValue(_ageRange.AbsoluteMaxValue); _search = FindViewById <Button>(Resource.Id.btn_searchPlayers_searchPlayers); _search.Click += Search_Click; _recyclerView = FindViewById <RecyclerView>(Resource.Id.rv_searchPlayers_players); _layoutManager = new LinearLayoutManager(this, LinearLayoutManager.Vertical, false); _recyclerView.SetLayoutManager(_layoutManager); _noPlayersFound = FindViewById <TextView>(Resource.Id.tv_searchPlayers_noPlayersFound); SetSupportActionBar(_toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); _toggleFilters = FindViewById <TextView>(Resource.Id.tv_searchPlayers_toggleFilters); _toggleFilters.Click += ToggleFilters_Click; _toggleFilters.Typeface = tf; _filters = FindViewById <TableLayout>(Resource.Id.tl_searchPlayers_filters); var positions = new List <string> { Literals.AllPositions }; positions.AddRange(Enum .GetNames(typeof(Position)) .Select(r => Literals.ResourceManager.GetString(r))); _positionsSpinner.Adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, positions.ToArray()); _resetFilters = FindViewById <Button>(Resource.Id.btn_searchPlayers_resetFilters); _resetFilters.Click += ResetFilters_Click; _account = AccountStore .Create() .FindAccountsForService(GetString(Resource.String.app_name)) .FirstOrDefault(); HttpResponseMessage getPlayersHttpResponse = await RestManager.GetAvailablePlayers(_searchPlayersCritera); HttpResponseMessage getCoachClubHttpResponse = await RestManager.GetMemberClub(_account.Username); string getCoachClubResponse = await getCoachClubHttpResponse.Content.ReadAsStringAsync(); string getPlayersResponse = await getPlayersHttpResponse.Content.ReadAsStringAsync(); if (getPlayersHttpResponse.IsSuccessStatusCode && !string.IsNullOrWhiteSpace(getPlayersResponse) && getPlayersResponse != "null") { _clubDetails = JsonConvert.DeserializeObject <ClubDetails>(getCoachClubResponse); _memberDetails = JsonConvert.DeserializeObject <IEnumerable <MemberDetails> >(getPlayersResponse); if (_memberDetails.Any()) { _adapter = new PlayerAdapter(this, _memberDetails.ToArray(), _clubDetails, _account); _recyclerView.SetAdapter(_adapter); } } }
public override async void OnActivityCreated(Bundle OnActivityCreated) { base.OnActivityCreated(OnActivityCreated); _account = AccountStore .Create(Context) .FindAccountsForService(GetString(Resource.String.app_name)) .FirstOrDefault(); HttpResponseMessage httpResponse = await RestManager.GetMemberClub(_account.Username); string response = await httpResponse.Content.ReadAsStringAsync(); bool isCoach = _account.Properties["roles"].Contains(Role.Coach.ToString()); if (string.IsNullOrWhiteSpace(response) || response == "null") { TextView noClubMessage = View.FindViewById <TextView>(Resource.Id.tv_club_noClubMessage); noClubMessage.Text = Literals.NoClubMessage; noClubMessage.Visibility = ViewStates.Visible; if (isCoach) { Button createClubButton = View.FindViewById <Button>(Resource.Id.btn_club_createClub); createClubButton.Visibility = ViewStates.Visible; createClubButton.Click += CreateClubButton_Click; } } else { _clubDetails = JsonConvert.DeserializeObject <ClubDetails>(response); string imagePath = await RestManager.GetClubPhoto(_clubDetails.Id); _mainPhoto = View.FindViewById <ImageView>(Resource.Id.iv_club_mainPhoto); var bitmap = BitmapFactory.DecodeFile(imagePath); _mainPhoto.SetImageBitmap(bitmap); TextView clubNameText = View.FindViewById <TextView>(Resource.Id.tv_club_clubName); clubNameText.Text = _clubDetails.Name; LinearLayout clubDetailsLayout = View.FindViewById <LinearLayout>(Resource.Id.ll_club_clubDetails); clubDetailsLayout.Visibility = ViewStates.Visible; if (isCoach) { Button searchPlayersButton = View.FindViewById <Button>(Resource.Id.btn_club_searchPlayers); searchPlayersButton.Click += SearchPlayersButton_Click; Button editClub = View.FindViewById <Button>(Resource.Id.btn_club_editClubDetails); editClub.Click += EditClub_Click; LinearLayout coachActions = View.FindViewById <LinearLayout>(Resource.Id.ll_club_coachActions); coachActions.Visibility = ViewStates.Visible; } else { Button leaveClub = View.FindViewById <Button>(Resource.Id.btn_club_leaveClub); leaveClub.Click += LeaveClub_Click; LinearLayout playerActions = View.FindViewById <LinearLayout>(Resource.Id.ll_club_playerActions); playerActions.Visibility = ViewStates.Visible; } _searchPlayersCritera.ClubId = _clubDetails.Id; HttpResponseMessage getPlayersHttpResponse = await RestManager.GetClubPlayers(_searchPlayersCritera); string getPlayersResponse = await getPlayersHttpResponse.Content.ReadAsStringAsync(); if (!string.IsNullOrWhiteSpace(getPlayersResponse) && getPlayersResponse != "null") { _memberDetails = JsonConvert.DeserializeObject <IEnumerable <MemberDetails> >(getPlayersResponse); if (_memberDetails.Any()) { _adapter = new PlayerAdapter(Activity, _memberDetails.ToArray(), _clubDetails, _account); _recyclerView = View.FindViewById <RecyclerView>(Resource.Id.rv_club_clubPlayers); _recyclerView.SetAdapter(_adapter); _layoutManager = new LinearLayoutManager(Activity, LinearLayoutManager.Vertical, false); _recyclerView.SetLayoutManager(_layoutManager); } } } }