use of com.android.dialer.database.DialerDatabaseHelper in project android_packages_apps_Dialer by MoKee.
the class SmartDialCursorLoader method loadInBackground.
/**
* Queries the SmartDial database and loads results in background.
* @return Cursor of contacts that matches the SmartDial query.
*/
@Override
public Cursor loadInBackground() {
if (DEBUG) {
Log.v(TAG, "Load in background " + mQuery);
}
if (!PermissionsUtil.hasContactsPermissions(mContext)) {
return new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
}
/**
* Loads results from the database helper.
*/
final DialerDatabaseHelper dialerDatabaseHelper = DatabaseHelperManager.getDatabaseHelper(mContext);
final ArrayList<ContactNumber> allMatches = dialerDatabaseHelper.getLooseMatches(mQuery, mNameMatcher);
if (DEBUG) {
Log.v(TAG, "Loaded matches " + String.valueOf(allMatches.size()));
}
/**
* Constructs a cursor for the returned array of results.
*/
final MatrixCursor cursor = new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
Object[] row = new Object[PhoneQuery.PROJECTION_PRIMARY.length];
for (ContactNumber contact : allMatches) {
row[PhoneQuery.PHONE_ID] = contact.dataId;
row[PhoneQuery.PHONE_NUMBER] = contact.phoneNumber;
row[PhoneQuery.CONTACT_ID] = contact.id;
row[PhoneQuery.LOOKUP_KEY] = contact.lookupKey;
row[PhoneQuery.PHOTO_ID] = contact.photoId;
row[PhoneQuery.DISPLAY_NAME] = contact.displayName;
row[PhoneQuery.CARRIER_PRESENCE] = contact.carrierPresence;
cursor.addRow(row);
}
return cursor;
}
use of com.android.dialer.database.DialerDatabaseHelper in project android_packages_apps_Dialer by LineageOS.
the class SmartDialCursorLoader method loadInBackground.
/**
* Queries the SmartDial database and loads results in background.
*
* @return Cursor of contacts that matches the SmartDial query.
*/
@Override
public Cursor loadInBackground() {
if (DEBUG) {
LogUtil.v(TAG, "Load in background " + mQuery);
}
if (!PermissionsUtil.hasContactsReadPermissions(mContext)) {
return new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
}
/**
* Loads results from the database helper.
*/
final DialerDatabaseHelper dialerDatabaseHelper = Database.get(mContext).getDatabaseHelper(mContext);
final ArrayList<ContactNumber> allMatches = dialerDatabaseHelper.getLooseMatches(mQuery, mNameMatcher);
if (DEBUG) {
LogUtil.v(TAG, "Loaded matches " + allMatches.size());
}
/**
* Constructs a cursor for the returned array of results.
*/
final MatrixCursor cursor = new MatrixCursor(PhoneQuery.PROJECTION_PRIMARY);
Object[] row = new Object[PhoneQuery.PROJECTION_PRIMARY.length];
for (ContactNumber contact : allMatches) {
row[PhoneQuery.PHONE_ID] = contact.dataId;
row[PhoneQuery.PHONE_NUMBER] = contact.phoneNumber;
row[PhoneQuery.CONTACT_ID] = contact.id;
row[PhoneQuery.LOOKUP_KEY] = contact.lookupKey;
row[PhoneQuery.PHOTO_ID] = contact.photoId;
row[PhoneQuery.DISPLAY_NAME] = contact.displayName;
row[PhoneQuery.CARRIER_PRESENCE] = contact.carrierPresence;
cursor.addRow(row);
}
return cursor;
}
Aggregations