protected override void OnStart()
 {
     base.OnStart();
     ViewModel.PropertyChanged += ViewModel_PropertyChanged;
     ViewModel.GroupChatHistoryItemList.CollectionChanged += GroupChatHistoryItemList_Changed;
     if (ViewModel.CurrentlyOpenDTO == null)
     {
         Finish();
     }
     else
     {
         if (ViewModel.GroupChatHistoryItemList.Count == 0)
         {
             LoadChatHistoryCollectionRequest model = new LoadChatHistoryCollectionRequest()
             {
                 LAST_MESSAGE_ID = -1,
                 THREAD_ID       = ViewModel.CurrentlyOpenDTO.GROUP_ID,
                 TOKEN           = MyApplication.Me.TOKEN
             };
             ViewModel.LoadGroupMessageHistoryCommand.Execute(model);
         }
         else
         {
             RunOnUiThread(() =>
             {
                 if (ViewModel.GroupChatHistoryItemList.Count > 0)
                 {
                     recyclerView.ScrollToPosition(ViewModel.GroupChatHistoryItemList.Count);
                 }
                 SetContentSupportActionBarItems();
             });
         }
     }
 }
 void LoadingMore_Refresh(object sender, EventArgs e)
 {
     if (CrossConnectivity.Current.IsConnected)
     {
         LoadChatHistoryCollectionRequest model;
         if (ViewModel.GroupChatHistoryItemList.Count > 0)
         {
             model = new LoadChatHistoryCollectionRequest()
             {
                 LAST_MESSAGE_ID = ViewModel.GroupChatHistoryItemList[0].ID,
                 THREAD_ID       = ViewModel.CurrentlyOpenDTO.GROUP_ID,
                 TOKEN           = MyApplication.Me.TOKEN
             };
         }
         else
         {
             model = new LoadChatHistoryCollectionRequest()
             {
                 LAST_MESSAGE_ID = -1,
                 THREAD_ID       = ViewModel.CurrentlyOpenDTO.GROUP_ID,
                 TOKEN           = MyApplication.Me.TOKEN
             };
         }
         ViewModel.LoadGroupMessageHistoryCommand.Execute(model);
     }
     else
     {
         DialogUtils.ShowOKDialog(this, @"Warning", @"No Internet Connection");
     }
 }
Ejemplo n.º 3
0
 protected override void OnStart()
 {
     base.OnStart();
     hideSoftKeyboard();
     ViewModel.PropertyChanged += ViewModel_PropertyChanged;
     ViewModel.PrivateChatHistoryCollection.CollectionChanged += PrivateChatHistoryItemCollection_Changed;
     //todo load past history with http here
     if (ViewModel.PrivateChatHistoryCollection.Count == 0)
     {
         LoadChatHistoryCollectionRequest model = new LoadChatHistoryCollectionRequest()
         {
             LAST_MESSAGE_ID = -1,
             THREAD_ID       = ViewModel.CurrentlyOpenDTO.EntryID,
             TOKEN           = MyApplication.Me.TOKEN
         };
         ViewModel.LoadPrivateMessageCommand.Execute(model);
     }
     else
     {
         RunOnUiThread(() =>
         {
             if (ViewModel.PrivateChatHistoryCollection.Count > 0)
             {
                 recyclerView.ScrollToPosition(ViewModel.PrivateChatHistoryCollection.Count);
             }
             txtToolbarStatus.Text = ViewModel.CurrentlyOpenDTO.OtherUserOnlineStatus ? "Online" : "Offline";
         });
     }
 }
Ejemplo n.º 4
0
        public async Task <List <ChatHistoryItemDTO> > GetLoadPrivateChatHistoryCollection(LoadChatHistoryCollectionRequest model)
        {
            using (var httpClient = GetHttpClient())
            {
                var stringContent = new List <KeyValuePair <string, string> >();
                stringContent.Add(new KeyValuePair <string, string>("TOKEN", model.TOKEN));
                stringContent.Add(new KeyValuePair <string, string>("LAST_MESSAGE_ID", $"{model.LAST_MESSAGE_ID}"));
                stringContent.Add(new KeyValuePair <string, string>("THREAD_ID", $"{model.THREAD_ID}"));

                var content = new MultipartFormDataContent();
                foreach (var keyValuePair in stringContent)
                {
                    content.Add(new StringContent(keyValuePair.Value), keyValuePair.Key);
                }
                var response = await httpClient.PostAsync(ServerURL.GetLoadPastChatHistoryURL, content);

                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string retVal = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    var responseItem = JsonConvert.DeserializeObject <CommonResponse>(retVal);
                    if (responseItem.RESULT)
                    {
                        try
                        {
                            var resultList = JsonConvert.DeserializeObject <List <ChatHistoryItemDTO> >(responseItem.MSG);
                            return(resultList);
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
            }
            return(null);
        }