public Task <MediaFile> SaveThumbnailAsync(string path) { if (path == null) { throw new ArgumentNullException("path"); } string lookupColumn = (IsAggregate) ? ContactsContract.ContactsColumns.LookupKey : ContactsContract.RawContactsColumns.ContactId; AsyncQuery <byte[]> query = new AsyncQuery <byte[]> (this.content, c => c.GetBlob(c.GetColumnIndex(ContactsContract.CommonDataKinds.Photo.PhotoColumnId))); query.StartQuery(0, null, ContactsContract.Data.ContentUri, new[] { ContactsContract.CommonDataKinds.Photo.PhotoColumnId, ContactsContract.DataColumns.Mimetype }, lookupColumn + "=? AND " + ContactsContract.DataColumns.Mimetype + "=?", new[] { Id, ContactsContract.CommonDataKinds.Photo.ContentItemType }, null); return(query.Task.ContinueWith(t => { if (t.Result == null) { return null; } File.WriteAllBytes(path, t.Result); return new MediaFile(path, deletePathOnDispose: false); }, TaskScheduler.Default)); }
public Task<MediaFile> SaveThumbnailAsync (string path) { if (path == null) throw new ArgumentNullException ("path"); string lookupColumn = (IsAggregate) ? ContactsContract.ContactsColumns.LookupKey : ContactsContract.RawContactsColumns.ContactId; AsyncQuery<byte[]> query = new AsyncQuery<byte[]> (this.content, c => c.GetBlob (c.GetColumnIndex (ContactsContract.CommonDataKinds.Photo.PhotoColumnId))); query.StartQuery (0, null, ContactsContract.Data.ContentUri, new[] { ContactsContract.CommonDataKinds.Photo.PhotoColumnId, ContactsContract.DataColumns.Mimetype }, lookupColumn + "=? AND " + ContactsContract.DataColumns.Mimetype + "=?", new[] { Id, ContactsContract.CommonDataKinds.Photo.ContentItemType }, null); return query.Task.ContinueWith (t => { if (t.Result == null) return null; File.WriteAllBytes (path, t.Result); return new MediaFile (path, deletePathOnDispose: false); }, TaskScheduler.Default); }