public async Task CallWebServiceForNewsGalleryList(int index) { if (!App.CheckInternetConnection()) { await DisplayAlert(AppResources.LNetworkError, AppResources.LNoInternetConnection, AppResources.LOk); } else { try { string lang = ""; if (Application.Current.Properties.ContainsKey("Language")) { lang = Application.Current.Properties["Language"] as string; } List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >(); values.Add(new KeyValuePair <string, string>("lang", lang)); values.Add(new KeyValuePair <string, string>("title", "")); values.Add(new KeyValuePair <string, string>("index", Convert.ToString(index))); if (Device.Idiom == TargetIdiom.Phone) { values.Add(new KeyValuePair <string, string>("limit", "6")); } else { values.Add(new KeyValuePair <string, string>("limit", "7")); } var response = await GeneralClass.GetResponse <CMO.ServicesClasses.RootObjectNewsGalleryList>(CMO.ServiceLayer.ServiceLinks.NewUpdates_ListURL, values); if (response != null) { if (response._resultflag == 1) { if (NewsList == null || index == 0) { NewsList = new ObservableCollection <Newslist>(); } for (int i = 0; i < response.newslist.Count; i++) { var ObjectNewslist = new Newslist(); ObjectNewslist.SetFontSize = App.GetFontSizeMedium(); ObjectNewslist.page_id = response.newslist[i].page_id; ObjectNewslist.title = response.newslist[i].title.ToUpper(); ObjectNewslist.date = response.newslist[i].date; ObjectNewslist.ipad_thumb_path = response.newslist[i].ipad_thumb_path; ObjectNewslist.large_news_photo = response.newslist[i].large_news_photo; ObjectNewslist.news_photo = response.newslist[i].news_photo; ObjectNewslist.content = response.newslist[i].content.Replace("<p>", "").Replace("</p>", "").Replace("&", "&"); #region (Text) Specific Design implemention for phone and tablet if (Device.Idiom == TargetIdiom.Phone) { ObjectNewslist.TitleWidth = new GridLength(3, GridUnitType.Star); ObjectNewslist.ImageWidth = new GridLength(2, GridUnitType.Star); //ObjectNewslist.TitleFontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)); } else if (Device.Idiom == TargetIdiom.Tablet) { ObjectNewslist.TitleWidth = new GridLength(4, GridUnitType.Star); ObjectNewslist.ImageWidth = new GridLength(2, GridUnitType.Star); // ObjectNewslist.TitleFontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); } else { ObjectNewslist.TitleWidth = new GridLength(4, GridUnitType.Star); ObjectNewslist.ImageWidth = new GridLength(2, GridUnitType.Star); //ObjectNewslist.TitleFontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); } #endregion NewsList.Add(ObjectNewslist); } totalItems = response.total_results; #region (Row Height) Specific Design implemention for phone and tablet if (Device.Idiom == TargetIdiom.Phone) { NewsGalleryLists.RowHeight = 100; } else if (Device.Idiom == TargetIdiom.Tablet) { NewsGalleryLists.RowHeight = 150; } else if (Device.Idiom == TargetIdiom.Desktop) { NewsGalleryLists.RowHeight = 3 * 100; } else { NewsGalleryLists.RowHeight = 150; } #endregion NewsGalleryLists.ItemsSource = NewsList; NewsGalleryLists.IsRefreshing = false; NewsGalleryLists.IsVisible = true; } else { if ((response._resultflag == 0) && (index == 0)) { if (App.CurrentPage() == "newsgallerylist") { await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk); } } } } else { if (App.CurrentPage() == "newsgallerylist") { await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk); } } } catch (WebException exception) { if (App.CurrentPage() == "newsgallerylist") { if (exception.Message.Contains("Network")) { await DisplayAlert(AppResources.LError, AppResources.LWebserverNotResponding, AppResources.LOk); } } } } loading.IsVisible = false; loading.IsRunning = false; loadingIndicator.IsVisible = false; NewsGalleryLists.IsRefreshing = false; }
public async Task CallWebServiceForNewsGalleryList() { loadingNewsList.IsEnabled = true; loadingNewsList.IsVisible = true; loadingNewsList.IsRunning = true; try { #region service parameters string lang = ""; if (Application.Current.Properties.ContainsKey("Language")) { lang = Application.Current.Properties["Language"] as string; } List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >(); values.Add(new KeyValuePair <string, string>("lang", lang)); values.Add(new KeyValuePair <string, string>("title", "")); values.Add(new KeyValuePair <string, string>("index", "0")); values.Add(new KeyValuePair <string, string>("limit", "4")); #endregion var response = await GeneralClass.GetResponse <CMO.ServicesClasses.RootObjectNewsGalleryList>(CMO.ServiceLayer.ServiceLinks.NewUpdates_ListURL, values); if (response != null) { if (response._resultflag == 1) { NEWSLIST = new List <Newslist>(); for (int i = 0; i < response.newslist.Count; i++) { var ObjectNewslist = new Newslist(); ObjectNewslist.SetFontSize = App.GetFontSizeMedium(); ObjectNewslist.SetFontSizeSmall = App.GetFontSizeSmall(); ObjectNewslist.title = response.newslist[i].title; ObjectNewslist.page_id = response.newslist[i].page_id; ObjectNewslist.date = response.newslist[i].date; if (Device.Idiom == TargetIdiom.Phone) { ObjectNewslist.thumb_img = response.newslist[i].thumb_img; } else { ObjectNewslist.thumb_img = response.newslist[i].ipad_thumb_path; } ObjectNewslist.news_photo = response.newslist[i].news_photo; ObjectNewslist.content = response.newslist[i].content.Replace("<p>", "").Replace("</p>", "").Replace("&", "&"); NEWSLIST.Add(ObjectNewslist); } } else { await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk); } } else { await DisplayAlert(AppResources.LError, AppResources.LSomethingWentWrong, AppResources.LOk); } } catch (WebException exception) { if (exception.Message.Contains("Network")) { await DisplayAlert(AppResources.LError, AppResources.LWebserverNotResponding, AppResources.LOk); } } }