public NewSelectUserPage() { InitializeComponent(); App.appSettings.TryGetValue <bool>(App.SHOW_FREE_SMS_SETTING, out isFreeSmsOn); if (isFreeSmsOn) { hideSmsContacts = true; } else { hideSmsContacts = false; } object obj; if (PhoneApplicationService.Current.State.TryGetValue(HikeConstants.FORWARD_MSG, out obj) && obj is object[]) { object[] attachmentForwardMessage = (object[])obj; if (attachmentForwardMessage.Length == 2 && attachmentForwardMessage[0] is MyChatBubble && ((MyChatBubble)attachmentForwardMessage[0]).FileAttachment.ContentType.Contains(HikeConstants.CONTACT)) { hideSmsContacts = false; isContactShared = true; } } //case when share contact is called if (PhoneApplicationService.Current.State.ContainsKey(HikeConstants.SHARE_CONTACT)) { isContactShared = true; hideSmsContacts = true; txtChat.Visibility = Visibility.Collapsed; txtTitle.Text = AppResources.ShareContact_Txt; } /* Case when this page is called from GroupInfo page*/ if (PhoneApplicationService.Current.State.ContainsKey(HikeConstants.EXISTING_GROUP_MEMBERS)) { isGroupChat = true; TAP_MSG = AppResources.SelectUser_TapMsg_Grp_Txt; } /* Case when this page is called from create group button.*/ if (PhoneApplicationService.Current.State.ContainsKey(HikeConstants.START_NEW_GROUP)) { isGroupChat = (bool)PhoneApplicationService.Current.State[HikeConstants.START_NEW_GROUP]; TAP_MSG = AppResources.SelectUser_TapMsg_Grp_Txt; } //if (isGroupChat) // title.Text = "new group chat"; shellProgress.IsVisible = true; BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += (s, e) => { allContactsList = UsersTableUtils.getAllContactsByGroup(); }; bw.RunWorkerAsync(); bw.RunWorkerCompleted += (s, e) => { jumpList = getGroupedList(allContactsList); if (!hideSmsContacts) { if (filteredJumpList == null) { MakeFilteredJumpList(); } contactsListBox.ItemsSource = filteredJumpList; } else { contactsListBox.ItemsSource = jumpList; } shellProgress.IsVisible = false; }; initPage(); App.HikePubSubInstance.addListener(HikePubSub.GROUP_END, this); }
public void updateAddressBook_Callback(JObject patchJsonObj) { if (stopContactScanning) { stopContactScanning = false; return; } if (patchJsonObj == null) { Thread.Sleep(1000); App.MqttManagerInstance.connect(); NetworkManager.turnOffNetworkManager = false; scanningComplete(); canGoBack = true; return; } List <ContactInfo> updatedContacts = ContactUtils.contactsMap == null ? null : AccountUtils.getContactList(patchJsonObj, ContactUtils.contactsMap, true); List <ContactInfo.DelContacts> hikeIds = null; // Code to delete the removed contacts if (ContactUtils.hike_contactsMap != null && ContactUtils.hike_contactsMap.Count != 0) { hikeIds = new List <ContactInfo.DelContacts>(ContactUtils.hike_contactsMap.Count); // This loop deletes all those contacts which are removed. foreach (string id in ContactUtils.hike_contactsMap.Keys) { ContactInfo.DelContacts dCn = new ContactInfo.DelContacts(id, ContactUtils.hike_contactsMap[id][0].Msisdn); hikeIds.Add(dCn); if (App.ViewModel.ConvMap.ContainsKey(dCn.Msisdn)) // check convlist map to remove the { try { // here we are removing name so that Msisdn will be shown instead of Name App.ViewModel.ConvMap[dCn.Msisdn].ContactName = null; } catch (Exception e) { Debug.WriteLine("REFRESH CONTACTS :: Delete contact exception " + e.StackTrace); } } else // if this contact is in favourite or pending and not in convMap update this also { ConversationListObject obj; obj = App.ViewModel.GetFav(id); if (obj == null) // this msisdn is not in favs , check in pending { obj = App.ViewModel.GetPending(id); } if (obj != null) { obj.ContactName = null; } } } } if (stopContactScanning) { stopContactScanning = false; return; } if (hikeIds != null && hikeIds.Count > 0) { /* Delete ids from hike user DB */ UsersTableUtils.deleteMultipleRows(hikeIds); // this will delete all rows in HikeUser DB that are not in Addressbook. } if (updatedContacts != null && updatedContacts.Count > 0) { UsersTableUtils.updateContacts(updatedContacts); ConversationTableUtils.updateConversation(updatedContacts); } allContactsList = UsersTableUtils.getAllContactsByGroup(); App.MqttManagerInstance.connect(); NetworkManager.turnOffNetworkManager = false; Deployment.Current.Dispatcher.BeginInvoke(() => { filteredJumpList = null; jumpList = getGroupedList(allContactsList); // this logic handles the case where hide sms contacts is there and user refreshed the list if (!hideSmsContacts) { MakeFilteredJumpList(); contactsListBox.ItemsSource = filteredJumpList; } else { contactsListBox.ItemsSource = jumpList; } progressIndicator.Hide(LayoutRoot); enableAppBar(); }); canGoBack = true; }