1
0
mirror of https://github.com/etesync/android synced 2024-12-23 07:08:16 +00:00

Import: always import, don't try to find duplicates based on UID.

This was causing issues when importing from a Google account in some cases
because we were getting weird UIDs.

This was also problematic when importing from other sources that
reported weird UIDs.
This commit is contained in:
Tom Hacohen 2018-01-22 15:39:58 +00:00
parent dd96ea38d0
commit 536bef9815
3 changed files with 16 additions and 40 deletions

View File

@ -277,15 +277,9 @@ public class ImportFragment extends DialogFragment {
for (Event event : events) {
try {
LocalEvent localEvent = localCalendar.getByUid(event.uid);
if (localEvent != null) {
localEvent.updateAsDirty(event);
result.updated++;
} else {
localEvent = new LocalEvent(localCalendar, event, event.uid, null);
localEvent.addAsDirty();
result.added++;
}
LocalEvent localEvent = new LocalEvent(localCalendar, event, event.uid, null);
localEvent.addAsDirty();
result.added++;
} catch (CalendarStorageException e) {
e.printStackTrace();
}
@ -311,15 +305,9 @@ public class ImportFragment extends DialogFragment {
for (Contact contact : contacts) {
try {
LocalContact localContact = (LocalContact) localAddressBook.getByUid(contact.uid);
if (localContact != null) {
localContact.updateAsDirty(contact);
result.updated++;
} else {
localContact = new LocalContact(localAddressBook, contact, contact.uid, null);
localContact.createAsDirty();
result.added++;
}
LocalContact localContact = new LocalContact(localAddressBook, contact, null, null);
localContact.createAsDirty();
result.added++;
} catch (ContactsStorageException e) {
e.printStackTrace();
}

View File

@ -248,17 +248,9 @@ public class LocalCalendarImportFragment extends ListFragment {
for (LocalEvent currentLocalEvent : localEvents) {
Event event = currentLocalEvent.getEvent();
try {
LocalEvent localEvent = event.uid == null ? null :
localCalendar.getByUid(event.uid);
if (localEvent != null) {
localEvent.updateAsDirty(event);
result.updated++;
} else {
localEvent = new LocalEvent(localCalendar, event, event.uid, null);
localEvent.addAsDirty();
result.added++;
}
LocalEvent localEvent = new LocalEvent(localCalendar, event, null, null);
localEvent.addAsDirty();
result.added++;
} catch (CalendarStorageException e) {
e.printStackTrace();

View File

@ -108,6 +108,9 @@ public class LocalContactImportFragment extends Fragment {
}
}
cursor.close();
provider.release();
recyclerView.setAdapter(new ImportContactAdapter(getContext(), localAddressBooks, new OnAccountSelected() {
@Override
public void accountSelected(int index) {
@ -162,19 +165,12 @@ public class LocalContactImportFragment extends Fragment {
int progress = 0;
for (LocalContact currentLocalContact : localContacts) {
Contact contact = currentLocalContact.getContact();
(new LocalContact(addressBook, contact, contact.uid, null)).createAsDirty();
(new LocalContact(addressBook, contact, null, null)).createAsDirty();
try {
LocalContact localContact = contact.uid == null ?
null : (LocalContact) addressBook.getByUid(contact.uid);
if (localContact != null) {
localContact.updateAsDirty(contact);
result.updated++;
} else {
localContact = new LocalContact(addressBook, contact, contact.uid, null);
localContact.createAsDirty();
result.added++;
}
LocalContact localContact = new LocalContact(addressBook, contact, null, null);
localContact.createAsDirty();
result.added++;
} catch (ContactsStorageException e) {
e.printStackTrace();
result.e = e;