public override async void OnResume() { base.OnResume(); if (Network.State != NetworkState.Disconnected) { historyList = await MeritMoneyBrain.GetHistory(Offset, BatchSize, type); LoadingPanel.Visibility = ViewStates.Gone; } else { LoadingPanel.Visibility = ViewStates.Invisible; NoInternetText.Visibility = ViewStates.Visible; } Refresh.Refresh += History_Refresh; RecyclerViewManager = new LinearLayoutManager(this.Context); HistoryView.SetLayoutManager(RecyclerViewManager); RecyclerViewAdapter = new HistoryAdapter(historyList, this.Context, LastHistoryItemDate, users); HistoryView.SetAdapter(RecyclerViewAdapter); mScrollListener = new ScrollListener(RecyclerViewManager, historyList, type); HistoryView.AddOnScrollListener(mScrollListener); for (int i = 0; i < historyList.Count(); i++) { new CacheListItemImage(RecyclerViewAdapter, i, Application.Context).Execute(historyList[i]); } }
public override async void onLoadMore(int page, RecyclerView view) { if (history.hasMore) { HistoryList listItem = await MeritMoneyBrain.GetHistory(page *BatchSize, BatchSize, type); var previousPosition = history.Count(); var itemsAdded = listItem.Count(); history.AddList(listItem); history.hasMore = listItem.hasMore; view.GetAdapter().NotifyItemRangeInserted(previousPosition + 1, itemsAdded); for (int i = previousPosition; i < previousPosition + itemsAdded; i++) { new CacheListItemImage(view.GetAdapter(), i, Application.Context).Execute(history[i]); } } }
private async void History_Refresh(object sender, EventArgs e) { if (Network.State != NetworkState.Disconnected) { Offset = 0; var historyList = await MeritMoneyBrain.GetHistory(Offset, BatchSize, type); ISharedPreferences info = Application.Context.GetSharedPreferences(Application.Context.GetString(Resource.String.ApplicationInfo), FileCreationMode.Private); String Date = info.GetString(Application.Context.GetString(Resource.String.ModifyDate), String.Empty); LastHistoryItemDate = info.GetString(Application.Context.GetString(Resource.String.HistoryLoadedDate), "0"); RecyclerViewAdapter.AddNewList(historyList, LastHistoryItemDate); } else { Toast.MakeText(this.Context, GetString(Resource.String.NoInternet), ToastLength.Short).Show(); } Refresh.Refreshing = false; }