/** * Refectively invokes action method on behavior * * @param name method name * @throws NoSuchMethodException * @throws IllegalAccessException * @throws InvocationTargetException */ protected void invokeBehavior(String name) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { BehaviorSkinBase skin = (BehaviorSkinBase) getView().getSkin(); BehaviorBase behavior = skin.getBehavior(); Method method = behavior.getClass().getDeclaredMethod(name); method.setAccessible(true); method.invoke(behavior); }
protected void invokeKey(String name) throws Exception { if (!needsKey) return; BehaviorSkinBase skin = (BehaviorSkinBase) getView().getSkin(); BehaviorBase behavior = skin.getBehavior(); Class<? extends BehaviorBase> behaviorClass = behavior.getClass(); Field field = behaviorClass.getDeclaredField(name); field.setAccessible(true); field.set(behavior, true); }
/** * Refectively invokes action method on behavior * * <p>NOTE to self: boolean.class != Boolean.class - getDeclaredMethod doesn't do any * primitve/Object type conversion. * * @param name method name * @param param boolean parameter * @throws NoSuchMethodException * @throws IllegalAccessException * @throws InvocationTargetException */ protected void invokeBehavior(String name, boolean param) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { BehaviorSkinBase skin = (BehaviorSkinBase) getView().getSkin(); BehaviorBase behavior = skin.getBehavior(); Class<? extends BehaviorBase> behaviorClass = behavior.getClass(); Method method = behaviorClass.getDeclaredMethod(name, boolean.class); method.setAccessible(true); method.invoke(behavior, param); }