Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit eba1a2de authored by 62160052's avatar 62160052
Browse files

Setup click listeners using listener binding

parent 02d67d78
No related branches found
No related tags found
No related merge requests found
......@@ -48,9 +48,9 @@ class FlavorFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
binding?.apply {
viewModel = sharedViewModel
lifecycleOwner = viewLifecycleOwner
nextButton.setOnClickListener { goToNextScreen() }
viewModel = sharedViewModel
flavorFragment = this@FlavorFragment
}
}
......
......@@ -48,9 +48,9 @@ class PickupFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
binding?.apply {
viewModel = sharedViewModel
lifecycleOwner = viewLifecycleOwner
nextButton.setOnClickListener { goToNextScreen() }
viewModel = sharedViewModel
pickupFragment = this@PickupFragment
}
}
......
......@@ -46,13 +46,7 @@ class StartFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding?.apply {
// Set up the button click listeners
orderOneCupcake.setOnClickListener { orderCupcake(1) }
orderSixCupcakes.setOnClickListener { orderCupcake(6) }
orderTwelveCupcakes.setOnClickListener { orderCupcake(12) }
}
binding?.startFragment = this
}
/**
......
......@@ -49,9 +49,9 @@ class SummaryFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
binding?.apply {
viewModel = sharedViewModel
lifecycleOwner = viewLifecycleOwner
sendButton.setOnClickListener { sendOrder() }
viewModel = sharedViewModel
summaryFragment = this@SummaryFragment
}
}
......
......@@ -24,6 +24,11 @@
<variable
name="viewModel"
type="com.example.cupcake.model.OrderViewModel" />
<variable
name="flavorFragment"
type="com.example.cupcake.FlavorFragment" />
</data>
<ScrollView
......@@ -107,6 +112,7 @@
<Button
android:id="@+id/next_button"
android:onClick="@{() -> flavorFragment.goToNextScreen()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/side_margin"
......
......@@ -24,6 +24,10 @@
<variable
name="viewModel"
type="com.example.cupcake.model.OrderViewModel" />
<variable
name="pickupFragment"
type="com.example.cupcake.PickupFragment" />
</data>
<ScrollView
......@@ -104,6 +108,7 @@
<Button
android:id="@+id/next_button"
android:onClick="@{() -> pickupFragment.goToNextScreen()}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/side_margin"
......
......@@ -20,6 +20,12 @@
xmlns:tools="http://schemas.android.com/tools"
tools:context=".StartFragment">
<data>
<variable
name="startFragment"
type="com.example.cupcake.StartFragment" />
</data>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
......@@ -50,6 +56,7 @@
<Button
android:id="@+id/order_one_cupcake"
android:onClick="@{() -> startFragment.orderCupcake(1)}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
......@@ -59,6 +66,7 @@
<Button
android:id="@+id/order_six_cupcakes"
android:onClick="@{() -> startFragment.orderCupcake(6)}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
......@@ -68,6 +76,7 @@
<Button
android:id="@+id/order_twelve_cupcakes"
android:onClick="@{() -> startFragment.orderCupcake(12)}"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
......
......@@ -23,6 +23,10 @@
<variable
name="viewModel"
type="com.example.cupcake.model.OrderViewModel" />
<variable
name="summaryFragment"
type="com.example.cupcake.SummaryFragment" />
</data>
<ScrollView
......@@ -131,6 +135,7 @@
<Button
android:id="@+id/send_button"
android:onClick="@{() -> summaryFragment.sendOrder()}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/side_margin"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment