Skip to content

Instantly share code, notes, and snippets.

@douglasiacovelli
Created August 22, 2019 01:23
Show Gist options
  • Select an option

  • Save douglasiacovelli/cab8d37a36c55ecece3ea4617d3118a1 to your computer and use it in GitHub Desktop.

Select an option

Save douglasiacovelli/cab8d37a36c55ecece3ea4617d3118a1 to your computer and use it in GitHub Desktop.
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