use of android.content.ComponentCallbacks in project atlas by alibaba.
the class FrameworkLifecycleHandler method started.
private void started() {
RuntimeVariables.androidApplication.registerActivityLifecycleCallbacks(new ActivityLifeCycleObserver());
RuntimeVariables.androidApplication.registerComponentCallbacks(new ComponentCallbacks() {
@Override
public void onConfigurationChanged(Configuration newConfig) {
if (RuntimeVariables.delegateResources != null) {
RuntimeVariables.delegateResources.updateConfiguration(newConfig, RuntimeVariables.delegateResources.getDisplayMetrics());
}
}
@Override
public void onLowMemory() {
}
});
if (RuntimeVariables.getProcessName(RuntimeVariables.androidApplication).equals(RuntimeVariables.androidApplication.getPackageName())) {
String autoStartBundle = (String) RuntimeVariables.getFrameworkProperty("autoStartBundles");
if (autoStartBundle != null) {
String[] bundles = autoStartBundle.split(",");
if (bundles.length > 0) {
for (int x = 0; x < bundles.length; x++) {
final String bundleName = bundles[0];
BundleImpl impl = (BundleImpl) Atlas.getInstance().getBundle(bundleName);
if (impl == null) {
BundleInstaller.startDelayInstall(bundleName, new BundleInstaller.InstallListener() {
@Override
public void onFinished() {
BundleImpl impl = (BundleImpl) Atlas.getInstance().getBundle(bundleName);
if (impl != null) {
try {
impl.start();
} catch (BundleException e) {
e.printStackTrace();
}
}
}
});
} else {
try {
impl.start();
} catch (BundleException e) {
e.printStackTrace();
}
}
}
}
}
}
}
use of android.content.ComponentCallbacks in project AndroidChromium by JackyAndroid.
the class UmaSessionStats method startNewSession.
/**
* Starts a new session for logging.
* @param tabModelSelector A TabModelSelector instance for recording tab counts on page loads.
* If null, UmaSessionStats does not record page loads and tab counts.
*/
public void startNewSession(TabModelSelector tabModelSelector) {
ensureNativeInitialized();
mTabModelSelector = tabModelSelector;
if (mTabModelSelector != null) {
mComponentCallbacks = new ComponentCallbacks() {
@Override
public void onLowMemory() {
// Not required
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
mKeyboardConnected = newConfig.keyboard != Configuration.KEYBOARD_NOKEYS;
}
};
mContext.registerComponentCallbacks(mComponentCallbacks);
mKeyboardConnected = mContext.getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS;
mTabModelSelectorTabObserver = new TabModelSelectorTabObserver(mTabModelSelector) {
@Override
public void onPageLoadFinished(Tab tab) {
recordPageLoadStats(tab);
}
};
}
nativeUmaResumeSession(sNativeUmaSessionStats);
updatePreferences();
updateMetricsServiceState();
}
Aggregations