Search in sources :

Example 96 with ContextWrapper

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));
}
Also used : RequestManager(com.bumptech.glide.RequestManager) ContextWrapper(android.content.ContextWrapper) Test(org.junit.Test)

Example 97 with 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));
}
Also used : RequestManager(com.bumptech.glide.RequestManager) ContextWrapper(android.content.ContextWrapper) Test(org.junit.Test)

Example 98 with 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);
}
Also used : OverlayManager(com.android.settings.display.ThemePreferenceController.OverlayManager) ThemePreferenceController(com.android.settings.display.ThemePreferenceController) PackageManager(android.content.pm.PackageManager) ContextWrapper(android.content.ContextWrapper) Before(org.junit.Before)

Example 99 with ContextWrapper

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;
    }
}
Also used : ContextWrapper(android.content.ContextWrapper)

Example 100 with ContextWrapper

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;
}
Also used : Activity(android.app.Activity) Intent(android.content.Intent) ContextWrapper(android.content.ContextWrapper)

Aggregations

ContextWrapper (android.content.ContextWrapper)109 Context (android.content.Context)37 Activity (android.app.Activity)25 File (java.io.File)16 Test (org.junit.Test)13 Intent (android.content.Intent)11 MockContentResolver (android.test.mock.MockContentResolver)11 PackageManager (android.content.pm.PackageManager)10 View (android.view.View)10 Resources (android.content.res.Resources)9 IOException (java.io.IOException)8 Before (org.junit.Before)8 ContentResolver (android.content.ContentResolver)6 UserManager (android.os.UserManager)6 LayoutInflater (android.view.LayoutInflater)6 ThemePreferenceController (com.android.settings.display.ThemePreferenceController)6 OverlayManager (com.android.settings.display.ThemePreferenceController.OverlayManager)6 ArrayList (java.util.ArrayList)6 AppWidgetHostView (android.appwidget.AppWidgetHostView)5 JsonParser (com.google.gson.JsonParser)5