1
0
mirror of https://github.com/etesync/android synced 2024-12-23 15:18:14 +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) { for (Event event : events) {
try { try {
LocalEvent localEvent = localCalendar.getByUid(event.uid); LocalEvent localEvent = new LocalEvent(localCalendar, event, event.uid, null);
if (localEvent != null) { localEvent.addAsDirty();
localEvent.updateAsDirty(event); result.added++;
result.updated++;
} else {
localEvent = new LocalEvent(localCalendar, event, event.uid, null);
localEvent.addAsDirty();
result.added++;
}
} catch (CalendarStorageException e) { } catch (CalendarStorageException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -311,15 +305,9 @@ public class ImportFragment extends DialogFragment {
for (Contact contact : contacts) { for (Contact contact : contacts) {
try { try {
LocalContact localContact = (LocalContact) localAddressBook.getByUid(contact.uid); LocalContact localContact = new LocalContact(localAddressBook, contact, null, null);
if (localContact != null) { localContact.createAsDirty();
localContact.updateAsDirty(contact); result.added++;
result.updated++;
} else {
localContact = new LocalContact(localAddressBook, contact, contact.uid, null);
localContact.createAsDirty();
result.added++;
}
} catch (ContactsStorageException e) { } catch (ContactsStorageException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -248,17 +248,9 @@ public class LocalCalendarImportFragment extends ListFragment {
for (LocalEvent currentLocalEvent : localEvents) { for (LocalEvent currentLocalEvent : localEvents) {
Event event = currentLocalEvent.getEvent(); Event event = currentLocalEvent.getEvent();
try { try {
LocalEvent localEvent = event.uid == null ? null : LocalEvent localEvent = new LocalEvent(localCalendar, event, null, null);
localCalendar.getByUid(event.uid); localEvent.addAsDirty();
result.added++;
if (localEvent != null) {
localEvent.updateAsDirty(event);
result.updated++;
} else {
localEvent = new LocalEvent(localCalendar, event, event.uid, null);
localEvent.addAsDirty();
result.added++;
}
} catch (CalendarStorageException e) { } catch (CalendarStorageException e) {
e.printStackTrace(); 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() { recyclerView.setAdapter(new ImportContactAdapter(getContext(), localAddressBooks, new OnAccountSelected() {
@Override @Override
public void accountSelected(int index) { public void accountSelected(int index) {
@ -162,19 +165,12 @@ public class LocalContactImportFragment extends Fragment {
int progress = 0; int progress = 0;
for (LocalContact currentLocalContact : localContacts) { for (LocalContact currentLocalContact : localContacts) {
Contact contact = currentLocalContact.getContact(); Contact contact = currentLocalContact.getContact();
(new LocalContact(addressBook, contact, contact.uid, null)).createAsDirty(); (new LocalContact(addressBook, contact, null, null)).createAsDirty();
try { try {
LocalContact localContact = contact.uid == null ? LocalContact localContact = new LocalContact(addressBook, contact, null, null);
null : (LocalContact) addressBook.getByUid(contact.uid); localContact.createAsDirty();
if (localContact != null) { result.added++;
localContact.updateAsDirty(contact);
result.updated++;
} else {
localContact = new LocalContact(addressBook, contact, contact.uid, null);
localContact.createAsDirty();
result.added++;
}
} catch (ContactsStorageException e) { } catch (ContactsStorageException e) {
e.printStackTrace(); e.printStackTrace();
result.e = e; result.e = e;