Ejemplo n.º 1
0
        void UpdatePosts(PullToRefreshViewModel refreshModel, StackLayout PostsContainer, PostItem message, string groupid)
        {
            if (string.Equals(message.GroupID, groupid))
            {
                Debug.WriteLine("signalr message and current group match!");
                //PostItem postwID = await App.DataDB.GetSinglePostByPostTextTitleUserIDGroupID(message.Body, message.Title, message.UserId, message.GroupID);//dont delete, sometimes azure gets delayed so calling it here gives it time
                if (message != null)
                {
                    Debug.WriteLine("Recieved PostItem, generated ID is: {0}", message.ID);

                    //add to top stack
                    Device.BeginInvokeOnMainThread(() => {
                        if (PostsContainer == null)
                        {
                            Debug.WriteLine("no posts in feed yet");
                            refreshModel.ExecuteRefreshCommand();
                        }
                        else
                        {
                            Debug.WriteLine("{0}, posts in feed", PostsContainer.Children.Count);
                            PostsContainer.Children.Insert(1, new PostItemStackLayout(message));
                        }
                    });
                }
                else
                {
                    Debug.WriteLine("Couldn't fetch PostItem from db");
                }
            }
            else
            {
                Debug.WriteLine("PostItem {0} received, does not match group id {1}", message.ID, message.GroupID);
            }
        }
Ejemplo n.º 2
0
        public CreatePostPage(PullToRefreshViewModel refresher, string title, string groupname, string groupid = null)
        {
            this.refresher       = refresher;
            this.GroupName       = groupname;
            this.groupid         = groupid;
            this.Title           = title;
            this.BackgroundColor = Color.White;

            Content = CreatePostLayout();
        }
Ejemplo n.º 3
0
 public async Task ListenForNewPosts(PullToRefreshViewModel refreshModel, StackLayout PostsContainer, string groupid)
 {
     App.ChatClient.OnMessageReceived += (sender, message) => {
         Debug.WriteLine("Post data received, processing");
         //add data to new postitemstacklayout, add to top of scrollfeed.content
         if (message is PostItem)
         {
             Debug.WriteLine("Recieved from SignalR: post by {0}, post body: {1}, in group {2}", message.Title, message.Body, message.GroupID);
             UpdatePosts(refreshModel, PostsContainer, message, groupid);
         }
     };
 }
Ejemplo n.º 4
0
        public GroupFeed(string groupname, string groupid = null)
        {
            MessagingCenter.Subscribe <PostItemStackLayout> (this, Values.NotBusy, (args) => {
                Debug.WriteLine("setting isbusy false");
                IsBusy = false;
            });
            MessagingCenter.Subscribe <PostItemStackLayout> (this, Values.Busy, (args) => {
                Debug.WriteLine("setting isbusy true");
                IsBusy = true;
            });

            ListenForRefresh();

            refreshHandler       = new PullToRefreshViewModel(this);
            BindingContext       = refreshHandler;
            this.groupid         = groupid;
            this.groupname       = groupname;
            this.BackgroundColor = Color.FromHex(Values.BACKGROUNDLIGHTSILVER);
            this.Title           = groupname;
            PopulateContent();
        }