use of com.github.dedis.popstellar.databinding.CastVoteFragmentBinding in project popstellar by dedis.
the class CastVoteFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// Inflate the layout for this fragment
CastVoteFragmentBinding mCastVoteFragBinding = CastVoteFragmentBinding.inflate(inflater, container, false);
mLaoDetailViewModel = LaoDetailActivity.obtainViewModel(requireActivity());
TextView laoNameView = mCastVoteFragBinding.castVoteLaoName;
TextView electionNameView = mCastVoteFragBinding.castVoteElectionName;
// setUp the cast Vote button
voteButton = mCastVoteFragBinding.castVoteButton;
voteButton.setEnabled(false);
// Getting election
Election election = mLaoDetailViewModel.getCurrentElection();
// Setting the Lao Name
laoNameView.setText(mLaoDetailViewModel.getCurrentLaoName().getValue());
// Setting election name
electionNameView.setText(election.getName());
int numberOfQuestions = election.getElectionQuestions().size();
// Setting up the votes for the adapter
mLaoDetailViewModel.setCurrentElectionVotes(setEmptyVoteList(numberOfQuestions));
// Setting the viewPager and its adapter
ViewPager2 viewPager2 = mCastVoteFragBinding.castVotePager;
CastVoteViewPagerAdapter adapter = new CastVoteViewPagerAdapter(mLaoDetailViewModel, mCastVoteFragBinding);
viewPager2.setAdapter(adapter);
viewPager2.setPageTransformer(new ZoomOutTransformer());
// Setting the indicator for horizontal swipe
CircleIndicator3 circleIndicator = mCastVoteFragBinding.swipeIndicator;
circleIndicator.setViewPager(viewPager2);
voteButton.setOnClickListener(buttonListener);
return mCastVoteFragBinding.getRoot();
}
Aggregations