Search in sources :

Example 6 with Context

use of android.content.Context in project Launcher3 by chislon.

the class Workspace method initWorkspace.

/**
     * Initializes various states for this workspace.
     */
protected void initWorkspace() {
    Context context = getContext();
    mCurrentPage = mDefaultPage;
    Launcher.setScreen(mCurrentPage);
    LauncherAppState app = LauncherAppState.getInstance();
    DeviceProfile grid = app.getDynamicGrid().getDeviceProfile();
    mIconCache = app.getIconCache();
    setWillNotDraw(false);
    setClipChildren(false);
    setClipToPadding(false);
    setChildrenDrawnWithCacheEnabled(true);
    // This is a bit of a hack to account for the fact that we translate the workspace
    // up a bit, and still need to draw the background covering the whole screen.
    setMinScale(mOverviewModeShrinkFactor - 0.2f);
    setupLayoutTransition();
    final Resources res = getResources();
    try {
        mBackground = res.getDrawable(R.drawable.apps_customize_bg);
    } catch (Resources.NotFoundException e) {
    // In this case, we will skip drawing background protection
    }
    mWallpaperOffset = new WallpaperOffsetInterpolator();
    Display display = mLauncher.getWindowManager().getDefaultDisplay();
    display.getSize(mDisplaySize);
    mMaxDistanceForFolderCreation = (0.55f * grid.iconSizePx);
    mFlingThresholdVelocity = (int) (FLING_THRESHOLD_VELOCITY * mDensity);
}
Also used : Context(android.content.Context) Resources(android.content.res.Resources) Display(android.view.Display)

Example 7 with Context

use of android.content.Context in project Launcher3 by chislon.

the class LauncherProvider method onCreate.

@Override
public boolean onCreate() {
    final Context context = getContext();
    mOpenHelper = new DatabaseHelper(context);
    LauncherAppState.setLauncherProvider(this);
    return true;
}
Also used : Context(android.content.Context)

Example 8 with Context

use of android.content.Context in project cucumber-jvm by cucumber.

the class AndroidObjectFactoryTest method injects_instrumentation_context_into_AndroidTestCase.

@Test
public void injects_instrumentation_context_into_AndroidTestCase() {
    // given
    final Class<?> androidTestCaseClass = AndroidTestCase.class;
    final AndroidTestCase androidTestCase = mock(AndroidTestCase.class);
    when(delegate.getInstance(androidTestCaseClass)).thenReturn(androidTestCase);
    final Context context = mock(Context.class);
    when(instrumentation.getTargetContext()).thenReturn(context);
    // when
    androidObjectFactory.getInstance(androidTestCaseClass);
    // then
    verify(androidTestCase).setContext(context);
}
Also used : Context(android.content.Context) AndroidTestCase(android.test.AndroidTestCase) Test(org.junit.Test)

Example 9 with Context

use of android.content.Context in project philm by chrisbanes.

the class ListFragment method onCreateView.

/**
     * Provide default implementation to return a simple list view.  Subclasses
     * can override to replace with their own layout.  If doing so, the
     * returned view hierarchy <em>must</em> have a ListView whose id
     * is {@link android.R.id#list android.R.id.list} and can optionally
     * have a sibling view id {@link android.R.id#empty android.R.id.empty}
     * that is to be shown when the list is empty.
     *
     * <p>If you are overriding this method with your own custom content,
     * consider including the standard layout {@link android.R.layout#list_content}
     * in your layout file, so that you continue to retain all of the standard
     * behavior of ListFragment.  In particular, this is currently the only
     * way to have the built-in indeterminant progress state be shown.
     */
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();
    FrameLayout contentRoot = new FrameLayout(context);
    // ------------------------------------------------------------------
    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    progress.setId(INTERNAL_PROGRESS_ID);
    progress.setVisibility(View.GONE);
    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER;
    contentRoot.addView(progress, lp);
    // ------------------------------------------------------------------
    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);
    FontTextView tv = new FontTextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    tv.setFont(FontTextView.FONT_ROBOTO_CONDENSED);
    final int p = getResources().getDimensionPixelSize(R.dimen.spacing_major);
    tv.setPadding(p, p, p, p);
    lframe.addView(tv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    E lv = createListView(context, inflater);
    lv.setId(android.R.id.list);
    lframe.addView(lv, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    contentRoot.addView(lframe, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
    // ------------------------------------------------------------------
    ProgressBar secondaryProgress = new SmoothProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
    secondaryProgress.setId(INTERNAL_SECONDARY_PROGRESS_ID);
    secondaryProgress.setVisibility(View.GONE);
    secondaryProgress.setIndeterminate(true);
    contentRoot.addView(secondaryProgress, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM));
    View root;
    if (getParentFragment() == null) {
        final LinearLayout toolbarRoot = new LinearLayout(context);
        toolbarRoot.setOrientation(LinearLayout.VERTICAL);
        // Finally, add the Toolbar
        inflater.inflate(R.layout.include_toolbar, toolbarRoot, true);
        toolbarRoot.addView(contentRoot, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f));
        root = toolbarRoot;
    } else {
        root = contentRoot;
    }
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    return root;
}
Also used : Context(android.content.Context) ViewGroup(android.view.ViewGroup) FontTextView(app.philm.in.view.FontTextView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) FrameLayout(android.widget.FrameLayout) FontTextView(app.philm.in.view.FontTextView) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) ProgressBar(android.widget.ProgressBar) SmoothProgressBar(fr.castorflex.android.smoothprogressbar.SmoothProgressBar) LinearLayout(android.widget.LinearLayout)

Example 10 with Context

use of android.content.Context in project ENViews by codeestX.

the class ExampleInstrumentedTest method useAppContext.

@Test
public void useAppContext() throws Exception {
    // Context of the app under test.
    Context appContext = InstrumentationRegistry.getTargetContext();
    assertEquals("moe.codeest.enviewsdemo", appContext.getPackageName());
}
Also used : Context(android.content.Context) Test(org.junit.Test)

Aggregations

Context (android.content.Context)7516 Test (org.junit.Test)1645 Intent (android.content.Intent)1356 View (android.view.View)797 TextView (android.widget.TextView)549 BroadcastReceiver (android.content.BroadcastReceiver)497 IntentFilter (android.content.IntentFilter)485 PackageManager (android.content.pm.PackageManager)383 Resources (android.content.res.Resources)369 ArrayList (java.util.ArrayList)358 Bundle (android.os.Bundle)292 PendingIntent (android.app.PendingIntent)281 File (java.io.File)280 LayoutInflater (android.view.LayoutInflater)279 ImageView (android.widget.ImageView)263 Drawable (android.graphics.drawable.Drawable)256 IOException (java.io.IOException)248 Uri (android.net.Uri)247 RecyclerView (android.support.v7.widget.RecyclerView)200 Activity (android.app.Activity)198