Java Code Examples for android.view.LayoutInflater#Factory2
The following examples show how to use
android.view.LayoutInflater#Factory2 .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: dynamic-support File: DynamicTheme.java License: Apache License 2.0 | 6 votes |
/** * Attach a local context to this theme. * <p>It can be an activity in case different themes are required for different activities. * * @param localContext The context to be attached with this theme. * @param layoutInflater The layout inflater factory for the local context. * <p>{@code null} to use no custom layout inflater. * * @return The {@link DynamicTheme} object to allow for chaining of calls to set methods. */ public DynamicTheme attach(@NonNull Context localContext, @Nullable LayoutInflater.Factory2 layoutInflater) { this.mLocalContext = localContext; this.mDefaultLocalTheme = new DynamicAppTheme(COLOR_PRIMARY_DEFAULT, COLOR_PRIMARY_DARK_DEFAULT, COLOR_ACCENT_DEFAULT, FONT_SCALE_DEFAULT, CORNER_SIZE_DEFAULT, Theme.BackgroundAware.ENABLE); this.mLocalTheme = new DynamicAppTheme(); if (localContext instanceof Activity && layoutInflater != null && ((Activity) localContext).getLayoutInflater().getFactory2() == null) { LayoutInflaterCompat.setFactory2(((Activity) localContext) .getLayoutInflater(), layoutInflater); } return this; }
Example 2
Source Project: Android-skin-support File: LayoutInflaterCompat.java License: MIT License | 6 votes |
/** * Attach a custom Factory interface for creating views while using * this LayoutInflater. This must not be null, and can only be set once; * after setting, you can not change the factory. * * @see LayoutInflater#setFactory(android.view.LayoutInflater.Factory) * @deprecated Use {@link #setFactory2(LayoutInflater, LayoutInflater.Factory2)} instead to set * and {@link LayoutInflater#getFactory2()} to get the factory. */ @Deprecated public static void setFactory( LayoutInflater inflater, LayoutInflaterFactory factory) { if (Build.VERSION.SDK_INT >= 21) { inflater.setFactory2(factory != null ? new LayoutInflaterCompat.Factory2Wrapper(factory) : null); } else { final LayoutInflater.Factory2 factory2 = factory != null ? new LayoutInflaterCompat.Factory2Wrapper(factory) : null; inflater.setFactory2(factory2); final LayoutInflater.Factory f = inflater.getFactory(); if (f instanceof LayoutInflater.Factory2) { // The merged factory is now set to getFactory(), but not getFactory2() (pre-v21). // We will now try and force set the merged factory to mFactory2 forceSetFactory2(inflater, (LayoutInflater.Factory2) f); } else { // Else, we will force set the original wrapped Factory2 forceSetFactory2(inflater, factory2); } } }
Example 3
Source Project: pretty File: PrettyLayoutInflater.java License: MIT License | 6 votes |
public PrettyLayoutInflater(Pretty pretty, final Activity activity) { super(activity); this.pretty = pretty; // if the activity is a FragmentActivity from the support lib then lets wrap it // so the <fragment> tags still work try { Class<?> fragAct = Class.forName("android.support.v4.app.FragmentActivity"); if (fragAct != null && fragAct.isInstance(activity)) { // FragmentActivity is a Factory1, not Factory2 wrappedFactory = new LayoutInflater.Factory2() { @Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { return onCreateView(name, context, attrs); } @Override public View onCreateView(String name, Context context, AttributeSet attrs) { return activity.onCreateView(name, context, attrs); } }; } } catch (Exception ignored) { /* ignored */ } super.setFactory2(new PrettyLayoutFactory(this, wrappedFactory, pretty)); }
Example 4
Source Project: scene File: SceneLayoutInflater.java License: Apache License 2.0 | 5 votes |
private void createLayoutInflaterIfNeeded() { if (this.mLayoutInflater != null) { return; } Context context = null; if (this.mScene.getTheme() == 0) { context = this.mScene.requireActivity(); } else { context = this.mScene.requireSceneContext(); } //create new LayoutInflater this.mLayoutInflater = this.mScene.requireActivity().getLayoutInflater().cloneInContext(context); LayoutInflater.Filter filter = getFilter(); if (filter != null) { this.mLayoutInflater.setFilter(filter); } LayoutInflater.Factory2 factory2 = getFactory2(); if (factory2 != null) { this.mLayoutInflater.setFactory2(factory2); } else { LayoutInflater.Factory factory = getFactory(); if (factory != null) { this.mLayoutInflater.setFactory(factory); } } }
Example 5
Source Project: pandroid File: PandroidViewFactory.java License: Apache License 2.0 | 5 votes |
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { for (LayoutInflater.Factory2 factory2 : factories) { View result = factory2.onCreateView(parent, name, context, attrs); if (result != null) return result; } return appDelegate.createView(parent, name, context, attrs); }
Example 6
Source Project: chameleon File: SkinActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getLayoutInflater(); mLayoutInfalter.applyCurrentSkin(); // AppCompatActivity 需要设置 AppCompatDelegate delegate = this.getDelegate(); if (delegate instanceof LayoutInflater.Factory2) { mLayoutInfalter.setFactory2((LayoutInflater.Factory2) delegate); } // 自己的逻辑 }
Example 7
Source Project: Neptune File: LayoutInflaterCompat.java License: Apache License 2.0 | 5 votes |
/** * 给LayoutInflater设置privateFactory * 解决同名View或者Fragment冲突的问题 */ public static void setPrivateFactory(LayoutInflater inflater) { LayoutInflater.Factory2 factory2 = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { // 5.0以下重复设置privateFactory没有FactoryMerger,而Activity会把自己设置成privateFactory factory2 = ReflectionUtils.on(inflater).get("mPrivateFactory"); } LayoutInflater.Factory2 privateFactory = new CompatPrivateFactory(factory2); Class<?>[] paramTypes = new Class[]{LayoutInflater.Factory2.class}; ReflectionUtils.on(inflater).call("setPrivateFactory", sMethods, paramTypes, privateFactory); }
Example 8
Source Project: pandroid File: PandroidApplication.java License: Apache License 2.0 | 5 votes |
/** * factories to use in the layout inflater. If pandroid view support is enable CompatViewFactory * will be added * * @return list of custom LayoutInflater factories */ @Override public List<LayoutInflater.Factory2> getLayoutInflaterFactories() { ArrayList<LayoutInflater.Factory2> factories = new ArrayList<>(); if (PandroidConfig.VIEW_SUPPORT) { factories.add(new PandroidCompatViewFactory()); } return factories; }
Example 9
Source Project: NightOwl File: InjectedInflaterV11.java License: Apache License 2.0 | 4 votes |
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public static LayoutInflater.Factory2 wrap(LayoutInflater.Factory2 factory){ return new Factory2WrapperImpl(factory); }
Example 10
Source Project: NightOwl File: InjectedInflaterV11.java License: Apache License 2.0 | 4 votes |
public LayoutInflater.Factory2 getCoreFactory() { return mFactory; }
Example 11
Source Project: BackgroundLibrary File: BackgroundFactory.java License: Apache License 2.0 | 4 votes |
public void setInterceptFactory2(LayoutInflater.Factory2 factory) { mViewCreateFactory2 = factory; }
Example 12
Source Project: pretty File: LayoutFactoryWrapper.java License: MIT License | 4 votes |
public LayoutFactoryWrapper(@NotNull LayoutInflater inflater, @Nullable LayoutInflater.Factory2 baseFactory) { this.inflater = inflater; this.base = baseFactory; }
Example 13
Source Project: Neptune File: LayoutInflaterCompat.java License: Apache License 2.0 | 4 votes |
CompatPrivateFactory(LayoutInflater.Factory2 factory) { mOrigFactory = factory; }
Example 14
Source Project: revolution-irc File: LiveThemeViewFactory.java License: GNU General Public License v3.0 | 4 votes |
public LiveThemeViewFactory(LiveThemeManager liveThemeManager, LayoutInflater.Factory2 parentFactory) { mLiveThemeManager = liveThemeManager; mParentFactory = parentFactory; }
Example 15
Source Project: NightOwl File: InjectedInflaterV11.java License: Apache License 2.0 | 4 votes |
private PrivateFactoryWrapperImpl(LayoutInflater.Factory2 factory, InjectedInflaterBase inflater) { super(inflater); mFactory = factory; }
Example 16
Source Project: Emoji File: MaterialEmojiLayoutFactory.java License: Apache License 2.0 | 4 votes |
public MaterialEmojiLayoutFactory(@Nullable final LayoutInflater.Factory2 delegate) { super(delegate); }
Example 17
Source Project: pretty File: PrettyLayoutInflater.java License: MIT License | 4 votes |
protected PrettyLayoutInflater(LayoutInflater original, Context newContext, LayoutInflater.Factory2 wrappedFactory, Pretty pretty) { super(original, newContext); this.pretty = pretty; super.setFactory2(new PrettyLayoutFactory(this, wrappedFactory, pretty)); }
Example 18
Source Project: NightOwl File: InjectedInflaterV11.java License: Apache License 2.0 | 4 votes |
private Factory2WrapperImpl(LayoutInflater.Factory2 factory) { mFactory = factory; }
Example 19
Source Project: dynamic-support File: DynamicSystemActivity.java License: Apache License 2.0 | 2 votes |
/** * Returns a layout inflater factory for this activity. * <p>It will be used to replace the app compat widgets with their dynamic counterparts * to provide the support for dynamic theme. * * <p><p>Override this method to provide a custom layout inflater. * * @return The layout inflater factory for this activity. */ protected @Nullable LayoutInflater.Factory2 getDynamicLayoutInflater() { return new DynamicLayoutInflater(); }
Example 20
Source Project: pandroid File: PandroidFactoryProvider.java License: Apache License 2.0 | votes |
List<LayoutInflater.Factory2> getLayoutInflaterFactories();