mirror of
https://github.com/etesync/android
synced 2025-01-23 14:10:54 +00:00
Fix crash with missing contact downloader when importing.
This commit is contained in:
parent
513dd21dbe
commit
3efa76579e
@ -160,7 +160,7 @@ public class ContactsSyncManager extends SyncManager {
|
||||
|
||||
protected void processSyncEntry(SyncEntry cEntry) throws IOException, ContactsStorageException, CalendarStorageException {
|
||||
InputStream is = new ByteArrayInputStream(cEntry.getContent().getBytes(Charsets.UTF_8));
|
||||
Contact.Downloader downloader = new ResourceDownloader();
|
||||
Contact.Downloader downloader = new ResourceDownloader(context);
|
||||
|
||||
Contact[] contacts = Contact.fromStream(is, Charsets.UTF_8, downloader);
|
||||
if (contacts.length == 0) {
|
||||
@ -242,7 +242,13 @@ public class ContactsSyncManager extends SyncManager {
|
||||
|
||||
// downloader helper class
|
||||
|
||||
private class ResourceDownloader implements Contact.Downloader {
|
||||
public static class ResourceDownloader implements Contact.Downloader {
|
||||
Context context;
|
||||
|
||||
public ResourceDownloader(Context context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] download(String url, String accepts) {
|
||||
HttpUrl httpUrl = HttpUrl.parse(url);
|
||||
|
@ -25,6 +25,7 @@ import com.etesync.syncadapter.resource.LocalAddressBook;
|
||||
import com.etesync.syncadapter.resource.LocalCalendar;
|
||||
import com.etesync.syncadapter.resource.LocalContact;
|
||||
import com.etesync.syncadapter.resource.LocalEvent;
|
||||
import com.etesync.syncadapter.syncadapter.ContactsSyncManager;
|
||||
import com.etesync.syncadapter.ui.Refreshable;
|
||||
|
||||
import org.apache.commons.codec.Charsets;
|
||||
@ -288,7 +289,8 @@ public class ImportFragment extends DialogFragment {
|
||||
}
|
||||
} else if (info.type.equals(CollectionInfo.Type.ADDRESS_BOOK)) {
|
||||
// FIXME: Handle groups and download icon?
|
||||
final Contact[] contacts = Contact.fromStream(importStream, Charsets.UTF_8, null);
|
||||
Contact.Downloader downloader = new ContactsSyncManager.ResourceDownloader(getContext());
|
||||
final Contact[] contacts = Contact.fromStream(importStream, Charsets.UTF_8, downloader);
|
||||
|
||||
if (contacts.length == 0) {
|
||||
App.log.warning("Empty/invalid file.");
|
||||
|
Loading…
Reference in New Issue
Block a user