void setupViewPager() { pagerAdapter = new WeatherPagerAdapter(SupportFragmentManager); viewPager = (ViewPager)FindViewById(Resource.Id.viewPager); viewPager.Adapter = pagerAdapter; viewPager.CurrentItem = Settings.WeatherPage; updateBackground(); viewPager.PageSelected += (sender, e) => { Analytics.TrackPageViewEnd(pagerAdapter.GetFragmentAtPosition(viewPagerCache), WuClient.Shared.Selected); Analytics.TrackPageViewStart(pagerAdapter.GetFragmentAtPosition(viewPager.CurrentItem), childPageName(viewPager.CurrentItem), WuClient.Shared.Selected); Settings.WeatherPage = e.Position; floatingButton?.Show(); updateBackground(); }; viewPager.PageScrollStateChanged += (sender, e) => { switch (e.State) { case ViewPager.ScrollStateDragging: viewPagerCache = viewPager.CurrentItem; break; case ViewPager.ScrollStateIdle: var fragment = pagerAdapter?.GetFragmentAtPosition(viewPagerCache) as IRecyclerViewFragment; fragment?.RecyclerView?.ScrollToPosition(0); break; } }; }
void reloadData() { for (int i = 0; i < 3; i++) { var fragment = pagerAdapter.GetFragmentAtPosition(i) as IRecyclerViewFragment; fragment?.Adapter?.NotifyDataSetChanged(); } }
protected override void OnPause() { Analytics.TrackPageViewEnd(pagerAdapter.GetFragmentAtPosition(viewPager.CurrentItem), WuClient.Shared.Selected); base.OnPause(); }
void setupViewPager () { pagerAdapter = new WeatherPagerAdapter (SupportFragmentManager); viewPager = (ViewPager)FindViewById (Resource.Id.viewPager); viewPager.Adapter = pagerAdapter; viewPager.CurrentItem = Settings.WeatherPage; updateBackground (); viewPager.PageSelected += (sender, e) => { Analytics.TrackPageViewEnd (pagerAdapter.GetFragmentAtPosition (viewPagerCache), WuClient.Shared.Selected); Analytics.TrackPageViewStart (pagerAdapter.GetFragmentAtPosition (viewPager.CurrentItem), childPageName (viewPager.CurrentItem), WuClient.Shared.Selected); Settings.WeatherPage = e.Position; floatingButton?.Show (); updateBackground (); }; viewPager.PageScrollStateChanged += (sender, e) => { switch (e.State) { case ViewPager.ScrollStateDragging: viewPagerCache = viewPager.CurrentItem; break; case ViewPager.ScrollStateIdle: var fragment = pagerAdapter?.GetFragmentAtPosition (viewPagerCache) as IRecyclerViewFragment; fragment?.RecyclerView?.ScrollToPosition (0); break; } }; }