Search in sources :

Example 1 with CastVoteFragmentBinding

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();
}
Also used : ViewPager2(androidx.viewpager2.widget.ViewPager2) CircleIndicator3(me.relex.circleindicator.CircleIndicator3) CastVoteViewPagerAdapter(com.github.dedis.popstellar.ui.detail.event.election.adapters.CastVoteViewPagerAdapter) ZoomOutTransformer(com.github.dedis.popstellar.ui.detail.event.election.ZoomOutTransformer) CastVoteFragmentBinding(com.github.dedis.popstellar.databinding.CastVoteFragmentBinding) TextView(android.widget.TextView) Election(com.github.dedis.popstellar.model.objects.Election) AndroidEntryPoint(dagger.hilt.android.AndroidEntryPoint)

Aggregations

TextView (android.widget.TextView)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 CastVoteFragmentBinding (com.github.dedis.popstellar.databinding.CastVoteFragmentBinding)1 Election (com.github.dedis.popstellar.model.objects.Election)1 ZoomOutTransformer (com.github.dedis.popstellar.ui.detail.event.election.ZoomOutTransformer)1 CastVoteViewPagerAdapter (com.github.dedis.popstellar.ui.detail.event.election.adapters.CastVoteViewPagerAdapter)1 AndroidEntryPoint (dagger.hilt.android.AndroidEntryPoint)1 CircleIndicator3 (me.relex.circleindicator.CircleIndicator3)1