use of android.content.ContextWrapper in project glide by bumptech.
the class RequestManagerRetrieverTest method testHandlesContextWrappersForActivities.
@Test
public void testHandlesContextWrappersForActivities() {
RetrieverHarness harness = new DefaultRetrieverHarness();
RequestManager requestManager = harness.doGet();
ContextWrapper contextWrapper = new ContextWrapper(harness.getController().get());
assertEquals(requestManager, retriever.get(contextWrapper));
}
use of android.content.ContextWrapper in project glide by bumptech.
the class RequestManagerRetrieverTest method testHandlesContextWrappersForApplication.
@Test
public void testHandlesContextWrappersForApplication() {
ContextWrapper contextWrapper = new ContextWrapper(RuntimeEnvironment.application);
RequestManager requestManager = retriever.get(RuntimeEnvironment.application);
assertEquals(requestManager, retriever.get(contextWrapper));
}
use of android.content.ContextWrapper in project platform_packages_apps_Settings by BlissRoms.
the class ThemePreferenceControllerTest method setup.
@Before
public void setup() {
mMockOverlayManager = mock(OverlayManager.class);
mMockPackageManager = mock(PackageManager.class);
mContext = new ContextWrapper(InstrumentationRegistry.getTargetContext()) {
@Override
public PackageManager getPackageManager() {
return mMockPackageManager;
}
};
mPreferenceController = new ThemePreferenceController(mContext, mMockOverlayManager);
}
use of android.content.ContextWrapper in project Timber by naman14.
the class MusicPlayer method unbindFromService.
public static void unbindFromService(final ServiceToken token) {
if (token == null) {
return;
}
final ContextWrapper mContextWrapper = token.mWrappedContext;
final ServiceBinder mBinder = mConnectionMap.remove(mContextWrapper);
if (mBinder == null) {
return;
}
mContextWrapper.unbindService(mBinder);
if (mConnectionMap.isEmpty()) {
mService = null;
}
}
use of android.content.ContextWrapper in project Timber by naman14.
the class MusicPlayer method bindToService.
public static final ServiceToken bindToService(final Context context, final ServiceConnection callback) {
Activity realActivity = ((Activity) context).getParent();
if (realActivity == null) {
realActivity = (Activity) context;
}
final ContextWrapper contextWrapper = new ContextWrapper(realActivity);
contextWrapper.startService(new Intent(contextWrapper, MusicService.class));
final ServiceBinder binder = new ServiceBinder(callback, contextWrapper.getApplicationContext());
if (contextWrapper.bindService(new Intent().setClass(contextWrapper, MusicService.class), binder, 0)) {
mConnectionMap.put(contextWrapper, binder);
return new ServiceToken(contextWrapper);
}
return null;
}
Aggregations