mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
replace getColumnIndex with getColumnIndexOrThrow
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
parent
ae61d707d0
commit
a5e9b8d91f
@ -209,7 +209,7 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
if (cursor != null) {
|
if (cursor != null) {
|
||||||
if (cursor.moveToFirst()) {
|
if (cursor.moveToFirst()) {
|
||||||
// userId @ server
|
// userId @ server
|
||||||
userId = cursor.getString(cursor.getColumnIndex(ContactsContract.Data.DATA1))
|
userId = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Data.DATA1))
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
|
@ -1382,7 +1382,7 @@ class ChatController(args: Bundle) :
|
|||||||
val cursor: Cursor? = activity?.contentResolver!!.query(contactUri, null, null, null, null)
|
val cursor: Cursor? = activity?.contentResolver!!.query(contactUri, null, null, null, null)
|
||||||
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
val id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID))
|
val id = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID))
|
||||||
val fileName = ContactUtils.getDisplayNameFromDeviceContact(context!!, id) + ".vcf"
|
val fileName = ContactUtils.getDisplayNameFromDeviceContact(context!!, id) + ".vcf"
|
||||||
val file = File(context?.cacheDir, fileName)
|
val file = File(context?.cacheDir, fileName)
|
||||||
writeContactToVcfFile(cursor, file)
|
writeContactToVcfFile(cursor, file)
|
||||||
@ -1427,7 +1427,7 @@ class ChatController(args: Bundle) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun writeContactToVcfFile(cursor: Cursor, file: File) {
|
private fun writeContactToVcfFile(cursor: Cursor, file: File) {
|
||||||
val lookupKey = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY))
|
val lookupKey = cursor.getString(cursor.getColumnIndexOrThrow(ContactsContract.Contacts.LOOKUP_KEY))
|
||||||
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
|
val uri = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_VCARD_URI, lookupKey)
|
||||||
|
|
||||||
val fd: AssetFileDescriptor = activity?.contentResolver!!.openAssetFileDescriptor(uri, "r")!!
|
val fd: AssetFileDescriptor = activity?.contentResolver!!.openAssetFileDescriptor(uri, "r")!!
|
||||||
|
@ -175,9 +175,11 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
if (contactCursor.count > 0) {
|
if (contactCursor.count > 0) {
|
||||||
contactCursor.moveToFirst()
|
contactCursor.moveToFirst()
|
||||||
for (i in 0 until contactCursor.count) {
|
for (i in 0 until contactCursor.count) {
|
||||||
val id = contactCursor.getString(contactCursor.getColumnIndex(ContactsContract.Contacts._ID))
|
val id = contactCursor.getString(contactCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID))
|
||||||
val lookup =
|
val lookup =
|
||||||
contactCursor.getString(contactCursor.getColumnIndex(ContactsContract.Contacts.LOOKUP_KEY))
|
contactCursor.getString(
|
||||||
|
contactCursor.getColumnIndexOrThrow(ContactsContract.Contacts.LOOKUP_KEY)
|
||||||
|
)
|
||||||
deviceContactsWithNumbers[lookup] = getPhoneNumbersFromDeviceContact(id)
|
deviceContactsWithNumbers[lookup] = getPhoneNumbersFromDeviceContact(id)
|
||||||
contactCursor.moveToNext()
|
contactCursor.moveToNext()
|
||||||
}
|
}
|
||||||
@ -228,13 +230,16 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
if (rawContactsCursor.count > 0) {
|
if (rawContactsCursor.count > 0) {
|
||||||
while (rawContactsCursor.moveToNext()) {
|
while (rawContactsCursor.moveToNext()) {
|
||||||
val lookupKey =
|
val lookupKey =
|
||||||
rawContactsCursor.getString(rawContactsCursor.getColumnIndex(ContactsContract.Data.LOOKUP_KEY))
|
rawContactsCursor.getString(
|
||||||
val contactId =
|
rawContactsCursor.getColumnIndexOrThrow(ContactsContract.Data.LOOKUP_KEY)
|
||||||
rawContactsCursor.getString(rawContactsCursor.getColumnIndex(ContactsContract.Data.CONTACT_ID))
|
|
||||||
|
|
||||||
if (contactsWithAssociatedPhoneNumbers == null || !contactsWithAssociatedPhoneNumbers.containsKey(
|
|
||||||
lookupKey
|
|
||||||
)
|
)
|
||||||
|
val contactId =
|
||||||
|
rawContactsCursor.getString(
|
||||||
|
rawContactsCursor.getColumnIndexOrThrow(ContactsContract.Data.CONTACT_ID)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (contactsWithAssociatedPhoneNumbers == null ||
|
||||||
|
!contactsWithAssociatedPhoneNumbers.containsKey(lookupKey)
|
||||||
) {
|
) {
|
||||||
deleteLinkedAccount(contactId)
|
deleteLinkedAccount(contactId)
|
||||||
}
|
}
|
||||||
@ -302,7 +307,7 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
if (contactCursor.count > 0) {
|
if (contactCursor.count > 0) {
|
||||||
contactCursor.moveToFirst()
|
contactCursor.moveToFirst()
|
||||||
|
|
||||||
val id = contactCursor.getString(contactCursor.getColumnIndex(ContactsContract.Contacts._ID))
|
val id = contactCursor.getString(contactCursor.getColumnIndexOrThrow(ContactsContract.Contacts._ID))
|
||||||
if (hasLinkedAccount(id)) {
|
if (hasLinkedAccount(id)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -416,7 +421,7 @@ class ContactAddressBookWorker(val context: Context, workerParameters: WorkerPar
|
|||||||
while (phonesNumbersCursor.moveToNext()) {
|
while (phonesNumbersCursor.moveToNext()) {
|
||||||
numbers.add(
|
numbers.add(
|
||||||
phonesNumbersCursor.getString(
|
phonesNumbersCursor.getString(
|
||||||
phonesNumbersCursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)
|
phonesNumbersCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ object ContactUtils {
|
|||||||
while (nameCursor.moveToNext()) {
|
while (nameCursor.moveToNext()) {
|
||||||
displayName =
|
displayName =
|
||||||
nameCursor.getString(
|
nameCursor.getString(
|
||||||
nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME)
|
nameCursor.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
nameCursor.close()
|
nameCursor.close()
|
||||||
|
@ -36,7 +36,7 @@ class UriUtils {
|
|||||||
val cursor: Cursor? = context.contentResolver.query(uri, null, null, null, null)
|
val cursor: Cursor? = context.contentResolver.query(uri, null, null, null, null)
|
||||||
try {
|
try {
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
filename = cursor.getString(cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME))
|
filename = cursor.getString(cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME))
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
cursor?.close()
|
cursor?.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user