Cleanup code, search with preceeding %
This commit is contained in:
@@ -245,7 +245,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
String whereArgs[] = null;
|
||||
if (mCurQuery != null) {
|
||||
where = KeychainContract.UserIds.USER_ID + " LIKE ?";
|
||||
whereArgs = new String[]{mCurQuery+"%"};
|
||||
whereArgs = new String[]{"%" + mCurQuery + "%"};
|
||||
}
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
// creating a Cursor for the data being displayed.
|
||||
@@ -352,7 +352,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(final Menu menu, final MenuInflater inflater) {
|
||||
|
||||
// Get the searchview
|
||||
MenuItem searchItem = menu.findItem(R.id.menu_key_list_public_search);
|
||||
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
|
||||
@@ -361,7 +360,6 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
mSearchView.setOnQueryTextListener(this);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -374,8 +372,7 @@ public class KeyListPublicFragment extends Fragment implements SearchView.OnQuer
|
||||
// Called when the action bar search text has changed. Update
|
||||
// the search filter, and restart the loader to do a new query
|
||||
// with this filter.
|
||||
String newQuery = !TextUtils.isEmpty(s) ? s : null;
|
||||
mCurQuery = newQuery;
|
||||
mCurQuery = !TextUtils.isEmpty(s) ? s : null;
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -204,22 +204,6 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
inMasterKeyList += ")";
|
||||
}
|
||||
|
||||
// if (searchString != null && searchString.trim().length() > 0) {
|
||||
// String[] chunks = searchString.trim().split(" +");
|
||||
// qb.appendWhere("(EXISTS (SELECT tmp." + UserIds._ID + " FROM " + UserIds.TABLE_NAME
|
||||
// + " AS tmp WHERE " + "tmp." + UserIds.KEY_ID + " = " + Keys.TABLE_NAME + "."
|
||||
// + Keys._ID);
|
||||
// for (int i = 0; i < chunks.length; ++i) {
|
||||
// qb.appendWhere(" AND tmp." + UserIds.USER_ID + " LIKE ");
|
||||
// qb.appendWhereEscapeString("%" + chunks[i] + "%");
|
||||
// }
|
||||
// qb.appendWhere("))");
|
||||
//
|
||||
// if (inIdList != null) {
|
||||
// qb.appendWhere(" OR (" + inIdList + ")");
|
||||
// }
|
||||
// }
|
||||
|
||||
String orderBy = UserIds.USER_ID + " ASC";
|
||||
if (inMasterKeyList != null) {
|
||||
// sort by selected master keys
|
||||
@@ -229,7 +213,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
String whereArgs[] = null;
|
||||
if (mCurQuery != null) {
|
||||
where = UserIds.USER_ID + " LIKE ?";
|
||||
whereArgs = new String[]{mCurQuery+"%"};
|
||||
whereArgs = new String[]{"%" + mCurQuery + "%"};
|
||||
}
|
||||
|
||||
// Now create and return a CursorLoader that will take care of
|
||||
@@ -274,8 +258,7 @@ public class SelectPublicKeyFragment extends ListFragmentWorkaround implements T
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable editable) {
|
||||
String newQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null;
|
||||
mCurQuery = newQuery;
|
||||
mCurQuery = !TextUtils.isEmpty(editable.toString()) ? editable.toString() : null;
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user