public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (Arguments != null) { site = Arguments.GetString("baseUrl", "http://smartreporter.altervista.org/"); } searching = false; loadedSite = "http://smartreporter.altervista.org/"; var rootView = inflater.Inflate(Resource.Layout.list_fragment, container, false); if (savedInstanceState != null) { IParcelable savedRecyclerLayoutState = (IParcelable)savedInstanceState.GetParcelable("recycler_layout"); listViewNews.GetLayoutManager().OnRestoreInstanceState(savedRecyclerLayoutState); } pbNews = rootView.FindViewById<RelativeLayout>(Resource.Id.pbNews); listViewNews = rootView.FindViewById<RecyclerView>(Resource.Id.list_news); emptyView = rootView.FindViewById<TextView>(Resource.Id.empty_view); //Setup layout manager PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(Application.Context); mLayoutManager.Orientation = LinearLayoutManager.Vertical; mLayoutManager.SetExtraLayoutSpace(GetScreenHeight(Activity)); listViewNews.SetLayoutManager(mLayoutManager); listViewNews.AddOnScrollListener(new mOnScrollListener(this)); refresher = rootView.FindViewById<SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorSchemeResources(Resource.Color.orange, Resource.Color.green, Resource.Color.blue); refresher.Refresh += (sender, e) => { pbNews.Visibility = ViewStates.Visible; load(site + "feed", true); page = 1; detecting = true; }; load(site + "feed", false); return rootView; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment var rootView = inflater.Inflate(Resource.Layout.list_fragment, container, false); pbNews = rootView.FindViewById<RelativeLayout>(Resource.Id.pbNews); listViewNews = rootView.FindViewById<RecyclerView>(Resource.Id.list_news); emptyView = rootView.FindViewById<TextView>(Resource.Id.empty_view); PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(Application.Context); mLayoutManager.Orientation = LinearLayoutManager.Vertical; mLayoutManager.SetExtraLayoutSpace(GetScreenHeight(Activity)); listViewNews.SetLayoutManager(mLayoutManager); listViewNews.SetLayoutManager(mLayoutManager); listViewNews.AddOnScrollListener(new mOnScrollListener(this)); refresher = rootView.FindViewById<SwipeRefreshLayout>(Resource.Id.refresher); refresher.SetColorSchemeResources(Resource.Color.orange, Resource.Color.green, Resource.Color.blue); refresher.Refresh+= (sender, e) => { pbNews.Visibility = ViewStates.Visible; load(site + "feed", true); page = 1; detecting = true; }; load (site+"feed",false); return rootView; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment var rootView = inflater.Inflate(Resource.Layout.favourites_fragment, container, false); listViewFav = rootView.FindViewById<RecyclerView> (Resource.Id.list_fav); pbFav = rootView.FindViewById<RelativeLayout> (Resource.Id.pbFav); noFavTV = rootView.FindViewById<TextView>(Resource.Id.no_fav_msg); //Setup layout manager PreCachingLayoutManager mLayoutManager = new PreCachingLayoutManager(Application.Context); mLayoutManager.Orientation = LinearLayoutManager.Vertical; mLayoutManager.SetExtraLayoutSpace(GetScreenHeight(Activity)); listViewFav.SetLayoutManager(mLayoutManager); var prefs = Application.Context.GetSharedPreferences ("AndroidReport",FileCreationMode.Private); JArray serializedPostList = JArray.Parse(prefs.GetString("favourites", "[]")); postList.Clear (); foreach (var serializedPost in serializedPostList) { Post obj = JsonConvert.DeserializeObject<Post>(serializedPost.ToString()); postList.Add (obj); } displayNews (); return rootView; }