Search in sources :

Example 81 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project SublimePicker by vikramkakkar.

the class SUtils method createThemeWrapper.

public static ContextThemeWrapper createThemeWrapper(Context context, int parentStyleAttr, int parentDefaultStyle, int childStyleAttr, int childDefaultStyle) {
    final TypedArray forParent = context.obtainStyledAttributes(new int[] { parentStyleAttr });
    int parentStyle = forParent.getResourceId(0, parentDefaultStyle);
    forParent.recycle();
    TypedArray forChild = context.obtainStyledAttributes(parentStyle, new int[] { childStyleAttr });
    int childStyleId = forChild.getResourceId(0, childDefaultStyle);
    forChild.recycle();
    return new ContextThemeWrapper(context, childStyleId);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray)

Example 82 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project SublimePicker by vikramkakkar.

the class SublimePicker method createThemeWrapper.

private static ContextThemeWrapper createThemeWrapper(Context context) {
    final TypedArray forParent = context.obtainStyledAttributes(new int[] { R.attr.sublimePickerStyle });
    int parentStyle = forParent.getResourceId(0, R.style.SublimePickerStyleLight);
    forParent.recycle();
    return new ContextThemeWrapper(context, parentStyle);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray)

Example 83 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project AndroidChromium by JackyAndroid.

the class WarmupManager method initializeViewHierarchy.

/**
     * Inflates and constructs the view hierarchy that the app will use.
     * @param baseContext The base context to use for creating the ContextWrapper.
     * @param toolbarContainerId Id of the toolbar container.
     */
public void initializeViewHierarchy(Context baseContext, int toolbarContainerId) {
    TraceEvent.begin("WarmupManager.initializeViewHierarchy");
    // Inflating the view hierarchy causes StrictMode violations on some
    // devices. Since layout inflation should happen on the UI thread, allow
    // the disk reads. crbug.com/644243.
    StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
    try {
        ThreadUtils.assertOnUiThread();
        if (mMainView != null && mToolbarContainerId == toolbarContainerId)
            return;
        ContextThemeWrapper context = new ContextThemeWrapper(baseContext, ChromeActivity.getThemeId());
        FrameLayout contentHolder = new FrameLayout(context);
        mMainView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.main, contentHolder);
        mToolbarContainerId = toolbarContainerId;
        if (toolbarContainerId != ChromeActivity.NO_CONTROL_CONTAINER) {
            ViewStub stub = (ViewStub) mMainView.findViewById(R.id.control_container_stub);
            stub.setLayoutResource(toolbarContainerId);
            stub.inflate();
        }
    } catch (InflateException e) {
        // See crbug.com/606715.
        Log.e(TAG, "Inflation exception.", e);
        mMainView = null;
    } finally {
        StrictMode.setThreadPolicy(oldPolicy);
        TraceEvent.end("WarmupManager.initializeViewHierarchy");
    }
}
Also used : StrictMode(android.os.StrictMode) ViewStub(android.view.ViewStub) ContextThemeWrapper(android.view.ContextThemeWrapper) FrameLayout(android.widget.FrameLayout) InflateException(android.view.InflateException)

Example 84 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project android_frameworks_base by ParanoidAndroid.

the class ActionBarImpl method getThemedContext.

public Context getThemedContext() {
    if (mThemedContext == null) {
        TypedValue outValue = new TypedValue();
        Resources.Theme currentTheme = mContext.getTheme();
        currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
        final int targetThemeRes = outValue.resourceId;
        if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
            mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
        } else {
            mThemedContext = mContext;
        }
    }
    return mThemedContext;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 85 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project android_frameworks_base by ParanoidAndroid.

the class Presentation method createPresentationContext.

private static Context createPresentationContext(Context outerContext, Display display, int theme) {
    if (outerContext == null) {
        throw new IllegalArgumentException("outerContext must not be null");
    }
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }
    Context displayContext = outerContext.createDisplayContext(display);
    if (theme == 0) {
        TypedValue outValue = new TypedValue();
        displayContext.getTheme().resolveAttribute(com.android.internal.R.attr.presentationTheme, outValue, true);
        theme = outValue.resourceId;
    }
    // Derive the display's window manager from the outer window manager.
    // We do this because the outer window manager have some extra information
    // such as the parent window, which is important if the presentation uses
    // an application window type.
    final WindowManagerImpl outerWindowManager = (WindowManagerImpl) outerContext.getSystemService(Context.WINDOW_SERVICE);
    final WindowManagerImpl displayWindowManager = outerWindowManager.createPresentationWindowManager(display);
    return new ContextThemeWrapper(displayContext, theme) {

        @Override
        public Object getSystemService(String name) {
            if (Context.WINDOW_SERVICE.equals(name)) {
                return displayWindowManager;
            }
            return super.getSystemService(name);
        }
    };
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.view.ContextThemeWrapper) WindowManagerImpl(android.view.WindowManagerImpl) TypedValue(android.util.TypedValue)

Aggregations

ContextThemeWrapper (android.view.ContextThemeWrapper)122 Context (android.content.Context)65 TypedValue (android.util.TypedValue)52 Resources (android.content.res.Resources)32 View (android.view.View)22 TextView (android.widget.TextView)17 TypedArray (android.content.res.TypedArray)16 AlertDialog (android.app.AlertDialog)15 DialogInterface (android.content.DialogInterface)13 OnClickListener (android.content.DialogInterface.OnClickListener)11 Drawable (android.graphics.drawable.Drawable)11 LayoutInflater (android.view.LayoutInflater)10 RecyclerView (android.support.v7.widget.RecyclerView)8 ImageView (android.widget.ImageView)8 MenuBuilder (com.actionbarsherlock.internal.view.menu.MenuBuilder)7 Point (android.graphics.Point)6 ViewStub (android.view.ViewStub)6 WindowManagerImpl (android.view.WindowManagerImpl)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5