mirror of
https://github.com/etesync/android
synced 2024-12-24 15:38:09 +00:00
Import: cleanup code a bit.
This should make it easier to debug null errors.
This commit is contained in:
parent
77d89f3b4b
commit
6f453faf06
@ -210,6 +210,7 @@ class ImportFragment : DialogFragment() {
|
|||||||
val result = ImportResult()
|
val result = ImportResult()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
val context = context!!
|
||||||
val importReader = InputStreamReader(inputStream)
|
val importReader = InputStreamReader(inputStream)
|
||||||
|
|
||||||
if (info.type == CollectionInfo.Type.CALENDAR) {
|
if (info.type == CollectionInfo.Type.CALENDAR) {
|
||||||
@ -226,7 +227,7 @@ class ImportFragment : DialogFragment() {
|
|||||||
|
|
||||||
finishParsingFile(events.size)
|
finishParsingFile(events.size)
|
||||||
|
|
||||||
val provider = context!!.contentResolver.acquireContentProviderClient(CalendarContract.CONTENT_URI)!!
|
val provider = context.contentResolver.acquireContentProviderClient(CalendarContract.CONTENT_URI)!!
|
||||||
val localCalendar: LocalCalendar?
|
val localCalendar: LocalCalendar?
|
||||||
try {
|
try {
|
||||||
localCalendar = LocalCalendar.findByName(account, provider, LocalCalendar.Factory, info.uid!!)
|
localCalendar = LocalCalendar.findByName(account, provider, LocalCalendar.Factory, info.uid!!)
|
||||||
@ -256,7 +257,7 @@ class ImportFragment : DialogFragment() {
|
|||||||
}
|
}
|
||||||
} else if (info.type == CollectionInfo.Type.ADDRESS_BOOK) {
|
} else if (info.type == CollectionInfo.Type.ADDRESS_BOOK) {
|
||||||
val oldUidToNewId = HashMap<String?, Long>()
|
val oldUidToNewId = HashMap<String?, Long>()
|
||||||
val downloader = ContactsSyncManager.ResourceDownloader(context!!)
|
val downloader = ContactsSyncManager.ResourceDownloader(context)
|
||||||
val contacts = Contact.fromReader(importReader, downloader)
|
val contacts = Contact.fromReader(importReader, downloader)
|
||||||
|
|
||||||
if (contacts.size == 0) {
|
if (contacts.size == 0) {
|
||||||
@ -269,8 +270,11 @@ class ImportFragment : DialogFragment() {
|
|||||||
|
|
||||||
finishParsingFile(contacts.size)
|
finishParsingFile(contacts.size)
|
||||||
|
|
||||||
val provider = context!!.contentResolver.acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI)!!
|
val provider = context.contentResolver.acquireContentProviderClient(ContactsContract.RawContacts.CONTENT_URI)!!
|
||||||
val localAddressBook = LocalAddressBook.findByUid(context!!, provider, account, info.uid!!)!!
|
val localAddressBook = LocalAddressBook.findByUid(context, provider, account, info.uid!!)
|
||||||
|
if (localAddressBook == null) {
|
||||||
|
throw FileNotFoundException("Failed to load local address book.")
|
||||||
|
}
|
||||||
|
|
||||||
for (contact in contacts.filter { contact -> !contact.group }) {
|
for (contact in contacts.filter { contact -> !contact.group }) {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user