Search in sources :

Example 21 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class ListMenuPresenter method initForMenu.

@Override
public void initForMenu(@NonNull Context context, @Nullable MenuBuilder menu) {
    if (mThemeRes != 0) {
        mContext = new ContextThemeWrapper(context, mThemeRes);
        mInflater = LayoutInflater.from(mContext);
    } else if (mContext != null) {
        mContext = context;
        if (mInflater == null) {
            mInflater = LayoutInflater.from(mContext);
        }
    }
    mMenu = menu;
    if (mAdapter != null) {
        mAdapter.notifyDataSetChanged();
    }
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper)

Example 22 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

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(displayContext);
    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)

Example 23 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project platform_frameworks_base by android.

the class FloatingToolbar method applyDefaultTheme.

/**
     * Returns a re-themed context with controlled look and feel for views.
     */
private static Context applyDefaultTheme(Context originalContext) {
    TypedArray a = originalContext.obtainStyledAttributes(new int[] { R.attr.isLightTheme });
    boolean isLightTheme = a.getBoolean(0, true);
    int themeId = isLightTheme ? R.style.Theme_Material_Light : R.style.Theme_Material;
    a.recycle();
    return new ContextThemeWrapper(originalContext, themeId);
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray) Point(android.graphics.Point)

Example 24 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project danci by ling0322.

the class ReciteFragment method onStartButtonClicked.

private void onStartButtonClicked() {
    state = FIRST;
    recite.start();
    if (recite.isFinsihed() == true) {
        Dialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AnneDialog)).setMessage("今天的单词都背完了哦,明天继续复习吧:)").setNegativeButton("确定", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface arg0, int arg1) {
            }
        }).create();
        dialog.show();
    } else {
        showTestButtons();
        updateDiaplay();
    }
}
Also used : AlertDialog(android.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.view.View.OnClickListener)

Example 25 with ContextThemeWrapper

use of android.view.ContextThemeWrapper in project danci by ling0322.

the class ReciteFragment method onBackKey.

@Override
public boolean onBackKey() {
    if (recite.isFinsihed() == true) {
        System.exit(0);
    }
    Dialog dialog = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.AnneDialog)).setMessage("单词还没有背完, 确定要退出吗?").setPositiveButton("退出", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface arg0, int arg1) {
            System.exit(0);
        }
    }).setNegativeButton("取消", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface arg0, int arg1) {
        }
    }).create();
    dialog.show();
    return true;
}
Also used : ContextThemeWrapper(android.view.ContextThemeWrapper) AlertDialog(android.app.AlertDialog) Dialog(android.app.Dialog) OnClickListener(android.view.View.OnClickListener)

Aggregations

ContextThemeWrapper (android.view.ContextThemeWrapper)121 Context (android.content.Context)64 TypedValue (android.util.TypedValue)52 Resources (android.content.res.Resources)32 View (android.view.View)22 TypedArray (android.content.res.TypedArray)16 TextView (android.widget.TextView)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