async Task <bool> GetRentals(bool forceRefresh = false) { loading = true; bool isFirst = currentPageId == 0; var newRentals = await rentals.GetRentals(currentPageId ++); hasNextPage = newRentals != null && newRentals.Last().Id != 1; if (newRentals == null) { currentPageId--; loading = false; return(false); } if (adapter == null || forceRefresh) { adapter = new RentalsAdapter(Activity); ListAdapter = adapter; } var oldCount = adapter.Count; adapter.AppendRentals(newRentals); if (!isFirst && ListView.LastVisiblePosition > oldCount - 4) { ListView.SmoothScrollByOffset(1); } lastLoadingTime = DateTime.Now; loading = false; return(true); }
async Task<bool> GetRentals (bool forceRefresh = false) { loading = true; bool isFirst = currentPageId == 0; var newRentals = await rentals.GetRentals (currentPageId++); hasNextPage = newRentals != null && newRentals.Last ().Id != 1; if (newRentals == null) { currentPageId--; loading = false; return false; } if (adapter == null || forceRefresh) { adapter = new RentalsAdapter (Activity); ListAdapter = adapter; } var oldCount = adapter.Count; adapter.AppendRentals (newRentals); if (!isFirst && ListView.LastVisiblePosition > oldCount - 4) ListView.SmoothScrollByOffset (1); lastLoadingTime = DateTime.Now; loading = false; return true; }