/// <summary> /// Подгружает следующую порцию элементов. /// </summary> /// <param name="count">Количество элементов, которое необходимо подгрузить.</param> public IAsyncOperation <LoadMoreItemsResult> LoadMoreItemsAsync(uint count) { return(Task.Run(async() => { HasMoreItems = false; State = ContentState.Loading; uint resultCount = 0; if (count < 10) { count = 50; } else if (count > 6000) { count = 6000; } var request = new GetFriendsRequest() { Count = count, Offset = _count, UserID = _userID }; var response = await request.ExecuteAsync(); await CoreHelper.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { if (response.Error.ErrorType == VKErrors.None) { _totalCount = response.Response.Count; resultCount = (uint)response.Response.Items.Count; for (int i = 0; i < response.Response.Items.Count; i++) { Add(response.Response.Items[i]); } _count += count; if (Count > 0) { State = ContentState.Normal; HasMoreItems = _count < _totalCount; } else { State = ContentState.NoData; } } else { State = ContentState.Error; } }); return new LoadMoreItemsResult { Count = resultCount }; }).AsAsyncOperation()); }
public async Task <List <FriendInfo> > GetFriendsAsync(string socialNetwork, ApiOptions options = null) { if (string.IsNullOrWhiteSpace(socialNetwork) == true) { throw new AppacitiveRuntimeException("Social network cannot be null or empty."); } var request = new GetFriendsRequest { UserId = this.Id, SocialNetwork = socialNetwork }; ApiOptions.Apply(request, options); var response = await request.ExecuteAsync(); if (response.Status.IsSuccessful == false) { throw response.Status.ToFault(); } return(response.Friends); }
public async Task<List<FriendInfo>> GetFriendsAsync(string socialNetwork, ApiOptions options = null) { if (string.IsNullOrWhiteSpace(socialNetwork) == true) throw new AppacitiveRuntimeException("Social network cannot be null or empty."); var request = new GetFriendsRequest { UserId = this.Id, SocialNetwork = socialNetwork }; ApiOptions.Apply(request, options); var response = await request.ExecuteAsync(); if (response.Status.IsSuccessful == false) throw response.Status.ToFault(); return response.Friends; }