android.view.LayoutInflater#Factory ( )源码实例Demo

下面列出了android.view.LayoutInflater#Factory ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: UltimateAndroid   文件: CalligraphyFactory.java
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
    View view = null;

    if (context instanceof LayoutInflater.Factory) {
        view = ((LayoutInflater.Factory) context).onCreateView(name, context, attrs);
    }

    if (factory != null && view == null) {
        view = factory.onCreateView(name, context, attrs);
    }

    if (view == null) {
        view = createViewOrFailQuietly(name, context, attrs);
    }

    if (view != null) {
        onViewCreated(view, name, context, attrs);
    }

    return view;
}
 
源代码2 项目: UltimateAndroid   文件: CalligraphyFactory.java
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
    View view = null;

    if (context instanceof LayoutInflater.Factory) {
        view = ((LayoutInflater.Factory) context).onCreateView(name, context, attrs);
    }

    if (factory != null && view == null) {
        view = factory.onCreateView(name, context, attrs);
    }

    if (view == null) {
        view = createViewOrFailQuietly(name, context, attrs);
    }

    if (view != null) {
        onViewCreated(view, name, context, attrs);
    }

    return view;
}
 
private View callActivityOnCreateView(View parent, String name, Context context, AttributeSet attrs) {
	View view = null;
	if (mOriginalWindowCallback instanceof LayoutInflater.Factory) {
		view = ((LayoutInflater.Factory) mOriginalWindowCallback)
				.onCreateView(name, context, attrs);
	}

	if (view != null) {
		return view;
	}

	if(Build.VERSION.SDK_INT >= 11) {
		if (mOriginalWindowCallback instanceof LayoutInflater.Factory2) {
			return ((LayoutInflater.Factory2) mOriginalWindowCallback)
					.onCreateView(parent, name, context, attrs);
		}
	}

	return null;
}
 
源代码4 项目: scene   文件: SceneLayoutInflater.java
@Override
public void setFactory(LayoutInflater.Factory factory) {
    super.setFactory(factory);
    if (this.mLayoutInflater != null) {
        this.mLayoutInflater.setFactory(factory);
    }
}
 
源代码5 项目: scene   文件: SceneLayoutInflater.java
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);
        }
    }
}
 
源代码6 项目: chameleon   文件: SkinLayoutInflater.java
/**
 * 初始化
 *
 * @param original
 */
private void init(LayoutInflater original) {

    //将自己设置为LayoutInflaterFactory,接管view的创建
    setFactory2(this);
    if (mConstructorArgsField != null) {
        try {
            mConstructorArgs = (Object[]) mConstructorArgsField.get(this);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }

    //将自己注册到换肤监听
    SkinEngine.registerSkinObserver(this);

    if (original == null) {
        return;
    }

    if (original instanceof SkinLayoutInflater) {
        SkinLayoutInflater skinLayoutInflater = (SkinLayoutInflater) original;
        this.mFactory = skinLayoutInflater.mFactory;
        this.mFactory2 = skinLayoutInflater.mFactory2;
    } else {
        LayoutInflater.Factory factory = original.getFactory();
        if (factory instanceof LayoutInflater.Factory2) {
            mFactory2 = (Factory2) factory;
        } else {
            mFactory = factory;
        }
    }
}
 
源代码7 项目: support   文件: TypefaceLayoutInflator.java
@Override
public void setFactory(LayoutInflater.Factory factory) {
    // Only set our factory and wrap calls to the Factory trying to be set!
    if (!(factory instanceof WrapperFactory)) {
        super.setFactory(new WrapperFactory(factory, this));
    } else {
        super.setFactory(factory);
    }
}
 
@Override
public View onCreateView(String name, Context context, AttributeSet attrs) {
    View view = null;
    name = transfer(name);
    if (context instanceof LayoutInflater.Factory) {
        view = ((LayoutInflater.Factory) context).onCreateView(name, context, attrs);
    }
    if (view == null && wrapped != null) {
        view = wrapped.onCreateView(name, context, attrs);
    }
    if (view == null) {
        view = createViewOrFailQuietly(name, context, attrs);
    }
    return view;
}
 
源代码9 项目: custom-typeface   文件: CustomTypefaceFactory.java
public LayoutInflater.Factory getFactory() {
    return mFactory;
}
 
源代码10 项目: BackgroundLibrary   文件: BackgroundFactory.java
public void setInterceptFactory(LayoutInflater.Factory factory) {
    mViewCreateFactory = factory;
}
 
源代码11 项目: BackgroundLibrary   文件: BackgroundFactory.java
public void setInterceptFactory(LayoutInflater.Factory factory) {
    mViewCreateFactory = factory;
}
 
源代码12 项目: UltimateAndroid   文件: CalligraphyFactory.java
public CalligraphyFactory(LayoutInflater.Factory factory, int attributeId) {
    this.factory = factory;
    this.mAttributeId = attributeId;
}
 
源代码13 项目: custom-typeface   文件: CustomTypefaceFactory.java
public CustomTypefaceFactory(Context context, CustomTypeface customTypeface,
        LayoutInflater.Factory factory) {
    mContext = context;
    mCustomTypeface = customTypeface;
    mFactory = factory;
}
 
源代码14 项目: NightOwl   文件: InjectedInflaterV7.java
public static LayoutInflater.Factory wrap(InjectedInflaterBase inflater, LayoutInflater.Factory factory){
    return new FactoryWrapperImpl(inflater,factory);
}
 
源代码15 项目: NightOwl   文件: InjectedInflaterV11.java
private FactoryWrapperImpl(LayoutInflater.Factory factory) {
    mFactory = factory;
}
 
源代码16 项目: NightOwl   文件: InjectedInflaterV11.java
public static LayoutInflater.Factory wrap(LayoutInflater.Factory factory){
    return new FactoryWrapperImpl(factory);
}
 
源代码17 项目: adt-leanback-support   文件: FragmentManager.java
LayoutInflater.Factory getLayoutInflaterFactory() {
    return this;
}
 
public PluginViewInflater(Context context, final LayoutInflater.Factory viewfactory) {
    mContext = context;
    mViewfactory = viewfactory;
}
 
public PluginViewFactory(Activity context, Window window, LayoutInflater.Factory viewfactory) {
	mContext = context;
	mWindow = window;
	mOriginalWindowCallback = window.getCallback();
	mViewfactory = viewfactory;
}
 
/**
 * Return the current {@link LayoutInflaterFactory} (or null). This is
 * called on each element name. If the factory returns a View, add that
 * to the hierarchy. If it returns null, proceed to call onCreateView(name).
 *
 * @return The {@link LayoutInflaterFactory} associated with the
 * {@link LayoutInflater}. Will be {@code null} if the inflater does not
 * have a {@link LayoutInflaterFactory} but a raw {@link LayoutInflater.Factory}.
 * @see LayoutInflater#getFactory()
 * @deprecated Use {@link #setFactory2(LayoutInflater, LayoutInflater.Factory2)} to set and
 * {@link LayoutInflater#getFactory2()} to get the factory.
 */
@Deprecated
public static LayoutInflaterFactory getFactory(LayoutInflater inflater) {
    LayoutInflater.Factory factory = inflater.getFactory();
    if (factory instanceof LayoutInflaterCompat.Factory2Wrapper) {
        return ((LayoutInflaterCompat.Factory2Wrapper) factory).mDelegateFactory;
    }
    return null;
}