本文整理汇总了Java中com.google.samples.apps.iosched.sync.SyncHelper.performPostSyncChores方法的典型用法代码示例。如果您正苦于以下问题:Java SyncHelper.performPostSyncChores方法的具体用法?Java SyncHelper.performPostSyncChores怎么用?Java SyncHelper.performPostSyncChores使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.samples.apps.iosched.sync.SyncHelper
的用法示例。
在下文中一共展示了SyncHelper.performPostSyncChores方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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));
}
}
示例2: 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();
}
示例3: 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();
}
}
示例4: onHandleIntent
import com.google.samples.apps.iosched.sync.SyncHelper; //导入方法依赖的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));
}
}