package com.futureplatforms.kirin.android.app;

import java.lang.reflect.ParameterizedType;

import com.futureplatforms.kirin.IKirinNativeObject;
import com.futureplatforms.kirin.KirinModule;

public class KirinFragmentMethods {

	@SuppressWarnings("unchecked")
	public static <Module extends KirinModule<KirinNativeObj>, KirinNativeObj extends IKirinNativeObject> void onCreate(
			IKirinFragment<Module> f) {
		Module module = null;
		try {
			module = (Module) ((Class<?>) ((ParameterizedType) f.getClass()
					.getGenericSuperclass()).getActualTypeArguments()[0])
					.newInstance();
			module.onPrototypeLoad((KirinNativeObj) f);
			f.setModule(module);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static <Module extends KirinModule<KirinNativeObj>, KirinNativeObj extends IKirinNativeObject> void onUnload(
			IKirinFragment<Module> f) {
		f.getModule().onUnload();
	}

}

@@ -440,104 +440,305 @@
 y %7B%0A
+%0A
 %09%09%09
-module = (Modu
+Object clazz = f.getClass().getGenericSuperclass();%0A%0A%09%09%09//get superclass until you get ParameterizedType%0A%09%09%09whi
 le
-)
  (
-(Class%3C?%3E) ((ParameterizedType) f.getClass()%0A%09%09%09%09%09.getGenericSuperclass())
+clazz != null && !(clazz instanceof ParameterizedType))%0A%09%09%09%09clazz = ((Class%3C?%3E) clazz).getGenericSuperclass();%0A%0A%09%09%09module = (Module) ((Class%3C?%3E) ((ParameterizedType) clazz)%0A%09%09%09%09%09
 .get
@@ -762,22 +762,16 @@
 ts()%5B0%5D)
-%0A%09%09%09%09%09
 .newInst

allow to extend class extending KirinFragment without parameters