private Constructor findConstructor (Class<T> type) { try { return ClassReflection.getConstructor(type, (Class[])null); } catch (Exception ex1) { try { Constructor constructor = ClassReflection.getDeclaredConstructor(type, (Class[])null); constructor.setAccessible(true); return constructor; } catch (ReflectionException ex2) { return null; } } }
private Constructor findConstructor (Class<T> type) { try { return ClassReflection.getConstructor(type, (Class[])null); } catch (Exception ex1) { try { Constructor constructor = ClassReflection.getDeclaredConstructor(type, (Class[])null); constructor.setAccessible(true); return constructor; } catch (ReflectionException ex2) { return null; } } }
println("Set to 10/11: " + fromDefaultConstructor); Constructor copyConstroctor = ClassReflection.getConstructor(Vector2.class, Vector2.class); Vector2 fromCopyConstructor = (Vector2)copyConstroctor.newInstance(fromDefaultConstructor); println("From copy constructor: " + fromCopyConstructor);
private Constructor findConstructor (Class<T> type) { try { return ClassReflection.getConstructor(type, (Class[])null); } catch (Exception ex1) { try { Constructor constructor = ClassReflection.getDeclaredConstructor(type, (Class[])null); constructor.setAccessible(true); return constructor; } catch (ReflectionException ex2) { return null; } } }
@Override public <T> T newDialog(Class<T> cls) { String className = cls.getName(); if (registeredDialogs.containsKey(className)) { try { final Class<T> dialogClazz = ClassReflection.forName(registeredDialogs.get(className)); Object dialogObject = ClassReflection.getConstructor(dialogClazz, Activity.class).newInstance(activity); return dialogClazz.cast(dialogObject); } catch (Exception e) { e.printStackTrace(); } } throw new RuntimeException(cls.getName() + "is not registered."); }
public <T> T newDialog(Class<T> cls) { String className = cls.getName(); if (registeredDialogs.containsKey(className)) { try { final Class<T> dialogClazz = ClassReflection.forName(registeredDialogs.get(className)); Object dialogObject = ClassReflection.getConstructor(dialogClazz).newInstance(); return (T) dialogObject; } catch (Exception e) { e.printStackTrace(); } } throw new RuntimeException(cls.getName() + "is not registered."); }
public <T> T newDialog(Class<T> cls) { String className = cls.getName(); if (registeredDialogs.containsKey(className)) { try { final Class<T> dialogClazz = ClassReflection.forName(registeredDialogs.get(className)); Object dialogObject = ClassReflection.getConstructor(dialogClazz).newInstance(); return (T) dialogObject; } catch (Exception e) { e.printStackTrace(); } } throw new RuntimeException(cls.getName() + "is not registered."); }
+ "Activity or Fragment classes or Activity is not available at the moment"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz, activityClazz).newInstance(activity);
+ "Activity or Fragment classes or Activity is not available at the moment"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz, activityClazz).newInstance(activity);
private void installHTMLGDXDialogs() { if (Gdx.app.getType() != ApplicationType.WebGL) { showDebugSkipInstall(ApplicationType.WebGL.name()); return; } try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.html.HTMLGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.WebGL.name()); } catch (ReflectionException e) { showErrorInstall(ApplicationType.WebGL.name(), "html"); e.printStackTrace(); } }
private void installDesktopGDXDialogs() { if (Gdx.app.getType() != ApplicationType.Desktop) { showDebugSkipInstall(ApplicationType.Desktop.name()); return; } try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.desktop.DesktopGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.Desktop.name()); } catch (ReflectionException e) { showErrorInstall(ApplicationType.Desktop.name(), "desktop"); e.printStackTrace(); } }
private void installDesktopGDXDialogs() { if (Gdx.app.getType() != ApplicationType.Desktop) { showDebugSkipInstall(ApplicationType.Desktop.name()); return; } try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.desktop.DesktopGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.Desktop.name()); } catch (ReflectionException e) { showErrorInstall(ApplicationType.Desktop.name(), "desktop"); e.printStackTrace(); } }
private void installHTMLGDXDialogs() { if (Gdx.app.getType() != ApplicationType.WebGL) { showDebugSkipInstall(ApplicationType.WebGL.name()); return; } try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.html.HTMLGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.WebGL.name()); } catch (ReflectionException e) { showErrorInstall(ApplicationType.WebGL.name(), "html"); e.printStackTrace(); } }
private void installIOSGDXDialogs() { if (Gdx.app.getType() != ApplicationType.iOS) { showDebugSkipInstall(ApplicationType.iOS.name()); return; } // there doesn't seem to be an easy way to tell robovm and moe apart try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.ios.IOSGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.iOS.name()+"-robovm"); } catch (ReflectionException e) { try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.iosmoe.IOSMOEGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.iOS.name() + "-moe"); } catch (ReflectionException ex) { showErrorInstall(ApplicationType.iOS.name(), "ios"); e.printStackTrace(); showErrorInstall(ApplicationType.iOS.name(), "ios-moe"); ex.printStackTrace(); } } }
private void installIOSGDXDialogs() { if (Gdx.app.getType() != ApplicationType.iOS) { showDebugSkipInstall(ApplicationType.iOS.name()); return; } // there doesn't seem to be an easy way to tell robovm and moe apart try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.ios.IOSGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.iOS.name()+"-robovm"); } catch (ReflectionException e) { try { final Class<?> dialogManagerClazz = ClassReflection.forName("de.tomgrill.gdxdialogs.iosmoe.IOSMOEGDXDialogs"); Object dialogManager = ClassReflection.getConstructor(dialogManagerClazz).newInstance(); this.gdxDialogs = (GDXDialogs) dialogManager; showDebugInstallSuccessful(ApplicationType.iOS.name() + "-moe"); } catch (ReflectionException ex) { showErrorInstall(ApplicationType.iOS.name(), "ios"); e.printStackTrace(); showErrorInstall(ApplicationType.iOS.name(), "ios-moe"); ex.printStackTrace(); } } }
loaderCls = ClassReflection.forName("de.tomgrill.gdxfirebase.iosmoe.database.IOSMOEFirebaseDatabase"); Object loaderObj = ClassReflection.getConstructor(loaderCls).newInstance(); GDXFirebase.setFirebaseDatabase(name, (FirebaseDatabase) loaderObj); Gdx.app.debug("gdx-firebase", "Realtime Database for " + Gdx.app.getType() + " installed successfully."); Object loaderObj = ClassReflection.getConstructor(loaderCls, String.class, FirebaseConfiguration.class).newInstance(name, firebaseConfiguration); GDXFirebase.setFirebaseDatabase(name, (FirebaseDatabase) loaderObj); Gdx.app.debug("gdx-firebase", "Realtime Database for " + Gdx.app.getType() + " installed successfully.");
Object firebaseFCM = ClassReflection.getConstructor(firebaseFCMClazz, activityClazz, FirebaseConfiguration.class).newInstance(activity, firebaseConfiguration); if (loaderCls != null) { Object loaderObj = ClassReflection.getConstructor(loaderCls).newInstance();
Object firebaseCrashlytics = ClassReflection.getConstructor(firebaseCrashlyticsClazz, activityClazz, FirebaseConfiguration.class).newInstance(activity, firebaseConfiguration);
loaderObj = ClassReflection.getConstructor(loaderCls).newInstance();
loaderObj = ClassReflection.getConstructor(loaderCls).newInstance();