Skip to content

Commit

Permalink
fix: lateinit property viewPager has not been initialized
Browse files Browse the repository at this point in the history
`onCollectionLoaded` is not guaranteed to be called synchronously

Fixes 16301
  • Loading branch information
david-allison authored and BrayanDSO committed May 12, 2024
1 parent d3f1bdd commit 636cf9e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions AnkiDroid/src/main/java/com/ichi2/anki/CardTemplateEditor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
}

slidingTabLayout = findViewById(R.id.sliding_tabs)
viewPager = findViewById(R.id.pager)
setNavigationBarColor(R.attr.appBarColor)

// Disable the home icon
Expand Down Expand Up @@ -185,9 +186,8 @@ open class CardTemplateEditor : AnkiActivity(), DeckSelectionListener {
}
fieldNames = tempModel!!.notetype.fieldsNames
// Set up the ViewPager with the sections adapter.
viewPager = findViewById<ViewPager2?>(R.id.pager).apply {
adapter = TemplatePagerAdapter(this@CardTemplateEditor)
}
viewPager.adapter = TemplatePagerAdapter(this@CardTemplateEditor)

// Set activity title
supportActionBar?.let {
it.setTitle(R.string.title_activity_template_editor)
Expand Down

0 comments on commit 636cf9e

Please sign in to comment.