Java Code Examples for android.view.LayoutInflater#Factory

The following examples show how to use android.view.LayoutInflater#Factory . 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
@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;
}
 
Example 2
@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;
}
 
Example 3
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;
}
 
Example 4
Source Project: scene   File: SceneLayoutInflater.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void setFactory(LayoutInflater.Factory factory) {
    super.setFactory(factory);
    if (this.mLayoutInflater != null) {
        this.mLayoutInflater.setFactory(factory);
    }
}
 
Example 5
Source Project: scene   File: SceneLayoutInflater.java    License: Apache License 2.0 5 votes vote down vote up
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 6
Source Project: chameleon   File: SkinLayoutInflater.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 初始化
 *
 * @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;
        }
    }
}
 
Example 7
Source Project: support   File: TypefaceLayoutInflator.java    License: Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 8
@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;
}
 
Example 9
public LayoutInflater.Factory getFactory() {
    return mFactory;
}
 
Example 10
public void setInterceptFactory(LayoutInflater.Factory factory) {
    mViewCreateFactory = factory;
}
 
Example 11
public void setInterceptFactory(LayoutInflater.Factory factory) {
    mViewCreateFactory = factory;
}
 
Example 12
public CalligraphyFactory(LayoutInflater.Factory factory, int attributeId) {
    this.factory = factory;
    this.mAttributeId = attributeId;
}
 
Example 13
public CustomTypefaceFactory(Context context, CustomTypeface customTypeface,
        LayoutInflater.Factory factory) {
    mContext = context;
    mCustomTypeface = customTypeface;
    mFactory = factory;
}
 
Example 14
Source Project: NightOwl   File: InjectedInflaterV7.java    License: Apache License 2.0 4 votes vote down vote up
public static LayoutInflater.Factory wrap(InjectedInflaterBase inflater, LayoutInflater.Factory factory){
    return new FactoryWrapperImpl(inflater,factory);
}
 
Example 15
Source Project: NightOwl   File: InjectedInflaterV11.java    License: Apache License 2.0 4 votes vote down vote up
private FactoryWrapperImpl(LayoutInflater.Factory factory) {
    mFactory = factory;
}
 
Example 16
Source Project: NightOwl   File: InjectedInflaterV11.java    License: Apache License 2.0 4 votes vote down vote up
public static LayoutInflater.Factory wrap(LayoutInflater.Factory factory){
    return new FactoryWrapperImpl(factory);
}
 
Example 17
LayoutInflater.Factory getLayoutInflaterFactory() {
    return this;
}
 
Example 18
public PluginViewInflater(Context context, final LayoutInflater.Factory viewfactory) {
    mContext = context;
    mViewfactory = viewfactory;
}
 
Example 19
public PluginViewFactory(Activity context, Window window, LayoutInflater.Factory viewfactory) {
	mContext = context;
	mWindow = window;
	mOriginalWindowCallback = window.getCallback();
	mViewfactory = viewfactory;
}
 
Example 20
/**
 * 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;
}