Skip to content

Commit dea13a1

Browse files
committed
Fix the omnibar initialization
1 parent 5a7e0d6 commit dea13a1

File tree

1 file changed

+10
-23
lines changed
  • app/src/main/java/com/duckduckgo/app/browser/omnibar

1 file changed

+10
-23
lines changed

app/src/main/java/com/duckduckgo/app/browser/omnibar/Omnibar.kt

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -73,60 +73,47 @@ class Omnibar(
7373
private val binding: FragmentBrowserTabBinding,
7474
isUnifiedOmnibarEnabled: Boolean,
7575
) {
76-
init {
76+
77+
val omnibarView: OmnibarView by lazy {
7778
if (isUnifiedOmnibarEnabled) {
7879
setupUnifiedOmnibar()
7980
} else {
8081
setupSingleOmnibar()
8182
}
8283
}
8384

84-
private fun setupSingleOmnibar() {
85+
private fun setupSingleOmnibar(): OmnibarView {
8586
binding.rootView.removeView(binding.unifiedOmnibarLayoutTop)
8687
binding.rootView.removeView(binding.unifiedOmnibarLayoutBottom)
8788

88-
when (omnibarPosition) {
89+
return when (omnibarPosition) {
8990
OmnibarPosition.TOP -> {
90-
// remove bottom variant
9191
binding.rootView.removeView(binding.singleOmnibarLayoutBottom)
92+
binding.singleOmnibarLayoutTop
9293
}
9394

9495
OmnibarPosition.BOTTOM -> {
95-
// remove top variant
9696
binding.rootView.removeView(binding.singleOmnibarLayoutTop)
97-
9897
adjustCoordinatorLayoutBehaviorForBottomOmnibar()
98+
binding.singleOmnibarLayoutBottom
9999
}
100100
}
101101
}
102102

103-
private fun setupUnifiedOmnibar() {
103+
private fun setupUnifiedOmnibar(): OmnibarView {
104104
binding.rootView.removeView(binding.singleOmnibarLayoutTop)
105105
binding.rootView.removeView(binding.singleOmnibarLayoutBottom)
106106

107-
when (omnibarPosition) {
107+
return when (omnibarPosition) {
108108
OmnibarPosition.TOP -> {
109-
// remove bottom variant
110109
binding.rootView.removeView(binding.unifiedOmnibarLayoutBottom)
110+
binding.unifiedOmnibarLayoutTop
111111
}
112112

113113
OmnibarPosition.BOTTOM -> {
114-
// remove top variant
115114
binding.rootView.removeView(binding.unifiedOmnibarLayoutTop)
116-
117115
adjustCoordinatorLayoutBehaviorForBottomOmnibar()
118-
}
119-
}
120-
}
121-
122-
val omnibarView: OmnibarView by lazy {
123-
when (omnibarPosition) {
124-
OmnibarPosition.TOP -> {
125-
binding.singleOmnibarLayoutTop
126-
}
127-
128-
OmnibarPosition.BOTTOM -> {
129-
binding.singleOmnibarLayoutBottom
116+
binding.unifiedOmnibarLayoutBottom
130117
}
131118
}
132119
}

0 commit comments

Comments
 (0)