添加了对contact类的注释

qjy
GenshinGanyu 2 years ago
parent ebb8c9e63b
commit dbf43d2653

@ -1,4 +1,4 @@
#Fri Mar 31 15:48:56 CST 2023 #Fri Mar 31 16:49:37 CST 2023
base.0=E\:\\AdvancedMiNotes\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex base.0=D\:\\Android_projects\\app\\build\\intermediates\\dex\\debug\\mergeDexDebug\\classes.dex
renamed.0=classes.dex renamed.0=classes.dex
path.0=classes.dex path.0=classes.dex

@ -36,20 +36,23 @@ public class Contact {
+ " FROM phone_lookup" + " FROM phone_lookup"
+ " WHERE min_match = '+')"; + " WHERE min_match = '+')";
/*
* /**
* Phonenumber*/ *
*
*/
public static String getContact(Context context, String phoneNumber) { public static String getContact(Context context, String phoneNumber) {
if (sContactCache == null) { if (sContactCache == null) {
sContactCache = new HashMap<String, String>(); sContactCache = new HashMap<String, String>();
} }
// 查找HashMap中是否已有phoneNumber信息如果存在则返回phoneNumber信息
if (sContactCache.containsKey(phoneNumber)) { if (sContactCache.containsKey(phoneNumber)) {
return sContactCache.get(phoneNumber); return sContactCache.get(phoneNumber);
} }
/*
+ /**
*/ * phoneNumber
*/
String selection = CALLER_ID_SELECTION.replace("+", String selection = CALLER_ID_SELECTION.replace("+",
PhoneNumberUtils.toCallerIDMinMatch(phoneNumber)); PhoneNumberUtils.toCallerIDMinMatch(phoneNumber));
Cursor cursor = context.getContentResolver().query( Cursor cursor = context.getContentResolver().query(
@ -59,12 +62,22 @@ public class Contact {
new String[]{phoneNumber}, new String[]{phoneNumber},
null); null);
/**
* moveToFirst()
*/
if (cursor != null && cursor.moveToFirst()) { if (cursor != null && cursor.moveToFirst()) {
/**
*
*/
try { try {
String name = cursor.getString(0); String name = cursor.getString(0);
sContactCache.put(phoneNumber, name); sContactCache.put(phoneNumber, name);
return name; return name;
} catch (IndexOutOfBoundsException e) { }
/**
*
*/
catch (IndexOutOfBoundsException e) {
Log.e(TAG, " Cursor get string error " + e.toString()); Log.e(TAG, " Cursor get string error " + e.toString());
return null; return null;
} finally { } finally {

Loading…
Cancel
Save