This repository has been archived by the owner on Nov 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Home
MAX POLKOVNIK edited this page Mar 27, 2018
·
7 revisions
This project uses Fody for weaving output assembly.
In every file which contains class members marked with [View], [MenuItem], [ViewEvent] will be generated method to resolve or bind members.
Before injecting
[Activity(Label = "TestActivity")]
public class TestActivity : Activity
{
[View] private Button _myButton { get; }
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.screen_test);
Injector.InjectViews();
_myButton.SetBackgroundColor(Color.AliceBlue);
}
}
After injecting:
[Activity(Label = "TestActivity")]
public class TestActivity : Activity
{
[View] private Button _myButton { get; set; }
protected virtual void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.screen_test);
Polkovnik_DroidInjector_InjectViews(Polkovnik_DroidInjector_GetRootView());
_myButton.SetBackgroundColor(Color.AliceBlue);
}
private void Polkovnik_DroidInjector_InjectViews(View view)
{
Button viewById = (Button) view.FindViewById(Resource.Id.myButton);
if (viewById == null)
throw new InjectorException("Can't find view for _myButton");
_myButton = viewById;
}
private View Polkovnik_DroidInjector_GetRootView()
{
return FindViewById(16908290);
}
}
No magic, no reflection...
Injection speed (detailed):
Framework | Injection time |
---|---|
Using FindViewById | 7ms |
DroidInjector | 10ms |
Genetics | 64ms |
Cheeseknife | 60ms |