This file contains 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
/** | |
* Example: | |
* | |
* <!--parent container (that's expanded to fullscreen)--> | |
* <androidx.constraintlayout.widget.ConstraintLayout | |
* android:layout_width="match_parent" | |
* android:layout_height="match_parent" | |
* ... | |
* app:applySystemBarsInsetOnPadding="@{true}"> | |
* ... |
This file contains 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
/** | |
* example: | |
* | |
* <!--parent container (that's expanded to fullscreen)--> | |
* <androidx.constraintlayout.widget.ConstraintLayout | |
* android:layout_width="match_parent" | |
* android:layout_height="match_parent" | |
* ... | |
* app:setDecorFitSystemWindow="@{true}"> | |
* ... |
This file contains 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 Item(val content: String) { | |
} |
This file contains 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 Category(val name: String, vararg item: Item) { | |
val listOfItems: List<Item> = item.toList() | |
} |
This file contains 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 ItemsAdapter( | |
private val context: Context, | |
private var items: List<Item> | |
) : | |
RecyclerView.Adapter<ItemsAdapter.ItemViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { | |
return ItemViewHolder( | |
LayoutInflater.from(context).inflate(R.layout.item_item, parent, false) | |
) |
This file contains 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 CategoriesAdapter( | |
private val context: Context, | |
private val listOfCategories: List<Category> | |
) : RecyclerView.Adapter<CategoriesAdapter.CategoryViewHolder>() { | |
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CategoryViewHolder { | |
return CategoryViewHolder( | |
LayoutInflater.from(context).inflate(R.layout.item_category, parent, false) | |
) | |
} |
This file contains 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
private val categories = mutableListOf( | |
Category( | |
"Category 1", | |
Item("Item 1"), | |
Item("Item 2"), | |
Item("Item 3"), | |
Item("Item 4"), | |
Item("Item 5"), | |
Item("Item 6") | |
), |
This file contains 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
initViews() | |
initTabLayout() | |
initRecycler() | |
} | |
private fun initViews() { |
This file contains 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
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
initViews() | |
initTabLayout() | |
initRecycler() | |
initMediator() // NEW | |
} |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ui.MainActivity"> | |
<com.google.android.material.tabs.TabLayout | |
android:id="@+id/tabLayout" |
OlderNewer