try {
if (className.indexOf(".") == -1) {
className = PRESENTER_PACKAGE + className;
}
Class c = Class.forName(className);
Constructor constructor = c.getConstructor(
Context.class, ViewInterface.class, Model.class);
return (Presenter) constructor.newInstance(context, view, model);
} catch (ClassNotFoundException e) {
Log.e(TAG, "Type not found: " + className, e);
} catch (NoSuchMethodException e) {
// Impossible to reach here.
Log.e(TAG, "No such constructor.", e);
} catch (InvocationTargetException e) {
Log.e(TAG, "Unexpected InvocationTargetException", e);
} catch (IllegalAccessException e) {
Log.e(TAG, "Unexpected IllegalAccessException", e);
} catch (InstantiationException e) {
Log.e(TAG, "Unexpected InstantiationException", e);
}
return null;