/// <summary> /// Builds the header containing the Eorzea Hour each window starts. /// </summary> private LinearLayout BuildHeader(RegionForecast forecast) { var layout = new LinearLayout(_view.Context) { Orientation = Orientation.Horizontal }; forecast.ZoneForecasts.First().WeatherResults.OrderBy(x => x.TimeOfWeather) .Select(x => Helpers.BuildTextView(x.StartTime, _view.Context, GravityFlags.Center, _imageHeight, _imageWidth)) .ToList() .ForEach(x => layout.AddView(x)); return(layout); }
/// <summary> /// Build the forecast panel based on the data supplied /// </summary> private LinearLayout BuildForecastView(RegionForecast forecast) { var labels = BuildLabelView(forecast); var forecastPanel = BuildForecastPanel(forecast); var layout = new LinearLayout(_view.Context) { Orientation = Orientation.Horizontal }; layout.AddView(labels); layout.AddView(forecastPanel); return(layout); }
/// <summary> /// Builds the zone labels for the weather forecast /// </summary> private LinearLayout BuildLabelView(RegionForecast forecast) { var layout = new LinearLayout(_view.Context) { Orientation = Orientation.Vertical }; var spacer = new TextView(_view.Context); spacer.SetMinHeight(_imageHeight); layout.AddView(spacer); forecast.ZoneForecasts .OrderBy(x => x.ZoneOrder) .Select(x => Helpers.BuildTextView(x.Zone, _view.Context, GravityFlags.Center, _imageHeight, _imageWidth)) .ToList() .ForEach(x => layout.AddView(x)); return(layout); }
/// <summary> /// Get the upcoming weather forecast for the specified region /// </summary> /// <param name="region"></param> /// <returns></returns> public static RegionForecast GetWeatherForecastForRegion(string region) { var forecast = new RegionForecast(region); var zones = GetZonesForRegion(region); var parameters = new WeatherParameters { MaxMatches = 25, MaxTries = 25 }; foreach (var zone in zones) { parameters.Zone = zone; var order = GetOrderForZone(zone); var results = GetUpcomingWeatherResults(parameters); forecast.AddZoneForecast(zone, order, results); } return(forecast); }
/// <summary> /// Builds the scrollable forecast section /// </summary> private HorizontalScrollView BuildForecastPanel(RegionForecast forecast) { var scrollView = new HorizontalScrollView(_view.Context); if (forecast.ZoneForecasts.FirstOrDefault() == null) { return(scrollView); } var forecastLayout = new LinearLayout(_view.Context) { Orientation = Orientation.Vertical }; forecastLayout.AddView(BuildHeader(forecast)); forecast.ZoneForecasts .OrderBy(x => x.ZoneOrder) .Select(BuildSingleZoneForecast) .ToList() .ForEach(x => forecastLayout.AddView(x)); scrollView.AddView(forecastLayout); return(scrollView); }