private BrowserParts getBrowserParts(final Context context,
final String account, final PendingInvalidation invalidation,
final SyncResult syncResult, final Semaphore semaphore) {
return new EmptyBrowserParts() {
@Override
public void finishNativeInitialization() {
// Startup succeeded, so we can notify the invalidation.
notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
invalidation.mVersion, invalidation.mPayload);
semaphore.release();
}
@Override
public void onStartupFailure() {
// The startup failed, so we defer the invalidation.
DelayedInvalidationsController.getInstance().addPendingInvalidation(
context, account, invalidation);
// Using numIoExceptions so Android will treat this as a soft error.
syncResult.stats.numIoExceptions++;
semaphore.release();
}
};
}
java类android.content.SyncResult的实例源码
ChromeBrowserSyncAdapter.java 文件源码
项目:chromium-for-android-56-debug-video
阅读 30
收藏 0
点赞 0
评论 0
LoginActivity.java 文件源码
项目:odoo-work
阅读 38
收藏 0
点赞 0
评论 0
private void getUserData(final OUser user) {
progressDialog.setMessage(getString(R.string.msg_setting_your_account));
new AsyncTask<Void, Void, Void>() {
@Override
protected Void doInBackground(Void... voids) {
registerForFCM(user);
ProjectTeams teams = new ProjectTeams(LoginActivity.this);
SyncAdapter adapter = teams.getSyncAdapter();
SyncResult result = adapter.syncModelData();
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
progressDialog.dismiss();
startSplashScreen();
}
}.execute();
}
SyncAdapter.java 文件源码
项目:odoo-work
阅读 40
收藏 0
点赞 0
评论 0
private void deleteFromLocal(OModel model, HashSet<Integer> checkIds, SyncResult syncResult) {
ODomain domain = new ODomain();
domain.add("id", "in", new ArrayList<>(checkIds));
OdooResult result = odoo.searchRead(model.getModelName(), new OdooFields("id"), domain, 0, 0, null);
if (result == null) {
Log.e(TAG, "FATAL : Request aborted.");
return;
}
if (result.containsKey("error")) {
Log.e(TAG, result.get("error") + "");
return;
}
HashSet<Integer> serverIds = new HashSet<>();
for (OdooRecord record : result.getRecords()) {
serverIds.add(record.getDouble("id").intValue());
}
checkIds.removeAll(serverIds);
int deleted = model.deleteAll(new ArrayList<>(checkIds));
if (syncResult != null) syncResult.stats.numDeletes += deleted;
}
SyncAdapter.java 文件源码
项目:odoo-work
阅读 42
收藏 0
点赞 0
评论 0
private void deleteFromServer(OModel model, SyncResult syncResult) {
LocalRecordState recordState = new LocalRecordState(mContext);
List<Integer> ids = recordState.getServerIds(model.getModelName());
if (!ids.isEmpty()) {
OdooResult result = odoo.unlinkRecord(model.getModelName(), ids);
if (result == null) {
Log.e(TAG, "FATAL : Request aborted.");
return;
}
if (result.containsKey("error")) {
Log.e(TAG, result.get("error") + "");
return;
}
if (result.getBoolean("result")) {
syncResult.stats.numSkippedEntries += ids.size();
recordState.delete("server_id in (" + TextUtils.join(", ", ids) + ") and model = ?", model.getModelName());
}
}
}
ForceSyncNowAction.java 文件源码
项目:iosched-reader
阅读 33
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
ConferenceDataHandler.resetDataTimestamp(context);
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}
TvGuideSyncAdapter.java 文件源码
项目:TVGuide
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
if ( Utility.isNotDuplicateSync(getContext())) {
if (BuildConfig.DEBUG) Log.d(LOG_TAG,"Start sync!");
sendSyncStatus(START_SYNC);
final TvService service = TvApiClient.getClient().create(TvService.class);
syncCategories(service, provider, syncResult);
syncChannels(service, provider, syncResult);
syncPrograms(service, provider, syncResult);
notifyTvGuide(syncResult.stats.numInserts, syncResult.stats.numIoExceptions);
prefHelper.setLastSyncTime(getContext().getString(R.string.pref_last_sync_time_key),
System.currentTimeMillis());
prefHelper.setFirstRun(getContext().getString(R.string.pref_fist_run_key),false);
sendSyncStatus(END_SYNC);
if (BuildConfig.DEBUG) Log.d(LOG_TAG,"End sync!");
}
}
BaseSyncAdapter.java 文件源码
项目:EasyAppleSyncAdapter
阅读 40
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider,
SyncResult syncResult) {
// required for dav4android (ServiceLoader)
Thread.currentThread().setContextClassLoader(getContext().getClassLoader());
try {
syncLocalAndRemoteCollections(account, provider);
syncCalendarsEvents(account, provider, extras);
// notify any registered caller that sync operation is finished
getContext().getContentResolver().notifyChange(GlobalConstant.CONTENT_URI, null, false);
} catch (InvalidAccountException | CalendarStorageException e) {
e.printStackTrace();
}
}
SyncAdapter.java 文件源码
项目:simplest-sync-adapter
阅读 39
收藏 0
点赞 0
评论 0
/**
* Called by the Android system in response to a request to run the sync adapter. The work
* required to read data from the network, parse it, and store it in the content provider
* should be done here. Extending AbstractThreadedSyncAdapter ensures that all methods within SyncAdapter
* run on a background thread. For this reason, blocking I/O and other long-running tasks can be
* run <em>in situ</em>, and you don't have to set up a separate thread for them.
*
* <p>
* <p>This is where we actually perform any work required to perform a sync.
* {@link AbstractThreadedSyncAdapter} guarantees that this will be called on a non-UI thread,
* so it is safe to perform blocking I/O here.
* <p>
*
* <p>The syncResult argument allows you to pass information back to the method that triggered
* the sync.
*/
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
// Your code to sync data
// between mobile database and
// the server goes here.
for (int i = 0; i < 15; i++) {
try {
Thread.sleep(1000);
Log.i(TAG, ">>>> sleeping the thread: " + (i + 1));
} catch (InterruptedException e) {
e.printStackTrace();
}
} // end for
// write DB data sanity checks at the end.
}
ForceSyncNowAction.java 文件源码
项目:smconf-android
阅读 31
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
ConferenceDataHandler.resetDataTimestamp(context);
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}
SyncAdapter.java 文件源码
项目:odoo-follow-up
阅读 48
收藏 0
点赞 0
评论 0
private void deleteFromLocal(OModel model, HashSet<Integer> checkIds, SyncResult syncResult) {
ODomain domain = new ODomain();
domain.add("id", "in", new ArrayList<>(checkIds));
OdooResult result = odoo.searchRead(model.getModelName(), new OdooFields("id"), domain, 0, 0, null);
if (result == null) {
Log.e(TAG, "FATAL : Request aborted.");
return;
}
if (result.containsKey("error")) {
Log.e(TAG, result.get("error") + "");
return;
}
HashSet<Integer> serverIds = new HashSet<>();
for (OdooRecord record : result.getRecords()) {
serverIds.add(record.getDouble("id").intValue());
}
checkIds.removeAll(serverIds);
int deleted = model.deleteAll(new ArrayList<>(checkIds));
if (syncResult != null) syncResult.stats.numDeletes += deleted;
}
SyncAdapter.java 文件源码
项目:odoo-follow-up
阅读 41
收藏 0
点赞 0
评论 0
private void deleteFromServer(OModel model, SyncResult syncResult) {
LocalRecordState recordState = new LocalRecordState(mContext);
List<Integer> ids = recordState.getServerIds(model.getModelName());
if (!ids.isEmpty()) {
OdooResult result = odoo.unlinkRecord(model.getModelName(), ids);
if (result == null) {
Log.e(TAG, "FATAL : Request aborted.");
return;
}
if (result.containsKey("error")) {
Log.e(TAG, result.get("error") + "");
return;
}
if (result.getBoolean("result")) {
syncResult.stats.numSkippedEntries += ids.size();
recordState.delete("server_id in (" + TextUtils.join(", ", ids) + ") and model = ?", model.getModelName());
}
}
}
SyncAdapter.java 文件源码
项目:gito-github-client
阅读 47
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority,
ContentProviderClient provider, SyncResult syncResult) {
String key = "onPerformSync";
final GithubRemoteDataSource githubRepository =
GithubRepository.Injection.provideRemoteDataSource(getContext());
githubRepository.getUserSync();
Cursor cursor = getContext().getContentResolver().query(RepositoryContract
.RepositoryEntry.CONTENT_URI_REPOSITORY_STARGAZERS,
RepositoryContract.RepositoryEntry.REPOSITORY_COLUMNS_WITH_ADDITIONAL_INFO,
null, null, null);
boolean forceSync = cursor == null || !cursor.moveToFirst();
if (cursor != null) {
cursor.close();
}
if (mSyncSettings.isSynced(key) && !forceSync) {
return;
} else {
mSyncSettings.synced(key);
}
List<Repository> repositories = githubRepository.getRepositoriesSync();
githubRepository.getRepositoriesWithAdditionalInfoSync(repositories);
githubRepository.getTrendingRepositoriesSync(githubRepository.getDefaultPeriodForTrending(),
githubRepository.getDefaultLanguageForTrending(), false);
}
SyncAdapter.java 文件源码
项目:TimesMunch
阅读 43
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
String data = "";
// try {
// URL url = new URL("http://api.nytimes.com/svc/news/v3/content/nyt/all/.json?limit=5&api-key=fd0457bbde566c4783e7643346b77859:5:74605174");
// HttpURLConnection connection = (HttpURLConnection) url.openConnection();
// connection.connect();
// InputStream inStream = connection.getInputStream();
// data = getInputData(inStream);
// } catch (Throwable e) {
// e.printStackTrace();
// }
//
//
// Gson gson = new Gson();
// NYTSearchResult result = gson.fromJson(data, NYTSearchResult.class);
// for (int i = 0; i < 5; i++) {
// String title = result.getResults().get(i).getTitle();
// Log.d(TAG, "THE TITLE OF THE " + (i + 1)
// + " ARTICLE IS: " + title);
// }
}
SyncAdapter.java 文件源码
项目:OurVLE
阅读 45
收藏 0
点赞 0
评论 0
/**
* Perform a sync for this account. SyncAdapter-specific parameters may
* be specified in extras, which is guaranteed to not be null. Invocations
* of this method are guaranteed to be serialized.
*
* @param account the account that should be synced
* @param extras SyncAdapter-specific parameters
* @param authority the authority of this sync request
* @param provider a ContentProviderClient that points to the ContentProvider for this
* authority
* @param syncResult SyncAdapter-specific parameters
*/
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
sharedPrefs = super.getContext().getSharedPreferences(MoodleConstants.PREFS_STRING, Context.MODE_PRIVATE);
first_update = sharedPrefs.getInt(MoodleConstants.FIRST_UPDATE, 404); // flag to check whether this is the first update
mSites = new Select().all().from(SiteInfo.class).execute();
if(mSites==null)
return;
if(mSites.size()<=0)
return;
token = mSites.get(0).getToken(); // gets the url token
courses = new Select().all().from(Course.class).execute(); // gets all the courses
updateLatestEvents();
updateLatestForumPosts();
updateLatestDiscussionPots();
// updateLatestCourseContent();
updateMembers();
}
ChromeBrowserSyncAdapter.java 文件源码
项目:AndroidChromium
阅读 39
收藏 0
点赞 0
评论 0
private BrowserParts getBrowserParts(final Context context,
final String account, final PendingInvalidation invalidation,
final SyncResult syncResult, final Semaphore semaphore) {
return new EmptyBrowserParts() {
@Override
public void finishNativeInitialization() {
// Startup succeeded, so we can notify the invalidation.
notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
invalidation.mVersion, invalidation.mPayload);
semaphore.release();
}
@Override
public void onStartupFailure() {
// The startup failed, so we defer the invalidation.
DelayedInvalidationsController.getInstance().addPendingInvalidation(
context, account, invalidation);
// Using numIoExceptions so Android will treat this as a soft error.
syncResult.stats.numIoExceptions++;
semaphore.release();
}
};
}
TimetableSyncAdapter.java 文件源码
项目:android-wg-planer
阅读 41
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
Lesson[] oldLessons = TimetableContentHelper.getTimetable(getContext());
Lesson[] lessons = new SyncServerInterface(getContext()).getTimetable();
lessons = ClassesUtils.filterLessons(getContext(), lessons);
if (lessons.length != oldLessons.length || !Utils.containsAll(lessons, oldLessons)) {
TimetableNotification.notify(getContext());
}
TimetableContentHelper.clearTimetable(getContext());
if (lessons.length > 0) {
TimetableContentHelper.addLessons(getContext(), lessons);
}
}
RepresentationsSyncAdapter.java 文件源码
项目:android-wg-planer
阅读 36
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
Representation[] oldRepresentations = RepresentationsContentHelper.getRepresentations(getContext());
Representation[] representations = new SyncServerInterface(getContext()).getRepresentations();
representations = ClassesUtils.filterRepresentations(getContext(), representations);
if (representations.length != oldRepresentations.length || !Utils.containsAll(representations, oldRepresentations)) {
RepresentationsNotification.notify(getContext());
}
RepresentationsContentHelper.clearRepresentations(getContext());
if (representations.length > 0) {
RepresentationsContentHelper.addRepresentations(getContext(), representations);
}
}
UserSyncAdapter.java 文件源码
项目:android-wg-planer
阅读 34
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
try {
String username = mAccountManager.blockingGetAuthToken(account, AccountGeneral.AUTHTOKEN_TYPE_FULL_ACCESS, true);
SyncServerInterface serverInterface = new SyncServerInterface(getContext());
User user = serverInterface.getUserInfo(username);
UserContentHelper.clearUsers(getContext());
if (user != null) {
UserContentHelper.addUser(getContext(), user);
}
} catch (OperationCanceledException | IOException | AuthenticatorException e) {
e.printStackTrace();
syncResult.stats.numParseExceptions++;
}
}
ForceSyncNowAction.java 文件源码
项目:2015-Google-I-O-app
阅读 33
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
ConferenceDataHandler.resetDataTimestamp(context);
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}
ChromiumSyncAdapter.java 文件源码
项目:Vafrinn
阅读 30
收藏 0
点赞 0
评论 0
private BrowserStartupController.StartupCallback getStartupCallback(final Context context,
final String account, final PendingInvalidation invalidation,
final SyncResult syncResult, final Semaphore semaphore) {
return new BrowserStartupController.StartupCallback() {
@Override
public void onSuccess(boolean alreadyStarted) {
// Startup succeeded, so we can notify the invalidation.
notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
invalidation.mVersion, invalidation.mPayload);
semaphore.release();
}
@Override
public void onFailure() {
// The startup failed, so we defer the invalidation.
DelayedInvalidationsController.getInstance().addPendingInvalidation(
context, account, invalidation);
// Using numIoExceptions so Android will treat this as a soft error.
syncResult.stats.numIoExceptions++;
semaphore.release();
}
};
}
AuthenticSyncAdapter.java 文件源码
项目:BeAuthentic
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, final SyncResult syncResult) {
final Account primaryAccount = Sessions.getPrimaryPhoneAccount(AccountManager.get(getContext()));
if (primaryAccount != null) {
retrieveMessageFromFirebase(primaryAccount, new ValueEventListenerAdapter() {
@Override
public void onDataChange(DataSnapshot snapshot) {
syncResult.stats.numUpdates++;
final Intent intent = new Intent(LoggedActivity.ACTION_REFRESH);
intent.putExtra(LoggedActivity.EXTRA_MESSAGE, TextUtils.isEmpty(snapshot.getValue().toString()) ? "" : snapshot.getValue().toString());
getContext().sendBroadcast(intent);
}
@Override
public void onCancelled(FirebaseError firebaseError) {
syncResult.stats.numIoExceptions++;
}
});
}
}
bty.java 文件源码
项目:FMTech
阅读 33
收藏 0
点赞 0
评论 0
public bty(btl parambtl, Context paramContext, int paramInt, bup parambup, SyncResult paramSyncResult, ois paramois, long paramLong)
{
this.a = paramInt;
this.b = parambup;
this.c = paramSyncResult;
this.t = paramois;
this.v = ((AutoBackupEnvironment)mbb.a(paramContext, AutoBackupEnvironment.class));
this.u = paramLong;
this.s = System.currentTimeMillis();
if (System.currentTimeMillis() - parambtl.j > 900000L)
{
parambtl.i = ((ifj)mbb.a(parambtl.f, ifj.class)).f().d();
parambtl.j = System.currentTimeMillis();
}
this.d = parambtl.i;
this.j = btl.a(parambtl, paramContext);
this.f = ((iwb)mbb.a(paramContext, iwb.class)).a(paramInt);
int i1 = parambtl.a().size();
this.e = ((this.d - b()) / i1);
this.r = Math.min(104857600L, this.e);
this.l = this.r;
SQLiteDatabase localSQLiteDatabase = bqj.a(paramContext, paramInt).getReadableDatabase();
this.h = btl.a(localSQLiteDatabase, 1);
this.g = btl.a(localSQLiteDatabase, 10);
}
auq.java 文件源码
项目:FMTech
阅读 33
收藏 0
点赞 0
评论 0
private final void a(int paramInt, bup parambup, SyncResult paramSyncResult, boolean paramBoolean)
{
try
{
if (Log.isLoggable("PhotoSyncService", 4)) {
new StringBuilder(66).append("----> Start highlights metadata down sync for account: ").append(paramInt);
}
bsn localbsn = bsn.e;
bry.a(getContext(), paramInt, parambup, localbsn);
bgp.a(getContext(), paramInt, dnn.b, System.currentTimeMillis());
return;
}
catch (Exception localException)
{
do
{
if (Log.isLoggable("PhotoSyncService", 6)) {
Log.e("PhotoSyncService", 65 + "----> doHighlightsMetadataDownSync error for account: " + paramInt);
}
} while (GooglePhotoDownsyncService.a(localException));
SyncStats localSyncStats = paramSyncResult.stats;
localSyncStats.numIoExceptions = (1L + localSyncStats.numIoExceptions);
}
}
auq.java 文件源码
项目:FMTech
阅读 35
收藏 0
点赞 0
评论 0
private final void a(List<Integer> paramList, bup parambup, SyncResult paramSyncResult)
{
hyi localhyi = (hyi)mbb.a(getContext(), hyi.class);
Iterator localIterator = paramList.iterator();
while (localIterator.hasNext())
{
int i = ((Integer)localIterator.next()).intValue();
if (localhyi.b(bwb.g, i))
{
try
{
a(i, parambup, paramSyncResult, false);
}
catch (Exception localException)
{
Log.e("PhotoSyncService", 83 + "----> performUnconditionalHighlightsMetadataDownSync error for account: " + i, localException);
}
if (!GooglePhotoDownsyncService.a(localException))
{
SyncStats localSyncStats = paramSyncResult.stats;
localSyncStats.numIoExceptions = (1L + localSyncStats.numIoExceptions);
}
}
}
}
ForceSyncNowAction.java 文件源码
项目:FMTech
阅读 32
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
ConferenceDataHandler.resetDataTimestamp(context);
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}
ChromeBrowserSyncAdapter.java 文件源码
项目:365browser
阅读 41
收藏 0
点赞 0
评论 0
private BrowserParts getBrowserParts(final Context context,
final String account, final PendingInvalidation invalidation,
final SyncResult syncResult, final Semaphore semaphore) {
return new EmptyBrowserParts() {
@Override
public void finishNativeInitialization() {
// Startup succeeded, so we can notify the invalidation.
notifyInvalidation(invalidation.mObjectSource, invalidation.mObjectId,
invalidation.mVersion, invalidation.mPayload);
semaphore.release();
}
@Override
public void onStartupFailure() {
// The startup failed, so we defer the invalidation.
DelayedInvalidationsController.getInstance().addPendingInvalidation(
context, account, invalidation);
// Using numIoExceptions so Android will treat this as a soft error.
syncResult.stats.numIoExceptions++;
semaphore.release();
}
};
}
SyncAdapter.java 文件源码
项目:aelf-dailyreadings
阅读 35
收藏 0
点赞 0
评论 0
private void syncReading(LecturesController.WHAT what, AelfDate when, SyncResult syncResult) throws InterruptedException {
// Load from network, if not in cache and not outdated
if(!mController.isLecturesInCache(what, when, false)) {
try {
Log.i(TAG, what.urlName()+" for "+when.toIsoString()+" QUEUED");
pendingDownloads.add(mController.getLecturesFromNetwork(what, when));
} catch (IOException e) {
if (e.getCause() instanceof InterruptedException) {
throw (InterruptedException) e.getCause();
}
// Error already propagated to Sentry. Do not propagate twice !
Log.e(TAG, "I/O error while syncing");
syncResult.stats.numIoExceptions++;
}
} else {
Log.i(TAG, what.urlName()+" for "+when.toIsoString()+" SKIPPED");
}
}
GmaSyncService.java 文件源码
项目:gma-android
阅读 38
收藏 0
点赞 0
评论 0
@Override
public void onHandleIntent(@NonNull final Intent intent) {
// short-circuit if we don't have a valid guid
final String guid = intent.getStringExtra(EXTRA_GUID);
if (guid == null) {
return;
}
// dispatch sync request
final int type = intent.getIntExtra(EXTRA_SYNCTYPE, SYNCTYPE_NONE);
final Bundle extras = intent.getExtras();
final SyncResult result = new SyncResult();
mSyncAdapter.dispatchSync(guid, type, extras, result);
// request a sync next time we are online if we had errors syncing
if (result.hasError()) {
final Account account = AccountUtils.getAccount(this, ACCOUNT_TYPE, guid);
if (account != null) {
ContentResolver.requestSync(account, SYNC_AUTHORITY, extras);
}
}
}
ForceSyncNowAction.java 文件源码
项目:saarang-iosched
阅读 36
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}
ForceSyncNowAction.java 文件源码
项目:AppDevFestSudeste2015
阅读 34
收藏 0
点赞 0
评论 0
@Override
public void run(final Context context, final Callback callback) {
final Bundle bundle = new Bundle();
bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true);
new AsyncTask<Context, Void, Void>() {
@Override
protected Void doInBackground(Context... contexts) {
Account account = AccountUtils.getActiveAccount(context);
if (account == null) {
callback.done(false, "Cannot sync if there is no active account.");
} else {
new SyncHelper(contexts[0]).performSync(new SyncResult(),
AccountUtils.getActiveAccount(context), bundle);
}
return null;
}
}.execute(context);
}