Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working on AppCompatActivity #218

Closed
ipopza opened this issue May 7, 2015 · 14 comments

Comments

@ipopza
Copy link

commented May 7, 2015

working normally on Activity/FragmentActivity

public abstract class AbstractActivity extends Activity {
   ...
}

but not working on AppCompatActivity (Android suport lib version 22.1.1)

public abstract class AbstractActivity extends AppCompatActivity {
   ...
}

@ipopza ipopza changed the title Can't working on AppCompatActivity Not working on AppCompatActivity May 7, 2015

@avestnik

This comment has been minimized.

Copy link

commented May 11, 2015

I have the same problem.

@robobindingacc

This comment has been minimized.

Copy link

commented May 11, 2015

Thanks for the issue report. I will look into it when i am available. Meanwhile, please have a try to see if you can locate the problem too. Thanks.

Cheng

@ipopza

This comment has been minimized.

Copy link
Author

commented May 12, 2015

Thanks for response.

@avestnik

This comment has been minimized.

Copy link

commented May 12, 2015

looks like ViewFactory.onCreateView is never called. I guess you should install it as Factory2 looking into

View createViewFromTag(View parent, String name, AttributeSet attrs, boolean inheritContext) {
...
        try {
            View view;
            if (mFactory2 != null) {
                view = mFactory2.onCreateView(parent, name, viewContext, attrs);
            } else if (mFactory != null) {
                view = mFactory.onCreateView(name, viewContext, attrs);
            } else {
                view = null;
            }
...
    }
@weicheng113

This comment has been minimized.

Copy link
Member

commented May 12, 2015

Hi dbis01,

Thanks. I am waiting for extra memory to arrive. Android Studio consumes
too much memory. I will look into it when it arrives.

Thanks,
Cheng
2015年5月12日 8:36 PM于 "dbis01" notifications@github.com写道:

looks like ViewFactory.onCreateView is never called. I guess you should
install it as Factory2 looking into

View createViewFromTag(View parent, String name, AttributeSet attrs, boolean inheritContext) {
...
try {
View view;
if (mFactory2 != null) {
view = mFactory2.onCreateView(parent, name, viewContext, attrs);
} else if (mFactory != null) {
view = mFactory.onCreateView(name, viewContext, attrs);
} else {
view = null;
}
...
}


Reply to this email directly or view it on GitHub
#218 (comment)
.

@abccbaandy

This comment has been minimized.

Copy link

commented May 13, 2015

same problem.

Not just AppCompatActivity, ActionBarActivity not work too if use

compile 'com.android.support:appcompat-v7:22.1.1'
@cliff76

This comment has been minimized.

Copy link

commented Jun 19, 2015

I also see this problem. I traced it partially to the installation of the Layout.Factory on the inflater. With AppCompat it installs the ViewFactory under a FactoryMerger. I think soehow the FactoryMerger gets lost when it rolls around to onCreateView. I haven't debugged it far enough to understand why.

@smclaughry

This comment has been minimized.

Copy link

commented Jun 19, 2015

As far as I can tell, when android.support.v7.app.ActionBarActivity was deprecated/replaced with android.support.v7.app.AppCompatActivity, there was an extra line added in onCreate() that calls getDelegate().installViewFactory().

This appears to wire up the ViewFactory that cliff76 mentions, but (if your code is structured as mine was) it is now happening before your call to BinderFactory.createViewBinder(), and .... well, my chain of reasoning started to break down at this point, but I solved the problem by calling createViewBinder() in my Activity.onCreate() BEFORE making the call to super.onCreate(). Now I'm successfully using RoboBinding with appcompat-v7:22.2.0.

(Note that this is the same codebase described by Mark in #212 and I suspect it's the same problem in #217 )

@cliff76

This comment has been minimized.

Copy link

commented Jun 20, 2015

I just tried creating viewBinder before calling onCreate and using it to do
the binding after onCreate but I get a crash:

 Caused by: java.lang.RuntimeException:

java.lang.ClassNotFoundException: Didn't find class
"android.widget.fragment" on path: DexPathList[[zip file
"/data/app/com.cliftoncraig.lingo.lingo-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.cliftoncraig.lingo.lingo-1,
/vendor/lib, /system/lib]]
at org.robobinding.ViewFactory.onCreateView(ViewFactory.java:38)
at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at
org.robobinding.NonBindingViewInflater.inflateWithoutRoot(NonBindingViewInflater.java:21)
at
org.robobinding.binder.BindingViewInflater.inflateView(BindingViewInflater.java:45)
at
org.robobinding.binder.ViewBinderImpl.inflateAndBind(ViewBinderImpl.java:37)

I'm trying to get this working in an ActionBarActivity from the
NavigationDrawer app template. I have this in my onCreate():

    final ViewBinder viewBinder = new

BinderFactoryBuilder().build().createViewBinder(this);
super.onCreate(savedInstanceState);
MainPresentationModel presentationModel = new MainPresentationModel();
// View rootView =
Binders.inflateAndBindWithoutPreInitializingViews(this,
R.layout.activity_main, presentationModel);
View rootView =
viewBinder.inflateAndBind(R.layout.activity_main, presentationModel);
setContentView(rootView);

If I comment out the 2nd attempt to create the root view from the
viewBinder and use the 1st attempt which calls through the Binders static
method then it doesn't crash but binding doesn't work.

On Fri, Jun 19, 2015 at 3:39 PM, Stephen McLaughry <notifications@github.com

wrote:

As far as I can tell, when android.support.v7.app.ActionBarActivity was
deprecated/replaced with android.support.v7.app.AppCompatActivity, there
was an extra line added in onCreate() that calls
getDelegate().installViewFactory().

This appears to wire up the ViewFactory that cliff76 mentions, but (if
your code is structured as mine was) it is now happening before your call
to BinderFactory.createViewBinder(), and .... well, my chain of reasoning
started to break down at this point, but I solved the problem by calling
createViewBinder() in my Activity.onCreate() BEFORE making the call to
super.onCreate(). Now I'm successfully using RoboBinding with
appcompat-v7:22.2.0.

(Note that this is the same codebase described by Mark in #212
#212 and I suspect
it's the same problem in #217
#217 )


Reply to this email directly or view it on GitHub
#218 (comment)
.

Clifton Craig
Senior Software Engineer
clifton.craig@gmail.com
717-344-9322
SkypeMe: cliftonccraig

@sl378

This comment has been minimized.

Copy link

commented Jul 20, 2015

Thanks @smclaughry , the solution you wrote works a treat for me #217 .
I think it's that the static reusableBinderFactory is not reusable anymore, so I just have to create a new one for every Activity.

@weicheng113

This comment has been minimized.

Copy link
Member

commented Jul 20, 2015

I will have a look by the end of this week. Was busy with the merged task #185, which enabled RoboBinding to cover 80% of Android simple property binding. If you have time available and have an idea of the fix, please do post your idea or make a pull request, as RoboBinding source code should be easy to understand.

Thanks, Cheng

@weicheng113

This comment has been minimized.

Copy link
Member

commented Jul 23, 2015

Fixed and tested. @dbis01 is right. mFactory will never be invoked. And now RoboBinding register itself as mFactory2.

@weicheng113 weicheng113 added this to the v0.8.10 milestone Aug 1, 2015

@astelmakh

This comment has been minimized.

Copy link

commented Nov 19, 2015

Please, tell me, how can i fix it ?

@weicheng113

This comment has been minimized.

Copy link
Member

commented Nov 21, 2015

@astelmakh, Please check the example here -
https://github.com/RoboBinding/RoboBinding-gallery/blob/master/app/src/main/res/layout/activity_fragment.xml

Cheng

2015-11-19 PM5:40于 "astelmakh" notifications@github.com写道:

Please, tell me, how can i fix it ?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.