com.badlogic.gdx.backends.android.AndroidEventListener Java Examples

The following examples show how to use com.badlogic.gdx.backends.android.AndroidEventListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 5 votes vote down vote up
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    synchronized (this.androidEventListeners) {
        for (int i = 0; i < this.androidEventListeners.size; ++i) {
            ((AndroidEventListener) this.androidEventListeners.get(i)).onActivityResult(requestCode, resultCode, data);
        }

    }
}
 
Example #2
Source File: GDXFacebookLoaderUnitTests.java    From gdx-facebook with Apache License 2.0 5 votes vote down vote up
private void androidPremocking() {

        Application mockApplication = mock(Application.class);
        when(mockApplication.getType()).thenReturn(Application.ApplicationType.Android);
        Gdx.app = mockApplication;

        try {
            mockConstructor = PowerMockito.mock(Constructor.class);
            mockFacebook = mock(AndroidGDXFacebook.class);
            mockField = mock(Field.class);
            mockObject = mock(Object.class);
            mockMethod = mock(Method.class);

            when(ClassReflection.forName(GDXFacebookVars.CLASSNAME_ANDROID)).thenReturn(AndroidGDXFacebook.class);
            when(ClassReflection.getConstructor(AndroidGDXFacebook.class, GDXFacebookConfig.class)).thenReturn(mockConstructor);
            when(mockConstructor.newInstance(anyObject())).thenReturn(mockFacebook);


            when(ClassReflection.forName("com.badlogic.gdx.Gdx")).thenReturn(Gdx.class);
            when(ClassReflection.getField(Gdx.class, "app")).thenReturn(mockField);
            when(mockField.get(null)).thenReturn(mockObject);


            when(ClassReflection.forName("com.badlogic.gdx.backends.android.AndroidEventListener")).thenReturn(AndroidEventListener.class);
            when(ClassReflection.forName("android.app.Activity")).thenReturn(Activity.class);

        } catch (ReflectionException e) {
            e.printStackTrace();
        }
    }
 
Example #3
Source File: GDXFacebookLoaderUnitTests.java    From gdx-facebook with Apache License 2.0 5 votes vote down vote up
private void androidPostmocking() {
    try {

        when(ClassReflection.getConstructor(AndroidGDXFacebook.class, Activity.class, GDXFacebookConfig.class)).thenReturn(mockConstructor);
        when(mockConstructor.newInstance(anyObject(), any(GDXFacebookConfig.class))).thenReturn(mockFacebook);
        when(ClassReflection.getMethod(mockObject.getClass(), "addAndroidEventListener", AndroidEventListener.class)).thenReturn(mockMethod);

    } catch (ReflectionException e) {
        e.printStackTrace();
    }
}
 
Example #4
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 4 votes vote down vote up
public void addAndroidEventListener(AndroidEventListener listener) {
    synchronized (this.androidEventListeners) {
        this.androidEventListeners.add(listener);
    }
}
 
Example #5
Source File: GdxDemoActivity.java    From thunderboard-android with Apache License 2.0 4 votes vote down vote up
public void removeAndroidEventListener(AndroidEventListener listener) {
    synchronized (this.androidEventListeners) {
        this.androidEventListeners.removeValue(listener, true);
    }
}