Java 类com.badlogic.gdx.backends.android.AndroidEventListener 实例源码

项目:gdx-facebook    文件:GDXFacebookLoaderUnitTests.java   
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();
        }
    }
项目:gdx-facebook    文件:GDXFacebookLoaderUnitTests.java   
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();
    }
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
/**
 * Adds an event listener for Android specific event such as onActivityResult(...).
 */
public void addAndroidEventListener(AndroidEventListener listener) {
    synchronized (androidEventListeners) {
        androidEventListeners.add(listener);
    }
}
项目:thunderboard-android    文件:GdxDemoActivity.java   
/**
 * Removes an event listener for Android specific event such as onActivityResult(...).
 */
public void removeAndroidEventListener(AndroidEventListener listener) {
    synchronized (androidEventListeners) {
        androidEventListeners.removeValue(listener, true);
    }
}
项目:gdx-pay    文件:IAP.java   
/**
     * AndroidApplication will call this dynamically via reflection.
     * We try to find installed IAP systems (jar-files present). If yes, we use them.
     */
    public static void setup() {
        try {
            final int requestCode = 1032; // requestCode for onActivityResult for purchases (could go into
// PurchaseManagerConfig)
            Activity activity = null;
            if (Gdx.app instanceof Activity) {
                activity = (Activity) Gdx.app;
            } else {
                Class<?> supportFragmentClass = findClass("android.support.v4.app.Fragment");
                if (supportFragmentClass != null
                    && supportFragmentClass.isAssignableFrom(Gdx.app.getClass())) {
                    activity = (Activity) supportFragmentClass.getMethod("getActivity").invoke(Gdx.app);
                } else {
                    Class<?> fragmentClass = findClass("android.app.Fragment");
                    if (fragmentClass != null && fragmentClass.isAssignableFrom(Gdx.app.getClass())) {
                        activity = (Activity) fragmentClass.getMethod("getActivity").invoke(Gdx.app);
                    }
                }
            }

            if (activity == null) {
                throw new RuntimeException("Can't find your gdx activity to instantiate Android IAP. "
                    + "Looks like you have implemented AndroidApplication without using "
                    + "Activity or Fragment classes or Activity is not available at the moment");
            }

            IAP iap = new IAP(activity, requestCode);

            // add a listener for Lifecycle events
            Gdx.app.addLifecycleListener(iap);

            // add a listener for Android Events events
            Method gdxAppAddAndroidEventListenerMethod = Gdx.app.getClass().getMethod("addAndroidEventListener",
                AndroidEventListener.class);
            gdxAppAddAndroidEventListenerMethod.invoke(Gdx.app, iap);

            // notify of success
            Gdx.app.log(TAG, "IAP: gdx-pay successfully instantiated.");
        } catch (Exception e) {
            Gdx.app.log(TAG, "IAP: Error creating IAP for Android.", e);
        }
    }
项目:gdx-pay    文件:ApplicationProxy.java   
@Override
public void addAndroidEventListener(AndroidEventListener listener) {
    application.addAndroidEventListener(listener);
}
项目:gdx-pay    文件:ApplicationProxy.java   
@Override
public void removeAndroidEventListener(AndroidEventListener listener) {
    application.removeAndroidEventListener(listener);
}
项目:gdx-pay    文件:ApplicationProxy.java   
@Override
public void addAndroidEventListener(AndroidEventListener listener) {
    application.addAndroidEventListener(listener);
}
项目:gdx-pay    文件:ApplicationProxy.java   
@Override
public void removeAndroidEventListener(AndroidEventListener listener) {
    application.removeAndroidEventListener(listener);
}
项目:gdx-pay    文件:V3GoogleInAppBillingServiceTest.java   
private AndroidEventListener captureAndroidEventListener() {
    verify(applicationProxy).addAndroidEventListener(androidEventListenerArgumentCaptor.capture());
    return androidEventListenerArgumentCaptor.getValue();
}
项目:gdx-pay    文件:ApplicationProxy.java   
void addAndroidEventListener(AndroidEventListener listener);
项目:gdx-pay    文件:ApplicationProxy.java   
void removeAndroidEventListener(AndroidEventListener listener);