Created
August 22, 2019 01:23
-
-
Save douglasiacovelli/cab8d37a36c55ecece3ea4617d3118a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SectionPagerAdapter( | |
| fragmentManager: FragmentManager, | |
| private val sections: List<Section> | |
| ): FragmentStatePagerAdapter(fragmentManager) { | |
| var currentFormSection: FormSection? = null | |
| override fun getItem(position: Int): Fragment { | |
| return when (sections[position].type) { | |
| SectionType.MAP -> MapFragment.newInstance(sections[position]) | |
| else -> FormFragment.newInstance(sections[position]) | |
| } | |
| } | |
| override fun setPrimaryItem(container: ViewGroup, position: Int, `object`: Any) { | |
| currentFormSection = `object` as FormSection | |
| super.setPrimaryItem(container, position, `object`) | |
| } | |
| override fun getCount(): Int { | |
| return sections.size | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment