android.content.ComponentCallbacks Java Examples
The following examples show how to use
android.content.ComponentCallbacks.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColorPickerDialog.java From Hangar with GNU General Public License v3.0 | 6 votes |
public ColorPickerDialog(Context context, int initialColor) { super(context); context.registerComponentCallbacks(new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration newConfig) { setUp(mOldColor.getColor(), mNewColor.getColor()); setAlphaSliderVisible(mAlphaSliderEnabled); setHexValueEnabled(mHexValueEnabled); } @Override public void onLowMemory() { } }); init(initialColor); }
Example #2
Source File: FrameworkLifecycleHandler.java From atlas with Apache License 2.0 | 6 votes |
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() { } }); }
Example #3
Source File: Application.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@CallSuper public void onConfigurationChanged(Configuration newConfig) { Object[] callbacks = collectComponentCallbacks(); if (callbacks != null) { for (int i=0; i<callbacks.length; i++) { ((ComponentCallbacks)callbacks[i]).onConfigurationChanged(newConfig); } } }
Example #4
Source File: DeviceDisplayInfo.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private void registerListener() { mAppContext.registerComponentCallbacks( new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration configuration) { updateNativeSharedDisplayInfo(); } @Override public void onLowMemory() { } }); }
Example #5
Source File: DeviceDisplayInfo.java From android-chromium with BSD 2-Clause "Simplified" License | 5 votes |
private void registerListener() { mAppContext.registerComponentCallbacks( new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration configuration) { updateNativeSharedDisplayInfo(); } @Override public void onLowMemory() { } }); }
Example #6
Source File: ViewConfigurationHelper.java From 365browser with Apache License 2.0 | 5 votes |
private void registerListener() { ContextUtils.getApplicationContext().registerComponentCallbacks( new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration configuration) { updateNativeViewConfigurationIfNecessary(); } @Override public void onLowMemory() { } }); }
Example #7
Source File: UmaSessionStats.java From 365browser with Apache License 2.0 | 5 votes |
/** * 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(); DefaultBrowserInfo.logDefaultBrowserStats(); }
Example #8
Source File: UmaSessionStats.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #9
Source File: UmaSessionStats.java From delion with Apache License 2.0 | 5 votes |
/** * 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); NetworkChangeNotifier.addConnectionTypeObserver(this); updatePreferences(); updateMetricsServiceState(); }
Example #10
Source File: DensityAdaption.java From HaoReader with GNU General Public License v3.0 | 5 votes |
public static void setCustomDensity(@NonNull AppCompatActivity activity, @NonNull final Application application) { final DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics(); if (sNonCompatDensity == 0) { sNonCompatDensity = appDisplayMetrics.density; sNonCompatScaledDensity = appDisplayMetrics.scaledDensity; application.registerComponentCallbacks(new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration newConfig) { if (newConfig != null && newConfig.fontScale > 0) { sNonCompatScaledDensity = application.getResources().getDisplayMetrics().scaledDensity; } } @Override public void onLowMemory() { } }); } final float targetDensity; Configuration configuration = activity.getResources().getConfiguration(); //获取设置的配置信息 if (configuration.orientation == Configuration.ORIENTATION_PORTRAIT) { targetDensity = appDisplayMetrics.widthPixels / 360f; } else { targetDensity = appDisplayMetrics.heightPixels / 640f; } final float targetScaledDensity = targetDensity * (sNonCompatScaledDensity / sNonCompatDensity); final int targetDensityDpi = (int) (160 * targetDensity); appDisplayMetrics.density = targetDensity; appDisplayMetrics.scaledDensity = targetScaledDensity; appDisplayMetrics.densityDpi = targetDensityDpi; final DisplayMetrics activityDisplayMetrics = activity.getResources().getDisplayMetrics(); activityDisplayMetrics.density = targetDensity; activityDisplayMetrics.scaledDensity = targetScaledDensity; activityDisplayMetrics.densityDpi = targetDensityDpi; }
Example #11
Source File: DisplayUtils.java From WanAndroid with MIT License | 5 votes |
public static void setCustomDensity(@NonNull Activity activity, @NonNull final Application application) { DisplayMetrics appDisplayMetrics = application.getResources().getDisplayMetrics(); if (sNoncompatDensity == 0) { sNoncompatDensity = appDisplayMetrics.density; sNoncompatScaledDensity = appDisplayMetrics.scaledDensity; // 防止系统切换后不起作用 application.registerComponentCallbacks(new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration newConfig) { if (newConfig != null && newConfig.fontScale > 0) { sNoncompatScaledDensity = application.getResources().getDisplayMetrics().scaledDensity; } } @Override public void onLowMemory() { } }); } float targetDensity = appDisplayMetrics.widthPixels / 360; // 防止字体变小 float targetScaleDensity = targetDensity * (sNoncompatScaledDensity / sNoncompatDensity); int targetDensityDpi = (int) (160 * targetDensity); appDisplayMetrics.density = targetDensity; appDisplayMetrics.scaledDensity = targetScaleDensity; appDisplayMetrics.densityDpi = targetDensityDpi; final DisplayMetrics activityDisplayMetrics = activity.getResources().getDisplayMetrics(); activityDisplayMetrics.density = targetDensity; activityDisplayMetrics.scaledDensity = targetScaleDensity; activityDisplayMetrics.densityDpi = targetDensityDpi; }
Example #12
Source File: Application.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
@CallSuper public void onLowMemory() { Object[] callbacks = collectComponentCallbacks(); if (callbacks != null) { for (int i=0; i<callbacks.length; i++) { ((ComponentCallbacks)callbacks[i]).onLowMemory(); } } }
Example #13
Source File: Density.java From Collection-Android with MIT License | 5 votes |
/** * 设计稿的宽度,以dp为单位,后面需要以f(浮点型)比如375f * @param application * @param width */ public static void setDensity(@NonNull final Application application, float width) { appDisplayMetrics = application.getResources().getDisplayMetrics(); WIDTH = width; registerActivityLifecycleCallbacks(application); if (appDensity == 0) { //初始化的时候赋值 appDensity = appDisplayMetrics.density; appScaledDensity = appDisplayMetrics.scaledDensity; //添加字体变化的监听 application.registerComponentCallbacks(new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration newConfig) { //字体改变后,将appScaledDensity重新赋值 if (newConfig != null && newConfig.fontScale > 0) { appScaledDensity = application.getResources().getDisplayMetrics().scaledDensity; } } @Override public void onLowMemory() { } }); } }
Example #14
Source File: DensityUtils.java From YCAudioPlayer with Apache License 2.0 | 5 votes |
public static void setDensity(@NonNull Application application) { //获取application的DisplayMetrics //DisplayMetrics 类提供了一种关于显示的通用信息,如显示大小,分辨率和字体。 appDisplayMetrics = application.getResources().getDisplayMetrics(); //获取状态栏高度 barHeight = StatusBarUtils.getStatusBarHeight(application); if (appDensity == 0) { //初始化的时候赋值 appDensity = appDisplayMetrics.density; appScaledDensity = appDisplayMetrics.scaledDensity; //添加字体变化的监听 application.registerComponentCallbacks(new ComponentCallbacks() { @Override public void onConfigurationChanged(Configuration newConfig) { //字体改变后,将appScaledDensity重新赋值 if (newConfig != null && newConfig.fontScale > 0) { appScaledDensity = BaseApplication.getInstance().getResources() .getDisplayMetrics().scaledDensity; } } @Override public void onLowMemory() { } }); } }
Example #15
Source File: FakeApplication.java From RxAppState with MIT License | 4 votes |
@Override public void registerComponentCallbacks(ComponentCallbacks callback) { if (callback instanceof ComponentCallbacks2) { componentCallbacks.add((ComponentCallbacks2) callback); } }
Example #16
Source File: LocalAidlServices.java From deagle with Apache License 2.0 | 4 votes |
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH) private static void unregisterComponentCallbacks(final Application app, final ComponentCallbacks callbacks) { if (app == null || VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH) return; app.unregisterComponentCallbacks(callbacks); }
Example #17
Source File: LocalAidlServices.java From deagle with Apache License 2.0 | 4 votes |
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH) private static void registerComponentCallbacks(final Application app, final ComponentCallbacks callbacks) { if (VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH) return; app.registerComponentCallbacks(callbacks); }
Example #18
Source File: Application.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public void registerComponentCallbacks(ComponentCallbacks callback) { synchronized (mComponentCallbacks) { mComponentCallbacks.add(callback); } }
Example #19
Source File: Application.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
public void unregisterComponentCallbacks(ComponentCallbacks callback) { synchronized (mComponentCallbacks) { mComponentCallbacks.remove(callback); } }
Example #20
Source File: BlueprintActivity.java From CompositeAndroid with Apache License 2.0 | 4 votes |
/** * Remove a {@link ComponentCallbacks} object that was previously registered * with {@link #registerComponentCallbacks(ComponentCallbacks)}. */ @Override public void unregisterComponentCallbacks(ComponentCallbacks callback) { super.unregisterComponentCallbacks(callback); }
Example #21
Source File: FakeApplication.java From RxAppState with MIT License | 4 votes |
@Override public void unregisterComponentCallbacks(ComponentCallbacks callback) { if (callback instanceof ComponentCallbacks2) { componentCallbacks.remove(callback); } }
Example #22
Source File: DelegateApplication.java From BtPlayer with Apache License 2.0 | 4 votes |
@Override public void unregisterComponentCallbacks(ComponentCallbacks callback) { app.unregisterComponentCallbacks(callback); }
Example #23
Source File: ContextUtil.java From PowerFileExplorer with GNU General Public License v3.0 | 4 votes |
@TargetApi(14) public static void registerComponentCallbacks(ComponentCallbacks callback) { Base.getContext().registerComponentCallbacks(callback); }
Example #24
Source File: CondomContext.java From MiPushFramework with GNU General Public License v3.0 | 4 votes |
@Override public void unregisterComponentCallbacks(final ComponentCallbacks callback) { if (SDK_INT >= ICE_CREAM_SANDWICH) mApplication.unregisterComponentCallbacks(callback); }
Example #25
Source File: DelegateApplication.java From BtPlayer with Apache License 2.0 | 4 votes |
@Override public void registerComponentCallbacks(ComponentCallbacks callback) { app.registerComponentCallbacks(callback); }
Example #26
Source File: DelegateApplication.java From AndroidDownload with Apache License 2.0 | 4 votes |
@Override public void registerComponentCallbacks(ComponentCallbacks callback) { app.registerComponentCallbacks(callback); }
Example #27
Source File: DelegateApplication.java From AndroidDownload with Apache License 2.0 | 4 votes |
@Override public void unregisterComponentCallbacks(ComponentCallbacks callback) { app.unregisterComponentCallbacks(callback); }
Example #28
Source File: CondomApplication.java From condom with Apache License 2.0 | 4 votes |
@Override public void registerComponentCallbacks(final ComponentCallbacks callback) { if (SDK_INT >= ICE_CREAM_SANDWICH) mApplication.registerComponentCallbacks(callback); }
Example #29
Source File: CondomApplication.java From condom with Apache License 2.0 | 4 votes |
@Override public void unregisterComponentCallbacks(final ComponentCallbacks callback) { if (SDK_INT >= ICE_CREAM_SANDWICH) mApplication.unregisterComponentCallbacks(callback); }
Example #30
Source File: customApp.java From AndroidDemo with MIT License | 4 votes |
@Override public void registerComponentCallbacks(ComponentCallbacks callback) { Log.d(TAG, "registerComponentCallbacks"); super.registerComponentCallbacks(callback); }