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

SyncAdapter support #52

Closed
zsiegel opened this issue Feb 24, 2014 · 7 comments
Closed

SyncAdapter support #52

zsiegel opened this issue Feb 24, 2014 · 7 comments

Comments

@zsiegel
Copy link

zsiegel commented Feb 24, 2014

I would love to be able to hook into the callback in Model.save() in order to tell the underlying content provider to start a sync adapter. For example the change might look like...

Sprinkles.sInstance.mContext.getContentResolver()
    .notifyChange(Utils.getNotificationUri(Model.this.getClass()), null, true);

The extra true param on the end would allow for using a SyncAdapter alongside Sprinkles.

I would be happy to implement this I'm just curious if @emilsjolander has any input on this.

Thanks

@zsiegel
Copy link
Author

zsiegel commented Feb 24, 2014

To clarify this is already possible its just not quite as integrated as I would like. I can trigger a sync by using the following code in the onSave callback.

Bundle extras = new Bundle();
extras.putBoolean(ContentResolver.SYNC_EXTRAS_UPLOAD, true);
ContentResolver.requestSync(account, AuthConstants.CONTENT_AUTHORITY, extras);

@emilsjolander
Copy link
Owner

I'm not 100% certain how the last parameter to notifyChange works but i guess it starts a sync adapter tied to the same authority as the notification uri?

@zsiegel
Copy link
Author

zsiegel commented Feb 25, 2014

That is correct. Its essentially doing the ContentResolver.requestSync(...) I am doing manually based on the notification URI.

@emilsjolander
Copy link
Owner

Ok, that means changing the last parameter to true won't do much as the notification uri is not coupled with any authority. Using the current code you could either always call Model.saveAsync(requestSyncCallback) or you could call your own requestSync() function after saving a model.

Implementing the change in the library could however also be nice. I don't really have any good suggestions on any api though because i use SyncAdapters far to seldom.

@zsiegel
Copy link
Author

zsiegel commented Feb 25, 2014

Let me work up a pull request with an updated notifyChange(...) method and then augment the sample application to see what changes may be required.

I think the only change required in the library itself is the updated notifyChange(...) method.

It will then be completely up to the user of the library to implement the SyncAdapter to their liking within their own application.

@emilsjolander
Copy link
Owner

I think this is a good idea, looking forward to a pull request!

@zsiegel
Copy link
Author

zsiegel commented Feb 26, 2014

Argh sorry i forgot to put the correct issue number in the pull request...

Duplicate #54

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

No branches or pull requests

2 participants