Skip to content
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

Added support for sync adapter access. #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

pepijntb
Copy link

@pepijntb pepijntb commented Oct 8, 2014

This adds support for sync adapters so that syncToNetwork (in getContentResolver().notifyChange) will default to true but when coming from sync adapter is becomes false by using makeUriFromSyncAdapter.

@bhurling
Copy link
Contributor

Could you please provide a short example on how you would use this feature in your app? I suspect makeUriFromSyncAdapter() should be public and static, right? Or do you call that method from the subclass only?

@pepijntb
Copy link
Author

You are right. It should be public static! And you would use it by updateing, deleting and creating from the syncadapter with the uri passed through makeUriFromSyncAdapter.

@ChristianKatzmann
Copy link
Member

The test failures seem related to this PR. Uri#getQueryParameter can return null ( http://developer.android.com/reference/android/net/Uri.html#getQueryParameter(java.lang.String) ), so please add an null-check.

Please check locally with ./gradlew check that all tests are green.

@@ -142,7 +148,7 @@ public Uri insert(Uri uri, ContentValues values) {
long rowId = mDatabase.insert(segments.get(0), null, values);

if (rowId > -1) {
getContentResolver().notifyChange(uri, null);
getContentResolver().notifyChange(uri, null, !uri.getQueryParameter(QUERY_CALLER_IS_SYNC_ADAPTER).equals(PARAM_TRUE));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add null-check here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants