Search in sources :

Example 1 with HasViews

use of org.androidannotations.api.view.HasViews in project androidannotations by androidannotations.

the class SomeSingletonTest method viewsAreNotInjected.

@Test
public void viewsAreNotInjected() throws Exception {
    Context context = mock(Context.class);
    OnViewChangedNotifier notifier = new OnViewChangedNotifier();
    OnViewChangedNotifier.replaceNotifier(notifier);
    SomeSingleton singleton = SomeSingleton_.getInstance_(context);
    notifier.notifyViewChanged(new HasViews() {

        @Override
        public View findViewById(int id) {
            return mock(View.class);
        }
    });
    assertThat(singleton.myTextView).isNull();
    assertThat(singleton.beanWithView.myTextView).isNull();
}
Also used : Context(android.content.Context) OnViewChangedNotifier(org.androidannotations.api.view.OnViewChangedNotifier) View(android.view.View) HasViews(org.androidannotations.api.view.HasViews) Test(org.junit.Test)

Example 2 with HasViews

use of org.androidannotations.api.view.HasViews in project androidannotations by androidannotations.

the class EComponentWithViewSupportHolder method setOnViewChanged.

protected void setOnViewChanged() {
    getGeneratedClass()._implements(OnViewChangedListener.class);
    onViewChanged = getGeneratedClass().method(PUBLIC, getCodeModel().VOID, "onViewChanged");
    onViewChanged.annotate(Override.class);
    onViewChangedBody = onViewChanged.body();
    onViewChangedBodyBeforeInjectionBlock = onViewChangedBody.blockVirtual();
    onViewChangedBodyViewHolderBlock = onViewChangedBody.blockVirtual();
    onViewChangedBodyInjectionBlock = onViewChangedBody.blockVirtual();
    onViewChangedBodyAfterInjectionBlock = onViewChangedBody.blockVirtual();
    onViewChangedHasViewsParam = onViewChanged.param(HasViews.class, "hasViews");
    AbstractJClass notifierClass = getJClass(OnViewChangedNotifier.class);
    getInitBodyInjectionBlock().staticInvoke(notifierClass, "registerOnViewChangedListener").arg(_this());
}
Also used : AbstractJClass(com.helger.jcodemodel.AbstractJClass) HasViews(org.androidannotations.api.view.HasViews)

Aggregations

HasViews (org.androidannotations.api.view.HasViews)2 Context (android.content.Context)1 View (android.view.View)1 AbstractJClass (com.helger.jcodemodel.AbstractJClass)1 OnViewChangedNotifier (org.androidannotations.api.view.OnViewChangedNotifier)1 Test (org.junit.Test)1