예제 #1
0
        //Handles messages from messaging service after GetMoreHistory() is called
        public void MessageRecieverLimited(MessagingTask task)
        {
            if (task.Conversation.Id != viewModel.Conversation.Id)
            {
                return;
            }
            Console.WriteLine("Starting adding");
            var topMessage = Items.Count >= 2 ? Items[1] : Items.FirstOrDefault();

            Console.WriteLine(topMessage == null);
            var messages = task.Messages;

            if (messages.Count == 0 || messages[0].Conversation != viewModel.Conversation.Id)
            {
                gotAllHistory = true;
                return;
            }
            var users = task.Users;

            users[LocalUserManager.LocalUser.Username] = LocalUserManager.LocalUser;
            updatingItems = true;
            ParseMessage(messages, users, true);
            updatingItems = false;

            if (topMessage != null && !lastVisible)
            {
                MessageListView.ScrollTo(topMessage, ScrollToPosition.MakeVisible, false);
            }
            else
            {
                MessageListView.ScrollTo(Items.LastOrDefault(), ScrollToPosition.End, false);
            }
            Console.WriteLine("Stopping adding");
        }
예제 #2
0
        //Handles messages from messaging service
        public void MessageReciever(MessagingTask task)
        {
            var messages = task.MessagesDict;
            var users    = task.Users;

            users[LocalUserManager.LocalUser.Username] = LocalUserManager.LocalUser;
            if (messages.ContainsKey(viewModel.Conversation.Id))
            {
                ParseMessage(messages[viewModel.Conversation.Id], users);
            }
        }
예제 #3
0
        private void GetMoreHistory()
        {
            //Gauti daugiau jau turimų pranešimų
            var task = new MessagingTask();

            task.GetCount     = 20;
            task.Message      = (Items.Count == 0 ? null : Items.First().MessageObject);
            task.Conversation = viewModel.Conversation;
            try
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    MessagingCenter.Send(task, MessagingTask.GetMessagesLimited);
                });
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
예제 #4
0
 /// <summary>
 /// stop rendering thread
 /// </summary>
 public void Dispose()
 {
     messagingTask.Dispose();
     messagingTask = null;
 }