...
 
Commits (2)
...@@ -168,6 +168,8 @@ public class ASiSTApplication extends Application { ...@@ -168,6 +168,8 @@ public class ASiSTApplication extends Application {
.build(); .build();
WorkManager.getInstance().enqueueUniquePeriodicWork("module_data_update", ExistingPeriodicWorkPolicy.KEEP, moduleDataUpdateWorkRequest); WorkManager.getInstance().enqueueUniquePeriodicWork("module_data_update", ExistingPeriodicWorkPolicy.KEEP, moduleDataUpdateWorkRequest);
this.startASiST(this.getApplicationContext());
} }
......
package de.bps.asist.core.manager; package de.bps.asist.core.manager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import de.bps.asist.module.AbstractAsistModule; import de.bps.asist.module.AbstractAsistModule;
...@@ -9,7 +11,7 @@ public class ASiSTModuleManager { ...@@ -9,7 +11,7 @@ public class ASiSTModuleManager {
private static final ASiSTModuleManager INSTANCE = new ASiSTModuleManager(); private static final ASiSTModuleManager INSTANCE = new ASiSTModuleManager();
private List<AbstractAsistModule> modules = new ArrayList<>(); private Map<Class<? extends AbstractAsistModule>, AbstractAsistModule> modules = new LinkedHashMap<>();
private ASiSTModuleManager(){ private ASiSTModuleManager(){
} }
...@@ -19,22 +21,19 @@ public class ASiSTModuleManager { ...@@ -19,22 +21,19 @@ public class ASiSTModuleManager {
} }
public void resetModuleList(){ public void resetModuleList(){
modules = new ArrayList<>(); this.modules.clear();
} }
public void register(AbstractAsistModule module){ public void register(AbstractAsistModule module){
modules.add(module); this.modules.put(module.getClass(), module);
} }
public <T extends AbstractAsistModule> T getModule( Class<T> moduleClass, T defaultValue ) { public <T extends AbstractAsistModule> T getModule(Class<T> moduleClass, T defaultValue ) {
T resultModule = defaultValue; T module = (T)this.modules.get(moduleClass);
for ( AbstractAsistModule registeredModule: this.modules ) { if(module == null) {
if( moduleClass.isInstance( registeredModule ) ) { module = defaultValue;
defaultValue = (T)registeredModule;
break;
}
} }
return resultModule; return module;
} }
public <T extends AbstractAsistModule> T getModule( Class<T> moduleClass) { public <T extends AbstractAsistModule> T getModule( Class<T> moduleClass) {
...@@ -42,7 +41,6 @@ public class ASiSTModuleManager { ...@@ -42,7 +41,6 @@ public class ASiSTModuleManager {
} }
public List<AbstractAsistModule> getModules() { public List<AbstractAsistModule> getModules() {
return modules; return new ArrayList<>(modules.values());
} }
}
} \ No newline at end of file
...@@ -27,7 +27,6 @@ import androidx.fragment.app.FragmentManager; ...@@ -27,7 +27,6 @@ import androidx.fragment.app.FragmentManager;
import androidx.legacy.app.ActionBarDrawerToggle; import androidx.legacy.app.ActionBarDrawerToggle;
import de.bps.asist.AbstractAsistActivity; import de.bps.asist.AbstractAsistActivity;
import de.bps.asist.R; import de.bps.asist.R;
import de.bps.asist.core.ASiSTApplication;
import de.bps.asist.core.manager.ASiSTModuleManager; import de.bps.asist.core.manager.ASiSTModuleManager;
import de.bps.asist.core.manager.preferences.ASiSTPreferenceManager; import de.bps.asist.core.manager.preferences.ASiSTPreferenceManager;
import de.bps.asist.gui.AbstractASiSTFragment; import de.bps.asist.gui.AbstractASiSTFragment;
...@@ -70,8 +69,6 @@ public class AsistStartActivity extends AbstractAsistActivity implements ActionB ...@@ -70,8 +69,6 @@ public class AsistStartActivity extends AbstractAsistActivity implements ActionB
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
ASiSTApplication.startASiST(this);
mTitle = mDrawerTitle = getTitle(); mTitle = mDrawerTitle = getTitle();
setContentView(R.layout.menu_layout); setContentView(R.layout.menu_layout);
......