public SampleView(Context context, AttributeSet attrs) { super(context, attrs); ObjectGraphService.inject(context, this); } @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); presenter.takeView(this); } @Override protected void onDetachedFromWindow() { presenter.dropView(this); super.onDetachedFromWindow(); } public void setSomething(Something something) { /* something */ } }