本文整理汇总了TypeScript中@providers/init.CoreInitDelegate类的典型用法代码示例。如果您正苦于以下问题:TypeScript CoreInitDelegate类的具体用法?TypeScript CoreInitDelegate怎么用?TypeScript CoreInitDelegate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoreInitDelegate类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(platform: Platform, device: Device, appProvider: CoreAppProvider, fileProvider: CoreFileProvider,
initDelegate: CoreInitDelegate, langProvider: CoreLangProvider, sitesProvider: CoreSitesProvider,
localNotificationsProvider: CoreLocalNotificationsProvider, pushNotificationsProvider: AddonPushNotificationsProvider) {
const currentSite = sitesProvider.getCurrentSite();
this.appName = appProvider.isDesktop() ? CoreConfigConstants.desktopappname : CoreConfigConstants.appname;
this.versionName = CoreConfigConstants.versionname;
this.versionCode = CoreConfigConstants.versioncode;
this.compilationTime = CoreConfigConstants.compilationtime;
this.lastCommit = CoreConfigConstants.lastcommit;
// Calculate the privacy policy to use.
this.privacyPolicy = (currentSite && (currentSite.getStoredConfig('tool_mobile_apppolicy') ||
currentSite.getStoredConfig('sitepolicy'))) || CoreConfigConstants.privacypolicy;
this.navigator = window.navigator;
if (window.location && window.location.href) {
const url = window.location.href;
this.locationHref = url.substr(0, url.indexOf('#'));
}
this.appReady = initDelegate.isReady() ? 'core.yes' : 'core.no';
this.deviceType = platform.is('tablet') ? 'core.tablet' : 'core.phone';
if (platform.is('android')) {
this.deviceOs = 'core.android';
} else if (platform.is('ios')) {
this.deviceOs = 'core.ios';
} else if (platform.is('windows')) {
this.deviceOs = 'core.windowsphone';
} else {
const matches = navigator.userAgent.match(/\(([^\)]*)\)/);
if (matches && matches.length > 1) {
this.deviceOs = matches[1];
} else {
this.deviceOs = 'core.unknown';
}
}
langProvider.getCurrentLanguage().then((lang) => {
this.currentLanguage = lang;
});
this.networkStatus = appProvider.isOnline() ? 'core.online' : 'core.offline';
this.wifiConnection = appProvider.isWifi() ? 'core.yes' : 'core.no';
this.deviceWebWorkers = !!window['Worker'] && !!window['URL'] ? 'core.yes' : 'core.no';
this.device = device;
if (fileProvider.isAvailable()) {
fileProvider.getBasePath().then((basepath) => {
this.fileSystemRoot = basepath;
this.fsClickable = fileProvider.usesHTMLAPI();
});
}
this.localNotifAvailable = localNotificationsProvider.isAvailable() ? 'core.yes' : 'core.no';
this.pushId = pushNotificationsProvider.getPushId();
}
示例2: constructor
constructor(mainMenuDelegate: CoreMainMenuDelegate, calendarHandler: AddonCalendarMainMenuHandler,
initDelegate: CoreInitDelegate, calendarProvider: AddonCalendarProvider, loginHelper: CoreLoginHelperProvider,
localNotificationsProvider: CoreLocalNotificationsProvider, updateManager: CoreUpdateManagerProvider) {
mainMenuDelegate.registerHandler(calendarHandler);
initDelegate.ready().then(() => {
calendarProvider.scheduleAllSitesEventsNotifications();
});
localNotificationsProvider.registerClick(AddonCalendarProvider.COMPONENT, (data) => {
if (data.eventid) {
initDelegate.ready().then(() => {
calendarProvider.isDisabled(data.siteId).then((disabled) => {
if (disabled) {
// The calendar is disabled in the site, don't open it.
return;
}
loginHelper.redirect('AddonCalendarListPage', {eventId: data.eventid}, data.siteId);
});
});
}
});
// Allow migrating the table from the old app to the new schema.
// In the old app some calculated properties were stored when it shouldn't. Filter only the fields we want.
updateManager.registerSiteTableMigration({
name: 'calendar_events',
newName: AddonCalendarProvider.EVENTS_TABLE,
filterFields: ['id', 'name', 'description', 'format', 'eventtype', 'courseid', 'timestart', 'timeduration',
'categoryid', 'groupid', 'userid', 'instance', 'modulename', 'timemodified', 'repeatid', 'visible', 'uuid',
'sequence', 'subscriptionid']
});
// Migrate the component name.
updateManager.registerLocalNotifComponentMigration('mmaCalendarComponent', AddonCalendarProvider.COMPONENT);
}
示例3: constructor
constructor(initDelegate: CoreInitDelegate, remoteThemesProvider: AddonRemoteThemesProvider, eventsProvider: CoreEventsProvider,
sitesProvider: CoreSitesProvider, loggerProvider: CoreLoggerProvider) {
const logger = loggerProvider.getInstance('AddonRemoteThemesModule');
// Preload the current site styles.
initDelegate.registerProcess({
name: 'AddonRemoteThemesPreloadCurrent',
priority: CoreInitDelegate.MAX_RECOMMENDED_PRIORITY + 250,
blocking: true,
load: remoteThemesProvider.preloadCurrentSite.bind(remoteThemesProvider)
});
// Preload the styles of the rest of sites.
initDelegate.registerProcess({
name: 'AddonRemoteThemesPreload',
blocking: true,
load: remoteThemesProvider.preloadSites.bind(remoteThemesProvider)
});
let addingSite;
// When a new site is added to the app, add its styles.
eventsProvider.on(CoreEventsProvider.SITE_ADDED, (data) => {
addingSite = data.siteId;
remoteThemesProvider.addSite(data.siteId).catch((error) => {
logger.error('Error adding site', error);
}).then(() => {
if (addingSite == data.siteId) {
addingSite = false;
}
// User has logged in, remove tmp styles and enable loaded styles.
if (data.siteId == sitesProvider.getCurrentSiteId()) {
remoteThemesProvider.unloadTmpStyles();
remoteThemesProvider.enable(data.siteId);
}
});
});
// Update styles when current site is updated.
eventsProvider.on(CoreEventsProvider.SITE_UPDATED, (data) => {
if (data.siteId === sitesProvider.getCurrentSiteId()) {
remoteThemesProvider.load(data.siteId).catch((error) => {
logger.error('Error loading site after site update', error);
});
}
});
// Enable styles of current site on login.
eventsProvider.on(CoreEventsProvider.LOGIN, (data) => {
remoteThemesProvider.unloadTmpStyles();
remoteThemesProvider.enable(data.siteId);
});
// Disable added styles on logout.
eventsProvider.on(CoreEventsProvider.LOGOUT, (data) => {
remoteThemesProvider.clear();
});
// Remove site styles when a site is deleted.
eventsProvider.on(CoreEventsProvider.SITE_DELETED, (site) => {
remoteThemesProvider.removeSite(site.id);
});
// Load temporary styles when site config is checked in login.
eventsProvider.on(CoreEventsProvider.LOGIN_SITE_CHECKED, (data) => {
remoteThemesProvider.loadTmpStyles(data.config.mobilecssurl).catch((error) => {
logger.error('Error loading tmp styles', error);
});
});
// Unload temporary styles when site config is "unchecked" in login.
eventsProvider.on(CoreEventsProvider.LOGIN_SITE_UNCHECKED, (data) => {
if (data.siteId && data.siteId === addingSite) {
// The tmp styles are from a site that is being added permanently.
// Wait for the final site styles to be loaded before removing the tmp styles so there is no blink effect.
} else {
// The tmp styles are from a site that wasn't added in the end. Just remove them.
remoteThemesProvider.unloadTmpStyles();
}
});
}
示例4:
localNotificationsProvider.registerClick(AddonCalendarProvider.COMPONENT, (data) => {
if (data.eventid) {
initDelegate.ready().then(() => {
calendarProvider.isDisabled(data.siteId).then((disabled) => {
if (disabled) {
// The calendar is disabled in the site, don't open it.
return;
}
loginHelper.redirect('AddonCalendarListPage', {eventId: data.eventid}, data.siteId);
});
});
}
});
示例5: ionViewDidLoad
/**
* View loaded.
*/
ionViewDidLoad(): void {
// Wait for the app to be ready.
this.initDelegate.ready().then(() => {
// Check if there was a pending redirect.
const redirectData = this.appProvider.getRedirect();
if (redirectData.siteId && redirectData.page) {
// Unset redirect data.
this.appProvider.storeRedirect('', '', '');
// Only accept the redirect if it was stored less than 20 seconds ago.
if (Date.now() - redirectData.timemodified < 20000) {
if (redirectData.siteId != CoreConstants.NO_SITE_ID) {
// The redirect is pointing to a site, load it.
return this.sitesProvider.loadSite(redirectData.siteId, redirectData.page, redirectData.params)
.then((loggedIn) => {
if (loggedIn) {
return this.loginHelper.goToSiteInitialPage(this.navCtrl, redirectData.page, redirectData.params,
{ animate: false });
}
}).catch(() => {
// Site doesn't exist.
return this.loadPage();
});
} else {
// No site to load, just open the state.
return this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false });
}
}
}
return this.loadPage();
}).then(() => {
// If we hide the splash screen now, the init view is still seen for an instant. Wait a bit to make sure it isn't seen.
setTimeout(() => {
this.splashScreen.hide();
}, 100);
});
}