mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/9561: Fix initialization order in HomeMenu
`init` blocks are executed before `val` initialization which is declared afterwards in the class. In this case, we had `quitItem` and `reconnectToSyncItem` as lazy, but declared after the `init` block which may need them. And so, while this compiles just fine, in practice we run into an NPE as the `init` block tries to get the lazy's value. Simply re-ordering initialization fixes the problem.
This commit is contained in:
parent
12237fdca1
commit
8d1befd34c
@ -51,6 +51,32 @@ class HomeMenu(
|
|||||||
private val menuCategoryTextColor =
|
private val menuCategoryTextColor =
|
||||||
ThemeManager.resolveAttribute(R.attr.menuCategoryText, context)
|
ThemeManager.resolveAttribute(R.attr.menuCategoryText, context)
|
||||||
|
|
||||||
|
// 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary.
|
||||||
|
private val reconnectToSyncItem by lazy {
|
||||||
|
BrowserMenuHighlightableItem(
|
||||||
|
context.getString(R.string.sync_reconnect),
|
||||||
|
R.drawable.ic_sync_disconnected,
|
||||||
|
iconTintColorResource = syncDisconnectedColor,
|
||||||
|
textColorResource = primaryTextColor,
|
||||||
|
highlight = BrowserMenuHighlight.HighPriority(
|
||||||
|
backgroundTint = syncDisconnectedBackgroundColor
|
||||||
|
),
|
||||||
|
isHighlighted = { true }
|
||||||
|
) {
|
||||||
|
onItemTapped.invoke(Item.Sync)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val quitItem by lazy {
|
||||||
|
BrowserMenuImageText(
|
||||||
|
context.getString(R.string.delete_browsing_data_on_quit_action),
|
||||||
|
R.drawable.ic_exit,
|
||||||
|
primaryTextColor
|
||||||
|
) {
|
||||||
|
onItemTapped.invoke(Item.Quit)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val coreMenuItems by lazy {
|
private val coreMenuItems by lazy {
|
||||||
val whatsNewItem = BrowserMenuHighlightableItem(
|
val whatsNewItem = BrowserMenuHighlightableItem(
|
||||||
context.getString(R.string.browser_menu_whats_new),
|
context.getString(R.string.browser_menu_whats_new),
|
||||||
@ -144,30 +170,4 @@ class HomeMenu(
|
|||||||
}, lifecycleOwner)
|
}, lifecycleOwner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 'Reconnect' and 'Quit' items aren't needed most of the time, so we'll only create the if necessary.
|
|
||||||
private val reconnectToSyncItem by lazy {
|
|
||||||
BrowserMenuHighlightableItem(
|
|
||||||
context.getString(R.string.sync_reconnect),
|
|
||||||
R.drawable.ic_sync_disconnected,
|
|
||||||
iconTintColorResource = syncDisconnectedColor,
|
|
||||||
textColorResource = primaryTextColor,
|
|
||||||
highlight = BrowserMenuHighlight.HighPriority(
|
|
||||||
backgroundTint = syncDisconnectedBackgroundColor
|
|
||||||
),
|
|
||||||
isHighlighted = { true }
|
|
||||||
) {
|
|
||||||
onItemTapped.invoke(Item.Sync)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val quitItem by lazy {
|
|
||||||
BrowserMenuImageText(
|
|
||||||
context.getString(R.string.delete_browsing_data_on_quit_action),
|
|
||||||
R.drawable.ic_exit,
|
|
||||||
primaryTextColor
|
|
||||||
) {
|
|
||||||
onItemTapped.invoke(Item.Quit)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user