Commit c3b4f17c authored by Fabius's avatar Fabius

Test if Module active

parent b01a4e24
......@@ -15,6 +15,7 @@ import java.util.List;
import de.bps.asist.AbstractAsistActivity;
import de.bps.asist.R;
import de.bps.asist.core.manager.ASiSTModuleManager;
import de.bps.asist.gui.AbstractASiSTFragment;
import de.bps.asist.module.AbstractAsistModule;
import de.bps.asist.module.canteen.CanteenModule;
......@@ -25,6 +26,7 @@ public class AsistStartFragment extends AbstractASiSTFragment {
private ExpandableListView listView;
private LinearLayout linearLayout;
private CanteenModule canteenModule;
@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
......@@ -39,13 +41,24 @@ public class AsistStartFragment extends AbstractASiSTFragment {
linearLayout = (LinearLayout) view.findViewById(R.id.linearLayoutStartFragmentCanteenButton);
boolean isModuleRegistered = false;
List<AbstractAsistModule> modules = ASiSTModuleManager.getInstance().getModules();
for(AbstractAsistModule module : modules){
if(module instanceof CanteenModule) {
isModuleRegistered = true;
canteenModule = (CanteenModule) module;
break;
}
}
if(!isModuleRegistered) linearLayout.setVisibility(View.GONE);
linearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AbstractAsistModule module = new CanteenModule();
AsistStartActivity asistStartActivity =(AsistStartActivity)getContext();
if(asistStartActivity instanceof AbstractAsistActivity && asistStartActivity != null) {
asistStartActivity.startModule(module);
asistStartActivity.startModule(canteenModule);
}
}
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment