Search in sources :

Example 1 with ComponentCallbacks

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();
                        }
                    }
                }
            }
        }
    }
}
Also used : BundleImpl(android.taobao.atlas.framework.BundleImpl) ComponentCallbacks(android.content.ComponentCallbacks) Configuration(android.content.res.Configuration) BundleInstaller(android.taobao.atlas.framework.BundleInstaller) BundleException(org.osgi.framework.BundleException)

Example 2 with ComponentCallbacks

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();
}
Also used : ComponentCallbacks(android.content.ComponentCallbacks) Configuration(android.content.res.Configuration) Tab(org.chromium.chrome.browser.tab.Tab) TabModelSelectorTabObserver(org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)

Aggregations

ComponentCallbacks (android.content.ComponentCallbacks)2 Configuration (android.content.res.Configuration)2 BundleImpl (android.taobao.atlas.framework.BundleImpl)1 BundleInstaller (android.taobao.atlas.framework.BundleInstaller)1 Tab (org.chromium.chrome.browser.tab.Tab)1 TabModelSelectorTabObserver (org.chromium.chrome.browser.tabmodel.TabModelSelectorTabObserver)1 BundleException (org.osgi.framework.BundleException)1