The compiler throws a build exception @Bindable associated with method must follow JavaBeans convention related to a getter that's marked @Bindable, which accepts one parameter (phototag) and returns a specific field's value based on that parameter value:
private boolean operationPhotoSaved;
private boolean material1PhotoSaved;
private boolean material2PhotoSaved;
private boolean material3PhotoSaved;
private boolean material4PhotoSaved;
private boolean material5PhotoSaved;
@Bindable
public boolean isPhotoSaved (PhotoTag photoTag){
boolean isSaved = false;
switch (photoTag) {
case OPERATIONPHOTO:
isSaved = this.operationPhotoSaved;
break;
case MATERIAL1PHOTO:
isSaved = this.material1PhotoSaved;
break;
case MATERIAL2PHOTO:
isSaved = this.material2PhotoSaved;
break;
case MATERIAL3PHOTO:
isSaved = this.material3PhotoSaved;
break;
case MATERIAL4PHOTO:
isSaved = this.material4PhotoSaved;
break;
case MATERIAL5PHOTO:
isSaved = this.material5PhotoSaved;
break;
}
return isSaved;
}
It seems this is not allowed in Android data-binding?
I eventually avoided the error by creating standard getters and setters for each field and set the @Bindable mark to the getters while removing it from the isPhotoSaved method, then call the getters from within that method:
private boolean operationPhotoSaved;
private boolean material1PhotoSaved;
private boolean material2PhotoSaved;
private boolean material3PhotoSaved;
private boolean material4PhotoSaved;
private boolean material5PhotoSaved;
private boolean videoSaved;
public boolean isPhotoSaved(PhotoTag photoTag) {
boolean isSaved = false;
switch (photoTag) {
case OPERATIONPHOTO:
isSaved = isOperationPhotoSaved();
break;
case MATERIAL1PHOTO:
isSaved = isMaterial1PhotoSaved();
break;
case MATERIAL2PHOTO:
isSaved = isMaterial2PhotoSaved();
break;
case MATERIAL3PHOTO:
isSaved = isMaterial3PhotoSaved();
break;
case MATERIAL4PHOTO:
isSaved = isMaterial4PhotoSaved();
break;
case MATERIAL5PHOTO:
isSaved = isMaterial5PhotoSaved();
break;
}
return isSaved;
}
@Bindable
public boolean isOperationPhotoSaved() {
return operationPhotoSaved;
}
public void setOperationPhotoSaved(boolean operationPhotoSaved) {
this.operationPhotoSaved = operationPhotoSaved;
}
@Bindable
public boolean isMaterial1PhotoSaved() {
return material1PhotoSaved;
}
public void setMaterial1PhotoSaved(boolean material1PhotoSaved) {
this.material1PhotoSaved = material1PhotoSaved;
}
@Bindable
public boolean isMaterial2PhotoSaved() {
return material2PhotoSaved;
}
public void setMaterial2PhotoSaved(boolean material2PhotoSaved) {
this.material2PhotoSaved = material2PhotoSaved;
}
@Bindable
public boolean isMaterial3PhotoSaved() {
return material3PhotoSaved;
}
public void setMaterial3PhotoSaved(boolean material3PhotoSaved) {
this.material3PhotoSaved = material3PhotoSaved;
}
@Bindable
public boolean isMaterial4PhotoSaved() {
return material4PhotoSaved;
}
public void setMaterial4PhotoSaved(boolean material4PhotoSaved) {
this.material4PhotoSaved = material4PhotoSaved;
}
@Bindable
public boolean isMaterial5PhotoSaved() {
return material5PhotoSaved;
}
public void setMaterial5PhotoSaved(boolean material5PhotoSaved) {
this.material5PhotoSaved = material5PhotoSaved;
}