public override void OnViewCreated(View view, Bundle savedInstanceState) { if (!IsInitialized) { base.OnViewCreated(view, savedInstanceState); Presenter.SourceChanged += PresenterSourceChanged; _adapter = new FeedAdapter <FeedPresenter>(Context, Presenter); _adapter.PostAction += PostAction; _adapter.AutoLinkAction += AutoLinkAction; _logo.Click += OnLogoClick; _browseButton.Click += GoToBrowseButtonClick; _toolbar.OffsetChanged += OnToolbarOffsetChanged; _scrollListner = new ScrollListener(); _scrollListner.ScrolledToBottom += LoadPosts; _refresher.Refresh += OnRefresh; _feedList.SetAdapter(_adapter); _feedList.SetLayoutManager(new LinearLayoutManager(Android.App.Application.Context)); _feedList.AddOnScrollListener(_scrollListner); _postPager.SetClipToPadding(false); _postPager.SetPadding(Style.PostPagerMargin * 2, 0, Style.PostPagerMargin * 2, 0); _postPager.PageMargin = Style.PostPagerMargin; _postPager.PageScrollStateChanged += PostPagerOnPageScrollStateChanged; _postPager.PageScrolled += PostPagerOnPageScrolled; _postPagerAdapter = new PostPagerAdapter <FeedPresenter>(_postPager, Context, Presenter); _postPagerAdapter.PostAction += PostAction; _postPagerAdapter.AutoLinkAction += AutoLinkAction; _postPagerAdapter.CloseAction += CloseAction; _postPager.Adapter = _postPagerAdapter; _postPager.SetPageTransformer(false, _postPagerAdapter, (int)LayerType.None); _emptyQueryLabel.Typeface = Style.Light; _emptyQueryLabel.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.EmptyCategory); _mainMessage.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.Greeting); _hintMessage.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.EmptyFeedHint); _browseButton.Text = AppSettings.LocalizationManager.GetText(LocalizationKeys.GoToBrowse); LoadPosts(); } var postUrl = Activity?.Intent?.GetStringExtra(CommentsFragment.ResultString); if (!string.IsNullOrWhiteSpace(postUrl)) { var count = Activity.Intent.GetIntExtra(CommentsFragment.CountString, 0); Activity.Intent.RemoveExtra(CommentsFragment.ResultString); Activity.Intent.RemoveExtra(CommentsFragment.CountString); var post = Presenter.FirstOrDefault(p => p.Url == postUrl); post.Children += count; _adapter.NotifyDataSetChanged(); } }
protected override void OnPostExecute(string result) { RssObject data = JsonConvert.DeserializeObject <RssObject>(result); //mDialog.Dismiss(); FeedAdapter adapter = new FeedAdapter(data, mainActivity); mainActivity.recyclerView.SetAdapter(adapter); adapter.NotifyDataSetChanged(); }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); recyclerView = FindViewById<RecyclerView>(Resource.Id.recyclerView1); layoutManager = new LinearLayoutManager(this); recyclerView.SetLayoutManager(layoutManager); service = new ServiceModule(); feeds = await service.GetFeeds(); feedAdapter = new FeedAdapter(feeds); feedAdapter.ItemClick += OnItemClick; recyclerView.SetAdapter(feedAdapter); }
protected async override void OnCreate(Bundle bundle) { base.OnCreate(bundle); using (var client = new HttpClient()) { var xmlFeed = await client.GetStringAsync("http://feeds.feedburner.com/wmexperts"); var doc = XDocument.Parse(xmlFeed); //XNamespace dc = "http://feeds.feedburner.com/wmexperts"; _items = (from item in doc.Descendants("item") select new RssItem { Title = item.Element("title").Value, PubDate = item.Element("pubDate").Value, //Creator = item.Element(dc + "creator").Value, Link = item.Element("link").Value }).ToArray(); ListAdapter = new FeedAdapter(this, _items); } }
public void UpdateAdapter(FeedAdapter adapter) { switch (adapter.key) { case FeedAdapterType.Title: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.Title); break; case FeedAdapterType.Link: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.Link); break; case FeedAdapterType.Description: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.Description); break; case FeedAdapterType.ContentType: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.ContentType); break; case FeedAdapterType.ContentURL: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.ContentURL); break; case FeedAdapterType.ThumbnailURL: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.ThumbnailURL); break; case FeedAdapterType.Keywords: adapter.ContentDisplay.GetComponent <IDisplay <string> >().SetContent(currentItem.Keywords); break; default: break; } }
public override void OnViewCreated(View view, Bundle savedInstanceState) { if (!IsInitialized) { base.OnViewCreated(view, savedInstanceState); Presenter.SourceChanged += PresenterSourceChanged; _adapter = new FeedAdapter <FeedPresenter>(Context, Presenter); _adapter.LikeAction += LikeAction; _adapter.UserAction += UserAction; _adapter.CommentAction += CommentAction; _adapter.VotersClick += VotersAction; _adapter.PhotoClick += FeedPhotoClick; _adapter.FlagAction += FlagAction; _adapter.HideAction += HideAction; _adapter.TagAction += TagAction; _postPagerAdapter = new PostPagerAdapter <FeedPresenter>(Context, Presenter); _postPagerAdapter.LikeAction += LikeAction; _postPagerAdapter.UserAction += UserAction; _postPagerAdapter.CommentAction += CommentAction; _postPagerAdapter.VotersClick += VotersAction; _postPagerAdapter.PhotoClick += PhotoClick; _postPagerAdapter.FlagAction += FlagAction; _postPagerAdapter.HideAction += HideAction; _postPagerAdapter.DeleteAction += DeleteAction; _postPagerAdapter.TagAction += TagAction; _postPagerAdapter.CloseAction += CloseAction; _logo.Click += OnLogoClick; _toolbar.OffsetChanged += OnToolbarOffsetChanged; _scrollListner = new ScrollListener(); _scrollListner.ScrolledToBottom += LoadPosts; _refresher.Refresh += OnRefresh; _feedList.SetAdapter(_adapter); _feedList.SetLayoutManager(new LinearLayoutManager(Android.App.Application.Context)); _feedList.AddOnScrollListener(_scrollListner); _postPager.SetClipToPadding(false); var pagePadding = (int)BitmapUtils.DpToPixel(20, Resources); _postPager.SetPadding(pagePadding, 0, pagePadding, 0); _postPager.PageMargin = pagePadding / 2; _postPager.PageScrollStateChanged += PostPagerOnPageScrollStateChanged; _postPager.PageScrolled += PostPagerOnPageScrolled; _postPager.Adapter = _postPagerAdapter; _postPager.SetPageTransformer(false, _postPagerAdapter, (int)LayerType.None); _emptyQueryLabel.Typeface = Style.Light; _emptyQueryLabel.Text = Localization.Texts.EmptyQuery; LoadPosts(); } var postUrl = Activity?.Intent?.GetStringExtra(CommentsFragment.ResultString); if (!string.IsNullOrWhiteSpace(postUrl)) { var count = Activity.Intent.GetIntExtra(CommentsFragment.CountString, 0); Activity.Intent.RemoveExtra(CommentsFragment.ResultString); Activity.Intent.RemoveExtra(CommentsFragment.CountString); var post = Presenter.FirstOrDefault(p => p.Url == postUrl); post.Children += count; _adapter.NotifyDataSetChanged(); } }