use of com.github.dedis.popstellar.model.objects.event.EventCategory.FUTURE in project popstellar by dedis.
the class EventExpandableListViewAdapter method getGroupView.
/**
* Gets a View that displays the given group. This View is only for the group--the Views for the
* group's children will be fetched using {@link #getChildView(int, int, boolean, View,
* ViewGroup)}.
*
* @param groupPosition the position of the group for which the View is returned
* @param isExpanded whether the group is expanded or collapsed
* @param convertView the old view to reuse, if possible. You should check that this view is
* non-null and of an appropriate type before using. If it is not possible to convert this
* view to display the correct data, this method can create a new view. It is not guaranteed
* that the convertView will have been previously created by {@link #getGroupView(int,
* boolean, View, ViewGroup)}.
* @param parent the parent that this view will eventually be attached to
* @return the View corresponding to the group at the specified position
*/
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
EventCategory eventCategory = (EventCategory) getGroup(groupPosition);
EventCategoryLayoutBinding binding;
if (convertView == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
binding = EventCategoryLayoutBinding.inflate(inflater, parent, false);
} else {
binding = DataBindingUtil.getBinding(convertView);
}
binding.setCategoryName(eventCategory.name());
Context context = parent.getContext();
AddEventListener addEventOnClickListener = () -> {
Builder builder = new Builder(context);
builder.setTitle("Select Event Type");
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<>(context, android.R.layout.select_dialog_singlechoice);
arrayAdapter.add("Roll-Call Event");
arrayAdapter.add("Election Event");
builder.setNegativeButton("Cancel", (dialog, which) -> dialog.dismiss());
builder.setAdapter(arrayAdapter, ((dialog, which) -> {
dialog.dismiss();
viewModel.chooseEventType(EventType.values()[which]);
}));
builder.show();
};
binding.setIsFutureCategory(eventCategory.equals(FUTURE));
binding.setViewmodel(viewModel);
binding.setLifecycleOwner(lifecycleOwner);
binding.setAddEventListener(addEventOnClickListener);
binding.executePendingBindings();
binding.addFutureEventButton.setFocusable(false);
return binding.getRoot();
}
Aggregations