List of usage examples for android.support.v4.view LayoutInflaterCompat setFactory
public static void setFactory(LayoutInflater inflater, LayoutInflaterFactory factory)
From source file:me.henrytao.mdcore.core.MdCore.java
/** * Call this method in Activity.onCreate and before super.onCreate(...) *//*from w ww . j av a 2s. com*/ public static void init(AppCompatActivity activity) { LayoutInflaterCompat.setFactory(activity.getLayoutInflater(), new MdLayoutInflaterFactory(activity.getDelegate())); }
From source file:com.github.fountaingeyser.typefacecompat.FactoryTypefaceCompat.java
public static void installViewFactory(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { LayoutInflaterCompat.setFactory(LayoutInflater.from(context), new FactoryTypefaceCompat(context)); }//from ww w . ja v a 2 s. c o m }
From source file:com.jalotsav.fireauth.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);//from w w w. ja v a 2 s . c o m if (!TextUtils.isEmpty(fireUser.getDisplayName())) mTvDisplayName.setText(fireUser.getDisplayName()); else mTvDisplayName.setVisibility(View.GONE); mTvEmail.setText(fireUser.getEmail()); } }
From source file:com.tr4android.support.extension.typeface.TypefaceCompatFactory.java
/** * 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./*from w ww . ja v a2 s. c om*/ * * @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)); } }
From source file:com.github.shareme.blackandroids.greenandroid.viewdecorator.ViewDecoratorInstaller.java
/** * Installs the helper to an activity. Once the helper is installed to an activity it can't be installed to another activty * * @param activity activity to install the helper to * @return true if installation was successful, false otherwise * @throws IllegalStateException if helper is already install with the activity * *//*w w w. j ava 2s. co m*/ @UiThread public boolean install(@NonNull AppCompatActivity activity) { AppCompatDelegate delegate = activity.getDelegate(); LayoutInflater layoutInflater = activity.getLayoutInflater(); if (layoutInflater.getFactory() == null) { LayoutInflaterFactory layoutInflaterFactory = new DecoratingLayoutInflaterFactory( new CompositingViewFactory(getPlatformViewFactory(layoutInflater), new AppCompatViewFactory(delegate, activity)), viewDecorator); LayoutInflaterCompat.setFactory(layoutInflater, layoutInflaterFactory); return true; } Log.w(TAG, "view decorator can't be installed, layout infalter already has view factory installed"); return false; }
From source file:org.mariotaku.twidere.activity.support.ThemedFragmentActivity.java
@NonNull @Override/* w ww. j a v a 2 s . c o m*/ public LayoutInflater getLayoutInflater() { final LayoutInflater inflater = super.getLayoutInflater(); if (inflater.getFactory() == null) { LayoutInflaterCompat.setFactory(inflater, new ThemedLayoutInflaterFactory(this, new LayoutInflaterFactory() { @Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { return ThemedFragmentActivity.this.onCreateView(parent, name, context, attrs); } })); } return inflater; }
From source file:com.example.matt.bingeList.viewControllers.activities.shows.TVShowBrowseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); Iconics.init(getApplicationContext()); Iconics.registerFont(new GoogleMaterial()); Iconics.registerFont(new CommunityMaterial()); if (PreferencesHelper.getTheme(getApplicationContext()) == ThemeEnum.NIGHT_THEME) { setTheme(R.style.DarkAppTheme_Base); }//ww w. ja v a2s. co m super.onCreate(savedInstanceState); setContentView(R.layout.browse_activity); ButterKnife.bind(this); // Adding Toolbar to Main screen setSupportActionBar(toolbar); getSupportActionBar().setTitle("Browse Shows"); // Setting ViewPager for each Tabs setupViewPager(viewPager); // Set Tabs inside Toolbar tabs.setupWithViewPager(viewPager); setTabDrawables(); // Adding menu icon to Toolbar ActionBar supportActionBar = getSupportActionBar(); if (supportActionBar != null) { supportActionBar.setHomeAsUpIndicator( new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_menu).sizeDp(16).color(Color.WHITE)); supportActionBar.setDisplayHomeAsUpEnabled(true); } // Create Navigation drawer mNavigationDrawer = new DrawerHelper().GetDrawer(this, toolbar, savedInstanceState); // Adding Floating Action Button to bottom right of main view IconicsDrawable search = new IconicsDrawable(this).icon(GoogleMaterial.Icon.gmd_search).sizeDp(16) .color(Color.WHITE); fab.setImageDrawable(search); final Intent intent = new Intent(this, SearchActivity.class); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { startActivity(intent); } }); }
From source file:com.github.shareme.blackandroids.greenandroid.viewdecorator.ViewDecoratorInstaller.java
@UiThread public boolean install(@NonNull Activity activity) { LayoutInflater layoutInflater = activity.getLayoutInflater(); if (layoutInflater.getFactory() == null) { LayoutInflaterFactory layoutInflaterFactory = new DecoratingLayoutInflaterFactory( getPlatformViewFactory(layoutInflater), viewDecorator); LayoutInflaterCompat.setFactory(layoutInflater, layoutInflaterFactory); return true; }/*from w ww .java 2 s . c om*/ return false; }
From source file:com.tr4android.support.extension.typeface.TypefaceCompatFactory.java
/** * 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.//from w w w. j ava2 s . c o m * 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)); } }
From source file:com.snake.salarycounter.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(R.style.AppTheme);/* w ww. j av a2 s . c o m*/ Fabric.with(this, new Crashlytics()); SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); if (!mSharedPreferences.contains(PASSWORD_PREFERENCE_KEY)) { Intent intent = new Intent(MainActivity.this, CustomPinActivity.class); intent.putExtra(AppLock.EXTRA_TYPE, AppLock.ENABLE_PINLOCK); startActivityForResult(intent, REQUEST_CODE_ENABLE); } /*else { Intent intent = new Intent(MainActivity.this, CustomPinActivity.class); intent.putExtra(AppLock.EXTRA_TYPE, AppLock.UNLOCK_PIN); startActivity(intent); }*/ // TODO: Move this to where you establish a user session //logUser(); LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); // Handle Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); //getSupportActionBar().setTitle("Setted title"); // Create the AccountHeader buildHeader(false, savedInstanceState); final Context that = this; authDrawerItem = new PrimaryDrawerItem().withSelectable(false).withName(R.string.account_title) .withIcon(CommunityMaterial.Icon.cmd_plus).withIdentifier(II_ACCOUNT); //Create the drawer result = new DrawerBuilder().withActivity(this).withToolbar(toolbar).withAccountHeader(headerResult) //set the AccountHeader we created earlier for the header .addDrawerItems( /*new PrimaryDrawerItem() .withName(R.string.drawer_item_home) .withIcon(CommunityMaterial.Icon.cmd_home) .withIdentifier(10) .withBadge("100") .withDescription("Description"),*/ new PrimaryDrawerItem().withName(R.string.drawer_item_shift_types).withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_calendar_multiple) .withIdentifier(II_SHIFT_TYPES), new PrimaryDrawerItem().withName(R.string.drawer_item_tabel).withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_calendar_clock).withIdentifier(II_TABLE), new PrimaryDrawerItem().withName(R.string.drawer_item_finance_conditions) .withSelectable(false).withIcon(CommunityMaterial.Icon.cmd_diamond) .withIdentifier(II_FINANCE_CONDITIONS), new PrimaryDrawerItem().withName(R.string.drawer_item_calendar).withSelectable(false) .withIcon(CommunityMaterial.Icon.cmd_calendar_text).withIdentifier(II_CALENDAR) //here we use a customPrimaryDrawerItem we defined in our sample app //this custom DrawerItem extends the PrimaryDrawerItem so it just overwrites some methods /* new OverflowMenuDrawerItem() .withName(R.string.drawer_item_menu_drawer_item) .withDescription(R.string.drawer_item_menu_drawer_item_desc) .withMenu(R.menu.menu_main) .withOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { @Override public boolean onMenuItemClick(MenuItem item) { Toast.makeText(MainActivity.this, item.getTitle(), Toast.LENGTH_SHORT).show(); return false; } }) .withIcon(GoogleMaterial.Icon.gmd_filter_center_focus) .withIdentifier(20), new CustomPrimaryDrawerItem() .withBackgroundRes(R.color.accent) .withName(R.string.drawer_item_free_play) .withIcon(FontAwesome.Icon.faw_gamepad), new PrimaryDrawerItem() .withName(R.string.drawer_item_custom) .withDescription("This is a description") .withIcon(FontAwesome.Icon.faw_eye) .withIdentifier(30), new CustomUrlPrimaryDrawerItem() .withName(R.string.drawer_item_fragment_drawer) .withDescription(R.string.drawer_item_fragment_drawer_desc) .withIcon("https://avatars3.githubusercontent.com/u/1476232?v=3&s=460") .withIdentifier(40), new SectionDrawerItem() .withName(R.string.drawer_item_section_header), new SecondaryDrawerItem() .withName(R.string.drawer_item_settings) .withIcon(FontAwesome.Icon.faw_cart_plus) .withIdentifier(50), new SecondaryDrawerItem() .withName(R.string.drawer_item_help) .withIcon(FontAwesome.Icon.faw_database) .withEnabled(false) .withIdentifier(60), new SecondaryDrawerItem() .withName(R.string.drawer_item_open_source) .withIcon(FontAwesome.Icon.faw_github) .withIdentifier(70), new SecondaryDrawerItem() .withName(R.string.drawer_item_contact) .withSelectedIconColor(Color.RED) .withIconTintingEnabled(true) .withIcon( new IconicsDrawable(this, GoogleMaterial.Icon.gmd_plus_one) .actionBar() .paddingDp(5) .colorRes(R.color.material_drawer_dark_primary_text)) .withTag("Bullhorn") .withIdentifier(80), new SecondaryDrawerItem() .withName(R.string.drawer_item_help) .withIcon(FontAwesome.Icon.faw_question) .withEnabled(false) .withIdentifier(90)*/ ) // add the items we want to use with our Drawer .withOnDrawerNavigationListener(new Drawer.OnDrawerNavigationListener() { @Override public boolean onNavigationClickListener(View clickedView) { //this method is only called if the Arrow icon is shown. The hamburger is automatically managed by the MaterialDrawer //if the back arrow is shown. close the activity MainActivity.this.finish(); //return true if we have consumed the event return true; } }).addStickyDrawerItems( //authDrawerItem, new SecondaryDrawerItem().withSelectable(false).withName(R.string.drawer_item_settings) .withIcon(CommunityMaterial.Icon.cmd_settings).withIdentifier(II_SETTINGS), new SecondaryDrawerItem().withSelectable(false).withName(R.string.drawer_item_about) .withIcon(CommunityMaterial.Icon.cmd_help).withIdentifier(II_ABOUT)) .withSelectedItem(-1).withSavedInstance(savedInstanceState) .withOnDrawerItemClickListener(new Drawer.OnDrawerItemClickListener() { @Override public boolean onItemClick(View view, int position, IDrawerItem drawerItem) { Intent intent = new Intent(); switch ((int) drawerItem.getIdentifier()) { case 1000: intent.setClass(that, CustomPinActivity.class); intent.putExtra(AppLock.EXTRA_TYPE, AppLock.ENABLE_PINLOCK); startActivity(intent); break; case 2000: intent.setClass(that, ListShiftTypeActivity.class); intent.putExtra(AppLock.EXTRA_TYPE, AppLock.UNLOCK_PIN); startActivity(intent); break; case II_SHIFT_TYPES: intent.setClass(that, ListShiftTypeActivity.class); startActivity(intent); break; case II_FINANCE_CONDITIONS: intent.setClass(that, ListFinanceConditionActivity.class); startActivity(intent); break; case II_TABLE: intent.setClass(that, ListTabelActivity.class); startActivity(intent); break; case II_CALENDAR: intent.setClass(that, CalendarActivity.class); startActivity(intent); break; case II_SETTINGS: intent.setClass(that, SettingsActivity.class); startActivity(intent); break; case II_ABOUT: showAbout(that); break; case II_ACCOUNT: break; default: Snackbar.make(view, "Clicked " + String.valueOf(drawerItem.getIdentifier()), Snackbar.LENGTH_LONG).setAction("Action", null).show(); return false; } return true; } }).build(); }