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();
}
Aggregations