private void SetView(WeatherNowViewModel weatherView) { AppCompatActivity?.RunOnUiThread(() => { // Background refreshLayout.Background = new ColorDrawable(weatherView.PendingBackground); bgImageView.ImageAlpha = BGAlpha; Glide.With(this.Context) .Load(weatherView.Background) .Apply(new RequestOptions().CenterCrop()) .Into(bgImageView); // Actionbar & StatusBar AppCompatActivity?.SupportActionBar.SetBackgroundDrawable(new ColorDrawable(weatherView.PendingBackground)); if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { AppCompatActivity?.Window.SetStatusBarColor(Color.Argb(255, (int)(weatherView.PendingBackground.R * 0.75), (int)(weatherView.PendingBackground.G * 0.75), (int)(weatherView.PendingBackground.B * 0.75))); } // Location locationName.Text = weatherView.Location; // Date Updated updateTime.Text = weatherView.UpdateDate; // Update Current Condition weatherTemp.Text = weatherView.CurTemp; weatherCondition.Text = weatherView.CurCondition; weatherIcon.Text = weatherView.WeatherIcon; // WeatherDetails // Astronomy sunrise.Text = weatherView.Sunrise; sunset.Text = weatherView.Sunset; // Wind feelslike.Text = weatherView.WindChill; windSpeed.Text = weatherView.WindSpeed; windDirection.Rotation = weatherView.WindDirection; // Atmosphere humidity.Text = weatherView.Humidity; pressure.Text = weatherView.Pressure; pressureState.Visibility = weatherView.RisingVisiblity; pressureState.Text = weatherView.RisingIcon; visiblity.Text = weatherView._Visibility; // Add UI elements forecastAdapter.UpdateItems(weatherView.Forecasts); forecastPanel.Visibility = ViewStates.Visible; // Additional Details if (weatherView.Extras.HourlyForecast.Count >= 1) { hrforecastAdapter.UpdateItems(weatherView.Extras.HourlyForecast); hrforecastPanel.Visibility = ViewStates.Visible; } else { hrforecastPanel.Visibility = ViewStates.Gone; } if (weatherView.Extras.TextForecast.Count >= 1) { forecastSwitch.Visibility = ViewStates.Visible; (txtForecastView.Adapter as TextForecastPagerAdapter).UpdateDataset(weatherView.Extras.TextForecast.ToList()); } else { forecastSwitch.Visibility = ViewStates.Gone; } if (!String.IsNullOrWhiteSpace(weatherView.Extras.Chance)) { chance.Text = cloudiness.Text = weatherView.Extras.Chance; qpfRain.Text = weatherView.Extras.Qpf_Rain; qpfSnow.Text = weatherView.Extras.Qpf_Snow; if (!Settings.API.Equals(WeatherAPI.MetNo)) { precipitationPanel.Visibility = ViewStates.Visible; if (IsLargeTablet(AppCompatActivity)) { // Add back panel if not present var panel = (Android.Support.V7.Widget.GridLayout)detailsPanel; int childIdx = panel.IndexOfChild(panel.FindViewById(Resource.Id.precipitation_card)); if (childIdx < 0) { panel.AddView(precipitationPanel, 0); } } } else { if (IsLargeTablet(AppCompatActivity)) { var panel = (Android.Support.V7.Widget.GridLayout)detailsPanel; panel.RemoveView(panel.FindViewById(Resource.Id.precipitation_card)); } else { precipitationPanel.Visibility = ViewStates.Gone; } } if (Settings.API.Equals(WeatherAPI.OpenWeatherMap) || Settings.API.Equals(WeatherAPI.MetNo)) { chanceLabel.Visibility = ViewStates.Gone; chance.Visibility = ViewStates.Gone; cloudinessLabel.Visibility = ViewStates.Visible; cloudiness.Visibility = ViewStates.Visible; } else { chanceLabel.Visibility = ViewStates.Visible; chance.Visibility = ViewStates.Visible; cloudinessLabel.Visibility = ViewStates.Gone; cloudiness.Visibility = ViewStates.Gone; } } else { if (IsLargeTablet(AppCompatActivity)) { var panel = (Android.Support.V7.Widget.GridLayout)detailsPanel; panel.RemoveView(panel.FindViewById(Resource.Id.precipitation_card)); } else { precipitationPanel.Visibility = ViewStates.Gone; } cloudinessLabel.Visibility = ViewStates.Gone; cloudiness.Visibility = ViewStates.Gone; } // Alerts if (wm.SupportsAlerts && weatherView.Extras.Alerts.Count > 0) { if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop) { alertButton.BackgroundTintList = ColorStateList.ValueOf(Color.OrangeRed); } else { var origDrawable = ContextCompat.GetDrawable(AppCompatActivity, Resource.Drawable.light_round_corner_bg); var compatDrawable = DrawableCompat.Wrap(origDrawable); DrawableCompat.SetTint(compatDrawable, Color.OrangeRed); alertButton.Background = compatDrawable; } alertButton.Visibility = ViewStates.Visible; ResizeAlertPanel(); } else { alertButton.Visibility = ViewStates.Invisible; } // Fix DetailsLayout AdjustDetailsLayout(); // Nav Header View UpdateNavHeader(weatherView); weatherCredit.Text = weatherView.WeatherCredit; }); }