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


Java SyncHelper.requestManualSync方法代码示例

本文整理汇总了Java中com.google.samples.apps.iosched.sync.SyncHelper.requestManualSync方法的典型用法代码示例。如果您正苦于以下问题:Java SyncHelper.requestManualSync方法的具体用法?Java SyncHelper.requestManualSync怎么用?Java SyncHelper.requestManualSync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.samples.apps.iosched.sync.SyncHelper的用法示例。


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

示例1: onAuthSuccess

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
/**
 * Called when authentication succeeds. This may either happen because the user just
 * authenticated for the first time (and went through the sign in flow), or because it's
 * a returning user.
 *
 * @param accountName        name of the account that just authenticated successfully.
 * @param newlyAuthenticated If true, this user just authenticated for the first time.
 *                           If false, it's a returning user.
 */
@Override
public void onAuthSuccess(String accountName, boolean newlyAuthenticated) {
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    LOGD(TAG, "onAuthSuccess, account " + accountName + ", newlyAuthenticated="
            + newlyAuthenticated);

    refreshAccountDependantData();

    if (newlyAuthenticated) {
        LOGD(TAG, "Enabling auto sync on content provider for account " + accountName);
        SyncHelper.updateSyncInterval(this, account);
        SyncHelper.requestManualSync(account);
    }

    setupAccountBox();
    populateNavDrawer();
    registerGCMClient();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:28,代码来源:BaseActivity.java

示例2: onReceive

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent widgetIntent) {
    final String action = widgetIntent.getAction();

    if (REFRESH_ACTION.equals(action)) {
        LOGD(TAG, "received REFRESH_ACTION from widget");
        final boolean shouldSync = widgetIntent.getBooleanExtra(EXTRA_PERFORM_SYNC, false);

        // Trigger sync
        Account chosenAccount = AccountUtils.getActiveAccount(context);
        if (shouldSync && chosenAccount != null) {
            SyncHelper.requestManualSync(chosenAccount);
        }

        // Notify the widget that the list view needs to be updated.
        final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
        final ComponentName cn = new ComponentName(context, ScheduleWidgetProvider.class);
        mgr.notifyAppWidgetViewDataChanged(mgr.getAppWidgetIds(cn),
                R.id.widget_schedule_list);

    }
    super.onReceive(context, widgetIntent);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:24,代码来源:ScheduleWidgetProvider.java

示例3: onAuthSuccess

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
/**
 * Called when authentication succeeds. This may either happen because the user just
 * authenticated for the first time (and went through the sign in flow), or because it's
 * a returning user.
 * @param accountName name of the account that just authenticated successfully.
 * @param newlyAuthenticated If true, this user just authenticated for the first time.
 * If false, it's a returning user.
 */
@Override
public void onAuthSuccess(String accountName, boolean newlyAuthenticated) {
    Account account = new Account(accountName, GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE);
    LOGD(TAG, "onAuthSuccess, account " + accountName + ", newlyAuthenticated=" + newlyAuthenticated);

    refreshAccountDependantData();

    if (newlyAuthenticated) {
        LOGD(TAG, "Enabling auto sync on content provider for account " + accountName);
        SyncHelper.updateSyncInterval(this, account);
        SyncHelper.requestManualSync(account);
    }

    setupAccountBox();
    populateNavDrawer();
    registerGCMClient();
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:26,代码来源:BaseActivity.java

示例4: onReceive

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
public void onReceive(final Context context, Intent widgetIntent) {
    final String action = widgetIntent.getAction();

    if (REFRESH_ACTION.equals(action)) {
        LOGD(TAG, "received REFRESH_ACTION from widget");
        final boolean shouldSync = widgetIntent.getBooleanExtra(EXTRA_PERFORM_SYNC, false);

        // Trigger sync
        if (shouldSync) {
            SyncHelper.requestManualSync();
        }

        // Notify the widget that the list view needs to be updated.
        final AppWidgetManager mgr = AppWidgetManager.getInstance(context);
        final ComponentName cn = new ComponentName(context, ScheduleWidgetProvider.class);
        mgr.notifyAppWidgetViewDataChanged(mgr.getAppWidgetIds(cn),
                R.id.widget_schedule_list);

    }
    super.onReceive(context, widgetIntent);
}
 
开发者ID:google,项目名称:iosched,代码行数:23,代码来源:ScheduleWidgetProvider.java

示例5: requestDataRefresh

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
protected void requestDataRefresh() {
    Account activeAccount = AccountUtils.getActiveAccount(this);
    ContentResolver contentResolver = getContentResolver();
    if (contentResolver.isSyncActive(activeAccount, ScheduleContract.CONTENT_AUTHORITY)) {
        LOGD(TAG, "Ignoring manual sync request because a sync is already in progress.");
        return;
    }
    mManualSyncRequest = true;
    LOGD(TAG, "Requesting manual data refresh.");
    SyncHelper.requestManualSync(activeAccount);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:12,代码来源:BaseActivity.java

示例6: requestModelUpdate

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
public boolean requestModelUpdate(UserActionEnum action, @Nullable Bundle args) {
    // If the action is a VIDEO_VIEWED we save the information that the video has been viewed by
    // the user in AppData.
    if (action.equals(VideoLibraryUserActionEnum.VIDEO_PLAYED)) {
        if (args != null && args.containsKey(KEY_VIDEO_ID)) {
            String playedVideoId = args.getString(KEY_VIDEO_ID);

            LOGD(TAG, "setVideoViewed id=" + playedVideoId);
            Uri myPlayedVideoUri = ScheduleContract.MyViewedVideos.buildMyViewedVideosUri(
                    AccountUtils.getActiveAccountName(mActivity));

            AsyncQueryHandler handler =
                    new AsyncQueryHandler(mActivity.getContentResolver()) {};
            final ContentValues values = new ContentValues();
            values.put(ScheduleContract.MyViewedVideos.VIDEO_ID, playedVideoId);
            handler.startInsert(-1, null, myPlayedVideoUri, values);

            // Because change listener is set to null during initialization, these
            // won't fire on pageview.
            mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity,
                    false));

            // Request an immediate user data sync to reflect the viewed video in the cloud.
            SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);
        } else {
            LOGE(TAG, "The VideoLibraryUserActionEnum.VIDEO_VIEWED action was called without a "
                    + "proper Bundle.");
            return false;
        }
    }
    return true;
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:34,代码来源:VideoLibraryModel.java

示例7: setSessionStarred

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(
            AccountUtils.getActiveAccountName(mActivity));

    AsyncQueryHandler handler =
            new AsyncQueryHandler(mActivity.getContentResolver()) {
            };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred?1:0);
    handler.startInsert(-1, null, myScheduleUri, values);

    // ANALYTICS EVENT: Add or remove a session from the schedule
    // Contains: Session title, whether it was added or removed (starred or unstarred)
    AnalyticsHelper.sendEvent(
            "Session", starred ? "Starred" : "Unstarred", title);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:28,代码来源:SessionsHelper.java

示例8: setSessionStarred

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(mActivity);

    AsyncQueryHandler handler =
            new AsyncQueryHandler(mActivity.getContentResolver()) {
            };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred?1:0);
    handler.startInsert(-1, null, myScheduleUri, values);

    /* [ANALYTICS:EVENT]
     * TRIGGER:   Add or remove a session from the schedule.
     * CATEGORY:  'Session'
     * ACTION:    'Starred' or 'Unstarred'
     * LABEL:     session title/subtitle
     * [/ANALYTICS]
     */
    AnalyticsManager.sendEvent(
            "Session", starred ? "Starred" : "Unstarred", title, 0L);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mActivity.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mActivity, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(AccountUtils.getActiveAccount(mActivity), true);

}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:33,代码来源:SessionsHelper.java

示例9: requestDataRefresh

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
protected void requestDataRefresh() {
    android.accounts.Account activeAccount = AccountUtils.getActiveAccount(this);
    if (activeAccount == null) {
        return;
    }
    if (ContentResolver.isSyncActive(activeAccount, ScheduleContract.CONTENT_AUTHORITY)) {
        LOGD(TAG, "Ignoring manual sync request because a sync is already in progress.");
        return;
    }
    LOGD(TAG, "Requesting manual data refresh.");
    SyncHelper.requestManualSync();
}
 
开发者ID:google,项目名称:iosched,代码行数:13,代码来源:BaseActivity.java

示例10: setSessionStarred

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
public void setSessionStarred(Uri sessionUri, boolean starred, String title) {
    LOGD(TAG, "setSessionStarred uri=" + sessionUri + " starred=" +
            starred + " title=" + title);
    String sessionId = ScheduleContract.Sessions.getSessionId(sessionUri);
    Uri myScheduleUri = ScheduleContract.MySchedule.buildMyScheduleUri(
            AccountUtils.getActiveAccountName(mContext));

    @SuppressLint("HandlerLeak") // this is short-lived
            AsyncQueryHandler handler = new AsyncQueryHandler(mContext.getContentResolver()) {
    };
    final ContentValues values = new ContentValues();
    values.put(ScheduleContract.MySchedule.SESSION_ID, sessionId);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_IN_SCHEDULE, starred ? 1 : 0);
    int offset = SyncUtils.getServerTimeOffset(mContext);
    values.put(ScheduleContract.MySchedule.MY_SCHEDULE_TIMESTAMP, new Date().getTime() +
            offset);
    handler.startInsert(-1, null, myScheduleUri, values);

    // ANALYTICS EVENT: Add or remove a session from the schedule
    // Contains: Session title, whether it was added or removed (starred or unstarred)
    AnalyticsHelper.sendEvent("Session", starred ? "Starred" : "Unstarred", "Session: " + title);

    // Because change listener is set to null during initialization, these
    // won't fire on pageview.
    mContext.sendBroadcast(ScheduleWidgetProvider.getRefreshBroadcastIntent(mContext, false));

    // Request an immediate user data sync to reflect the starred user sessions in the cloud
    SyncHelper.requestManualSync(true);

    // No need to manually setup calendar or notifications so they happen on sync
}
 
开发者ID:google,项目名称:iosched,代码行数:32,代码来源:SessionsHelper.java

示例11: onHandleIntent

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    Context appContext = getApplicationContext();

    if (SettingsUtils.isDataBootstrapDone(appContext)) {
        LOGD(TAG, "Data bootstrap already done.");
        return;
    }
    try {
        LOGD(TAG, "Starting data bootstrap process.");
        // Load data from bootstrap raw resource.
        String bootstrapJson = JSONHandler
                .parseResource(appContext, R.raw.bootstrap_data);

        // Apply the data we read to the database with the help of the ConferenceDataHandler.
        ConferenceDataHandler dataHandler = new ConferenceDataHandler(appContext);
        dataHandler.applyConferenceData(new String[]{bootstrapJson},
                BuildConfig.BOOTSTRAP_DATA_TIMESTAMP, false);

        SyncHelper.performPostSyncChores(appContext);

        LOGI(TAG, "End of bootstrap -- successful. Marking bootstrap as done.");
        SettingsUtils.markSyncSucceededNow(appContext);
        SettingsUtils.markDataBootstrapDone(appContext);

        getContentResolver().notifyChange(Uri.parse(ScheduleContract.CONTENT_AUTHORITY),
                null, false);

    } catch (IOException ex) {
        // This is serious -- if this happens, the app won't work :-(
        // This is unlikely to happen in production, but IF it does, we apply
        // this workaround as a fallback: we pretend we managed to do the bootstrap
        // and hope that a remote sync will work.
        LOGE(TAG, "*** ERROR DURING BOOTSTRAP! Problem in bootstrap data?", ex);
        LOGE(TAG,
                "Applying fallback -- marking boostrap as done; sync might fix problem.");
        SettingsUtils.markDataBootstrapDone(appContext);
    } finally {
        // Request a manual sync immediately after the bootstrapping process, in case we
        // have an active connection. Otherwise, the scheduled sync could take a while.
        SyncHelper.requestManualSync(AccountUtils.getActiveAccount(appContext));
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:44,代码来源:DataBootstrapService.java

示例12: performDataBootstrap

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
/**
 * Performs the one-time data bootstrap. This means taking our prepackaged conference data
 * from the R.raw.bootstrap_data resource, and parsing it to populate the database. This
 * data contains the sessions, speakers, etc.
 */
private void performDataBootstrap() {
    final Context appContext = getApplicationContext();
    LOGD(TAG, "Starting data bootstrap background thread.");
    mDataBootstrapThread = new Thread(new Runnable() {
        @Override
        public void run() {
            LOGD(TAG, "Starting data bootstrap process.");
            try {
                // Load data from bootstrap raw resource
                String bootstrapJson = JSONHandler.parseResource(appContext, R.raw.bootstrap_data);

                // Apply the data we read to the database with the help of the ConferenceDataHandler
                ConferenceDataHandler dataHandler = new ConferenceDataHandler(appContext);
                dataHandler.applyConferenceData(new String[]{bootstrapJson},
                        Config.BOOTSTRAP_DATA_TIMESTAMP, false);
                SyncHelper.performPostSyncChores(appContext);
                LOGI(TAG, "End of bootstrap -- successful. Marking boostrap as done.");
                PrefUtils.markSyncSucceededNow(appContext);
                PrefUtils.markDataBootstrapDone(appContext);
                getContentResolver().notifyChange(Uri.parse(ScheduleContract.CONTENT_AUTHORITY),
                        null, false);
            } catch (IOException ex) {
                // This is serious -- if this happens, the app won't work :-(
                // This is unlikely to happen in production, but IF it does, we apply
                // this workaround as a fallback: we pretend we managed to do the bootstrap
                // and hope that a remote sync will work.
                LOGE(TAG, "*** ERROR DURING BOOTSTRAP! Problem in bootstrap data?");
                LOGE(TAG, "Applying fallback -- marking boostrap as done; sync might fix problem.");
                PrefUtils.markDataBootstrapDone(appContext);
            }

            mDataBootstrapThread = null;

            // Request a manual sync immediately after the bootstrapping process, in case we
            // have an active connection. Otherwise, the scheduled sync could take a while.
            SyncHelper.requestManualSync(AccountUtils.getActiveAccount(appContext));
        }
    });
    mDataBootstrapThread.start();
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:46,代码来源:BaseActivity.java

示例13: onUpgrade

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    LOGD(TAG, "onUpgrade() from " + oldVersion + " to " + newVersion);

    // Cancel any sync currently in progress
    Account account = AccountUtils.getActiveAccount(mContext);
    if (account != null) {
        LOGI(TAG, "Cancelling any pending syncs for account");
        ContentResolver.cancelSync(account, ScheduleContract.CONTENT_AUTHORITY);
    }

    // Current DB version. We update this variable as we perform upgrades to reflect
    // the current version we are in.
    int version = oldVersion;

    // Indicates whether the data we currently have should be invalidated as a
    // result of the db upgrade. Default is true (invalidate); if we detect that this
    // is a trivial DB upgrade, we set this to false.
    boolean dataInvalidated = true;

    // Check if we can upgrade from release A to release C
    if (version == VER_2014_RELEASE_A) {
        // release A format can be upgraded to release C format
        LOGD(TAG, "Upgrading database from 2014 release A to 2014 release C.");
        upgradeAtoC(db);
        version = VER_2014_RELEASE_C;
    }

    LOGD(TAG, "After upgrade logic, at version " + version);

    // at this point, we ran out of upgrade logic, so if we are still at the wrong
    // version, we have no choice but to delete everything and create everything again.
    if (version != CUR_DATABASE_VERSION) {
        LOGW(TAG, "Upgrade unsuccessful -- destroying old data during upgrade");

        db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_TAGS_DELETE);
        db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_SPEAKERS_DELETE);
        db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_FEEDBACK_DELETE);
        db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.SESSIONS_MY_SCHEDULE_DELETE);
        db.execSQL("DROP TRIGGER IF EXISTS " + Triggers.DeprecatedTriggers.SESSIONS_TRACKS_DELETE);

        db.execSQL("DROP TABLE IF EXISTS " + Tables.BLOCKS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.ROOMS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.TAGS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SPEAKERS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.MY_SCHEDULE);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_SPEAKERS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_TAGS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.ANNOUNCEMENTS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.FEEDBACK);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SESSIONS_SEARCH);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.SEARCH_SUGGEST);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.MAPMARKERS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.MAPTILES);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.EXPERTS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.HASHTAGS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.PEOPLE_IVE_MET);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.VIDEOS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.PARTNERS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.TRACKS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.SESSIONS_TRACKS);
        db.execSQL("DROP TABLE IF EXISTS " + Tables.DeprecatedTables.SANDBOX);

        onCreate(db);
        version = CUR_DATABASE_VERSION;
    }

    if (dataInvalidated) {
        LOGD(TAG, "Data invalidated; resetting our data timestamp.");
        ConferenceDataHandler.resetDataTimestamp(mContext);
        if (account != null) {
            LOGI(TAG, "DB upgrade complete. Requesting resync.");
            SyncHelper.requestManualSync(account);
        }
    }
}
 
开发者ID:gdg-bh,项目名称:AppDevFestSudeste2015,代码行数:78,代码来源:ScheduleDatabase.java

示例14: onHandleIntent

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    Context appContext = getApplicationContext();

    if (SettingsUtils.isDataBootstrapDone(appContext)) {
        LOGD(TAG, "Data bootstrap already done.");
        return;
    }
    try {
        LOGD(TAG, "Starting data bootstrap process.");
        // Load data from bootstrap raw resource.
        String bootstrapJson = JSONHandler
                .parseResource(appContext, R.raw.bootstrap_data);

        // Apply the data we read to the database with the help of the ConferenceDataHandler.
        ConferenceDataHandler dataHandler = new ConferenceDataHandler(appContext);
        dataHandler.applyConferenceData(new String[]{bootstrapJson},
                BuildConfig.BOOTSTRAP_DATA_TIMESTAMP, false);

        SyncHelper.performPostSyncChores(appContext);

        LOGI(TAG, "End of bootstrap -- successful. Marking bootstrap as done.");
        SettingsUtils.markSyncSucceededNow(appContext);
        SettingsUtils.markDataBootstrapDone(appContext);

        getContentResolver().notifyChange(Uri.parse(ScheduleContract.CONTENT_AUTHORITY),
                null, false);

    } catch (IOException ex) {
        // This is serious -- if this happens, the app won't work :-(
        // This is unlikely to happen in production, but IF it does, we apply
        // this workaround as a fallback: we pretend we managed to do the bootstrap
        // and hope that a remote sync will work.
        LOGE(TAG, "*** ERROR DURING BOOTSTRAP! Problem in bootstrap data?", ex);
        LOGE(TAG,
                "Applying fallback -- marking boostrap as done; sync might fix problem.");
        SettingsUtils.markDataBootstrapDone(appContext);
    } finally {
        // Request a manual sync immediately after the bootstrapping process, in case we
        // have an active connection. Otherwise, the scheduled sync could take a while.
        SyncHelper.requestManualSync();
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:44,代码来源:DataBootstrapService.java

示例15: onHandleIntent

import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(@Nullable Intent intent) {
    if (intent == null) {
        return;
    }

    String accountName = intent.getStringExtra(KEY_ACCOUNT_NAME);
    if (accountName == null) {
        return;
    }

    // TODO: It would be better if the default value for the account in
    // the non-signed in case was not "null". When that is modified update this.
    String previousAccountName = null;

    // The task is to upgrade all user data that was associated with a non-logged in user
    // and update it to the signed in user.
    ArrayList<ContentProviderOperation> ops = new ArrayList<>(3);
    //noinspection ConstantConditions
    ops.add(ContentProviderOperation
            .newUpdate(ScheduleContractHelper.addOverrideAccountUpdateAllowed(
                    MySchedule.buildMyScheduleUri(previousAccountName)))
            .withValue(MySchedule.MY_SCHEDULE_ACCOUNT_NAME, accountName)
            .build());

    //noinspection ConstantConditions
    ops.add(ContentProviderOperation
            .newUpdate(ScheduleContractHelper.addOverrideAccountUpdateAllowed(
                    MyFeedbackSubmitted.buildMyFeedbackSubmittedUri(previousAccountName)))
            .withValue(MyFeedbackSubmitted.MY_FEEDBACK_SUBMITTED_ACCOUNT_NAME, accountName)
            .build());

    // Delete any reservations (should be none)
    //noinspection ConstantConditions
    ops.add(ContentProviderOperation
            .newDelete(MyReservations.buildMyReservationUri(previousAccountName))
            .withSelection(MyReservations.MY_RESERVATION_ACCOUNT_NAME, null)
            .build());

    try {
        ContentProviderResult[] results =
                getContentResolver().applyBatch(ScheduleContract.CONTENT_AUTHORITY, ops);
        if (LogUtils.LOGGING_ENABLED) {
            for (ContentProviderResult res : results) {
                LOGV(TAG, "Result of update: uri: " + res.uri + " count: " + res.count);
            }
        }
    } catch (RemoteException | OperationApplicationException e) {
        LOGE(TAG, "Unexpected exception upgrading the user data to signed in user", e);
    } finally {
        // Note: Once we are done with the upgrade we trigger a manual sync for user data
        SyncHelper.requestManualSync(true);
    }
}
 
开发者ID:google,项目名称:iosched,代码行数:55,代码来源:PostSignInUpgradeService.java


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