private void UpdateAdapter(SkaterJson obj) { Deployment.Current.Dispatcher.BeginInvoke(() => { this.Skater = obj; IsLoading = false; }); }
public SkaterViewController(SkaterJson skater) { _skater = skater; }
void UpdateAdapter(SkaterJson skater) { InvokeOnMainThread(() => { try { _skater = skater; Bio.Text = _skater.Bio; Bio.SizeToFit(); loses.Text = "Loses: " + _skater.Losses; wins.Text = "Wins: " + _skater.Wins; leagueLink.Text = _skater.LeagueName; List<GenericTableItem> items = new List<GenericTableItem>(); items.Add(new GenericTableItem() { Key = "First Name: ", Value = _skater.FirstName }); items.Add(new GenericTableItem() { Key = "DOB: ", Value = DateTimeExt.Age(_skater.DOB) + " - " + _skater.DOB.ToShortDateString() }); items.Add(new GenericTableItem() { Key = "Weight: ", Value = _skater.Weight }); items.Add(new GenericTableItem() { Key = "Height: ", Value = _skater.HeightFeet + "," + _skater.HeightInches }); items.Add(new GenericTableItem() { Key = "Gender: ", Value = _skater.Gender }); table.Source = new GenericTableView(items); table.ReloadData(); if (!String.IsNullOrEmpty(_skater.LeagueLogo)) { leagueImage = new UIImageView(); NSUrl nsUrlLeague = new NSUrl(_skater.LeagueLogo); NSData dataLeague = NSData.FromUrl(nsUrlLeague); leagueImage.Frame = new RectangleF(5, 180, 100, 100); leagueImage.Image = new UIImage(dataLeague); } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.iPhone); } }); }
private static SkaterJson DisplaySkaterJson(Member mem) { SkaterJson m = new SkaterJson(); var photos = mem.Photos.OrderByDescending(x => x.Created).Where(x => x.IsPrimaryPhoto == true).FirstOrDefault(); if (photos != null) { m.photoUrl = photos.ImageUrl; m.ThumbUrl = photos.ImageUrlThumb; } else if (mem.Gender == (int)GenderEnum.Female) { m.photoUrl = ServerConfig.WEBSITE_DEFAULT_LOCATION + "/content/roller-girl.jpg"; m.ThumbUrl = m.photoUrl; m.Gender = GenderEnum.Female.ToString(); } else if (mem.Gender == (int)GenderEnum.Male) { m.photoUrl = ServerConfig.WEBSITE_DEFAULT_LOCATION + "/content/roller-person.gif"; m.ThumbUrl = m.photoUrl; m.Gender = GenderEnum.Male.ToString(); } m.DerbyNameUrl = ServerConfig.WEBSITE_DEFAULT_LOCATION + "/roller-derby-skater/" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(mem.DerbyName) + "/" + mem.MemberId.ToString().Replace("-", ""); m.DerbyName = mem.DerbyName; m.DerbyNumber = mem.PlayerNumber; m.MemberId = mem.MemberId.ToString().Replace("-", ""); if (!String.IsNullOrEmpty(mem.Bio)) m.Bio = htmlStrip.Replace(mem.Bio, String.Empty); m.DOB = mem.DateOfBirth.GetValueOrDefault(); if (mem.HeightInches != 0) { m.HeightFeet = (int)(mem.HeightInches / 12); m.HeightInches = (int)(mem.HeightInches % 12); } m.Weight = mem.WeightInLbs.ToString(); m.FirstName = mem.Firstname; var leag = mem.Leagues.Where(x => x.League.LeagueId == mem.CurrentLeagueId).FirstOrDefault(); if (leag != null) { m.LeagueUrl = ServerConfig.WEBSITE_DEFAULT_LOCATION + "/roller-derby-league/" + RDN.Utilities.Strings.StringExt.ToSearchEngineFriendly(leag.League.Name) + "/" + mem.CurrentLeagueId.ToString().Replace("-", ""); m.LeagueName = leag.League.Name; m.LeagueId = leag.League.LeagueId.ToString().Replace("-", ""); if (leag.League.Logo != null) m.LeagueLogo = leag.League.Logo.ImageUrl; } return m; }
public ActionResult ViewMembersMap() { try { var memId = RDN.Library.Classes.Account.User.GetMemberId(); var league = MemberCache.GetLeagueOfMember(memId); ViewBag.LeagueName = league.Name; ViewBag.LeagueId = league.LeagueId.ToString().Replace("-", ""); List<SkaterJson> Members = new List<SkaterJson>(); var mems = MemberCache.GetLeagueMembers(memId, league.LeagueId); foreach (var mem in mems) { var memObj = new SkaterJson { DerbyName = mem.DerbyName }; if (mem.ContactCard != null && mem.ContactCard.Addresses.FirstOrDefault() != null) { var add = mem.ContactCard.Addresses.FirstOrDefault(); memObj.Address1 = add.Address1; memObj.Address2 = add.Address2; memObj.City = add.CityRaw; memObj.State = add.StateRaw; memObj.Zip = add.Zip; memObj.Country = add.Country; if (add.Coords != null) { memObj.Latitude = add.Coords.Latitude.ToString(); memObj.Longitude = add.Coords.Longitude.ToString(); } } var photo = mem.Photos.Where(x => x.IsPrimaryPhoto == true).FirstOrDefault(); if (photo != null) { memObj.photoUrl = photo.ImageUrl; memObj.ThumbUrl = photo.ImageThumbUrl; } Members.Add(memObj); } return View(Members); } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } return Redirect(Url.Content("~/?u=" + SiteMessagesEnum.sww.ToString())); }
protected override void OnCreate(Bundle bundle) { try { RequestWindowFeature(WindowFeatures.NoTitle); base.OnCreate(bundle); LoggerMobile.Instance.logMessage("Opening SkaterActivty", LoggerEnum.message); var skaterString = Intent.GetStringExtra("skater"); skater = Json.DeserializeObject<SkaterJson>(skaterString); LoggerMobile.Instance.logMessage("On Skater: " + skater.DerbyName + " " + skater.MemberId, LoggerEnum.message); SetContentView(Resource.Layout.SkaterProfile); LegacyBar = FindViewById<LegacyBar.Library.Bar.LegacyBar>(Resource.Id.actionbar); LegacyBar.SeparatorColor = Color.Purple; LegacyBar.SetHomeAction(new BackAction(this, null, Resource.Drawable.skater, this)); LegacyBar.Title = skater.DerbyName; // Get our button from the layout resource, // and attach an event to it if (!skater.GotExtendedContent) { LegacyBar.ProgressBarVisibility = ViewStates.Visible; Action<SkaterJson> skaters = new Action<SkaterJson>(UpdateAdapter); Skater.PullSkater(skater.MemberId, (Context)this, skaters); } TextView ProfileNameNumber = FindViewById<TextView>(Resource.Id.ProfileNameNumber); ProfileNameNumber.Text = skater.DerbyName + " " + skater.DerbyNumber; gamesCount = FindViewById<TextView>(Resource.Id.gamesCount); gamesCount.Text = skater.GamesCount.ToString(); winsLoses = FindViewById<TextView>(Resource.Id.winsLoses); winsLoses.Text = skater.Wins + "-" + skater.Losses; bio = FindViewById<TextView>(Resource.Id.bio); if (!String.IsNullOrEmpty(skater.Bio)) bio.Text = Html.FromHtml(skater.Bio).ToString(); profileHeight = FindViewById<TextView>(Resource.Id.profileHeight); profileHeight.Text = skater.HeightFeet + "-" + skater.HeightInches; profileWeight = FindViewById<TextView>(Resource.Id.profileWeight); if (!String.IsNullOrEmpty(skater.Weight)) profileWeight.Text = skater.Weight; else profileWeight.Text = "0"; profileName = FindViewById<TextView>(Resource.Id.profileName); if (!String.IsNullOrEmpty(skater.FirstName)) profileName.Text = skater.FirstName; else profileName.Text = " "; var profileAge = FindViewById<TextView>(Resource.Id.profileAge); var profileBorn = FindViewById<TextView>(Resource.Id.profileBorn); if (skater.DOB.ToShortDateString() != "1/1/0001") { DateTime today = DateTime.Today; int age = today.Year - skater.DOB.Year; if (skater.DOB > today.AddYears(-age)) age--; profileAge.Text = age.ToString(); profileBorn.Text = skater.DOB.ToShortDateString(); } else { var ageRow = FindViewById<TableRow>(Resource.Id.ageRow); ageRow.Visibility = ViewStates.Gone; var bornRow = FindViewById<TableRow>(Resource.Id.bornRow); bornRow.Visibility = ViewStates.Gone; } SetProfileImage(skater); teamNameBtn = FindViewById<Button>(Resource.Id.teamNameBtn); if (!String.IsNullOrEmpty(skater.LeagueName)) { teamNameBtn.Text = skater.LeagueName; SetLeagueImage(skater); //just pulls the league so we can insert it into the DB.. var callback = new Action<LeagueJsonDataTable>(leagueCallback); League.PullLeague(skater.LeagueId, this, callback); teamNameBtn.Click += teamNameBtn_Click; } m_AdView = FindViewById(Resource.Id.adView); if (SettingsMobile.Instance.User != null && SettingsMobile.Instance.User.IsValidSub) { } } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this); } }
void UpdateAdapter(SkaterJson skater) { SetLeagueImage(skater); RunOnUiThread(() => { try { if (!String.IsNullOrEmpty(skater.Bio)) bio.Text = Html.FromHtml(skater.Bio).ToString(); gamesCount.Text = skater.GamesCount.ToString(); winsLoses.Text = skater.Wins + "-" + skater.Losses; profileHeight.Text = skater.HeightFeet + "-" + skater.HeightInches; if (!String.IsNullOrEmpty(skater.Weight)) profileWeight.Text = skater.Weight; else profileWeight.Text = "0"; if (!String.IsNullOrEmpty(skater.FirstName)) profileName.Text = skater.FirstName; else profileName.Text = " "; LegacyBar.ProgressBarVisibility = ViewStates.Gone; } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.Android, (Context)this); } }); }
private void SetLeagueImage(SkaterJson skater) { if (!String.IsNullOrEmpty(skater.LeagueLogo)) { Task<bool>.Factory.StartNew( () => { try { var i = Image.GetImageBitmapFromUrl(skater.LeagueLogo); this.RunOnUiThread(() => { teamNameBtn.SetCompoundDrawablesWithIntrinsicBounds(new BitmapDrawable(i), null, null, null); }); } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.Android, this); } return true; }); } }
private void SetProfileImage(SkaterJson skater) { ImageView profileImage = FindViewById<ImageView>(Resource.Id.profileImage); if (!String.IsNullOrEmpty(skater.ThumbUrl) && !skater.ThumbUrl.Contains("roller-girl.jpg")) { Task<bool>.Factory.StartNew( () => { try { var i = Image.GetImageBitmapFromUrl(skater.ThumbUrl); this.RunOnUiThread(() => { profileImage.SetImageBitmap(i); }); } catch (Exception exception) { ErrorHandler.Save(exception, MobileTypeEnum.Android, this, additionalInformation: skater.ThumbUrl); } return true; }); } }
protected void Page_Load(object sender, EventArgs e) { try { if (Page.IsCallback) return; if (Request.RawUrl.ToLowerInvariant().Contains("/news/")) { DisplayCategories(); } else if (Request.RawUrl.ToLowerInvariant().Contains("/author/")) { DisplayAuthors(); } else if (Request.RawUrl.ToLowerInvariant().Contains("?tag=")) { DisplayTag(); } else { PostRepository repository = new PostRepository(); Posts = repository.FindPublic(take: 60); } StoreItem = SiteCache.GetRandomPublishedStoreItems(3); PostsColumn1 = new List<PostItem>(); PostsColumn2 = new List<PostItem>(); PostsColumn3 = new List<PostItem>(); // var resul = SiteSingleton.Instance.GetLastTweets("#derbyscores");// Search by HashTag var resul = SiteSingleton.Instance.GetTweetsStatus("@rollinnews"); //Get 150 tweets from Home Timeline. Tweets = resul; if (Tweets == null) Tweets = new List<TweetSharp.TwitterStatus>(); int i = 0; foreach (var post in Posts) { if (i % 3 == 0) PostsColumn1.Add(post); else if (i % 3 == 1) PostsColumn2.Add(post); else if (i % 3 == 2) PostsColumn3.Add(post); i += 1; } //Disabled as #derbyscores no longer needed. //Games = RDN.Library.Cache.SiteCache.GetPastGames(0, 15); LeagueOfWeek = SiteCache.GetLeagueOfWeek(); if (LeagueOfWeek != null) { if (!String.IsNullOrEmpty(LeagueOfWeek.Logo.ImageThumbUrl)) LeagueOfWeek.Logo.ImageThumbUrl = LeagueOfWeek.Logo.ImageUrl; } SkaterOfWeek = SiteCache.GetSkaterOfWeek(); if (SkaterOfWeek != null) { if (SkaterOfWeek.Bio.Length > 230) SkaterOfWeek.Bio = SkaterOfWeek.Bio.Remove(230) + "..."; } } catch (Exception exception) { ErrorDatabaseManager.AddException(exception, exception.GetType()); } }