use of org.androidannotations.holder.OnSeekBarChangeListenerHolder in project androidannotations by androidannotations.
the class SeekBarProgressChangeHandler method process.
@Override
public void process(Element element, EComponentWithViewSupportHolder holder) throws Exception {
String methodName = element.getSimpleName().toString();
ExecutableElement executableElement = (ExecutableElement) element;
List<? extends VariableElement> parameters = executableElement.getParameters();
int seekBarViewParameterPosition = -1;
int progressParameterPosition = -1;
int fromUserParameterPosition = -1;
for (int i = 0; i < parameters.size(); i++) {
VariableElement parameter = parameters.get(i);
TypeMirror parameterType = parameter.asType();
if (CanonicalNameConstants.SEEKBAR.equals(parameterType.toString())) {
seekBarViewParameterPosition = i;
} else if (parameterType.getKind() == TypeKind.INT || CanonicalNameConstants.INTEGER.equals(parameterType.toString())) {
progressParameterPosition = i;
} else if (parameterType.getKind() == TypeKind.BOOLEAN || CanonicalNameConstants.BOOLEAN.equals(parameterType.toString())) {
fromUserParameterPosition = i;
}
}
List<JFieldRef> idsRefs = annotationHelper.extractAnnotationFieldRefs(element, IRClass.Res.ID, true);
for (JFieldRef idRef : idsRefs) {
OnSeekBarChangeListenerHolder onSeekBarChangeListenerHolder = holder.getOnSeekBarChangeListenerHolder(idRef);
JBlock methodBody = onSeekBarChangeListenerHolder.getOnProgressChangedBody();
IJExpression activityRef = holder.getGeneratedClass().staticRef("this");
JInvocation textChangeCall = methodBody.invoke(activityRef, methodName);
for (int i = 0; i < parameters.size(); i++) {
if (i == seekBarViewParameterPosition) {
JVar seekBarViewParameter = onSeekBarChangeListenerHolder.getOnProgressChangedSeekBarParam();
textChangeCall.arg(seekBarViewParameter);
} else if (i == progressParameterPosition) {
JVar progressParameter = onSeekBarChangeListenerHolder.getOnProgressChangedProgressParam();
textChangeCall.arg(progressParameter);
} else if (i == fromUserParameterPosition) {
JVar fromUserParameter = onSeekBarChangeListenerHolder.getOnProgressChangedFromUserParam();
textChangeCall.arg(fromUserParameter);
}
}
}
}
use of org.androidannotations.holder.OnSeekBarChangeListenerHolder in project androidannotations by androidannotations.
the class AbstractSeekBarTouchHandler method process.
@Override
public void process(Element element, EComponentWithViewSupportHolder holder) throws Exception {
String methodName = element.getSimpleName().toString();
List<JFieldRef> idsRefs = annotationHelper.extractAnnotationFieldRefs(element, IRClass.Res.ID, true);
for (JFieldRef idRef : idsRefs) {
OnSeekBarChangeListenerHolder onSeekBarChangeListenerHolder = holder.getOnSeekBarChangeListenerHolder(idRef);
JBlock methodBody = getMethodBodyToCall(onSeekBarChangeListenerHolder);
IJExpression activityRef = holder.getGeneratedClass().staticRef("this");
JInvocation textChangeCall = methodBody.invoke(activityRef, methodName);
ExecutableElement executableElement = (ExecutableElement) element;
List<? extends VariableElement> parameters = executableElement.getParameters();
if (parameters.size() == 1) {
JVar progressParameter = getMethodParamToPass(onSeekBarChangeListenerHolder);
textChangeCall.arg(progressParameter);
}
}
}
Aggregations