androidx.core.view.LayoutInflaterCompat Java Examples

The following examples show how to use androidx.core.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: DynamicTheme.java    From dynamic-support with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: SkinManager.java    From NewFastFrame with Apache License 2.0 5 votes vote down vote up
public void apply(AppCompatActivity activity) {
//        if (activity.getSharedPreferences(ThemeUtil.NAME, Context.MODE_PRIVATE).getBoolean(ThemeUtil.IS_NIGHT, false)) {
//            activity.setTheme(R.style.CustomTheme_Night);
//        } else {
//            activity.setTheme(R.style.CustomTheme_Day);
//        }
        factoryMap.put(activity, new SkinLayoutInflaterFactory(activity));
        LayoutInflaterCompat.setFactory(activity.getLayoutInflater(), factoryMap.get(activity));
    }
 
Example #3
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.setFactory2(getLayoutInflater(), getSkinDelegate());
    super.onCreate(savedInstanceState);
    updateStatusBarColor();
    updateWindowBackground();
}
 
Example #4
Source File: SkinActivityLifecycle.java    From Android-skin-support with MIT License 5 votes vote down vote up
private void installLayoutFactory(Context context) {
    LayoutInflater layoutInflater = LayoutInflater.from(context);
    try {
        Field field = LayoutInflater.class.getDeclaredField("mFactorySet");
        field.setAccessible(true);
        field.setBoolean(layoutInflater, false);
        LayoutInflaterCompat.setFactory(layoutInflater, getSkinDelegate(context));
    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
Example #5
Source File: TouchEffectsFactory.java    From TouchEffects with MIT License 4 votes vote down vote up
public static void initTouchEffects(@NonNull Activity activity){
    LayoutInflaterCompat.setFactory2(activity.getLayoutInflater(),new TouchEffectsInflaterFactory());
}
 
Example #6
Source File: TouchEffectsFactory.java    From TouchEffects with MIT License 4 votes vote down vote up
public static void initTouchEffects(@NonNull Activity activity, TouchEffectsWholeType touchEffectsWholeType){
    LayoutInflaterCompat.setFactory2(activity.getLayoutInflater(),new TouchEffectsInflaterFactory(touchEffectsWholeType));
}
 
Example #7
Source File: AboutActivity.java    From Aegis with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    LayoutInflaterCompat.setFactory2(getLayoutInflater(), new IconicsLayoutInflater2(getDelegate()));

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_about);

    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
    }

    View btnLicenses = findViewById(R.id.btn_licenses);
    btnLicenses.setOnClickListener(v -> showLicenseDialog());

    TextView appVersion = findViewById(R.id.app_version);
    appVersion.setText(getCurrentAppVersion());

    View btnAppVersion = findViewById(R.id.btn_app_version);
    btnAppVersion.setOnClickListener(v -> {
        copyToClipboard(getCurrentAppVersion(), R.string.version_copied);
    });

    View btnGithub = findViewById(R.id.btn_github);
    btnGithub.setOnClickListener(v -> openUrl(GITHUB));

    View btnAlexander = findViewById(R.id.btn_alexander);
    btnAlexander.setOnClickListener(v -> openUrl(WEBSITE_ALEXANDER));

    View btnMichael = findViewById(R.id.btn_michael);
    btnMichael.setOnClickListener(v -> openUrl(GITHUB_MICHAEL));

    View btnMail = findViewById(R.id.btn_email);
    btnMail.setOnClickListener(v -> openMail(MAIL_BEEMDEVELOPMENT));

    View btnWebsite = findViewById(R.id.btn_website);
    btnWebsite.setOnClickListener(v -> openUrl(WEBSITE_BEEMDEVELOPMENT));

    View btnRate = findViewById(R.id.btn_rate);
    btnRate.setOnClickListener(v -> openUrl(PLAYSTORE_BEEMDEVELOPMENT ));

    View btnChangelog = findViewById(R.id.btn_changelog);
    btnChangelog.setOnClickListener(v -> {
        ChangelogDialog.create().setTheme(getCurrentTheme()).show(getSupportFragmentManager(), "CHANGELOG_DIALOG");
    });
}