Search in sources :

Example 21 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project MarkyMark-Android by M2Mobi.

the class ThemedContext method getWrapper.

/**
 * Wraps a context with a ContextThemeWrapper with the MarkyMark theme
 *
 * @param pContext
 * 		Context used by the wrapper
 * @return Returns a ContextThemeWrapper with the MarkyMark theme
 */
private static ContextThemeWrapper getWrapper(Context pContext) {
    final TypedArray array = pContext.getTheme().obtainStyledAttributes(new int[] { R.attr.MarkyMarkTheme });
    final int id = array.getResourceId(0, R.style.MarkyMarkStyle);
    array.recycle();
    return new ContextThemeWrapper(pContext, id);
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray)

Example 22 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project FastHub by k0shk0sh.

the class BaseDialogFragment method onCreateView.

@SuppressLint("RestrictedApi")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentLayout() != 0) {
        final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
        LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
        View view = themeAwareInflater.inflate(fragmentLayout(), container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
    return super.onCreateView(inflater, container, savedInstanceState);
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Nullable(android.support.annotation.Nullable)

Example 23 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project FastHub by k0shk0sh.

the class BaseFragment method onCreateView.

@SuppressLint("RestrictedApi")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentLayout() != 0) {
        final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
        LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
        View view = themeAwareInflater.inflate(fragmentLayout(), container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
    return super.onCreateView(inflater, container, savedInstanceState);
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Nullable(android.support.annotation.Nullable)

Example 24 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project FastHub by k0shk0sh.

the class BaseMvpBottomSheetDialogFragment method onCreateView.

@SuppressLint("RestrictedApi")
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (fragmentLayout() != 0) {
        final Context contextThemeWrapper = new ContextThemeWrapper(getContext(), getContext().getTheme());
        LayoutInflater themeAwareInflater = inflater.cloneInContext(contextThemeWrapper);
        View view = themeAwareInflater.inflate(fragmentLayout(), container, false);
        unbinder = ButterKnife.bind(this, view);
        return view;
    }
    return super.onCreateView(inflater, container, savedInstanceState);
}
Also used : Context(android.content.Context) ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) LayoutInflater(android.view.LayoutInflater) View(android.view.View) SuppressLint(android.annotation.SuppressLint) Nullable(android.support.annotation.Nullable)

Example 25 with ContextThemeWrapper

use of android.support.v7.view.ContextThemeWrapper in project EssayJoke by qiyei2015.

the class SkinAppCompatViewInflater method themifyContext.

/**
 * Allows us to emulate the {@code android:theme} attribute for devices before L.
 */
private static Context themifyContext(Context context, AttributeSet attrs, boolean useAndroidTheme, boolean useAppTheme) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.View, 0, 0);
    int themeId = 0;
    if (useAndroidTheme) {
        // First try reading android:theme if enabled
        themeId = a.getResourceId(R.styleable.View_android_theme, 0);
    }
    if (useAppTheme && themeId == 0) {
        // ...if that didn't work, try reading app:theme (for legacy reasons) if enabled
        themeId = a.getResourceId(R.styleable.View_theme, 0);
        if (themeId != 0) {
            LogManager.i(LOG_TAG, "app:theme is now deprecated. " + "Please move to using android:theme instead.");
        }
    }
    a.recycle();
    if (themeId != 0 && (!(context instanceof ContextThemeWrapper) || ((ContextThemeWrapper) context).getThemeResId() != themeId)) {
        // If the context isn't a ContextThemeWrapper, or it is but does not have
        // the same theme as we need, wrap it in a new wrapper
        context = new ContextThemeWrapper(context, themeId);
    }
    return context;
}
Also used : ContextThemeWrapper(android.support.v7.view.ContextThemeWrapper) TypedArray(android.content.res.TypedArray)

Aggregations

View (android.view.View)40 ContextThemeWrapper (android.support.v7.view.ContextThemeWrapper)38 ContextThemeWrapper (android.view.ContextThemeWrapper)31 Context (android.content.Context)25 DialogInterface (android.content.DialogInterface)24 TextView (android.widget.TextView)22 RecyclerView (android.support.v7.widget.RecyclerView)21 ImageView (android.widget.ImageView)21 AlertDialog (android.support.v7.app.AlertDialog)20 LayoutInflater (android.view.LayoutInflater)18 Intent (android.content.Intent)13 Nullable (android.support.annotation.Nullable)10 ColorPreferences (me.ccrama.redditslide.ColorPreferences)10 Drawable (android.graphics.drawable.Drawable)9 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)9 EditText (android.widget.EditText)8 Bundle (android.os.Bundle)7 ArrayList (java.util.ArrayList)7 SuppressLint (android.annotation.SuppressLint)6 Dialog (android.app.Dialog)6