当前位置: 首页>>代码示例>>Java>>正文


Java SyncResult类代码示例

本文整理汇总了Java中android.content.SyncResult的典型用法代码示例。如果您正苦于以下问题:Java SyncResult类的具体用法?Java SyncResult怎么用?Java SyncResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SyncResult类属于android.content包,在下文中一共展示了SyncResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import android.content.SyncResult; //导入依赖的package包/类
@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);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:20,代码来源:ForceSyncNowAction.java

示例2: getBrowserParts

import android.content.SyncResult; //导入依赖的package包/类
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();
        }
    };
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:24,代码来源:ChromeBrowserSyncAdapter.java

示例3: getUserData

import android.content.SyncResult; //导入依赖的package包/类
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();
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:23,代码来源:LoginActivity.java

示例4: deleteFromLocal

import android.content.SyncResult; //导入依赖的package包/类
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;
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:21,代码来源:SyncAdapter.java

示例5: deleteFromServer

import android.content.SyncResult; //导入依赖的package包/类
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());
        }
    }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:20,代码来源:SyncAdapter.java

示例6: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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!");
    }
}
 
开发者ID:graviton57,项目名称:TVGuide,代码行数:19,代码来源:TvGuideSyncAdapter.java

示例7: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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();
    }
}
 
开发者ID:6thsolution,项目名称:EasyAppleSyncAdapter,代码行数:17,代码来源:BaseSyncAdapter.java

示例8: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
/**
 * 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.
}
 
开发者ID:jaydeepw,项目名称:simplest-sync-adapter,代码行数:36,代码来源:SyncAdapter.java

示例9: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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);
}
 
开发者ID:DmitryMalkovich,项目名称:gito-github-client,代码行数:27,代码来源:SyncAdapter.java

示例10: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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);
//        }
    }
 
开发者ID:TimesMunch,项目名称:TimesMunch,代码行数:23,代码来源:SyncAdapter.java

示例11: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:UWICompSociety,项目名称:OurVLE,代码行数:36,代码来源:SyncAdapter.java

示例12: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:heinrichreimer,项目名称:android-wg-planer,代码行数:18,代码来源:TimetableSyncAdapter.java

示例13: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:heinrichreimer,项目名称:android-wg-planer,代码行数:18,代码来源:RepresentationsSyncAdapter.java

示例14: onPerformSync

import android.content.SyncResult; //导入依赖的package包/类
@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++;
    }
}
 
开发者ID:heinrichreimer,项目名称:android-wg-planer,代码行数:19,代码来源:UserSyncAdapter.java

示例15: getStartupCallback

import android.content.SyncResult; //导入依赖的package包/类
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();
        }
    };
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:24,代码来源:ChromiumSyncAdapter.java


注:本文中的android.content.SyncResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。