Minor cleanup based on feedback of jomoto
This commit is contained in:
parent
bf6e3a9061
commit
b5969d4279
2 changed files with 16 additions and 32 deletions
|
@ -320,22 +320,6 @@ public class MainApp extends Application {
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> ArrayList<T> getSpecificPluginsListByInterfaceTypeSafe(Class<T> interfaceClass) {
|
|
||||||
ArrayList<T> newList = new ArrayList<>();
|
|
||||||
|
|
||||||
if (pluginsList != null) {
|
|
||||||
for (PluginBase p : pluginsList) {
|
|
||||||
if (p.getClass() != ConfigBuilderPlugin.class
|
|
||||||
&& interfaceClass.isAssignableFrom(p.getClass()))
|
|
||||||
newList.add((T) p);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("pluginsList=null");
|
|
||||||
}
|
|
||||||
|
|
||||||
return newList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, int type) {
|
public static ArrayList<PluginBase> getSpecificPluginsVisibleInListByInterface(Class interfaceClass, int type) {
|
||||||
ArrayList<PluginBase> newList = new ArrayList<>();
|
ArrayList<PluginBase> newList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
|
@ -244,32 +244,32 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
ArrayList<PluginBase> pluginsInCategory;
|
ArrayList<PluginBase> pluginsInCategory;
|
||||||
|
|
||||||
// PluginBase.APS
|
// PluginBase.APS
|
||||||
activeAPS = this.setFragmentVisibility(APSInterface.class, PluginBase.APS);
|
activeAPS = this.determineActivePlugin(APSInterface.class, PluginBase.APS);
|
||||||
|
|
||||||
// PluginBase.INSULIN
|
// PluginBase.INSULIN
|
||||||
activeInsulin = this.setFragmentVisibility(InsulinInterface.class, PluginBase.INSULIN);
|
activeInsulin = this.determineActivePlugin(InsulinInterface.class, PluginBase.INSULIN);
|
||||||
|
|
||||||
// PluginBase.SENSITIVITY
|
// PluginBase.SENSITIVITY
|
||||||
activeSensitivity = this.setFragmentVisibility(SensitivityInterface.class, PluginBase.SENSITIVITY);
|
activeSensitivity = this.determineActivePlugin(SensitivityInterface.class, PluginBase.SENSITIVITY);
|
||||||
|
|
||||||
// PluginBase.PROFILE
|
// PluginBase.PROFILE
|
||||||
activeProfile = this.setFragmentVisibility(ProfileInterface.class, PluginBase.PROFILE);
|
activeProfile = this.determineActivePlugin(ProfileInterface.class, PluginBase.PROFILE);
|
||||||
|
|
||||||
// PluginBase.BGSOURCE
|
// PluginBase.BGSOURCE
|
||||||
activeBgSource = this.setFragmentVisibility(BgSourceInterface.class, PluginBase.BGSOURCE);
|
activeBgSource = this.determineActivePlugin(BgSourceInterface.class, PluginBase.BGSOURCE);
|
||||||
|
|
||||||
// PluginBase.PUMP
|
// PluginBase.PUMP
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
|
pluginsInCategory = MainApp.getSpecificPluginsList(PluginBase.PUMP);
|
||||||
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
|
activePump = (PumpInterface) getTheOneEnabledInArray(pluginsInCategory, PluginBase.PUMP);
|
||||||
if (activePump == null)
|
if (activePump == null)
|
||||||
activePump = VirtualPumpPlugin.getPlugin(); // for NSClient build
|
activePump = VirtualPumpPlugin.getPlugin(); // for NSClient build
|
||||||
this.disableFragmentVisiblities(((PluginBase)activePump).getName(), pluginsInCategory, PluginBase.PUMP);
|
this.setFragmentVisiblities(((PluginBase)activePump).getName(), pluginsInCategory, PluginBase.PUMP);
|
||||||
|
|
||||||
// PluginBase.LOOP
|
// PluginBase.LOOP
|
||||||
activeLoop = this.setFragmentVisibility(PluginBase.LOOP);
|
activeLoop = this.determineActivePlugin(PluginBase.LOOP);
|
||||||
|
|
||||||
// PluginBase.TREATMENT
|
// PluginBase.TREATMENT
|
||||||
activeTreatments = this.setFragmentVisibility(PluginBase.TREATMENT);
|
activeTreatments = this.determineActivePlugin(PluginBase.TREATMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -281,18 +281,18 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private <T> T setFragmentVisibility(Class<T> pluginInterface, int pluginType) {
|
private <T> T determineActivePlugin(Class<T> pluginInterface, int pluginType) {
|
||||||
ArrayList<PluginBase> pluginsInCategory;
|
ArrayList<PluginBase> pluginsInCategory;
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(pluginInterface);
|
pluginsInCategory = MainApp.getSpecificPluginsListByInterface(pluginInterface);
|
||||||
|
|
||||||
return this.setFragmentVisibility(pluginsInCategory, pluginType);
|
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T> T setFragmentVisibility(int pluginType) {
|
private <T> T determineActivePlugin(int pluginType) {
|
||||||
ArrayList<PluginBase> pluginsInCategory;
|
ArrayList<PluginBase> pluginsInCategory;
|
||||||
pluginsInCategory = MainApp.getSpecificPluginsList(pluginType);
|
pluginsInCategory = MainApp.getSpecificPluginsList(pluginType);
|
||||||
|
|
||||||
return this.setFragmentVisibility(pluginsInCategory, pluginType);
|
return this.determineActivePlugin(pluginsInCategory, pluginType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,20 +309,20 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
|
||||||
* @param <T>
|
* @param <T>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private <T> T setFragmentVisibility(ArrayList<PluginBase> pluginsInCategory,
|
private <T> T determineActivePlugin(ArrayList<PluginBase> pluginsInCategory,
|
||||||
int pluginType) {
|
int pluginType) {
|
||||||
T activePlugin = (T) getTheOneEnabledInArray(pluginsInCategory, pluginType);
|
T activePlugin = (T) getTheOneEnabledInArray(pluginsInCategory, pluginType);
|
||||||
|
|
||||||
if (activePlugin != null) {
|
if (activePlugin != null) {
|
||||||
this.disableFragmentVisiblities(((PluginBase)activePlugin).getName(),
|
this.setFragmentVisiblities(((PluginBase)activePlugin).getName(),
|
||||||
pluginsInCategory, pluginType);
|
pluginsInCategory, pluginType);
|
||||||
}
|
}
|
||||||
|
|
||||||
return activePlugin;
|
return activePlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disableFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
|
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
|
||||||
int pluginType) {
|
int pluginType) {
|
||||||
if (Config.logConfigBuilder)
|
if (Config.logConfigBuilder)
|
||||||
log.debug("Selected interface: " + activePluginName);
|
log.debug("Selected interface: " + activePluginName);
|
||||||
for (PluginBase p : pluginsInCategory) {
|
for (PluginBase p : pluginsInCategory) {
|
||||||
|
|
Loading…
Reference in a new issue