• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ConferenceDataHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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: run

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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(), bundle);
            }
          return null;
        }
    }.execute(context);
}
 
开发者ID:google,项目名称:iosched,代码行数:19,代码来源:ForceSyncNowAction.java


示例3: onHandleIntent

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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


示例4: performDataBootstrap

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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


示例5: onUpgrade

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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


示例6: onHandleIntent

import com.google.samples.apps.iosched.sync.ConferenceDataHandler; //导入依赖的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


示例7: onHandleIntent

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

    try {
        // Load data from bootstrap a local file

        LOGD(TAG, "Starting full data bootstrap from file: " + BOOTSTRAP_FILE);

        if (!new File(BOOTSTRAP_FILE).canRead()) {
            LOGE(TAG, "File " + BOOTSTRAP_FILE + " could not be read. No bootstrap possible.");
        }

        String bootstrapJson = JSONHandler.parseFile(BOOTSTRAP_FILE);

        // 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:google,项目名称:iosched,代码行数:46,代码来源:LocalRefreshingBootstrapService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CellProtos类代码示例发布时间:2022-05-23
下一篇:
Java ElementColorProvider类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap