Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (25 sloc) 847 Bytes
package com.example.kylejablonski.mvpdemo
class MainPresenter(
private val view: Contract.View,
private val model: MainModel
) : Contract.Presenter {
override fun start() {
view.displayTipOptions(model.tipOptions)
view.selectDefaultTipOption(model.defaultTipIndex)
view.displayInitialPrice(model.checkAmount)
}
override fun changeTipPercentage(position: Int) {
model.setTipOption(position)
if (position < 0) {
view.selectDefaultTipOption(model.defaultTipIndex)
}
}
override fun computeTotalPrice(billPrice: String) {
val finalPrice = model.computeTotalPrice(billPrice)
if (finalPrice == 0.0) {
view.displayError()
} else {
view.displayFinalPriceWithTip(finalPrice, model.tipAmount)
}
}
}
You can’t perform that action at this time.