Search in sources :

Example 1 with RollCallEventLayoutBinding

use of com.github.dedis.popstellar.databinding.RollCallEventLayoutBinding in project popstellar by dedis.

the class WalletListAdapter method getView.

@Override
public View getView(int position, View view, ViewGroup viewGroup) {
    RollCallEventLayoutBinding binding;
    if (view == null) {
        // inflate
        LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
        binding = RollCallEventLayoutBinding.inflate(inflater, viewGroup, false);
    } else {
        binding = DataBindingUtil.getBinding(view);
    }
    if (binding == null)
        throw new IllegalStateException("Binding could not be find in the view");
    RollCall rollCall = rollCalls.get(position);
    binding.rollcallDate.setText("Ended: " + DATE_FORMAT.format(new Date(1000 * rollCall.getEnd())));
    binding.rollcallTitle.setText("Roll Call: " + rollCall.getName());
    binding.rollcallLocation.setText("Location: " + rollCall.getLocation());
    binding.rollcallOpenButton.setVisibility(View.GONE);
    binding.rollcallReopenButton.setVisibility(View.GONE);
    binding.rollcallScheduledButton.setVisibility(View.GONE);
    binding.rollcallEnterButton.setVisibility(View.GONE);
    binding.rollcallClosedButton.setVisibility(View.GONE);
    binding.rollcallAttendeesListButton.setVisibility(View.VISIBLE);
    binding.rollcallAttendeesListButton.setOnClickListener(clicked -> viewModel.openAttendeesList(rollCall.getId()));
    Boolean isOrganizer = viewModel.isOrganizer().getValue();
    if (isOrganizer != null && !isOrganizer) {
        binding.rollcallTokenButton.setVisibility(View.VISIBLE);
        binding.rollcallTokenButton.setOnClickListener(clicked -> viewModel.openRollCallToken(rollCall.getId()));
    }
    binding.setLifecycleOwner(lifecycleOwner);
    binding.executePendingBindings();
    return binding.getRoot();
}
Also used : RollCallEventLayoutBinding(com.github.dedis.popstellar.databinding.RollCallEventLayoutBinding) LayoutInflater(android.view.LayoutInflater) RollCall(com.github.dedis.popstellar.model.objects.RollCall) Date(java.util.Date)

Example 2 with RollCallEventLayoutBinding

use of com.github.dedis.popstellar.databinding.RollCallEventLayoutBinding in project popstellar by dedis.

the class EventExpandableListViewAdapter method setupRollCallElement.

/**
 * Setup the text and buttons that appear for a roll call in the list
 *
 * @param rollCall the rollCall Event
 * @param layoutEventBinding the binding of the generic layoutEvent that we use to display events
 * @return the View corresponding to the child at the specified position
 */
private View setupRollCallElement(RollCall rollCall, EventLayoutBinding layoutEventBinding) {
    RollCallEventLayoutBinding binding = layoutEventBinding.includeLayoutRollCall;
    binding.rollcallDate.setText("Start: " + DATE_FORMAT.format(new Date(1000 * rollCall.getStart())));
    binding.rollcallTitle.setText("Roll Call: " + rollCall.getName());
    binding.rollcallLocation.setText("Location: " + rollCall.getLocation());
    binding.rollcallOpenButton.setVisibility(View.GONE);
    binding.rollcallReopenButton.setVisibility(View.GONE);
    binding.rollcallScheduledButton.setVisibility(View.GONE);
    binding.rollcallEnterButton.setVisibility(View.GONE);
    binding.rollcallClosedButton.setVisibility(View.GONE);
    boolean isOrganizer = viewModel.isOrganizer().getValue();
    if (isOrganizer && rollCall.getState() == EventState.CREATED) {
        binding.rollcallOpenButton.setVisibility(View.VISIBLE);
    } else if (isOrganizer && rollCall.getState() == CLOSED) {
        binding.rollcallReopenButton.setVisibility(View.VISIBLE);
    } else if (!isOrganizer && rollCall.getState() == EventState.CREATED) {
        binding.rollcallScheduledButton.setVisibility(View.VISIBLE);
    } else if (!isOrganizer && rollCall.getState() == EventState.OPENED) {
        binding.rollcallEnterButton.setVisibility(View.VISIBLE);
    } else if (!isOrganizer && rollCall.getState() == CLOSED) {
        binding.rollcallClosedButton.setVisibility(View.VISIBLE);
    }
    binding.rollcallOpenButton.setOnClickListener(clicked -> viewModel.openRollCall(rollCall.getId()));
    binding.rollcallReopenButton.setOnClickListener(clicked -> viewModel.openRollCall(rollCall.getId()));
    binding.rollcallEnterButton.setOnClickListener(clicked -> viewModel.enterRollCall(rollCall.getPersistentId()));
    binding.setLifecycleOwner(lifecycleOwner);
    binding.executePendingBindings();
    return layoutEventBinding.getRoot();
}
Also used : RollCallEventLayoutBinding(com.github.dedis.popstellar.databinding.RollCallEventLayoutBinding) Date(java.util.Date)

Aggregations

RollCallEventLayoutBinding (com.github.dedis.popstellar.databinding.RollCallEventLayoutBinding)2 Date (java.util.Date)2 LayoutInflater (android.view.LayoutInflater)1 RollCall (com.github.dedis.popstellar.model.objects.RollCall)1