Search in sources :

Example 1 with ElectionResultPagerAdapter

use of com.github.dedis.popstellar.ui.detail.event.election.adapters.ElectionResultPagerAdapter in project popstellar by dedis.

the class ElectionResultFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    ElectionResultFragmentBinding mElectionResultFragBinding = ElectionResultFragmentBinding.inflate(inflater, container, false);
    mLaoDetailViewModel = LaoDetailActivity.obtainViewModel(requireActivity());
    TextView laoNameView = mElectionResultFragBinding.electionResultLaoName;
    TextView electionNameView = mElectionResultFragBinding.electionResultPresentationTitle;
    // Getting election
    Election election = mLaoDetailViewModel.getCurrentElection();
    // Setting the Lao Name
    laoNameView.setText(mLaoDetailViewModel.getCurrentLaoName().getValue());
    // Setting election name
    electionNameView.setText(election.getName());
    ElectionResultPagerAdapter adapter = new ElectionResultPagerAdapter(mLaoDetailViewModel);
    ViewPager2 viewPager2 = mElectionResultFragBinding.electionResultPager;
    viewPager2.setAdapter(adapter);
    // Setting the circle indicator
    CircleIndicator3 circleIndicator = mElectionResultFragBinding.swipeIndicatorElectionResults;
    circleIndicator.setViewPager(viewPager2);
    mElectionResultFragBinding.setLifecycleOwner(getActivity());
    return mElectionResultFragBinding.getRoot();
}
Also used : ViewPager2(androidx.viewpager2.widget.ViewPager2) ElectionResultFragmentBinding(com.github.dedis.popstellar.databinding.ElectionResultFragmentBinding) ElectionResultPagerAdapter(com.github.dedis.popstellar.ui.detail.event.election.adapters.ElectionResultPagerAdapter) CircleIndicator3(me.relex.circleindicator.CircleIndicator3) TextView(android.widget.TextView) Election(com.github.dedis.popstellar.model.objects.Election)

Aggregations

TextView (android.widget.TextView)1 ViewPager2 (androidx.viewpager2.widget.ViewPager2)1 ElectionResultFragmentBinding (com.github.dedis.popstellar.databinding.ElectionResultFragmentBinding)1 Election (com.github.dedis.popstellar.model.objects.Election)1 ElectionResultPagerAdapter (com.github.dedis.popstellar.ui.detail.event.election.adapters.ElectionResultPagerAdapter)1 CircleIndicator3 (me.relex.circleindicator.CircleIndicator3)1