/** * Creates the view for the given fragment. This will trigger {@link * me.tatarka.simplefragment.SimpleFragment#onCreateView(LayoutInflater, ViewGroup)} * immediately. This will <em>not</em> occur automatically on configuration changes, you are * responsible for calling it again in those cases. * * @param fragment The {@code SimpleFragment} to createView. * @throws java.lang.IllegalArgumentException If the given fragment is null or was not added to * this manager. */ public View createView(SimpleFragment fragment, LayoutInflater layoutInflater, @Nullable ViewGroup parentView) { if (fragment == null) { throw new IllegalArgumentException("SimpleFragment cannot be null."); } if (!fragments.contains(fragment)) { throw new IllegalArgumentException("Attempting to createView fragment that was not added: '" + fragment + "'"); } if (fragment.getView() != null) { throw new IllegalArgumentException("Attempting to createView fragment that has already been attached."); } // To support <fragment> tags in nested layouts, we need a custom inflater. LayoutInflater fragmentInflater = layoutInflater.cloneInContext(activity); LayoutInflaterCompat.setFactory(fragmentInflater, new SimpleFragmentViewInflater(fragment.getSimpleFragmentManager())); return fragment.createView(fragmentInflater, parentView); }
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"); } }
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; }
@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); }
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(); } }
@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory2(getLayoutInflater(), new ThemedViewFactory(this)); mCurrentPrimaryColor = ThemeHelper.getPrimaryColor(this); mCurrentAccentColor = ThemeHelper.getAccentColor(this); super.onCreate(savedInstanceState); applyStatusBarColor(); if (ThemeHelper.hasCustomPrimaryColor(this) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { setTaskDescription(new ActivityManager.TaskDescription(null, null, mCurrentPrimaryColor)); } }
public void installViewFactory() { LayoutInflater layoutInflater = LayoutInflater.from(this.mContext); if (layoutInflater.getFactory() == null) { LayoutInflaterCompat.setFactory(layoutInflater, this); } else if (!(LayoutInflaterCompat.getFactory(layoutInflater) instanceof AppCompatDelegateImplV7)) { Log.i("AppCompatDelegate", "The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's"); } }
@Override protected final void onCreate(@Nullable 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); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); } mActivity = this; mApplication = (PTApplication) getApplication(); mBundle = getIntent().getExtras() != null ? getIntent().getExtras() : new Bundle(); unbinder = ButterKnife.bind(this); mLoadingView = new LoadingView(this, getLoadingMessage()); // loadState = (ILoadState) findViewById(R.id.load_state_view); // mPTLoading = new PTLoading.Builder(this) // .setCanceledOnTouchOutside(false) // .setIcon(R.drawable.button_loading_icon) // .setMsg(getString(R.string.loading_data)) // .build(); // mPTToast = new PTToast.Builder(this) // .setShowTime(1300) // .build(); if (useEventBus()) EventBusUtils.register(this); onViewCreated(savedInstanceState); }
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(); } }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { LayoutInflaterCompat.setFactory(getLayoutInflater(), getSkinDelegate()); super.onCreate(savedInstanceState); updateStatusBarColor(); updateWindowBackground(); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); skinFactory = new SkinFactory(ApkSkin.path); LayoutInflaterCompat.setFactory(getLayoutInflater(), skinFactory); }
@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); }
/** * this method should be called in Activity onCreate method, * and before method super.onCreate(savedInstanceState); * * @param activity */ public void attach(AppCompatActivity activity) { if (activity.getDelegate() instanceof LayoutInflaterFactory) { LayoutInflaterFactory originInflaterFactory = (LayoutInflaterFactory) activity.getDelegate(); LayoutInflaterFactory proxyInflaterFactory = (LayoutInflaterFactory) Proxy.newProxyInstance( originInflaterFactory.getClass().getClassLoader(), new Class[]{LayoutInflaterFactory.class}, new InflaterHandler(originInflaterFactory, activity)); LayoutInflater layoutInflater = LayoutInflater.from(activity); LayoutInflaterCompat.setFactory(layoutInflater, proxyInflaterFactory); } }
@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bindView(); initView(); setupComponent(); }
@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); super.onCreate(savedInstanceState); ThemeUtil.setCustomTheme(this); LanguageUtil.updateLanguage(this); tintBars(); }
@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); }
public void ReplaceSystemControls() { LayoutInflaterCompat.setFactory(LayoutInflater.from(this), new LayoutInflaterFactory() { @Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { // /** // * 可以在这里将系统类替换为自定义View,不要在这里做处理,到相应的类中复写该方法 // */ // if (name.equals("ImageView")) { // return new Button(context, attrs); // } return getDelegate().createView(parent, name, context, attrs); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { mSkinInflaterFactory = new SkinInflaterFactory(); LayoutInflaterCompat.setFactory(getLayoutInflater(), mSkinInflaterFactory); super.onCreate(savedInstanceState); changeStatusColor(); setContentView(layoutResoursId()); }
public void go() { checkGone(); if (activity != null) { LayoutInflaterCompat.setFactory(activity.getLayoutInflater(), new EmojiconLayoutInflaterFactory(this)); } else { emojiconize(view); } gone = true; }
public void installViewFactory(@Nullable LayoutInflaterFactory delegateFactory) { this.delegateFactory = delegateFactory; LayoutInflater layoutInflater = LayoutInflater.from(activity); if (layoutInflater.getFactory() == null) { LayoutInflaterCompat.setFactory(layoutInflater, this); } else { Log.i(TAG, "The Activity's LayoutInflater already has a Factory installed" + " so we can not install AppCompat's"); } }
public final void installViewFactory() { LayoutInflater localLayoutInflater = LayoutInflater.from(this.mContext); if (localLayoutInflater.getFactory() == null) { LayoutInflaterCompat.setFactory(localLayoutInflater, this); return; } Log.i("AppCompatDelegate", "The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's"); }
public LayoutInflater getLayoutInflater(Bundle paramBundle) { LayoutInflater localLayoutInflater = this.mHost.onGetLayoutInflater(); getChildFragmentManager(); LayoutInflaterCompat.setFactory(localLayoutInflater, this.mChildFragmentManager); return localLayoutInflater; }
protected void onCreate(@Nullable Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(this); LayoutInflaterCompat.setFactory(layoutInflater, this); super.onCreate(savedInstanceState); SkinManager.getInstance().addChangedListener(this); }
public void installViewFactory() { LayoutInflater layoutinflater = LayoutInflater.from(mContext); if (layoutinflater.getFactory() == null) { LayoutInflaterCompat.setFactory(layoutinflater, this); return; } else { Log.i("AppCompatDelegate", "The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's"); return; } }
public LayoutInflater getLayoutInflater(Bundle bundle) { bundle = mHost.onGetLayoutInflater(); getChildFragmentManager(); LayoutInflaterCompat.setFactory(bundle, mChildFragmentManager.getLayoutInflaterFactory()); return bundle; }
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); } }
@Override protected void onCreate(Bundle savedInstanceState) { LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); super.onCreate(savedInstanceState); Icepick.restoreInstanceState(this, savedInstanceState); }
@Override protected void onCreate(Bundle savedInstanceState) { findViewById(android.R.id.content).setSystemUiVisibility(findViewById(android.R.id.content).getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); //as we use an icon from Android-Iconics via xml we add the IconicsLayoutInflater //https://github.com/mikepenz/Android-Iconics LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate())); super.onCreate(savedInstanceState); setContentView(R.layout.activity_sample); // Handle Toolbar Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setTitle(R.string.sample_collapsible); //style our ui new MaterializeBuilder().withActivity(this).build(); //create our FastAdapter fastItemAdapter = new FastItemAdapter<>(); fastItemAdapter.withSelectable(true); //get our recyclerView and do basic setup RecyclerView rv = (RecyclerView) findViewById(R.id.rv); rv.setLayoutManager(new LinearLayoutManager(this)); rv.setItemAnimator(new SlideDownAlphaAnimator()); rv.setAdapter(fastItemAdapter); //fill with some sample data List<IItem> items = new ArrayList<>(); for (int i = 1; i <= 100; i++) { if (i % 10 == 0) { SimpleSubExpandableItem expandableItem = new SimpleSubExpandableItem(); expandableItem .withName("Test " + i) .withIdentifier(100 + i); //add subitems so we can showcase the collapsible functionality List<IItem> subItems = new LinkedList<>(); for (int ii = 1; ii <= 5; ii++) { SimpleSubItem sampleItem = new SimpleSubItem(); sampleItem .withName("-- Test " + ii) .withIdentifier(1000 + ii); subItems.add(sampleItem); } expandableItem.withSubItems(subItems); items.add(expandableItem); } else { items.add(new SimpleSubItem().withName("Test " + i).withIdentifier(100 + i)); } } fastItemAdapter.add(items); //restore selections (this has to be done after the items were added fastItemAdapter.withSavedInstanceState(savedInstanceState); //set the back arrow in the toolbar getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(false); }
/** * 初始化夜间控制器 * @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; }
public LayoutInflater getLayoutInflater(Bundle savedInstanceState) { LayoutInflater result = this.mHost.onGetLayoutInflater(); getChildFragmentManager(); LayoutInflaterCompat.setFactory(result, this.mChildFragmentManager.getLayoutInflaterFactory()); return result; }
public static void setInflaterFactory(LayoutInflater li, Activity activity) { LayoutInflaterCompat.setFactory(li, new InflationInterceptor( activity instanceof ATEActivity ? (ATEActivity) activity : null, li, activity instanceof AppCompatActivity ? ((AppCompatActivity) activity).getDelegate() : null)); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { LayoutInflater layoutInflater = LayoutInflater.from(this); LayoutInflaterCompat.setFactory(layoutInflater, this); super.onCreate(savedInstanceState); }
/** * 初始化夜间控制器 * @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; }
public static void installViewFactory(Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { LayoutInflaterCompat.setFactory(LayoutInflater.from(context), new TypefaceCompatFactory(context, false)); } }