private void SwipeRefreshLayoutOnRefresh(object sender, EventArgs e) { try { //Get Data Api MAdapter.TrendingList.Clear(); MAdapter.NotifyDataSetChanged(); MainScrollEvent.IsLoading = false; StartApiService(); } catch (Exception exception) { Console.WriteLine(exception); } }
//private void StartApiServiceWeather() //{ // if (!Methods.CheckConnectivity()) // Toast.MakeText(Context, Context.GetString(Resource.String.Lbl_CheckYourInternetConnection), ToastLength.Short)?.Show(); // else // PollyController.RunRetryPolicyFunction(new List<Func<Task>> {async () => await GetWeatherApi(), async () => await GetExchangeCurrencyApi() }); //} private async Task GetWeatherApi() { switch (AppSettings.ShowWeather) { case true when Methods.CheckConnectivity(): { GetWeatherObject respond = await ApiRequest.GetWeather(); if (respond != null) { var checkList = GlobalContext.TrendingTab.MAdapter.TrendingList.FirstOrDefault(q => q.Type == Classes.ItemType.Weather); switch (checkList) { case null: { var weather = new Classes.TrendingClass { Id = 600, Weather = respond, Type = Classes.ItemType.Weather }; GlobalContext.TrendingTab.MAdapter.TrendingList.Add(weather); GlobalContext.TrendingTab.MAdapter.TrendingList.Add(new Classes.TrendingClass { Type = Classes.ItemType.Divider }); break; } default: checkList.Weather = respond; break; } } Activity?.RunOnUiThread(() => MAdapter.NotifyDataSetChanged()); break; } } }