android.support.v4.view.LayoutInflaterCompat Java Examples

The following examples show how to use android.support.v4.view.LayoutInflaterCompat. 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 File: PandroidViewFactory.java    From pandroid with Apache License 2.0 6 votes vote down vote up
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");
    }

}
 
Example #2
Source File: FireHome.java    From Learning-Resources with MIT License 6 votes vote down vote up
@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());
    }
}
 
Example #3
Source File: CustomThemeHelper.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: RobotoInflater.java    From Android-RobotoTextView with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example #5
Source File: SkinCompatActivity.java    From AndroidSkinAnimator with MIT License 5 votes vote down vote up
@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);
}
 
Example #6
Source File: AndroidSkinHook.java    From Android-Skin with MIT License 5 votes vote down vote up
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();
    }
}
 
Example #7
Source File: SkinActivityLifecycle.java    From Android-skin-support with MIT License 5 votes vote down vote up
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");
    }
}
 
Example #8
Source File: SkinCompatActivity.java    From Android-skin-support with MIT License 5 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate());
    super.onCreate(savedInstanceState);
    updateStatusBarColor();
    updateWindowBackground();
}
 
Example #9
Source File: BaseSkinActivity.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: MainActivity.java    From Droid2JoyStick with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    bindView();
    initView();
    setupComponent();
}
 
Example #11
Source File: BaseActivity.java    From NMSAlphabetAndroidApp with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
    super.onCreate(savedInstanceState);
    ThemeUtil.setCustomTheme(this);
    LanguageUtil.updateLanguage(this);
    tintBars();
}
 
Example #12
Source File: BaseSkinActivity.java    From ChangeSkin with Apache License 2.0 5 votes vote down vote up
protected void onCreate(@Nullable Bundle savedInstanceState)
{
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    super.onCreate(savedInstanceState);
    SkinManager.getInstance().addChangedListener(this);
}
 
Example #13
Source File: BaseActivity.java    From GithubApp with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #14
Source File: BaseSkinActivity.java    From ReadMark with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: FireSignin.java    From Learning-Resources with MIT License 4 votes vote down vote up
@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);
}
 
Example #16
Source File: MdCore.java    From android-md-core with Apache License 2.0 4 votes vote down vote up
/**
 * Call this method in Activity.onCreate and before super.onCreate(...)
 */
public static void init(AppCompatActivity activity) {
  LayoutInflaterCompat.setFactory(activity.getLayoutInflater(), new MdLayoutInflaterFactory(activity.getDelegate()));
}
 
Example #17
Source File: SkinnableActivity.java    From SkinSprite with MIT License 4 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    LayoutInflater layoutInflater = LayoutInflater.from(this);
    LayoutInflaterCompat.setFactory(layoutInflater, this);
    super.onCreate(savedInstanceState);
}
 
Example #18
Source File: ChangeModeController.java    From youqu_master with Apache License 2.0 4 votes vote down vote up
/**
     * 初始化夜间控制器
     * @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;
    }
 
Example #19
Source File: Fragment.java    From letv with Apache License 2.0 4 votes vote down vote up
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) {
    LayoutInflater result = this.mHost.onGetLayoutInflater();
    getChildFragmentManager();
    LayoutInflaterCompat.setFactory(result, this.mChildFragmentManager.getLayoutInflaterFactory());
    return result;
}
 
Example #20
Source File: WidgetInflaterFactory.java    From relight with Apache License 2.0 4 votes vote down vote up
public static LayoutInflater getLayoutInflater(AppCompatActivity activity) {
    LayoutInflater inflater = LayoutInflater.from(activity).cloneInContext(activity);
    LayoutInflaterCompat.setFactory2(inflater, new WidgetInflaterFactory());
    return inflater;
}
 
Example #21
Source File: TypefaceCompatFactory.java    From AppCompat-Extension-Library with Apache License 2.0 3 votes vote down vote up
/**
 * 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));
    }
}
 
Example #22
Source File: TypefaceCompatFactory.java    From AppCompat-Extension-Library with Apache License 2.0 3 votes vote down vote up
/**
 * 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));
    }
}