Esempio n. 1
0
        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);
        }
Esempio n. 2
0
		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;
		}