has custom bindable lib - https://github.com/gueei/AndroidBinding
package gueei.binding;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.LayoutInflater.Factory;
import java.util.ArrayList;
public class ViewFactory implements import android.view.LayoutInflater.Factory; {
}
Here my snippet:
import gueei.binding.Binder;
import gueei.binding.Binder.InflateResult;
import gueei.binding.ViewFactory;
import androidx.fragment.app.FragmentActivity;
LayoutInflater layoutInflater = LayoutInflater.from(context)
.cloneInContext(context);
LayoutInflater.Factory layoutInflaterFactory = layoutInflater
.getFactory();
ViewFactory bindingViewFactory = null;
if (!(layoutInflaterFactory instanceof FragmentActivity)) {
bindingViewFactory = (ViewFactory) layoutInflaterFactory;
}
if (bindingViewFactory == null) {
bindingViewFactory = new ViewFactory(layoutInflater);
layoutInflater.setFactory(bindingViewFactory);
}
And when I use android.support.v4.app.FragmentActivity
my code work fine.
But now I upgrade android project to use androidx.appcompat.app.AppCompatActivity;
and as result in line:
bindingViewFactory = (ViewFactory) layoutInflaterFactory;
I has runtime error:
FATAL EXCEPTION: main
Process: com.myproject.tango.debug, PID: 10249
java.lang.ClassCastException: androidx.appcompat.app.AppCompatDelegateImpl cannot be cast to gueei.binding.ViewFactory
at com.myproject.binding.widget.BindableWidgetHelper.bindv4Fragment(BindableWidgetHelper.java:138)
at com.myproject.commons.LayoutService.addView(LayoutService.java:128)
at com.myproject.commons.LayoutService.addBody(LayoutService.java:150)
at com.myproject.tango.widget.banner.BannerFragment.prepareChild(BannerFragment.java:211)
at com.myproject.commons.roots.RootFragment.onCreateView(RootFragment.java:103)
at com.myproject.tango.widget.banner.BannerFragment_.onCreateView(BannerFragment_.java:42)
at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2612)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:874)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManagerImpl.java:1228)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:1293)