-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Updated deleteAll() method to delete all searches instead of 10(#2181) #2185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2185 +/- ##
=========================================
+ Coverage 5.72% 5.77% +0.05%
=========================================
Files 231 231
Lines 11587 11604 +17
Branches 1078 1079 +1
=========================================
+ Hits 663 670 +7
- Misses 10869 10878 +9
- Partials 55 56 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'd recommend adding a null check and had a couple of tiny formatting niggles
db.delete(recentSearch.getContentUri(), null, null); | ||
Timber.d("QUERY_NAME %s - query deleted", recentSearch.getQuery()); | ||
try { | ||
cursor = db.query( RecentSearchesContentProvider.BASE_URI, Table.ALL_FIELDS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Horizontal whitespace - GSG 4.6.2
cursor = db.query( RecentSearchesContentProvider.BASE_URI, Table.ALL_FIELDS, | |
cursor = db.query(RecentSearchesContentProvider.BASE_URI, Table.ALL_FIELDS, |
It might be an idea to put each argument of db.query
on a different line so it looks like
cursor = db.query(
RecentSearchesContentProvider.BASE_URI,
Table.ALL_FIELDS,
null,
new String[]{},
Table.COLUMN_LAST_USED + " DESC"
);
} catch (RemoteException e) { | ||
throw new RuntimeException(e); | ||
} finally { | ||
cursor.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to do a null check to avoid NPE i.e. if (cursor != null) {
try { | ||
cursor = db.query( RecentSearchesContentProvider.BASE_URI, Table.ALL_FIELDS, | ||
null, new String[]{}, Table.COLUMN_LAST_USED + " DESC"); | ||
while (cursor != null && cursor.moveToNext() ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Horizontal whitespace - GSG 4.6.2
while (cursor != null && cursor.moveToNext() ) { | |
while (cursor != null && cursor.moveToNext()) { |
Test results Tested Automated tests pass Does delete all recent searches in my testing, whereas in previous version can consistently recreate situations where it doesn't, so it fixes #2181. |
Done:) |
Will merge once Travis passes. |
Tested |
Fixes #2181 Clearing recent searches only removes last 10
What changes did you make and why?
Some minor changes in deleteAll() method. Now it deletes all the searches instead of just 10.
Tested on Motorola Moto G5 plus with API level 24.