Merge "Some code refactoring"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2f1b4e2fd9
@@ -530,7 +530,7 @@ public class Index {
|
||||
|
||||
private void indexOneResource(SQLiteDatabase database, String localeStr,
|
||||
SearchIndexableResource sir) {
|
||||
if (sir.xmlResId > 0) {
|
||||
if (sir.xmlResId > SearchIndexableResources.NO_DATA_RES_ID) {
|
||||
indexFromResource(sir.context, database, localeStr,
|
||||
sir.xmlResId, sir.className, sir.iconResId, sir.rank,
|
||||
sir.intentAction, sir.intentTargetPackage, sir.intentTargetClass);
|
||||
@@ -646,14 +646,31 @@ public class Index {
|
||||
raw.key);
|
||||
}
|
||||
|
||||
private void indexFromLocalProvider(SQLiteDatabase database, String localeStr,
|
||||
SearchIndexableResource sir) {
|
||||
private Indexable.SearchIndexProvider getSearchIndexProvider(String className) {
|
||||
try {
|
||||
final Class<?> clazz = Class.forName(sir.className);
|
||||
final Class<?> clazz = Class.forName(className);
|
||||
if (Indexable.class.isAssignableFrom(clazz)) {
|
||||
final Field f = clazz.getField(FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER);
|
||||
final Indexable.SearchIndexProvider provider =
|
||||
(Indexable.SearchIndexProvider) f.get(null);
|
||||
return (Indexable.SearchIndexProvider) f.get(null);
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(LOG_TAG, "Cannot find class: " + className, e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e(LOG_TAG, "Cannot find field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(LOG_TAG,
|
||||
"Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void indexFromLocalProvider(SQLiteDatabase database, String localeStr,
|
||||
SearchIndexableResource sir) {
|
||||
final Indexable.SearchIndexProvider provider = getSearchIndexProvider(sir.className);
|
||||
if (provider == null) {
|
||||
Log.w(LOG_TAG, "Cannot find provider: " + sir.className);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<SearchIndexableRaw> rawList =
|
||||
provider.getRawDataToIndex(sir.context, sir.enabled);
|
||||
@@ -704,15 +721,6 @@ public class Index {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(LOG_TAG, "Cannot find class: " + sir.className, e);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e(LOG_TAG, "Cannot find field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e(LOG_TAG,
|
||||
"Illegal access to field '" + FIELD_NAME_SEARCH_INDEX_DATA_PROVIDER + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateOneRowWithFilteredData(SQLiteDatabase database, String locale,
|
||||
String title, String summaryOn, String summaryOff, String entries,
|
||||
|
@@ -47,7 +47,7 @@ import java.util.HashMap;
|
||||
|
||||
public final class SearchIndexableResources {
|
||||
|
||||
private static int NO_DATA_RES_ID = 0;
|
||||
public static int NO_DATA_RES_ID = 0;
|
||||
|
||||
private static final int RANK_WIFI = 1;
|
||||
private static final int RANK_BT = 2;
|
||||
|
Reference in New Issue
Block a user