I have this item (an item is an object linked to a xml view), to build it I need 2 things, get labels from codes, and get text from the strings.xml android file.
please ignore the long to int and int to long convertion, for some reason the database value where randomly set to long and int but they could all be int, I will refactor this later.
refManager
is calling a DAO
to fetch data from the database.
I have a for loop, building several OperationInstallItem
//constructor
public OperationInstallItem(final Resources resources, final RefManager refManager,
final ModuleCategoryEnum category, final ModeleOperationEntity modeleOperationEntity,
boolean isMandatory) {
//basic init
this.category = category
this.isMandatory = isMandatory;
this.refTypeOperation = modeleOperationEntity.getRefTypeOperation();
this.refTypeInstallation = Long.valueOf(modeleOperationEntity.getRefTypeInstallation());
//label init
this.operationLabel = refManager.getOperationLabel(Ints.checkedCast(refTypeOperation));
this.installationShortLabel = parametrageManager.getInstallationShortLabelt(refTypeInstallation);
this.installationLongLabel = parametrageManager.getInstallationLongLabel(refTypeInstallation);
this.title = resources.getString(R.string.operation_intallation_title)
//icons specific to this class
CodeTypeOperation codeTypeOperation =
CodeTypeOperation.getEnumByCode(Ints.checkedCast(refTypeOperation));
addModuleAdapterIconId = codeTypeOperation.getIcon();
moduleAdapterIconId = codeTypeOperation.getIcon();
moduleAdapterIconselectedId = codeTypeOperation.getIconSelected();
moduleFragmentClass = TDBAddModuleFragment.class;
}
Most of my collueages are uneasy with passing a manager as a constructor arguments but noone of them can explain me why. "it's just not done this way"
same thing with Resources resources
that allow you to get String values from the strings.xml file doing this resources.getString(R.string.operation_intallation_title)
,
according to them, it is bad to pass it in the constructor.
I don't get it, I need those labels/title, if I do this before the instanciation and pass it as parameters it's the exact same thing. no performance gain, nothing is different.
Or is there something I'm missing?