Fix android.os.strictmode.LeakedClosableViolation
Test: Check log. Change-Id: I488fc6c4288bc3843a2be35a8e2988738441263e Signed-off-by: Taesu Lee <taesu82.lee@samsung.com>
This commit is contained in:
@@ -156,25 +156,33 @@ public class ContactRecipientAutoCompleteView extends RecipientEditTextView {
|
||||
ContactRecipientEntryUtils.isSendToDestinationContact(entry)) {
|
||||
// This is a generated/send-to contact chip, try to look it up and
|
||||
// display a chip for the corresponding local contact.
|
||||
final Cursor lookupResult = ContactUtil.lookupDestination(getContext(),
|
||||
entry.getDestination()).performSynchronousQuery();
|
||||
if (lookupResult != null && lookupResult.moveToNext()) {
|
||||
// Found a match, remove the generated entry and replace with
|
||||
// a better local entry.
|
||||
publishProgress(new ChipReplacementTuple(recipient,
|
||||
ContactUtil.createRecipientEntryForPhoneQuery(
|
||||
lookupResult, true)));
|
||||
} else if (PhoneUtils.isValidSmsMmsDestination(
|
||||
entry.getDestination())){
|
||||
// No match was found, but we have a valid destination so let's at
|
||||
// least create an entry that shows an avatar.
|
||||
publishProgress(new ChipReplacementTuple(recipient,
|
||||
ContactRecipientEntryUtils.constructNumberWithAvatarEntry(
|
||||
entry.getDestination())));
|
||||
} else {
|
||||
// Not a valid contact. Remove and show an error.
|
||||
publishProgress(new ChipReplacementTuple(recipient, null));
|
||||
invalidChipsRemoved++;
|
||||
try (final Cursor lookupResult =
|
||||
ContactUtil.lookupDestination(
|
||||
getContext(), entry.getDestination())
|
||||
.performSynchronousQuery()) {
|
||||
if (lookupResult != null && lookupResult.moveToNext()) {
|
||||
// Found a match, remove the generated entry and replace with a
|
||||
// better local entry.
|
||||
publishProgress(
|
||||
new ChipReplacementTuple(
|
||||
recipient,
|
||||
ContactUtil.createRecipientEntryForPhoneQuery(
|
||||
lookupResult, true)));
|
||||
} else if (PhoneUtils.isValidSmsMmsDestination(
|
||||
entry.getDestination())) {
|
||||
// No match was found, but we have a valid destination so let's
|
||||
// at least create an entry that shows an avatar.
|
||||
publishProgress(
|
||||
new ChipReplacementTuple(
|
||||
recipient,
|
||||
ContactRecipientEntryUtils
|
||||
.constructNumberWithAvatarEntry(
|
||||
entry.getDestination())));
|
||||
} else {
|
||||
// Not a valid contact. Remove and show an error.
|
||||
publishProgress(new ChipReplacementTuple(recipient, null));
|
||||
invalidChipsRemoved++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user