Last active
September 11, 2017 10:29
-
-
Save ruigoncalo/3633a79b9c9b7f38a978d340c62448a4 to your computer and use it in GitHub Desktop.
Spek with Subjects - View
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 DistancesView : FrameLayout, DistancesPresenter.View { | |
@Inject lateinit var presenter: DistancesPresenter | |
constructor(context: Context?) : super(context) { | |
init() | |
} | |
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) { | |
init() | |
} | |
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { | |
init() | |
} | |
private fun init() { | |
LayoutInflater.from(context).inflate(R.layout.layout_distances, this, true) | |
} | |
override fun onAttachedToWindow() { | |
super.onAttachedToWindow() | |
//[dagger] inject dependency declared in parent Activity's component | |
(context as ParentActivity).component.inject(this) | |
presenter.attachView(this) | |
presenter.start() | |
} | |
override fun onDetachedFromWindow() { | |
super.onDetachedFromWindow() | |
presenter.stop() | |
} | |
override fun displayDistancesToGreen(distanceToGreenBack: String, | |
distanceToGreenCenter: String, | |
distanceToGreenFront: String) { | |
backGreenDistanceText.text = distanceToGreenBack | |
centerGreenDistanceText.text = distanceToGreenCenter | |
frontGreenDistanceText.text = distanceToGreenFront | |
} | |
override fun displayDistanceUnit(isMetricDistanceUnit: Boolean) { | |
distanceUnitText.text = if (isMetricDistanceUnit) { | |
context.getString(R.string.round_meters_distance_unit) | |
} else { | |
context.getString(R.string.round_yards_distance_unit) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment