Skip to content

Commit

Permalink
For mozilla-mobile#10453: Add item decoration after setAdapter() is c…
Browse files Browse the repository at this point in the history
…alled.

Applying item decoration needs to be done after setAdapter() is called
because it affects measurement of items views.
  • Loading branch information
mcarare committed May 7, 2020
1 parent 9177871 commit 55d1740
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions app/src/main/java/org/mozilla/fenix/HomeActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,6 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
TabsTray::class.java.name -> {
val layout = LinearLayoutManager(context)
val adapter = TabsAdapter { parentView, tabsTray ->
val decoration = DividerItemDecoration(
context,
DividerItemDecoration.VERTICAL
)
val drawable = AppCompatResources.getDrawable(context, R.drawable.tab_tray_divider)
drawable?.let {
decoration.setDrawable(it)
tabsTray.addItemDecoration(decoration)
}

DefaultTabViewHolder(
LayoutInflater.from(parentView.context).inflate(
R.layout.tab_tray_item,
Expand All @@ -241,7 +231,17 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
tabsTray
)
}
BrowserTabsTray(context, attrs, tabsAdapter = adapter, layout = layout)
val browserTabsTray = BrowserTabsTray(context, attrs, tabsAdapter = adapter, layout = layout)
val decoration = DividerItemDecoration(
context,
DividerItemDecoration.VERTICAL
)
val drawable = AppCompatResources.getDrawable(context, R.drawable.tab_tray_divider)
drawable?.let {
decoration.setDrawable(it)
}
browserTabsTray.addItemDecoration(decoration)
browserTabsTray
}
else -> super.onCreateView(parent, name, context, attrs)
}
Expand Down

0 comments on commit 55d1740

Please sign in to comment.