This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| implementation "com.google.android.play:core:1.8.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MainActivity : AppCompatActivity() { | |
| private lateinit var binding: ActivityMainBinding | |
| private lateinit var headerAdapter: HeaderAdapter | |
| private lateinit var footerAdapter: FooterAdapter | |
| private lateinit var listAdapter: ListAdapter | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| binding = ActivityMainBinding.inflate(layoutInflater) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val concatAdapter = ConcatAdapter(headerAdapter, usersAdapter, footerAdapter) | |
| binding.mainRecyclerView.layoutManager = LinearLayoutManager(this) | |
| binding.mainRecyclerView.adapter = concatAdapter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" | |
| android:orientation="vertical"> | |
| <androidx.recyclerview.widget.RecyclerView | |
| android:id="@+id/mainRecyclerView" | |
| android:layout_width="match_parent" | |
| android:layout_height="match_parent" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fun setupRecyclerViewAdapters() { | |
| val headerAdapter = HeaderAdapter() | |
| val footerAdapter = FooterAdapter("Remarks from your data source") | |
| val usersAdapter = UsersListAdapter() | |
| usersAdapter.setUsersListData(someUsersList) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserListAdapter() : RecyclerView.Adapter<UserListAdapter.ViewHolder>() { | |
| private var items= emptyList<User>() | |
| inner class ViewHolder(val binding: UserListItemLayoutBinding) : | |
| RecyclerView.ViewHolder(binding.root) { } | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
| return ViewHolder( | |
| UserListItemLayoutBinding.inflate( | |
| LayoutInflater.from(parent.context), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class HeaderAdapter() : | |
| RecyclerView.Adapter<HeaderAdapter.ViewHolder>() { | |
| inner class ViewHolder(val binding: HeaderLayoutBinding) : | |
| RecyclerView.ViewHolder(binding.root) { } | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { | |
| return ViewHolder( | |
| HeaderLayoutBinding.inflate( | |
| LayoutInflater.from(parent.context), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style name="AppTheme" parent="Theme.MaterialComponents.DayNight"> | |
| <!-- Customize your theme here. --> | |
| ... | |
| </style> |