diff --git a/AndroidTestAutomationStarter/app/build.gradle b/AndroidTestAutomationStarter/app/build.gradle
index df7788ef..0bec9926 100644
--- a/AndroidTestAutomationStarter/app/build.gradle
+++ b/AndroidTestAutomationStarter/app/build.gradle
@@ -36,8 +36,8 @@ dependencies {
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:recyclerview-v7:26.1.0'
- kapt 'com.google.dagger:dagger-compiler:2.11'
- implementation 'com.google.dagger:dagger:2.11'
+ kapt 'com.google.dagger:dagger-compiler:2.10'
+ implementation 'com.google.dagger:dagger:2.10'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-moshi:2.3.0'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
diff --git a/AndroidTestAutomationStarter/app/src/main/AndroidManifest.xml b/AndroidTestAutomationStarter/app/src/main/AndroidManifest.xml
index c481b0d9..9459ab83 100644
--- a/AndroidTestAutomationStarter/app/src/main/AndroidManifest.xml
+++ b/AndroidTestAutomationStarter/app/src/main/AndroidManifest.xml
@@ -22,6 +22,7 @@
+
\ No newline at end of file
diff --git a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/BasketActivity.kt b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/BasketActivity.kt
index 1db595dc..e678f16c 100644
--- a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/BasketActivity.kt
+++ b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/BasketActivity.kt
@@ -1,19 +1,23 @@
package com.novoda.androidstoreexample.activities
+import android.content.Intent
import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
+import android.view.View
import com.novoda.androidstoreexample.R
import com.novoda.androidstoreexample.adapters.BasketAdapter
import com.novoda.androidstoreexample.dagger.basket.BasketModule
import com.novoda.androidstoreexample.dagger.component.AppComponent
+import com.novoda.androidstoreexample.listener.BasketAdapterListener
import com.novoda.androidstoreexample.models.Order
+import com.novoda.androidstoreexample.models.Product
import com.novoda.androidstoreexample.mvp.presenter.BasketPresenter
import com.novoda.androidstoreexample.mvp.view.BasketView
+import com.novoda.androidstoreexample.utilities.PRODUCT_ID_EXTRA
import kotlinx.android.synthetic.main.activity_basket.*
import javax.inject.Inject
class BasketActivity : BaseActivity(), BasketView {
-
@Inject
lateinit var presenter: BasketPresenter
@@ -30,16 +34,43 @@ class BasketActivity : BaseActivity(), BasketView {
}
override fun showBasketItems(orders: List) {
- val basketAdapter = BasketAdapter(this, orders) {
+ val listener = object: BasketAdapterListener {
+ override fun onProductImageClicked(product: Product) {
+ presenter.onBasketItemClicked(product)
+ }
+
+ override fun onIncreaseAmountClicked(product: Product) {
+ presenter.onIncreaseItemClicked(product)
+ }
+
+ override fun onDecreaseAmountClicked(product: Product) {
+ presenter.onDecreaseAmountClicked(product)
+ }
}
+ val basketAdapter = BasketAdapter(this, orders, listener)
basketList.layoutManager = LinearLayoutManager(this)
basketList.adapter = basketAdapter
}
+ override fun showTotalAmountOfBasket(totalPrice: Int) {
+ basket_total_text_field.text = applicationContext.getString(R.string.price_template, totalPrice)
+ }
+
+ override fun onProductClicked(product: Product) {
+ val intent = Intent(this, ProductDetailsActivity::class.java)
+ intent.putExtra(PRODUCT_ID_EXTRA, product.id)
+ startActivity(intent)
+ }
+
override fun getActivityLayout(): Int {
return R.layout.activity_basket
}
+ override fun onCheckoutClicked(view: View) {
+ val intent = Intent(this, CheckoutActivity::class.java)
+ startActivity(intent)
+ }
+
override fun injectDependencies(appComponent: AppComponent) {
appComponent.injectBasket(BasketModule(this)).inject(this)
}
diff --git a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/CheckoutActivity.kt b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/CheckoutActivity.kt
new file mode 100644
index 00000000..6c99f6c5
--- /dev/null
+++ b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/CheckoutActivity.kt
@@ -0,0 +1,36 @@
+package com.novoda.androidstoreexample.activities
+
+import android.os.Bundle
+import com.novoda.androidstoreexample.R
+import com.novoda.androidstoreexample.dagger.checkout.CheckoutModule
+import com.novoda.androidstoreexample.dagger.component.AppComponent
+import com.novoda.androidstoreexample.mvp.presenter.CheckoutPresenter
+import kotlinx.android.synthetic.main.activity_checkout.*
+import javax.inject.Inject
+
+class CheckoutActivity : BaseActivity() {
+ @Inject
+ lateinit var presenter: CheckoutPresenter
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_checkout)
+ buy_button.setOnClickListener {
+ presenter.onBuyClick()
+ }
+ }
+
+ override fun getActivityLayout(): Int {
+ return R.layout.activity_checkout
+ }
+
+ override fun injectDependencies(appComponent: AppComponent) {
+ appComponent.injectCheckout(CheckoutModule(this)).inject(this)
+ }
+
+ override fun showProgress() {
+ }
+
+ override fun hideProgress() {
+ }
+}
diff --git a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ConfirmationActivity.kt b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ConfirmationActivity.kt
new file mode 100644
index 00000000..379c4f52
--- /dev/null
+++ b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ConfirmationActivity.kt
@@ -0,0 +1,46 @@
+package com.novoda.androidstoreexample.activities
+
+import android.content.Intent
+import android.os.Bundle
+import android.view.View
+import com.novoda.androidstoreexample.R
+import com.novoda.androidstoreexample.dagger.component.AppComponent
+import com.novoda.androidstoreexample.dagger.confirmation.ConfirmationModule
+import com.novoda.androidstoreexample.mvp.presenter.ConfirmationPresenter
+import com.novoda.androidstoreexample.mvp.view.ConfirmationView
+import kotlinx.android.synthetic.main.activity_purchase_confirmation.*
+import javax.inject.Inject
+
+class ConfirmationActivity : BaseActivity(), ConfirmationView {
+ override fun getActivityLayout(): Int {
+ return R.layout.activity_purchase_confirmation
+ }
+
+ @Inject
+ lateinit var presenter: ConfirmationPresenter
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ setContentView(R.layout.activity_purchase_confirmation)
+ home_button.setOnClickListener {
+ presenter.onHomeClicked()
+ }
+ }
+
+ override fun injectDependencies(appComponent: AppComponent) {
+ appComponent.injectConfirmation(ConfirmationModule(this)).inject(this)
+ }
+
+
+ override fun onHomeClicked(view: View) {
+ val intent = Intent(this, MainActivity::class.java)
+ startActivity(intent)
+ }
+
+ override fun showProgress() {
+ }
+
+ override fun hideProgress() {
+ }
+
+}
diff --git a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ProductDetailsActivity.kt b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ProductDetailsActivity.kt
index a5b5c188..cde40292 100644
--- a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ProductDetailsActivity.kt
+++ b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/activities/ProductDetailsActivity.kt
@@ -32,7 +32,7 @@ class ProductDetailsActivity : BaseActivity(), ProductDetailView {
productDetailImage.setImageResource(resourceId)
productDetailTitle.text = product.title
productDetailDescription.text = product.productDescription
- productDetailPrice.text = product.price
+ productDetailPrice.text = applicationContext.getString(R.string.price_template, product.price)
}
override fun getActivityLayout(): Int {
diff --git a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/adapters/BasketAdapter.kt b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/adapters/BasketAdapter.kt
index 8017ce7d..02f8fccd 100644
--- a/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/adapters/BasketAdapter.kt
+++ b/AndroidTestAutomationStarter/app/src/main/java/com/novoda/androidstoreexample/adapters/BasketAdapter.kt
@@ -5,21 +5,23 @@ import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import com.novoda.androidstoreexample.R
+import com.novoda.androidstoreexample.listener.BasketAdapterListener
import com.novoda.androidstoreexample.models.Order
import com.novoda.androidstoreexample.utilities.ImageHelper
class BasketAdapter(
private val context: Context,
private val orders: List,
- private val itemClicked: (Int) -> Unit
+ private val listener: BasketAdapterListener
) : RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): Holder {
val view = LayoutInflater.from(context).inflate(R.layout.basket_item, parent, false)
- return Holder(view, itemClicked)
+ return Holder(view, listener)
}
override fun getItemCount(): Int {
@@ -30,16 +32,33 @@ class BasketAdapter(
holder?.bindProducts(orders[position], context)
}
- inner class Holder(itemView: View, private val itemClicked: (Int) -> Unit) : RecyclerView.ViewHolder(itemView) {
+ inner class Holder(itemView: View, private val productListener: BasketAdapterListener) : RecyclerView.ViewHolder(itemView) {
private val productImage = itemView.findViewById(R.id.basketProductImage)
private val productTitle = itemView.findViewById(R.id.basketProductTitle)
- private val numberOfProducts = itemView.findViewById(R.id.NumberOfItemsTextField)
+ private val plusButton = itemView.findViewById