protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.UserProfile); _account = AccountStore .Create(this) .FindAccountsForService(GetString(Resource.String.app_name)) .FirstOrDefault(); if (_account == null) { Intent intent = new Intent(this, typeof(LoginActivity)); StartActivity(intent); } else { RestManager.SetAccessToken(_account.Properties["token"]); HttpResponseMessage httpResponse = await RestManager.GetMemberDetails(_account.Username); string response = await httpResponse.Content.ReadAsStringAsync(); if (!string.IsNullOrWhiteSpace(response) && response != "null") { _memberDetails = JsonConvert.DeserializeObject <MemberDetails>(response); } _viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); SetupViewPager(_viewPager); _tabLayout = FindViewById <TabLayout>(Resource.Id.sliding_tabs); _tabLayout.SetupWithViewPager(_viewPager); } }
public override async void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); _account = AccountStore .Create(Context) .FindAccountsForService(GetString(Resource.String.app_name)) .FirstOrDefault(); RestManager.SetAccessToken(_account.Properties["token"]); HttpResponseMessage httpResponse = await RestManager.GetMemberDetails(_account.Username); string response = await httpResponse.Content.ReadAsStringAsync(); if (!string.IsNullOrWhiteSpace(response) && response != "null") { _memberDetails = JsonConvert.DeserializeObject <MemberDetails>(response); } var imagePath = await RestManager.GetMemberPhoto(_account.Username); TextView firstName = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_firstName); TextView lastName = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_lastName); TextView height = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_height); TextView weight = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_weight); TextView dateOfBirth = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_dateOfBirth); TextView preferedPosition = View.FindViewById <TextView>(Resource.Id.tv_memberDetails_preferedPosition); LinearLayout playerSection = View.FindViewById <LinearLayout>(Resource.Id.ll_memberDetails_playerSection); _mainPhoto = View.FindViewById <ImageView>(Resource.Id.iv_memberDetails_mainPhoto); var bitmap = BitmapFactory.DecodeFile(imagePath); _mainPhoto.SetImageBitmap(bitmap); firstName.Text = _memberDetails.FirstName; lastName.Text = _memberDetails.LastName; if (string.Compare(_account.Properties["roles"], Role.Player.ToString(), true) == 0) { height.Text = _memberDetails.Height.HasValue ? string.Format(Literals.HeightCmFormat, string.Empty, _memberDetails.Height.Value.ToString()) : "0"; weight.Text = _memberDetails.Weight.HasValue ? string.Format(Literals.WeightKgFormat, string.Empty, _memberDetails.Weight.Value.ToString()) : "0"; dateOfBirth.Text = _memberDetails.DateOfBirth.HasValue ? _memberDetails.DateOfBirth.Value.ToShortDateString() : string.Empty; preferedPosition.Text = Literals.ResourceManager.GetString(_memberDetails.PreferedPosition.Value.ToString()); playerSection.Visibility = ViewStates.Visible; } Button logout = View.FindViewById <Button>(Resource.Id.btn_memberDetails_logout); logout.Click += Logout_Click; logout.Visibility = ViewStates.Visible; Button editMemberDetails = View.FindViewById <Button>(Resource.Id.btn_memberDetails_edit); editMemberDetails.Click += EditMemberDetails_Click; }