-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add helper contentObservable for contentObserver #145
Conversation
f45cc93
to
fc6bb1b
Compare
static Observable<Uri> fromContentObserver(final ContentResolver contentResolver, | ||
final Uri uri, final Handler schedulerHandler) { | ||
if (SDK_INT < 16) { | ||
return Observable.error(new UnsupportedOperationException()); |
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.
Just throw
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 reminder.
fc6bb1b
to
c135e0e
Compare
This would need a test. Not sure how to do it with Robolectric, but with an integration test you can extend |
*/ | ||
static Observable<Uri> fromContentObserver(final ContentResolver contentResolver, | ||
final Uri uri, final Handler schedulerHandler) { | ||
if (SDK_INT < 16) { |
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.
Can you use Build.VERSION_CODES.JELLY_BEAN
instead of 16
?
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.
Saw this too, but doesn't this project build with 4.0 because it's not an Android module?
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.
Meh, you're right. That's annoying. I guess this could be reversed to SDK_INT > VERSION_CODES.ICE_CREAM_SANDWICH_MR1
, not sure if that feels weird though.
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.
There's a 4.1.1.4 in Maven Central that can be used to get JELLY_BEAN
ShadowContentObserver#dispatchChange might be a good place to look for tests. |
Yeah, but Robolectric :( |
An improved version here wuman@c85d2ff. Didn't want to send a separate pull request because it's largely based on this PR. Improvements include:
@HTChang Feel free to incorporate my changes as you see fit. |
c135e0e
to
f7f3b2e
Compare
@wuman thanks, already modified my code per your suggestion! |
Damn, I just needed this too and implemented it when I saw this PR.. But, I have an addition:
From Javadoc:
|
This has been removed as part of #172 for a future release. Consider building on SqlBrite's ability to query a content resolver (not that I'm biased...). |
Add an helper function
that makes the ContentObserver as an Observable