protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.EditClub);

            _club    = JsonConvert.DeserializeObject <ClubDetails>(Intent.GetStringExtra("club"));
            _toolbar = FindViewById <Toolbar>(Resource.Id.tbr_editClub_toolbar);

            SetSupportActionBar(_toolbar);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetHomeButtonEnabled(true);

            _pickImage        = FindViewById <Button>(Resource.Id.btn_editClub_pickPhoto);
            _pickImage.Click += PickImage_Click;

            _clubImage = FindViewById <ImageView>(Resource.Id.iv_editClub_clubPhoto);
            _imagePath = await RestManager.GetClubPhoto(_club.Id);

            var bitmap = BitmapFactory.DecodeFile(_imagePath);

            _clubImage.SetImageBitmap(bitmap);

            _clubName      = FindViewById <EditText>(Resource.Id.et_editClub_clubName);
            _clubName.Text = _club.Name;

            Button editClub = FindViewById <Button>(Resource.Id.btn_editClub_editClub);

            editClub.Click += EditClub_Click;
        }
Exemple #2
0
        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);
                    }
                }
            }
        }