Java Code Examples for android.content.Context#registerComponentCallbacks()
The following examples show how to use
android.content.Context#registerComponentCallbacks() .
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: OdysseyBaseFragment.java From odyssey with GNU General Public License v3.0 | 6 votes |
@Override public void onAttach(@NonNull Context context) { super.onAttach(context); if (null == mComponentCallback) { mComponentCallback = new OdysseyComponentCallback(); } // Register the memory trim callback with the system. context.registerComponentCallbacks(mComponentCallback); // This makes sure that the container activity has implemented // the callback interface. If not, it throws an exception try { mToolbarAndFABCallback = (ToolbarAndFABCallback) context; } catch (ClassCastException e) { throw new ClassCastException(context.toString() + " must implement ToolbarAndFABCallback"); } }
Example 2
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 3
Source File: MemoryPressureListener.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative private static void registerSystemCallback(Context context) { context.registerComponentCallbacks( new ComponentCallbacks2() { @Override public void onTrimMemory(int level) { maybeNotifyMemoryPresure(level); } @Override public void onLowMemory() { nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL); } @Override public void onConfigurationChanged(Configuration configuration) { } }); }
Example 4
Source File: MemoryPressureListener.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
@CalledByNative private static void registerSystemCallback(Context context) { context.registerComponentCallbacks( new ComponentCallbacks2() { @Override public void onTrimMemory(int level) { maybeNotifyMemoryPresure(level); } @Override public void onLowMemory() { nativeOnMemoryPressure(MemoryPressureLevelList.MEMORY_PRESSURE_CRITICAL); } @Override public void onConfigurationChanged(Configuration configuration) { } }); }
Example 5
Source File: MemoryManagerImpl.java From Camera2 with Apache License 2.0 | 5 votes |
/** * Use this to create a wired-up memory manager. * * @param context this is used to register for system memory events. * @param mediaSaver this used to check if the saving queue is full. * @return A wired-up memory manager instance. */ public static MemoryManagerImpl create(Context context, MediaSaver mediaSaver) { ActivityManager activityManager = AndroidServices.instance().provideActivityManager(); int maxAllowedNativeMemory = getMaxAllowedNativeMemory(context); MemoryQuery mMemoryQuery = new MemoryQuery(activityManager); MemoryManagerImpl memoryManager = new MemoryManagerImpl(maxAllowedNativeMemory, mMemoryQuery); context.registerComponentCallbacks(memoryManager); mediaSaver.setQueueListener(memoryManager); return memoryManager; }
Example 6
Source File: AppLabelCache.java From island with Apache License 2.0 | 5 votes |
AppLabelCache(final Context context, final Callback callback) { mStore = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE); if (CLEAR_CACHE_UPON_START) mStore.edit().clear().apply(); mCallback = callback; mPackageManager = context.getPackageManager(); context.registerComponentCallbacks(this); // No un-registration since AppLabelCache is never released. onConfigurationChanged(context.getResources().getConfiguration()); }
Example 7
Source File: LanguagesChange.java From MultiLanguages with Apache License 2.0 | 4 votes |
/** * 注册系统语种变化监听 */ static void register(Context context) { context.registerComponentCallbacks(new LanguagesChange()); }
Example 8
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }
Example 9
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }
Example 10
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }
Example 11
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }
Example 12
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }
Example 13
Source File: Controller.java From droidel with Apache License 2.0 | 4 votes |
public Controller(Context ctx) { ctx.registerComponentCallbacks(this); }