protected override void Dispose(bool disposing) { LayoutManager?.Dispose(); LayoutManager = null; WeatherHourlyItemAdapter?.Dispose(); WeatherHourlyItemAdapter = null; RecyclerView = null; base.Dispose(disposing); }
protected virtual void OnBindDetailsViewHolder(WeatherDailyItemViewHolderBase viewHolder, int position, WeatherDataPointHourly[] hourly) { if (Daily == null || viewHolder == null || WeatherTools == null) { return; } var item = Daily[position]; var context = viewHolder.ItemView.Context; var sunriseText = string.Empty; if (item.Astronomy?.Sunrise != null) { sunriseText = WeatherTools.Format("{0} {1:t}", context.GetString(Resource.String.Sunrise), item.Astronomy.Sunrise.Value.ToLocalTime()); } if (viewHolder.Sunrise != null) { viewHolder.Sunrise.Text = sunriseText; viewHolder.Sunrise.Visibility = IsVisible(sunriseText); } var sunsetText = string.Empty; if (item.Astronomy?.Sunset != null) { sunsetText = WeatherTools.Format("{0} {1:t}", context.GetString(Resource.String.Sunset), item.Astronomy.Sunset.Value.ToLocalTime()); } if (viewHolder.Sunset != null) { viewHolder.Sunset.Text = sunsetText; viewHolder.Sunset.Visibility = IsVisible(sunsetText); } if (viewHolder.WeatherByHourly != null) { LayoutManager?.Dispose(); LayoutManager = new LinearLayoutManager(context, LinearLayoutManager.Horizontal, false); WeatherHourlyItemAdapter?.Dispose(); WeatherHourlyItemAdapter = new WeatherHourlyItemAdapter(hourly, _weakReferenceWeatherTools); viewHolder.WeatherByHourly.SetLayoutManager(LayoutManager); viewHolder.WeatherByHourly.SetAdapter(WeatherHourlyItemAdapter); } }