public void Handle(DocumentUploadedEvent message) { Execute.ExecuteOnUIThread(delegate { if (message.OwnerId == this._ownerId && (this.SectionId == 0L || (long)message.Document.type == this.SectionId)) { DocumentHeader item = new DocumentHeader(message.Document, (int)this.SectionId, this._isOwnerCommunityAdmined, 0L); this.Items.Insert(item, 0); GenericCollectionViewModel <DocumentsInfo, DocumentHeader> expr_8D = this.Items; int totalCount = expr_8D.TotalCount; expr_8D.TotalCount = totalCount + 1; this.Items.NotifyChanged(); } }); }
public void GetData(GenericCollectionViewModel <List <Link>, Link> caller, int offset, int count, Action <BackendResult <List <Link>, ResultCode> > callback) { if (offset > 0) { callback(new BackendResult <List <Link>, ResultCode>() { ResultCode = ResultCode.Succeeded, ResultData = new List <Link>() }); } else { FavoritesService.Instance.GetFaveLinks(callback); } }
private void Initialize() { EventAggregator.Current.Subscribe((object)this); this._helperGetFriendsAndMutual = new AsyncHelper <BackendResult <FriendsAndMutualFriends, ResultCode> >((Action <Action <BackendResult <FriendsAndMutualFriends, ResultCode> > >)(a => UsersService.Instance.GetFriendsAndMutual(this._uid, a))); this._helperGetCurrentUserFriends = new AsyncHelper <BackendResult <List <User>, ResultCode> >((Action <Action <BackendResult <List <User>, ResultCode> > >)(a => UsersService.Instance.GetFriendsWithRequests((Action <BackendResult <AllFriendsList, ResultCode> >)(async(res) => {//omg_re async if (res.ResultCode == ResultCode.Succeeded) { FriendsCache.Instance.SetFriends(res.ResultData.friends, res.ResultData.requests); await ContactsManager.Instance.SyncContactsAsync(res.ResultData.friends); this.RequestsViewModel = res.ResultData.requests; CountersManager.Current.Counters.friends = this.RequestsViewModel.menu_counter; EventAggregator.Current.Publish((object)new CountersChanged(CountersManager.Current.Counters)); } Action <BackendResult <List <User>, ResultCode> > action = a; BackendResult <List <User>, ResultCode> backendResult = new BackendResult <List <User>, ResultCode>(); backendResult.Error = res.Error; backendResult.ResultCode = res.ResultCode; AllFriendsList resultData = res.ResultData; List <User> userList = resultData != null ? resultData.friends : (List <User>)null; backendResult.ResultData = userList; action(backendResult); })))); this._helperFriendsFromList = new AsyncHelper <BackendResult <List <User>, ResultCode> >((Action <Action <BackendResult <List <User>, ResultCode> > >)(a => UsersService.Instance.GetFriendsForList(this._lid, a))); this._allFriendsVM = new GenericCollectionViewModel <List <User>, Group <FriendHeader> >((ICollectionDataProvider <List <User>, Group <FriendHeader> >) this) { NeedCollectionCountBeforeFullyLoading = true, RecreateCollectionOnRefresh = true }; this._onlineFriendsVM = new GenericCollectionViewModel <List <User>, FriendHeader>((ICollectionDataProvider <List <User>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; this._commonFriendsVM = new GenericCollectionViewModel <List <User>, FriendHeader>((ICollectionDataProvider <List <User>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; this._friendsListVM = new GenericCollectionViewModel <List <FriendsList>, FriendHeader>((ICollectionDataProvider <List <FriendsList>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; if (this._lid != 0) { return; } this._allFriendsVM.NoContentText = CommonResources.NoContent_Friends; this._allFriendsVM.NoContentImage = "../Resources/NoContentImages/Friends.png"; }
public LikesViewModel(long ownerId, long itemId, LikeObjectType type, int knownCount) { this._ownerId = ownerId; this._itemId = itemId; this._type = type; this._allCount = knownCount; this._all = new GenericCollectionViewModel <LikesList, FriendHeader>((ICollectionDataProvider <LikesList, FriendHeader>) this); this._all.LoadCount = 60; this._all.ReloadCount = 100; this._friends = new GenericCollectionViewModel <LikesList, FriendHeader>((ICollectionDataProvider <LikesList, FriendHeader>) this); this._friends.LoadCount = 60; this._friends.ReloadCount = 100; this._shared = new GenericCollectionViewModel <LikesList, FriendHeader>((ICollectionDataProvider <LikesList, FriendHeader>) this); this._shared.LoadCount = 60; this._shared.ReloadCount = 100; }
public void GetData(GenericCollectionViewModel <VKList <Group>, SubscriptionItemHeader> caller, int offset, int count, Action <BackendResult <VKList <Group>, ResultCode> > callback) { if (this._categoryId == 0) { this.CatalogCategories.LoadData(false, false, (Action <BackendResult <GroupCatalogInfoExtended, ResultCode> >)null, false); } GroupsService.Current.GetCatalog(this._categoryId, (Action <BackendResult <VKList <Group>, ResultCode> >)(res => { if (res.ResultCode == ResultCode.CatalogIsNotAvailable || res.ResultCode == ResultCode.CatalogCategoriesAreNotAvailable) { res.ResultCode = ResultCode.Succeeded; res.ResultData = new VKList <Group>(); } callback(res); })); }
public string GetFooterTextForCount(GenericCollectionViewModel <FriendRequests, FriendRequestData> caller, int count) { if (count <= 0) { if (this._areSuggestedFriends) { return(CommonResources.NoSuggestedFriends); } return(CommonResources.NoFriendRequestsFrm); } if (!this._areSuggestedFriends) { return(UIStringFormatterHelper.FormatNumberOfSomething(count, CommonResources.OneFriendRequestFrm, CommonResources.TwoFourFriendRequestsFrm, CommonResources.FiveFriendRequestsFrm, true, null, false)); } return(UIStringFormatterHelper.FormatNumberOfSomething(count, CommonResources.SuggestedFriendOneFrm, CommonResources.SuggestedFriendTwoFrm, CommonResources.SuggestedFriendFiveFrm, true, null, false)); }
public void GetData(GenericCollectionViewModel <VKList <User>, SubscriptionItemHeader> caller, int offset, int count, Action <BackendResult <VKList <User>, ResultCode> > callback) { switch (this._mode) { case FriendsSearchMode.Default: UsersService.Instance.GetFriendsSuggestions(this._recommendationsNextFrom, count, (Action <BackendResult <VKList <User>, ResultCode> >)(e => { if (e.ResultCode == ResultCode.Succeeded) { if (e.ResultData.items.Count > 0) { Execute.ExecuteOnUIThread((Action)(() => this.ListHeaderVisibility = Visibility.Visible)); } this._recommendationsNextFrom = e.ResultData.next_from; } callback(e); })); break; case FriendsSearchMode.Register: if (this._contactsLoaded || !this._allowSendContacts) { break; } FriendsImportHelper.LoadData((IFriendsImportProvider)ContactsFriendsImportProvider.Instance, (Action <FriendsImportResponse>)(response => { VKList <User> resultData = new VKList <User>(); List <ISubscriptionItemHeader> foundUsers = response.FoundUsers; if (foundUsers.Count > 0) { Execute.ExecuteOnUIThread((Action)(() => this.ListHeaderVisibility = Visibility.Visible)); List <User> list = (List <User>)Enumerable.ToList <User>(Enumerable.Where <User>(Enumerable.Select <SubscriptionItemHeader, User>(Enumerable.OfType <SubscriptionItemHeader>((IEnumerable)foundUsers), (Func <SubscriptionItemHeader, User>)(subscriptionItem => subscriptionItem.GetUser())), (Func <User, bool>)(user => user != null))); resultData.count = list.Count; resultData.items.AddRange((IEnumerable <User>)list); } this._contactsLoaded = true; callback(new BackendResult <VKList <User>, ResultCode>(ResultCode.Succeeded, resultData)); }), (Action <ResultCode>)(resultCode => callback(new BackendResult <VKList <User>, ResultCode>(resultCode, null)))); break; } }
public string GetFooterTextForCount(GenericCollectionViewModel <WallData, IVirtualizable> caller, int count) { switch (this._mode) { case SuggestedPostponedMode.Suggested: if (count <= 0) { return(CommonResources.SuggestedPosts_NoPosts); } return(UIStringFormatterHelper.FormatNumberOfSomething(count, CommonResources.SuggestedNews_OneSuggestedPostFrm, CommonResources.SuggestedNews_TwoFourSuggestedPostsFrm, CommonResources.SuggestedNews_FiveSuggestedPostsFrm, true, null, false)); case SuggestedPostponedMode.Postponed: if (count <= 0) { return(CommonResources.PostponedNews_NoPosts); } return(UIStringFormatterHelper.FormatNumberOfSomething(count, CommonResources.PostponedNews_OnePostponedPostFrm, CommonResources.PostponedNews_TwoFourPostponedPostsFrm, CommonResources.PostponedNews_FivePostponedPostsFrm, true, null, false)); default: return(""); } }
public FavoritesViewModel() { this._photosVM = new GenericCollectionViewModel <PhotosListWithCount, AlbumPhotoHeaderFourInARow>((ICollectionDataProvider <PhotosListWithCount, AlbumPhotoHeaderFourInARow>) this) { NoContentText = CommonResources.NoContent_Favorites_Photos, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._videosVM = new GenericCollectionViewModel <VKList <VKClient.Common.Backend.DataObjects.Video>, VideoHeader>((ICollectionDataProvider <VKList <VKClient.Common.Backend.DataObjects.Video>, VideoHeader>) this) { NoContentText = CommonResources.NoContent_Favorites_Videos, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._postsVM = new GenericCollectionViewModel <WallData, IVirtualizable>((ICollectionDataProvider <WallData, IVirtualizable>) this) { NoContentText = CommonResources.NoContent_Favorites_Posts, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._usersVM = new GenericCollectionViewModel <UsersListWithCount, FriendHeader>((ICollectionDataProvider <UsersListWithCount, FriendHeader>) this) { NoContentText = CommonResources.NoContent_Favorites_Users, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._linksVM = new GenericCollectionViewModel <VKList <Link>, Link>((ICollectionDataProvider <VKList <Link>, Link>) this) { NoContentText = CommonResources.NoContent_Favorites_Links, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._productsVM = new GenericCollectionViewModel <VKList <Product>, TwoInARowItemViewModel <Product> >((ICollectionDataProvider <VKList <Product>, TwoInARowItemViewModel <Product> >) this) { NoContentText = CommonResources.NoContent_Favorites_Products, NoContentImage = "../Resources/NoContentImages/Favorites.png" }; this._photosVM.LoadCount = 40; this._photosVM.ReloadCount = 80; EventAggregator.Current.Subscribe(this); }
public string GetFooterTextForCount(GenericCollectionViewModel <List <User>, FriendHeader> caller, int count) { return(this.GetFooterTextForCountFriends(count)); }
public string GetFooterTextForCount(GenericCollectionViewModel <GroupCatalogInfoExtended, CatalogCategoryHeader> caller, int count) { return(""); }
public void GetData(GenericCollectionViewModel <GroupCatalogInfoExtended, CatalogCategoryHeader> caller, int offset, int count, Action <BackendResult <GroupCatalogInfoExtended, ResultCode> > callback) { GroupsService.Current.GetCatalogCategoriesPreview(callback); }
public string GetFooterTextForCount(GenericCollectionViewModel <VKList <Group>, SubscriptionItemHeader> caller, int count) { return(UIStringFormatterHelper.FormatNumberOfSomething(count, CommonResources.OneCommunityFrm, CommonResources.TwoFourCommunitiesFrm, CommonResources.FiveCommunitiesFrm, true, null, false)); }
public void GetData(GenericCollectionViewModel <VKList <UserOrGroupSource>, SubscriptionItemHeader> caller, int offset, int count, Action <BackendResult <VKList <UserOrGroupSource>, ResultCode> > callback) { NewsFeedService.Current.GetSuggestedSources(offset, count, true, callback); }
public void GetData(GenericCollectionViewModel <VKList <Product>, TwoInARowItemViewModel <Product> > caller, int offset, int count, Action <BackendResult <VKList <Product>, ResultCode> > callback) { FavoritesService.Instance.GetFaveProducts(this._productsCount, count, callback); }
public void GetData(GenericCollectionViewModel <UsersListWithCount, FriendHeader> caller, int offset, int count, Action <BackendResult <UsersListWithCount, ResultCode> > callback) { FavoritesService.Instance.GetFaveUsers(offset, count, callback); }
public void GetData(GenericCollectionViewModel <VKList <VKClient.Common.Backend.DataObjects.Video>, VideoHeader> caller, int offset, int count, Action <BackendResult <VKList <VKClient.Common.Backend.DataObjects.Video>, ResultCode> > callback) { FavoritesService.Instance.GetFaveVideos(offset, count, callback); }
public void GetData(GenericCollectionViewModel <List <FriendsList>, FriendHeader> caller, int offset, int count, Action <BackendResult <List <FriendsList>, ResultCode> > callback) { UsersService.Instance.GetLists(callback); }
public void GetData(GenericCollectionViewModel <List <User>, FriendHeader> caller, int offset, int count, Action <BackendResult <List <User>, ResultCode> > callback) { if (caller == this._onlineFriendsVM) { if (this.OwnFriends) { Action <BackendResult <List <User>, ResultCode> > callback1 = (Action <BackendResult <List <User>, ResultCode> >)(backendResult => { if (backendResult.ResultCode == ResultCode.Succeeded) { callback(new BackendResult <List <User>, ResultCode>(ResultCode.Succeeded) { ResultData = (List <User>)Enumerable.ToList <User>(Enumerable.Where <User>(backendResult.ResultData, (Func <User, bool>)(u => u.online == 1))) }); } else { callback(backendResult); } }); switch (this._mode) { case FriendsViewModel.Mode.Friends: { this._helperGetCurrentUserFriends.RunAction(callback1, this._getOnlineCalled); this._helperGetFriendsRequests.RunAction(callback1, this._getOnlineCalled); break; } case FriendsViewModel.Mode.Lists: this._helperFriendsFromList.RunAction(callback1, this._getOnlineCalled); break; } } else { this._helperGetFriendsAndMutual.RunAction((Action <BackendResult <FriendsAndMutualFriends, ResultCode> >)(backendResult => { if (backendResult.ResultCode == ResultCode.Succeeded) { callback(new BackendResult <List <User>, ResultCode>(ResultCode.Succeeded) { ResultData = (List <User>)Enumerable.ToList <User>(Enumerable.Where <User>(backendResult.ResultData.friends, (Func <User, bool>)(u => u.online == 1))) }); } else { callback(new BackendResult <List <User>, ResultCode>(backendResult.ResultCode)); } }), this._getOnlineCalled); } this._getOnlineCalled = true; } else { if (caller != this._commonFriendsVM) { return; } this._helperGetFriendsAndMutual.RunAction((Action <BackendResult <FriendsAndMutualFriends, ResultCode> >)(backendResult => { if (backendResult.ResultCode == ResultCode.Succeeded) { ILookup <long, User> lookup = (ILookup <long, User>)Enumerable.ToLookup <User, long>(backendResult.ResultData.friends, (Func <User, long>)(u => u.uid)); List <User> userList = new List <User>(); List <long> .Enumerator enumerator = backendResult.ResultData.mutualFriends.GetEnumerator(); try { while (enumerator.MoveNext()) { long current = enumerator.Current; User user = lookup[current].FirstOrDefault <User>(); if (user != null) { userList.Add(user); } } } finally { enumerator.Dispose(); } callback(new BackendResult <List <User>, ResultCode>(ResultCode.Succeeded) { ResultData = userList }); } else { callback(new BackendResult <List <User>, ResultCode>(backendResult.ResultCode)); } }), this._getCommonCalled); this._getCommonCalled = true; } }
private void Initialize() { EventAggregator.Current.Subscribe(this); this._helperGetFriendsAndMutual = new AsyncHelper <BackendResult <FriendsAndMutualFriends, ResultCode> >((Action <Action <BackendResult <FriendsAndMutualFriends, ResultCode> > >)(a => UsersService.Instance.GetFriendsAndMutual(this._uid, a))); this._helperGetCurrentUserFriends = new AsyncHelper <BackendResult <List <User>, ResultCode> >((Action <Action <BackendResult <List <User>, ResultCode> > >)(a => UsersService.Instance.GetFriendsAndLists((Action <BackendResult <AllFriendsList, ResultCode> >)(async res => { if (res.ResultCode == ResultCode.Succeeded) {//todo:bug FriendsCache.Instance.SetFriends(res.ResultData.items, null /*res.ResultData.requests*/); await ContactsManager.Instance.SyncContactsAsync(res.ResultData.items); //this.RequestsViewModel = res.ResultData.requests; //if (this.RequestsViewModel != null) //{//todo:bug // CountersManager.Current.Counters.friends = this.RequestsViewModel.menu_counter; // EventAggregator.Current.Publish(new CountersChanged(CountersManager.Current.Counters)); //} } BackendResult <List <User>, ResultCode> backendResult = new BackendResult <List <User>, ResultCode>(); backendResult.Error = res.Error; backendResult.ResultCode = res.ResultCode; AllFriendsList resultData = res.ResultData; //List<User> userList = resultData != null ? resultData.friends : null; //backendResult.ResultData = userList; a(backendResult); })))); // this._helperGetFriendsRequests = new AsyncHelper <BackendResult <List <User>, ResultCode> >((Action <Action <BackendResult <List <User>, ResultCode> > >)(a => UsersService.Instance.GetFriendRequests((Action <BackendResult <FriendRequestsMaterial, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { if (this.RequestsViewModel == null) { this.RequestsViewModel = new FriendRequests(); } FriendRequestsMaterial d = res.ResultData; this.RequestsViewModel.count = d.count; this.RequestsViewModel.profiles = d.profiles; foreach (FriendRequestsMaterial.FriendRequestItem f in d.items) { FriendRequest fr = new FriendRequest(); fr.message = f.message; fr.from = f.user_id; this.RequestsViewModel.requests.Add(fr); } CountersManager.Current.Counters.friends = this.RequestsViewModel.menu_counter; EventAggregator.Current.Publish(new CountersChanged(CountersManager.Current.Counters)); } BackendResult <List <User>, ResultCode> backendResult = new BackendResult <List <User>, ResultCode>(); backendResult.Error = res.Error; backendResult.ResultCode = res.ResultCode; FriendRequestsMaterial resultData = res.ResultData; a(backendResult); })))); // this._helperFriendsFromList = new AsyncHelper <BackendResult <List <User>, ResultCode> >((Action <Action <BackendResult <List <User>, ResultCode> > >)(a => UsersService.Instance.GetFriendsForList(this._lid, a))); this._allFriendsVM = new GenericCollectionViewModel <List <User>, Group <FriendHeader> >((ICollectionDataProvider <List <User>, Group <FriendHeader> >) this) { NeedCollectionCountBeforeFullyLoading = true, RecreateCollectionOnRefresh = true }; this._onlineFriendsVM = new GenericCollectionViewModel <List <User>, FriendHeader>((ICollectionDataProvider <List <User>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; this._commonFriendsVM = new GenericCollectionViewModel <List <User>, FriendHeader>((ICollectionDataProvider <List <User>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; this._friendsListVM = new GenericCollectionViewModel <List <FriendsList>, FriendHeader>((ICollectionDataProvider <List <FriendsList>, FriendHeader>) this) { NeedCollectionCountBeforeFullyLoading = true }; if (this._lid != 0L) { return; } this._allFriendsVM.NoContentText = CommonResources.NoContent_Friends; this._allFriendsVM.NoContentImage = "../Resources/NoContentImages/Friends.png"; }
public string GetFooterTextForCount(GenericCollectionViewModel <NewsFeedData, IVirtualizable> caller, int count) { return(FeedbackViewModel.GetNewsFooterText(count)); }
public void GetData(GenericCollectionViewModel <DocumentsInfo, DocumentHeader> caller, int offset, int count, Action <BackendResult <DocumentsInfo, ResultCode> > callback) { DocumentsService.Current.GetDocuments(callback, offset, count, this._ownerId, this.SectionId); }
public void GetData(GenericCollectionViewModel <PhotosListWithCount, AlbumPhotoHeaderFourInARow> caller, int offset, int count, Action <BackendResult <PhotosListWithCount, ResultCode> > callback) { FavoritesService.Instance.GetFavePhotos(offset, count, callback); }
public string GetFooterTextForCount(GenericCollectionViewModel <List <FriendsList>, FriendHeader> caller, int count) { return(FriendsViewModel.GetListsCountStr(count)); }
public void GetData(GenericCollectionViewModel <WallData, IVirtualizable> caller, int offset, int count, Action <BackendResult <WallData, ResultCode> > callback) { FavoritesService.Instance.GetFavePosts(offset, count, callback); }
public void GetData(GenericCollectionViewModel <List <User>, UserGroupHeader> caller, int offset, int count, Action <BackendResult <List <User>, ResultCode> > callback) { UsersService.Instance.GetFollowers(this._userOrGroupId, offset, callback); }
public void GetData(GenericCollectionViewModel <VKList <Link>, Link> caller, int offset, int count, Action <BackendResult <VKList <Link>, ResultCode> > callback) { FavoritesService.Instance.GetFaveLinks(offset, count, callback); }
public NewsFeedSuggestedSourcesViewModel() { this._suggestedSourcesVM = new GenericCollectionViewModel <VKList <UserOrGroupSource>, SubscriptionItemHeader>((ICollectionDataProvider <VKList <UserOrGroupSource>, SubscriptionItemHeader>) this); this._suggestedSourcesVM.LoadCount = 200; }
public void GetData(GenericCollectionViewModel <UsersListWithCount, FriendHeader> caller, int offset, int count, Action <BackendResult <UsersListWithCount, ResultCode> > callback) { PollService.Current.GetVoters(this._ownerId, this._pollId, this._answerId, offset, count, callback); }
public void GetData(GenericCollectionViewModel <WallData, IVirtualizable> caller, int offset, int count, Action <BackendResult <WallData, ResultCode> > callback) { WallService.Current.GetWall(this.OwnerId, offset, count, callback, this.ModeFilter); }