2020-04-16 15:44:53 +00:00
|
|
|
/*
|
2022-02-28 15:15:59 +00:00
|
|
|
* Copyright (c) 2022 Proton AG
|
2021-03-17 11:33:06 +00:00
|
|
|
*
|
2022-02-28 15:15:59 +00:00
|
|
|
* This file is part of Proton Mail.
|
2021-03-17 11:33:06 +00:00
|
|
|
*
|
2022-02-28 15:15:59 +00:00
|
|
|
* Proton Mail is free software: you can redistribute it and/or modify
|
2020-04-16 15:44:53 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2021-03-17 11:33:06 +00:00
|
|
|
*
|
2022-02-28 15:15:59 +00:00
|
|
|
* Proton Mail is distributed in the hope that it will be useful,
|
2020-04-16 15:44:53 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2021-03-17 11:33:06 +00:00
|
|
|
*
|
2020-04-16 15:44:53 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2022-02-28 15:15:59 +00:00
|
|
|
* along with Proton Mail. If not, see https://www.gnu.org/licenses/.
|
2020-04-16 15:44:53 +00:00
|
|
|
*/
|
|
|
|
package ch.protonmail.android.activities.contactDetails
|
|
|
|
|
2021-04-07 09:03:31 +00:00
|
|
|
import android.database.sqlite.SQLiteBlobTooBigException
|
2020-04-16 15:44:53 +00:00
|
|
|
import android.os.AsyncTask
|
2021-03-17 14:54:52 +00:00
|
|
|
import ch.protonmail.android.data.local.ContactDao
|
2021-03-18 09:46:25 +00:00
|
|
|
import ch.protonmail.android.data.local.model.FullContactDetails
|
2021-04-07 09:03:31 +00:00
|
|
|
import timber.log.Timber
|
2020-04-16 15:44:53 +00:00
|
|
|
|
2021-05-27 12:53:25 +00:00
|
|
|
@Deprecated("removed with the new ContactDetailsViewModel")
|
2020-11-12 16:53:02 +00:00
|
|
|
class ExtractFullContactDetailsTask(
|
2021-03-17 14:54:52 +00:00
|
|
|
private val contactDao: ContactDao,
|
2020-11-12 16:53:02 +00:00
|
|
|
private val contactId: String,
|
|
|
|
private val callback: (FullContactDetails?) -> Unit
|
|
|
|
) : AsyncTask<Void, Void, FullContactDetails>() {
|
2020-04-16 15:44:53 +00:00
|
|
|
|
2020-11-12 16:53:02 +00:00
|
|
|
override fun doInBackground(vararg voids: Void): FullContactDetails? {
|
2021-04-07 09:03:31 +00:00
|
|
|
return try {
|
2021-05-26 13:27:18 +00:00
|
|
|
contactDao.findFullContactDetailsByIdBlocking(contactId)
|
2021-04-07 09:03:31 +00:00
|
|
|
} catch (tooBigException: SQLiteBlobTooBigException) {
|
|
|
|
Timber.i(tooBigException, "Data too big to be fetched")
|
|
|
|
null
|
|
|
|
}
|
2020-11-12 16:53:02 +00:00
|
|
|
}
|
2020-04-16 15:44:53 +00:00
|
|
|
|
2020-11-12 16:53:02 +00:00
|
|
|
override fun onPostExecute(fullContactDetails: FullContactDetails?) {
|
|
|
|
callback(fullContactDetails)
|
|
|
|
}
|
2020-04-16 15:44:53 +00:00
|
|
|
}
|