void resultCompletion(ObservableCollection <ResultJewelry> wDatas) { if (wDatas == null) { Toast.MakeText(this.Context, Resource.String.no_internet, ToastLength.Short).Show(); } else if (wDatas.Count == 0) { mAdapter.removeLoadingView(); isLoading = false; Toast.MakeText(this.Context, Resource.String.no_more_data, ToastLength.Short).Show(); } else { mAdapter.removeLoadingView(); List <ResultJewelry> mModels = new List <ResultJewelry>(wDatas); isLoading = false; if (mAdapter.ItemCount == 0) { mAdapter = new ResultJewelryAdapter(view.Context, mModels, mRecyclerView); mRecyclerView.SetAdapter(mAdapter); } else { mAdapter.addMany(mModels); mAdapter.NotifyDataSetChanged(); isLoading = false; } } }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); view = inflater.Inflate(Resource.Layout.layout_recyclerview, container, false); viewModel = new WebDataModel <ResultJewelry>(); mRecyclerView = view.FindViewById <RecyclerView>(Resource.Id.recyclerView); if (mRecyclerView != null) { mRecyclerView.HasFixedSize = true; var layoutManager = new LinearLayoutManager(Activity); var onScrollListener = new XamarinRecyclerViewOnScrollListener(layoutManager); onScrollListener.LoadMoreEvent += (object sender, EventArgs e) => { int totalItems = mRecyclerView.GetAdapter().ItemCount; loadData("AF MAN01", totalItems, (totalItems + 10), "n", false); }; mRecyclerView.AddOnScrollListener(onScrollListener); mRecyclerView.SetLayoutManager(layoutManager); List <ResultJewelry> mModels = new List <ResultJewelry>(); //ObservableCollection<ResultJewelry> wDatas = new ObservableCollection<ResultJewelry>(); //for (String movie : MOVIES) { // mModels.add(new ResultJewelryModel(movie)); //} //foreach (string movie in MOVIES) //{ // mModels.Add(new ResultJewelryModel(movie)); //} //viewModel.GetWebDataTask("http://montemagno.com/monkeys.json"); //ObservableCollection<ResultJewelry> wDatas = viewModel.wDatas; mAdapter = new ResultJewelryAdapter(view.Context, mModels, mRecyclerView); mRecyclerView.SetAdapter(mAdapter); loadData("AF MAN01", 0, 10, "n", false); } return(view); }