Search in sources :

Example 1 with ElectionManageFragmentBinding

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

the class ManageElectionFragment method onCreateView.

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    ElectionManageFragmentBinding mManageElectionFragBinding = ElectionManageFragmentBinding.inflate(inflater, container, false);
    laoDetailViewModel = LaoDetailActivity.obtainViewModel(requireActivity());
    terminate = mManageElectionFragBinding.terminateElection;
    editStartTimeButton = mManageElectionFragBinding.editStartTime;
    editEndTimeButton = mManageElectionFragBinding.editEndTime;
    editName = mManageElectionFragBinding.editName;
    editQuestion = mManageElectionFragBinding.editQuestion;
    TextView currentTime = mManageElectionFragBinding.displayedCurrentTime;
    TextView startTime = mManageElectionFragBinding.displayedStartTime;
    TextView endTime = mManageElectionFragBinding.displayedEndTime;
    editStartDateButton = mManageElectionFragBinding.editStartDate;
    editEndDateButton = mManageElectionFragBinding.editEndDate;
    TextView question = mManageElectionFragBinding.electionQuestion;
    TextView laoName = mManageElectionFragBinding.manageElectionLaoName;
    TextView electionName = mManageElectionFragBinding.manageElectionTitle;
    Date dCurrent = new java.util.Date(// Get's the date based on the unix time stamp
    System.currentTimeMillis());
    Date dStart = new java.util.Date(laoDetailViewModel.getCurrentElection().getStartTimestampInMillis());
    Date dEnd = new java.util.Date(laoDetailViewModel.getCurrentElection().getEndTimestampInMillis());
    currentTime.setText(// Set's the start time in the form dd/MM/yyyy HH:mm z
    DATE_FORMAT.format(dCurrent));
    startTime.setText(DATE_FORMAT.format(dStart));
    endTime.setText(DATE_FORMAT.format(dEnd));
    laoName.setText(laoDetailViewModel.getCurrentLaoName().getValue());
    electionName.setText(laoDetailViewModel.getCurrentElection().getName());
    List<ElectionQuestion> electionQuestions = laoDetailViewModel.getCurrentElection().getElectionQuestions();
    if (electionQuestions.isEmpty()) {
        question.setText("No election question !");
    } else {
        question.setText("Election Question : " + electionQuestions.get(0).getQuestion());
    }
    mManageElectionFragBinding.setLifecycleOwner(getActivity());
    return mManageElectionFragBinding.getRoot();
}
Also used : ElectionManageFragmentBinding(com.github.dedis.popstellar.databinding.ElectionManageFragmentBinding) ElectionQuestion(com.github.dedis.popstellar.model.network.method.message.data.election.ElectionQuestion) TextView(android.widget.TextView) Date(java.util.Date) Nullable(androidx.annotation.Nullable)

Aggregations

TextView (android.widget.TextView)1 Nullable (androidx.annotation.Nullable)1 ElectionManageFragmentBinding (com.github.dedis.popstellar.databinding.ElectionManageFragmentBinding)1 ElectionQuestion (com.github.dedis.popstellar.model.network.method.message.data.election.ElectionQuestion)1 Date (java.util.Date)1