[sample] Factor out adapter into separate LayoutAdapter class