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

robobinding and appcompat-v7 -- lost styles #200

Closed
avestnik opened this Issue Feb 3, 2015 · 4 comments

Comments

Projects
None yet
2 participants
@avestnik

avestnik commented Feb 3, 2015

widgets are loosing theme when view is inflated with robobinders. see attachment:

first row when view is inflated under robobonding

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
    {
        ViewBinder binder = ... .getReusableBinderFactory().createViewBinder(getActivity());
        return binder.inflateAndBindWithoutAttachingToRoot(R.layout.fragment_trips, tripsViewModel, container); 
    }

second row -- with regular inflater

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        return inflater.inflate(R.layout.fragment_trip_tickets, container, false);
    }

robobinding and appcompat

@weicheng113

This comment has been minimized.

Member

weicheng113 commented Feb 3, 2015

Hi dbis01,

Thanks for the report. This looks strange. Internally RoboBinding is doing
same thing. The only difference i can see is the inflater instance. could
you please attach me smallest example? Thanks.

Regards,
Cheng
2015年2月4日 2:02 AM于 "dbis01" notifications@github.com写道:

widgets are loosing theme when view is inflated with robobinders. see
attachment:

first row when view is inflated under robobonding

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState)
{
    ViewBinder binder = ... .getReusableBinderFactory().createViewBinder(getActivity());
    return binder.inflateAndBindWithoutAttachingToRoot(R.layout.fragment_trips, tripsViewModel, container);
}

second row -- with regular inflater

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
    return inflater.inflate(R.layout.fragment_trip_tickets, container, false);
}

[image: robobinding and appcompat]
https://cloud.githubusercontent.com/assets/9352915/6025814/69a826ae-abe6-11e4-8ad0-0c71d5f1b533.png


Reply to this email directly or view it on GitHub
#200.

@avestnik

This comment has been minimized.

avestnik commented Feb 4, 2015

Hi Cheng, please find here a clean repro for the problem. Comment out different parts of MainActivity.onCreate to test both ways

Just a guess, could it be that the problem relates to the way appcompat deals with tinting on pre-5.0 devices?

"The widget tinting in appcompat works by intercepting any layout inflation and inserting a special tint-aware version of the widget in its place."

Would it be enough to inject original inflater into viewBinder as nonBindingInflater?

@weicheng113

This comment has been minimized.

Member

weicheng113 commented Jul 19, 2015

@weicheng113

This comment has been minimized.

Member

weicheng113 commented Jul 25, 2015

Fixed and tested against the test project provided. Thanks for the valuable bug report.

ViewBinder.with(LayoutInflater layoutInflater) method is finally removed, as it is unrelated. Reading through the LayoutInflater/Factory/Factory2 source code. Appcompat Tinting is done through registering its own Factory into LayoutInflater. The reason RoboBinding did not work previously was RoboBinding replaced the Factory and now RoboBinding ViewFactory works as a wrapper around Appcompat Factory.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment