keylist: filter results by all user ids for search (fixes #1645)

This commit is contained in:
Vincent Breitmoser
2015-12-29 00:17:13 +01:00
parent 6f74ba2f2d
commit 24ef87535f
3 changed files with 28 additions and 24 deletions

View File

@@ -305,27 +305,16 @@ public class KeyListFragment extends LoaderFragment
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
// This is called when a new Loader needs to be created. This
// sample only has one Loader, so we don't care about the ID.
Uri baseUri = KeyRings.buildUnifiedKeyRingsUri();
String where = null;
String whereArgs[] = null;
if (mQuery != null) {
String[] words = mQuery.trim().split("\\s+");
whereArgs = new String[words.length];
for (int i = 0; i < words.length; ++i) {
if (where == null) {
where = "";
} else {
where += " AND ";
}
where += KeyRings.USER_ID + " LIKE ?";
whereArgs[i] = "%" + words[i] + "%";
}
Uri uri;
if (!TextUtils.isEmpty(mQuery)) {
uri = KeyRings.buildUnifiedKeyRingsFindByUserIdUri(mQuery);
} else {
uri = KeyRings.buildUnifiedKeyRingsUri();
}
// Now create and return a CursorLoader that will take care of
// creating a Cursor for the data being displayed.
return new CursorLoader(getActivity(), baseUri,
KeyListAdapter.PROJECTION, where, whereArgs, ORDER);
return new CursorLoader(getActivity(), uri, KeyListAdapter.PROJECTION, null, null, ORDER);
}
@Override
@@ -351,8 +340,6 @@ public class KeyListFragment extends LoaderFragment
}
mAdapter.swapCursor(data);
mStickyList.setAdapter(mAdapter);
// end action mode, if any
if (mActionMode != null) {
mActionMode.finish();