Commit 8b310cf7 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Improved contact display using background preloading

parent 424bac85
No preview for this file type
......@@ -108,6 +108,7 @@
<Compile Include="LocalizedStrings.cs" />
<Compile Include="Model\AlphaKeyGroup.cs" />
<Compile Include="Model\CallLogs.cs" />
<Compile Include="Model\ContactManager.cs" />
<Compile Include="Model\ContactPictureConverter.cs" />
<Compile Include="Model\LinphoneManager.cs" />
<Compile Include="Model\SettingsManager.cs" />
......
using Microsoft.Phone.UserData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Linphone.Model
{
public class ContactManager
{
private static ContactManager _instance = new ContactManager();
public static ContactManager Instance
{
get { return _instance; }
}
private List<AlphaKeyGroup<Contact>> _contacts;
public ContactManager()
{
Microsoft.Phone.UserData.Contacts contacts = new Microsoft.Phone.UserData.Contacts();
contacts.SearchCompleted += contacts_SearchCompleted;
contacts.SearchAsync(String.Empty, FilterKind.None, "Phone Contacts");
}
private void contacts_SearchCompleted(object sender, Microsoft.Phone.UserData.ContactsSearchEventArgs e)
{
_contacts = AlphaKeyGroup<Contact>.CreateGroups(e.Results, System.Threading.Thread.CurrentThread.CurrentUICulture,
(Contact c) => { return c.DisplayName; }, true);
}
public List<AlphaKeyGroup<Contact>> GetContactsGroupedByLetters()
{
return _contacts;
}
}
}
......@@ -18,17 +18,7 @@ namespace Linphone.Views
{
InitializeComponent();
Microsoft.Phone.UserData.Contacts contacts = new Microsoft.Phone.UserData.Contacts();
contacts.SearchCompleted += contacts_SearchCompleted;
contacts.SearchAsync(String.Empty, FilterKind.None, "Phone Contacts");
}
void contacts_SearchCompleted(object sender, Microsoft.Phone.UserData.ContactsSearchEventArgs e)
{
List<AlphaKeyGroup<Contact>> dataSource = AlphaKeyGroup<Contact>.CreateGroups(e.Results, System.Threading.Thread.CurrentThread.CurrentUICulture,
(Contact c) => { return c.DisplayName; }, true);
contactsList.ItemsSource = dataSource;
contactsList.ItemsSource = ContactManager.Instance.GetContactsGroupedByLetters();
}
}
}
\ No newline at end of file
......@@ -23,6 +23,8 @@ namespace Linphone
InitializeComponent();
numpad.Address = sipAddress;
BuildLocalizedApplicationBar();
ContactManager contactManager = ContactManager.Instance; //Force creation and init of ContactManager
}
protected override void OnNavigatedTo(NavigationEventArgs e)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment