示例#1
0
文件: EksiDb.cs 项目: uttyc/Horizonx2
 public int SaveFavAsync(EksiEntry entry)
 {
     if (entry.Id != 0)
     {
         return(_db.Update(entry));
     }
     else
     {
         return(_db.Insert(entry));
     }
 }
示例#2
0
        private void RefreshData()
        {
            //var randomPage = new Random().Next(1, 3078);
            //var url = "https://eksisozluk.com/ogrenildiginde-ufku-iki-katina-cikaran-seyler--2593151?p=" + randomPage;
            var url = "https://eksisozluk.com/";
            var web = new HtmlWeb();
            var doc = web.Load(url);
            //var list = doc.DocumentNode.SelectNodes("//ul[@id='entry-item-list']//li").ToList();
            var topic   = doc.DocumentNode.SelectSingleNode("//div[@id='topic']");
            var headers = topic.SelectNodes("//h1[@id='title']").ToList();
            var items   = topic.SelectNodes("//ul[@id='entry-item-list']//li").ToList();
            var dates   = topic.SelectNodes("//a[@class='entry-date permalink']").ToList();
            var entries = new List <EksiEntry>();

            for (int i = 0; i < items.Count; i++)
            {
                var entry = new EksiEntry()
                {
                    Header      = headers[i].InnerText,
                    Author      = items[i].GetAttributeValue("data-author", ""),
                    Content     = items[i].InnerText,
                    Likes       = Convert.ToInt32(items[i].GetAttributeValue("data-favorite-count", "0")),
                    PublishDate = dates[i].InnerText
                };
                entries.Add(entry);
            }
            //var nodeCollection = doc.DocumentNode.SelectNodes("//div[@class='wrapper']//li");
            //CarouselView.ItemsSource = entries;



            EntriesList.RefreshCommand = new Command(() =>
            {
                //Do your stuff.
                RefreshData();
                EntriesList.IsRefreshing = false;
            });
            EntriesList.ItemsSource = entries;

            //EntriesList.ItemTemplate = new DataTemplate(typeof(EntryViewCell));
            //customCell.SetBinding(EntryViewCell.ContentThumbnailProperty, "ContentThumbnail");
            //customCell.SetBinding(EntryViewCell.LikesProperty, "Likes");
            //customCell.SetBinding(EntryViewCell.AuthorProperty, "Author");
        }
示例#3
0
        public EksiEntryView(EksiEntry entry, bool canBeFavorited)
        {
            _entry = entry;
            var btnAddToFavs = new Button {
                Text = "Favorilere Ekle", TextColor = Color.White, BackgroundColor = Color.FromRgb(129, 193, 75), CornerRadius = 50, Margin = new Thickness(5)
            };

            btnAddToFavs.Clicked += BtnAddToFavs_Clicked;
            var btnRemoveFromFavs = new Button {
                Text = "Favorilerden Çıkar", TextColor = Color.White, BackgroundColor = Color.Crimson, CornerRadius = 50, Margin = new Thickness(5)
            };

            btnRemoveFromFavs.Clicked += BtnRemoveFromFavs_Clicked;
            NavigationPage.SetBackButtonTitle(this, "Geri");

            Content = new StackLayout
            {
                Children =
                {
                    new StackLayout
                    {
                        Children =
                        {
                            new Label      {
                                Text = _entry.Header, TextColor = Color.FromRgb(129, 193, 75), FontSize = 25, Margin = new Thickness(5), FontAttributes = FontAttributes.Bold
                            },
                            new ScrollView {
                                Orientation = ScrollOrientation.Vertical,
                                Content     = new Label {
                                    Text = _entry.Content, Margin = new Thickness(5), TextColor = (Color)Application.Current.Resources["ListViewSecondaryColor"]
                                }
                            },
                            canBeFavorited ? btnAddToFavs: btnRemoveFromFavs
                        },
                    }
                },
                BackgroundColor = (Color)Application.Current.Resources["PageBackgroundColor"]
            };
        }
示例#4
0
文件: EksiDb.cs 项目: uttyc/Horizonx2
 public int DeleteFavAsync(EksiEntry entry)
 {
     return(_db.Delete(entry));
 }