Example usage for android.support.v4.view LayoutInflaterCompat setFactory

List of usage examples for android.support.v4.view LayoutInflaterCompat setFactory

Introduction

In this page you can find the example usage for android.support.v4.view LayoutInflaterCompat setFactory.

Prototype

public static void setFactory(LayoutInflater inflater, LayoutInflaterFactory factory) 

Source Link

Document

Attach a custom Factory interface for creating views while using this LayoutInflater.

Usage

From source file:org.mariotaku.twidere.fragment.support.BaseSupportFragment.java

@Override
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    if (!(activity instanceof IThemedActivity)) {
        return super.getLayoutInflater(savedInstanceState);
    }//from  ww w  .j  a  va 2s .c  o m
    final LayoutInflater inflater = activity.getLayoutInflater().cloneInContext(getThemedContext());
    getChildFragmentManager(); // Init if needed; use raw implementation below.
    final LayoutInflaterFactory delegate = FragmentManagerTrojan
            .getLayoutInflaterFactory(getChildFragmentManager());
    LayoutInflaterCompat.setFactory(inflater,
            new ThemedLayoutInflaterFactory((IThemedActivity) activity, delegate));
    return inflater;
}

From source file:com.nttec.everychan.ui.theme.CustomThemeHelper.java

public static void setCustomTheme(Context context, SparseIntArray customAttrs) {
    if (customAttrs == null || customAttrs.size() == 0) {
        currentAttrs = null;//  w  ww .  java 2  s . c  o  m
        return;
    }

    TypedValue tmp = new TypedValue();
    context.getTheme().resolveAttribute(android.R.attr.textColorPrimary, tmp, true);
    int textColorPrimaryOriginal = (tmp.type >= TypedValue.TYPE_FIRST_COLOR_INT
            && tmp.type <= TypedValue.TYPE_LAST_COLOR_INT) ? tmp.data : Color.TRANSPARENT;
    int textColorPrimaryOverridden = customAttrs.get(android.R.attr.textColorPrimary, textColorPrimaryOriginal);

    try {
        processWindow(context, customAttrs, textColorPrimaryOriginal, textColorPrimaryOverridden);
    } catch (Exception e) {
        Logger.e(TAG, e);
    }

    CustomThemeHelper instance = new CustomThemeHelper(context, customAttrs, textColorPrimaryOriginal,
            textColorPrimaryOverridden);
    LayoutInflaterCompat.setFactory(instance.inflater, instance);
    currentAttrs = customAttrs;
}

From source file:android.support.v7.app.AppCompatDelegateImplV7.java

@Override
public void installViewFactory() {
    LayoutInflater layoutInflater = LayoutInflater.from(mContext);
    if (layoutInflater.getFactory() == null) {
        LayoutInflaterCompat.setFactory(layoutInflater, this);
    } else {//from  w  ww  .ja  v a2  s . c o  m
        Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed"
                + " so we can not install AppCompat's");
    }
}