类android.support.v4.view.LayoutInflaterCompat源码实例Demo

下面列出了怎么用android.support.v4.view.LayoutInflaterCompat的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: pandroid   文件: PandroidViewFactory.java
public static void installPandroidViewFactory(AppCompatActivity compatActivity) {
    List<LayoutInflater.Factory2> factories = new ArrayList<>();
    if (compatActivity instanceof PandroidFactoryProvider) {
        addProviderFactories((PandroidFactoryProvider) compatActivity, factories);
    }
    if (compatActivity.getApplication() instanceof PandroidFactoryProvider) {
        addProviderFactories((PandroidFactoryProvider) compatActivity.getApplication(), factories);
    }
    if (!factories.isEmpty()) {
        LayoutInflater inflater = LayoutInflater.from(compatActivity);
        if (inflater.getFactory2() == null) {
            PandroidViewFactory factory = new PandroidViewFactory(compatActivity.getDelegate(), factories);
            LayoutInflaterCompat.setFactory2(inflater, factory);
        } else {
            LogcatLogger.getInstance().w(TAG, "can't set layout inflater factory");
        }
    } else {
        LogcatLogger.getInstance().w(TAG, "Your activity or application should implement PandroidFactoryProvider to install PandroidLayoutInflaterFactory");
    }

}
 
源代码2 项目: Learning-Resources   文件: FireHome.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lo_fire_auth_home);

    mImgvwProfile = (ImageView) findViewById(R.id.imgvw_fireauth_home_profile);
    mTvDisplayName = (TextView) findViewById(R.id.tv_fireauth_home_displayname);
    mTvEmail = (TextView) findViewById(R.id.tv_fireauth_home_email);

    mFireAuth = FirebaseAuth.getInstance();
    FirebaseUser fireUser = mFireAuth.getCurrentUser();
    if (fireUser != null) {

        Picasso.with(this)
                .load(fireUser.getPhotoUrl())
                .placeholder(R.drawable.img_firebase_logo)
                .into(mImgvwProfile);
        if(!TextUtils.isEmpty(fireUser.getDisplayName()))
            mTvDisplayName.setText(fireUser.getDisplayName());
        else mTvDisplayName.setVisibility(View.GONE);
        mTvEmail.setText(fireUser.getEmail());
    }
}
 
源代码3 项目: Overchan-Android   文件: CustomThemeHelper.java
public static void setCustomTheme(Context context, SparseIntArray customAttrs) {
    if (customAttrs == null || customAttrs.size() == 0) {
        currentAttrs = null;
        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;
}
 
源代码4 项目: AndroidSkinAnimator   文件: SkinCompatActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    if (needAnimator()) {
        AnimatorManager.setConfig(new AnimatorConfig.Builder()
                .textviewVisibleAnimationType(ViewAnimatorType.AlphaHideAnimator)
                .textviewTextAnimationType(ViewAnimatorType.AlphaUpdateAnimator)
                .imageviewVisibleAnimationType(ViewAnimatorType.AlphaHideAnimator)
                .build());
    }
    LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate());
    super.onCreate(savedInstanceState);
}
 
源代码5 项目: Android-Skin   文件: AndroidSkinHook.java
private void hookLayoutInflater(Context context) {
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    try {
        Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
        field.setAccessible(true);
        field.setBoolean(layoutInflater, false);
        LayoutInflaterCompat.setFactory2(layoutInflater, AndroidSkinFactory.from(context,layoutInflater));
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
private void installLayoutFactory(Context context) {
    try {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
    } catch (Exception e) {
        Slog.i("SkinActivity", "A factory has already been set on this LayoutInflater");
    }
}
 
源代码7 项目: Android-skin-support   文件: SkinCompatActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate());
    super.onCreate(savedInstanceState);
    updateStatusBarColor();
    updateWindowBackground();
}
 
源代码8 项目: ReadMark   文件: BaseSkinActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    //在setContentView之前设置好工厂
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    SkinManager.getInstance().init(this);
    /*if (layoutInflater.getFactory() == null) {
        LayoutInflaterCompat.setFactory(layoutInflater, this);
    }*/
    super.onCreate(savedInstanceState);
}
 
源代码9 项目: Droid2JoyStick   文件: MainActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bindView();
    initView();
    setupComponent();
}
 
源代码10 项目: NMSAlphabetAndroidApp   文件: BaseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    ThemeUtil.setCustomTheme(this);
    LanguageUtil.updateLanguage(this);
    tintBars();
}
 
源代码11 项目: GithubApp   文件: BaseActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    // define the IconicsLayoutInflater
    // this is compatible with calligraphy and other libs which wrap the baseContext
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));

    super.onCreate(savedInstanceState);
}
 
源代码12 项目: ReadMark   文件: BaseSkinActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    //在setContentView之前设置好工厂
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    SkinManager.getInstance().init(this);
    /*if (layoutInflater.getFactory() == null) {
        LayoutInflaterCompat.setFactory(layoutInflater, this);
    }*/
    super.onCreate(savedInstanceState);
}
 
源代码13 项目: ChangeSkin   文件: BaseSkinActivity.java
protected void onCreate(@Nullable Bundle savedInstanceState)
{
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    super.onCreate(savedInstanceState);
    SkinManager.getInstance().addChangedListener(this);
}
 
源代码14 项目: Android-RobotoTextView   文件: RobotoInflater.java
public static void attach(@NonNull Activity activity) {
    if (activity instanceof AppCompatActivity) {
        LayoutInflaterCompat.setFactory(activity.getLayoutInflater(),
                new RobotoInflater(((AppCompatActivity) activity).getDelegate(), activity.getWindow()));
    } else {
        final Window window = activity.getWindow();
        final Window.Callback callback = window.getCallback();
        LayoutInflaterCompat.setFactory(activity.getLayoutInflater(),
                new RobotoInflater(AppCompatDelegate.create(activity, StubAppCompatCallback.INSTANCE), window));
        window.setCallback(callback);
    }
}
 
源代码15 项目: youqu_master   文件: ChangeModeController.java
/**
     * 初始化夜间控制器
     * @param activity 上下文
     * @return
     */
    public ChangeModeController init(final Activity activity,final Class mClass){
        init();
        LayoutInflaterCompat.setFactory(LayoutInflater.from(activity), new LayoutInflaterFactory() {
            @Override
            public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
                View view = null;
                try {
                    if(name.indexOf('.') == -1){
                        if ("View".equals(name)) {
                            view = LayoutInflater.from(context).createView(name, "android.view.", attrs);
                        }
                        if (view == null) {
                            view = LayoutInflater.from(context).createView(name, "android.widget.", attrs);
                        }
                        if (view == null) {
                            view = LayoutInflater.from(context).createView(name, "android.webkit.", attrs);
                        }

                    }else{
                        if (view == null){
                            view = LayoutInflater.from(context).createView(name, null, attrs);
                        }
                    }
                    if(view != null){
                   // Log.e("TAG", "name = " + name);
                        for (int i = 0; i < attrs.getAttributeCount(); i++) {
//                            Log.e("TAG", attrs.getAttributeName(i) + " , " + attrs.getAttributeValue(i));
                            if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND)) {
                                mBackGroundViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
                            }
                            if (attrs.getAttributeName(i).equals(ATTR_TEXTCOLOR)) {
                                mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
                            }
                            if (attrs.getAttributeName(i).equals(ATTR_TWO_TEXTCOLOR)) {
                                mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
                            }
                            if (attrs.getAttributeName(i).equals(ATTR_THREE_TEXTCOLOR)) {
                                mOneTextColorViews.add(new AttrEntity<TextView>((TextView)view,getAttr(mClass,attrs.getAttributeValue(i))));
                            }
                            if (attrs.getAttributeName(i).equals(ATTR_BACKGROUND_DRAWABLE)) {
                                mBackGroundDrawableViews.add(new AttrEntity<View>(view,getAttr(mClass,attrs.getAttributeValue(i))));
                            }

                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                }
                return view;
            }
        });
        return this;
    }
 
源代码16 项目: relight   文件: WidgetInflaterFactory.java
public static LayoutInflater getLayoutInflater(AppCompatActivity activity) {
    LayoutInflater inflater = LayoutInflater.from(activity).cloneInContext(activity);
    LayoutInflaterCompat.setFactory2(inflater, new WidgetInflaterFactory());
    return inflater;
}
 
源代码17 项目: letv   文件: Fragment.java
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
    LayoutInflater result = this.mHost.onGetLayoutInflater();
    getChildFragmentManager();
    LayoutInflaterCompat.setFactory(result, this.mChildFragmentManager.getLayoutInflaterFactory());
    return result;
}
 
源代码18 项目: Learning-Resources   文件: FireSignin.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    FacebookSdk.sdkInitialize(getApplicationContext());
    mCallbackManager = CallbackManager.Factory.create();
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lo_fire_signin);

    mCrdntrlyot = (CoordinatorLayout) findViewById(R.id.cordntrlyot_fireauth);
    mTxtinptlyotEmail = (TextInputLayout) findViewById(R.id.txtinputlyot_fireauth_email);
    mTxtinptlyotPaswrd = (TextInputLayout) findViewById(R.id.txtinputlyot_fireauth_password);
    mTxtinptEtEmail = (TextInputEditText) findViewById(R.id.txtinptet_fireauth_email);
    mTxtinptEtPaswrd = (TextInputEditText) findViewById(R.id.txtinptet_fireauth_password);
    mAppcmptbtnSignup = (AppCompatButton) findViewById(R.id.appcmptbtn_fireauth_signin);
    mTvFrgtPaswrd = (TextView) findViewById(R.id.tv_fireauth_frgtpaswrd);
    mImgvwFirebase = (ImageView) findViewById(R.id.imgvw_fireauth_firebase);
    mImgvwGp = (ImageView) findViewById(R.id.imgvw_fireauth_social_gp);
    mImgvwFb = (ImageView) findViewById(R.id.imgvw_fireauth_social_fb);
    mPrgrsbrMain = (ProgressBar) findViewById(R.id.prgrsbr_fireauth);

    mFireAuth = FirebaseAuth.getInstance();
    mFireDB = FirebaseDatabase.getInstance();

    FirebaseAuth.getInstance().signOut();

    GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestIdToken(getString(R.string.default_web_client_id))
            .requestEmail()
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();

    mAppcmptbtnSignup.setOnClickListener(this);
    mTvFrgtPaswrd.setOnClickListener(this);
    mImgvwFirebase.setOnClickListener(this);
    mImgvwGp.setOnClickListener(this);
    mImgvwFb.setOnClickListener(this);
}
 
源代码19 项目: SkinSprite   文件: SkinnableActivity.java
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    super.onCreate(savedInstanceState);
}
 
源代码20 项目: android-md-core   文件: MdCore.java
/**
 * Call this method in Activity.onCreate and before super.onCreate(...)
 */
public static void init(AppCompatActivity activity) {
  LayoutInflaterCompat.setFactory(activity.getLayoutInflater(), new MdLayoutInflaterFactory(activity.getDelegate()));
}
 
/**
 * Installs the factory to the given context prior to API level 21.
 * It will use AppCompat's layout inflater to inflate views and
 * set a proper Roboto typeface to the view. Roboto fonts are also used
 * when user is using a custom font.
 *
 * @param context A context.
 * @see #installViewFactory(Context, boolean)
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static void installViewFactory(Context context) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        LayoutInflaterCompat.setFactory(LayoutInflater.from(context),
                new TypefaceCompatFactory(context, false));
    }
}
 
/**
 * Installs the factory to the given context prior to API level 21.
 * It will use AppCompat's layout inflater to inflate views and
 * set a proper typeface to the view if needed.
 * If typeface detection is enabled the factory automatically detects the used system typeface
 * and adjust its behavior properly.
 * This makes sure that the newer Roboto typefaces are only used if no custom typefaces are applied by the system.
 * <p>
 * <b>Note:</b> Typeface detection only works starting with API level 14 and comes with a small performance penalty.
 *
 * @param context                  A context.
 * @param typefaceDetectionEnabled True if the factory should automatically detect the used system typeface and adjust its behavior properly.
 *                                 This makes sure that the newer Roboto typefaces are only used if no custom typefaces are applied by the system.
 * @since 0.1.1
 * @deprecated
 */
@Deprecated
public static void installViewFactory(Context context, boolean typefaceDetectionEnabled) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        LayoutInflaterCompat.setFactory(LayoutInflater.from(context),
                new TypefaceCompatFactory(context, typefaceDetectionEnabled));
    }
}
 
 类所在包
 类方法
 同包方法